Merge pull request #2161 from akortunov/switchnode

Do not create a redundant parent node for LOD and Switch nodes
pull/541/head
Bret Curtis 6 years ago committed by GitHub
commit 7a9ff9f7b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -27,6 +27,7 @@
Bug #4820: Spell absorption is broken
Bug #4827: NiUVController is handled incorrectly
Bug #4828: Potion looping effects VFX are not shown for NPCs
Bug #4837: CTD when a mesh with NiLODNode root node with particles is loaded
Feature #2229: Improve pathfinding AI
Feature #3442: Default values for fallbacks from ini file
Feature #3610: Option to invert X axis

@ -434,8 +434,23 @@ namespace NifOsg
osg::ref_ptr<osg::Group> node;
osg::Object::DataVariance dataVariance = osg::Object::UNSPECIFIED;
// TODO: it is unclear how to handle transformations of LOD and Switch nodes and controllers for them.
switch (nifNode->recType)
{
case Nif::RC_NiLODNode:
{
const Nif::NiLODNode* niLodNode = static_cast<const Nif::NiLODNode*>(nifNode);
node = handleLodNode(niLodNode);
dataVariance = osg::Object::STATIC;
break;
}
case Nif::RC_NiSwitchNode:
{
const Nif::NiSwitchNode* niSwitchNode = static_cast<const Nif::NiSwitchNode*>(nifNode);
node = handleSwitchNode(niSwitchNode);
dataVariance = osg::Object::STATIC;
break;
}
case Nif::RC_NiTriShape:
case Nif::RC_NiAutoNormalParticles:
case Nif::RC_NiRotatingParticles:
@ -597,35 +612,6 @@ namespace NifOsg
if (nifNode->recType != Nif::RC_NiTriShape && !nifNode->controller.empty() && node->getDataVariance() == osg::Object::DYNAMIC)
handleNodeControllers(nifNode, static_cast<osg::MatrixTransform*>(node.get()), animflags);
if (nifNode->recType == Nif::RC_NiLODNode)
{
const Nif::NiLODNode* niLodNode = static_cast<const Nif::NiLODNode*>(nifNode);
osg::ref_ptr<osg::LOD> lod = handleLodNode(niLodNode);
node->addChild(lod); // unsure if LOD should be above or below this node's transform
node = lod;
}
if (nifNode->recType == Nif::RC_NiSwitchNode)
{
const Nif::NiSwitchNode* niSwitchNode = static_cast<const Nif::NiSwitchNode*>(nifNode);
osg::ref_ptr<osg::Switch> switchNode = handleSwitchNode(niSwitchNode);
node->addChild(switchNode);
if (niSwitchNode->name == Constants::NightDayLabel && !SceneUtil::hasUserDescription(rootNode, Constants::NightDayLabel))
rootNode->getOrCreateUserDataContainer()->addDescription(Constants::NightDayLabel);
const Nif::NodeList &children = niSwitchNode->children;
for(size_t i = 0;i < children.length();++i)
{
if(!children[i].empty())
handleNode(children[i].getPtr(), switchNode, imageManager, boundTextures, animflags, skipMeshes, hasMarkers, isAnimated, textKeys, rootNode);
}
// show only first child by default
switchNode->setSingleChildOn(0);
return switchNode;
}
const Nif::NiNode *ninode = dynamic_cast<const Nif::NiNode*>(nifNode);
if(ninode)
{
@ -644,6 +630,16 @@ namespace NifOsg
}
}
if (nifNode->recType == Nif::RC_NiSwitchNode)
{
// show only first child by default
node->asSwitch()->setSingleChildOn(0);
const Nif::NiSwitchNode* niSwitchNode = static_cast<const Nif::NiSwitchNode*>(nifNode);
if (niSwitchNode->name == Constants::NightDayLabel && !SceneUtil::hasUserDescription(rootNode, Constants::NightDayLabel))
rootNode->getOrCreateUserDataContainer()->addDescription(Constants::NightDayLabel);
}
return node;
}

Loading…
Cancel
Save