Update to add scale into account to compute the LoD level

This commit is contained in:
samuncle 2019-03-03 17:43:59 +01:00
parent eead6f6005
commit 00042ac82e
3 changed files with 11 additions and 3 deletions

View File

@ -241,8 +241,11 @@ void LODNode::OnRegisterSceneNode()
scene::ISceneNode::OnRegisterSceneNode(); scene::ISceneNode::OnRegisterSceneNode();
} }
void LODNode::autoComputeLevel() void LODNode::autoComputeLevel(float scale)
{ {
printf("Scale2 %f\n", scale);
m_volume *= scale;
printf("Factor %f\n", m_volume);
// This will be set based on the amount of objects in a scene. // This will be set based on the amount of objects in a scene.
float agressivity = 1.0; float agressivity = 1.0;
@ -272,8 +275,11 @@ void LODNode::add(int level, scene::ISceneNode* node, bool reparent)
{ {
Box = node->getBoundingBox(); Box = node->getBoundingBox();
m_volume = Box.getArea(); m_volume = Box.getArea();
printf("\nLod\n==========================\n");
printf("Level %d\n", level);
printf("Area %f\n", Box.getArea()); printf("Area %f\n", Box.getArea());
printf("Volume %f\n", Box.getVolume()); printf("Volume %f\n", Box.getVolume());
printf("Scale %f, %f, %f \n", node->getScale().X, node->getScale().Y, node->getScale().Z);
// samuncle suggested to put a slight randomisation in LOD // samuncle suggested to put a slight randomisation in LOD
// I'm not convinced (Auria) but he's the artist pro, so I listen ;P // I'm not convinced (Auria) but he's the artist pro, so I listen ;P

View File

@ -111,7 +111,7 @@ public:
/** /**
* This method can be used to automatically compute LoD level * This method can be used to automatically compute LoD level
*/ */
void autoComputeLevel(); void autoComputeLevel(float scale);
void forceLevelOfDetail(int n); void forceLevelOfDetail(int n);

View File

@ -142,7 +142,9 @@ LODNode* ModelDefinitionLoader::instanciateAsLOD(const XMLNode* node, scene::ISc
lod_node->add(group[m].m_distance, scene_node, true); lod_node->add(group[m].m_distance, scene_node, true);
} }
} }
lod_node->autoComputeLevel(); vector3df scale = vector3df(1.f, 1.f, 1.f);
node->get("scale", &scale);
lod_node->autoComputeLevel(scale.getLength());
#ifdef DEBUG #ifdef DEBUG
std::string debug_name = groupname+" (LOD track-object)"; std::string debug_name = groupname+" (LOD track-object)";