mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-20 20:39:42 +00:00
Merge pull request #2148 from akortunov/switchnode
Improve switchable nodes handling
This commit is contained in:
commit
4f0847b63e
3 changed files with 20 additions and 1 deletions
|
@ -325,6 +325,7 @@ namespace NifOsg
|
|||
osg::ref_ptr<osg::LOD> handleLodNode(const Nif::NiLODNode* niLodNode)
|
||||
{
|
||||
osg::ref_ptr<osg::LOD> lod (new osg::LOD);
|
||||
lod->setName(niLodNode->name);
|
||||
lod->setCenterMode(osg::LOD::USER_DEFINED_CENTER);
|
||||
lod->setCenter(niLodNode->lodCenter);
|
||||
for (unsigned int i=0; i<niLodNode->lodLevels.size(); ++i)
|
||||
|
@ -339,6 +340,7 @@ namespace NifOsg
|
|||
osg::ref_ptr<osg::Switch> handleSwitchNode(const Nif::NiSwitchNode* niSwitchNode)
|
||||
{
|
||||
osg::ref_ptr<osg::Switch> switchNode (new osg::Switch);
|
||||
switchNode->setName(niSwitchNode->name);
|
||||
switchNode->setNewChildDefaultValue(false);
|
||||
return switchNode;
|
||||
}
|
||||
|
|
|
@ -737,6 +737,20 @@ bool Optimizer::CombineStaticTransformsVisitor::removeTransforms(osg::Node* node
|
|||
// RemoveEmptyNodes.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Optimizer::RemoveEmptyNodesVisitor::apply(osg::Switch& switchNode)
|
||||
{
|
||||
// We should keep all switch child nodes since they reflect different switch states.
|
||||
for (unsigned int i=0; i<switchNode.getNumChildren(); ++i)
|
||||
traverse(*switchNode.getChild(i));
|
||||
}
|
||||
|
||||
void Optimizer::RemoveEmptyNodesVisitor::apply(osg::LOD& lod)
|
||||
{
|
||||
// don't remove any direct children of the LOD because they are used to define each LOD level.
|
||||
for (unsigned int i=0; i<lod.getNumChildren(); ++i)
|
||||
traverse(*lod.getChild(i));
|
||||
}
|
||||
|
||||
void Optimizer::RemoveEmptyNodesVisitor::apply(osg::Group& group)
|
||||
{
|
||||
if (group.getNumParents()>0)
|
||||
|
@ -1856,7 +1870,8 @@ bool Optimizer::MergeGeometryVisitor::mergePrimitive(osg::DrawElementsUInt& lhs,
|
|||
|
||||
bool Optimizer::MergeGroupsVisitor::isOperationPermissible(osg::Group& node)
|
||||
{
|
||||
return !node.asTransform() &&
|
||||
return !node.asSwitch() &&
|
||||
!node.asTransform() &&
|
||||
!node.getCullCallback() &&
|
||||
!node.getEventCallback() &&
|
||||
!node.getUpdateCallback() &&
|
||||
|
|
|
@ -321,6 +321,8 @@ class Optimizer
|
|||
BaseOptimizerVisitor(optimizer, REMOVE_REDUNDANT_NODES) {}
|
||||
|
||||
virtual void apply(osg::Group& group);
|
||||
virtual void apply(osg::LOD& lod);
|
||||
virtual void apply(osg::Switch& switchNode);
|
||||
|
||||
void removeEmptyNodes();
|
||||
|
||||
|
|
Loading…
Reference in a new issue