forked from mirror/openmw-tes3mp
Prune empty nodes in RemoveDrawableVisitor
Gets rid of 28 useless transform nodes in base_anim.1st.nif.
This commit is contained in:
parent
f017fd6860
commit
a5b72a358b
2 changed files with 22 additions and 1 deletions
|
@ -182,6 +182,11 @@ namespace
|
||||||
virtual void apply(osg::Geode &node)
|
virtual void apply(osg::Geode &node)
|
||||||
{
|
{
|
||||||
// Not safe to remove in apply(), since the visitor is still iterating the child list
|
// Not safe to remove in apply(), since the visitor is still iterating the child list
|
||||||
|
osg::Group* parent = node.getParent(0);
|
||||||
|
// prune nodes that would be empty after the removal
|
||||||
|
if (parent->getNumChildren() == 1 && parent->getDataVariance() == osg::Object::STATIC)
|
||||||
|
mToRemove.push_back(parent);
|
||||||
|
else
|
||||||
mToRemove.push_back(&node);
|
mToRemove.push_back(&node);
|
||||||
traverse(node);
|
traverse(node);
|
||||||
}
|
}
|
||||||
|
|
|
@ -451,6 +451,22 @@ namespace NifOsg
|
||||||
transformNode->addCullCallback(new BillboardCallback);
|
transformNode->addCullCallback(new BillboardCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set a default DataVariance (used as hint by optimization routines).
|
||||||
|
switch (nifNode->recType)
|
||||||
|
{
|
||||||
|
case Nif::RC_NiTriShape:
|
||||||
|
case Nif::RC_NiAutoNormalParticles:
|
||||||
|
case Nif::RC_NiRotatingParticles:
|
||||||
|
// Leaf nodes in the NIF hierarchy, so won't be able to dynamically attach children.
|
||||||
|
// No support for keyframe controllers (just crashes in the original engine).
|
||||||
|
transformNode->setDataVariance(osg::Object::STATIC);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// could have new children attached at any time, or added external keyframe controllers from .kf files
|
||||||
|
transformNode->setDataVariance(osg::Object::DYNAMIC);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
transformNode->setName(nifNode->name);
|
transformNode->setName(nifNode->name);
|
||||||
|
|
||||||
if (parentNode)
|
if (parentNode)
|
||||||
|
|
Loading…
Reference in a new issue