Commit aec7ea3c by NTAuthority

minimum render distances for LODs

parent 5e938f6a
Pipeline #76 skipped
......@@ -36,6 +36,24 @@ struct ModelManager : public streaming::StreamingTypeInterface
rw::Object* CloneModel(void);
void ReleaseModel(rw::Object* rwobj);
inline float GetMinimumDistance(void) const
{
// if not a LOD, no minimum distance
if (this->lodDistance < 300.0f)
{
return 0.0f;
}
// if we have a non-LOD model, don't draw once we draw that
if (this->non_lod_model)
{
return this->non_lod_model->GetLODDistance();
}
// use the game-specific minimum distance
return this->minimumDistance;
}
private:
friend struct ModelManager;
......@@ -56,8 +74,10 @@ struct ModelManager : public streaming::StreamingTypeInterface
streaming::ident_t id;
streaming::ident_t texDictID;
float lodDistance;
float minimumDistance;
int flags;
ModelResource* non_lod_model; // non-SA: model of a higher-quality model than this one
ModelResource* lod_model; // model of a lower quality model than this one.
eModelType modelType;
......
......@@ -91,10 +91,12 @@ streaming::ident_t ModelManager::RegisterAtomicModel(
modelEntry->id = id;
modelEntry->texDictID = -1;
modelEntry->lodDistance = lodDistance;
modelEntry->minimumDistance = 100.0f; // NOTE: only valid for III!
modelEntry->flags = flags;
modelEntry->modelPtr = NULL;
modelEntry->modelType = eModelType::ATOMIC;
modelEntry->lod_model = NULL;
modelEntry->non_lod_model = NULL;
modelEntry->lockModelLoading = SRWLOCK_INIT;
......@@ -139,7 +141,7 @@ streaming::ident_t ModelManager::RegisterAtomicModel(
// We are only interresting for LOD matching if our name is longer than three characters.
std::string lod_id = name.substr( 3 );
if ( strncmp( name.c_str(), "LOD", 3 ) == 0 )
if ( lodDistance > 300.0f )
{
isLODModel = true;
}
......@@ -159,6 +161,7 @@ streaming::ident_t ModelManager::RegisterAtomicModel(
ModelResource *baseModelEntry = findBaseModel->second;
baseModelEntry->lod_model = modelEntry;
modelEntry->non_lod_model = baseModelEntry;
}
}
else
......@@ -172,6 +175,7 @@ streaming::ident_t ModelManager::RegisterAtomicModel(
ModelResource *lodModelEntry = findLODModel->second;
modelEntry->lod_model = lodModelEntry;
lodModelEntry->non_lod_model = modelEntry;
}
}
......
......@@ -283,8 +283,16 @@ void World::RenderWorld( void *gfxDevice )
rw::Sphere worldSphere;
rw::V3d entityPos = entity->GetMatrix().pos;
float entityDistance = rw::length(rw::sub(entityPos, cameraPos));
if (rw::length(rw::sub(entityPos, cameraPos)) > entity->GetModelInfo()->GetLODDistance())
auto modelInfo = entity->GetModelInfo();
if (entityDistance > modelInfo->GetLODDistance())
{
continue;
}
if (entityDistance < modelInfo->GetMinimumDistance())
{
continue;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment