1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-04-01 00:36:46 +00:00

Merge pull request #2592 from akortunov/switchnode

Use transformations of NiSwitchNode
This commit is contained in:
Alexei Dobrohotov 2019-11-15 19:46:45 +03:00 committed by GitHub
commit ef138e9afc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -341,6 +341,7 @@ namespace NifOsg
osg::ref_ptr<osg::Switch> switchNode (new osg::Switch); osg::ref_ptr<osg::Switch> switchNode (new osg::Switch);
switchNode->setName(niSwitchNode->name); switchNode->setName(niSwitchNode->name);
switchNode->setNewChildDefaultValue(false); switchNode->setNewChildDefaultValue(false);
switchNode->setSingleChildOn(niSwitchNode->initialIndex);
return switchNode; return switchNode;
} }
@ -433,7 +434,7 @@ namespace NifOsg
osg::ref_ptr<osg::Group> node; osg::ref_ptr<osg::Group> node;
osg::Object::DataVariance dataVariance = osg::Object::UNSPECIFIED; osg::Object::DataVariance dataVariance = osg::Object::UNSPECIFIED;
// TODO: it is unclear how to handle transformations of LOD and Switch nodes and controllers for them. // TODO: it is unclear how to handle transformations of LOD nodes and controllers for them.
switch (nifNode->recType) switch (nifNode->recType)
{ {
case Nif::RC_NiLODNode: case Nif::RC_NiLODNode:
@ -444,12 +445,6 @@ namespace NifOsg
break; break;
} }
case Nif::RC_NiSwitchNode: 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_NiTriShape:
case Nif::RC_NiTriStrips: case Nif::RC_NiTriStrips:
case Nif::RC_NiAutoNormalParticles: case Nif::RC_NiAutoNormalParticles:
@ -625,6 +620,19 @@ namespace NifOsg
&& !nifNode->controller.empty() && node->getDataVariance() == osg::Object::DYNAMIC) && !nifNode->controller.empty() && node->getDataVariance() == osg::Object::DYNAMIC)
handleNodeControllers(nifNode, static_cast<osg::MatrixTransform*>(node.get()), animflags); handleNodeControllers(nifNode, static_cast<osg::MatrixTransform*>(node.get()), animflags);
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);
else if (niSwitchNode->name == Constants::HerbalismLabel && !SceneUtil::hasUserDescription(rootNode, Constants::HerbalismLabel))
rootNode->getOrCreateUserDataContainer()->addDescription(Constants::HerbalismLabel);
node = switchNode;
}
const Nif::NiNode *ninode = dynamic_cast<const Nif::NiNode*>(nifNode); const Nif::NiNode *ninode = dynamic_cast<const Nif::NiNode*>(nifNode);
if(ninode) if(ninode)
{ {
@ -643,16 +651,6 @@ namespace NifOsg
} }
} }
if (nifNode->recType == Nif::RC_NiSwitchNode)
{
const Nif::NiSwitchNode* niSwitchNode = static_cast<const Nif::NiSwitchNode*>(nifNode);
node->asSwitch()->setSingleChildOn(niSwitchNode->initialIndex);
if (niSwitchNode->name == Constants::NightDayLabel && !SceneUtil::hasUserDescription(rootNode, Constants::NightDayLabel))
rootNode->getOrCreateUserDataContainer()->addDescription(Constants::NightDayLabel);
else if (niSwitchNode->name == Constants::HerbalismLabel && !SceneUtil::hasUserDescription(rootNode, Constants::HerbalismLabel))
rootNode->getOrCreateUserDataContainer()->addDescription(Constants::HerbalismLabel);
}
return node; return node;
} }