Add base to compute lod level automatically
This commit is contained in:
parent
0b6e153111
commit
bf6e81b97d
@ -177,6 +177,7 @@ void LODNode::OnRegisterSceneNode()
|
||||
m_nodes[0]->getType() == scene::ESNT_ANIMATED_MESH) &&
|
||||
now > m_last_tick)
|
||||
{
|
||||
printf("Hi, we are in level mode one :p\n\n");
|
||||
if (m_previous_visibility == WAS_HIDDEN && shown)
|
||||
{
|
||||
scene::IMesh* mesh;
|
||||
@ -251,13 +252,37 @@ void LODNode::OnRegisterSceneNode()
|
||||
|
||||
void LODNode::add(int level, scene::ISceneNode* node, bool reparent)
|
||||
{
|
||||
// Dynamic auto computation of LoD level
|
||||
printf("Autocomputation of LoD level: >%s<\n ---- \n", node->getName());
|
||||
|
||||
Box = node->getBoundingBox();
|
||||
float volume = Box.getVolume();
|
||||
float max_draw = 0.0;
|
||||
|
||||
if (volume < 2.0)
|
||||
{
|
||||
max_draw = (volume * 1.3) + 50.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
max_draw = (volume * 0.05) + 100;
|
||||
}
|
||||
|
||||
int level2 = (int) max_draw * (m_detail.size() + 1) * 0.3;
|
||||
|
||||
|
||||
printf("Volume: %f\n", max_draw);
|
||||
printf("Level: %d\n", level);
|
||||
|
||||
printf("Level2: %d\n", level2);
|
||||
|
||||
// samuncle suggested to put a slight randomisation in LOD
|
||||
// I'm not convinced (Auria) but he's the artist pro, so I listen ;P
|
||||
// The last level should not be randomized because after that the object disappears,
|
||||
// and the location is disapparition needs to be deterministic
|
||||
if (m_detail.size() > 0)
|
||||
{
|
||||
assert(m_detail.back()<level*level);
|
||||
assert(m_detail.back()<level2*level2);
|
||||
m_detail[m_detail.size() - 1] += (int)(((rand()%1000)-500)/500.0f*(m_detail[m_detail.size() - 1]*0.2f));
|
||||
}
|
||||
|
||||
@ -266,7 +291,7 @@ void LODNode::add(int level, scene::ISceneNode* node, bool reparent)
|
||||
node->grab();
|
||||
node->remove();
|
||||
node->setPosition(core::vector3df(0,0,0));
|
||||
m_detail.push_back(level*level);
|
||||
m_detail.push_back(level2*level2);
|
||||
m_nodes.push_back(node);
|
||||
m_nodes_set.insert(node);
|
||||
node->setParent(this);
|
||||
|
@ -62,6 +62,9 @@ private:
|
||||
* m_forced_lod is >=0, only this level is be used. */
|
||||
int m_forced_lod;
|
||||
|
||||
// Volume of the bounding box (for autoLOD computation)
|
||||
int m_volume;
|
||||
|
||||
enum PreviousVisibility
|
||||
{
|
||||
FIRST_PASS,
|
||||
|
Loading…
Reference in New Issue
Block a user