mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 07:53:53 +00:00
Merge pull request #2141 from akortunov/switchnode
Support NiSwitchNode
This commit is contained in:
commit
8ddb45eb22
4 changed files with 41 additions and 0 deletions
|
@ -26,6 +26,7 @@
|
|||
Feature #3610: Option to invert X axis
|
||||
Feature #4673: Weapon sheathing
|
||||
Feature #4730: Native animated containers support
|
||||
Feature #4812: Support NiSwitchNode
|
||||
Task #4686: Upgrade media decoder to a more current FFmpeg API
|
||||
|
||||
0.45.0
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <osg/Geometry>
|
||||
#include <osg/Array>
|
||||
#include <osg/LOD>
|
||||
#include <osg/Switch>
|
||||
#include <osg/TexGen>
|
||||
#include <osg/ValueObject>
|
||||
|
||||
|
@ -335,6 +336,13 @@ namespace NifOsg
|
|||
return lod;
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::Switch> handleSwitchNode(const Nif::NiSwitchNode* niSwitchNode)
|
||||
{
|
||||
osg::ref_ptr<osg::Switch> switchNode (new osg::Switch);
|
||||
switchNode->setNewChildDefaultValue(false);
|
||||
return switchNode;
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::Image> handleSourceTexture(const Nif::NiSourceTexture* st, Resource::ImageManager* imageManager)
|
||||
{
|
||||
if (!st)
|
||||
|
@ -593,6 +601,23 @@ namespace NifOsg
|
|||
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);
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -807,6 +807,13 @@ void Optimizer::RemoveRedundantNodesVisitor::apply(osg::LOD& lod)
|
|||
traverse(*lod.getChild(i));
|
||||
}
|
||||
|
||||
void Optimizer::RemoveRedundantNodesVisitor::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::RemoveRedundantNodesVisitor::apply(osg::Group& group)
|
||||
{
|
||||
if (typeid(group)==typeid(osg::Group) &&
|
||||
|
@ -1862,6 +1869,12 @@ void Optimizer::MergeGroupsVisitor::apply(osg::LOD &lod)
|
|||
traverse(lod);
|
||||
}
|
||||
|
||||
void Optimizer::MergeGroupsVisitor::apply(osg::Switch &switchNode)
|
||||
{
|
||||
// We should keep all switch child nodes since they reflect different switch states.
|
||||
traverse(switchNode);
|
||||
}
|
||||
|
||||
void Optimizer::MergeGroupsVisitor::apply(osg::Group &group)
|
||||
{
|
||||
if (group.getNumChildren() <= 1)
|
||||
|
|
|
@ -340,6 +340,7 @@ class Optimizer
|
|||
virtual void apply(osg::Group& group);
|
||||
virtual void apply(osg::Transform& transform);
|
||||
virtual void apply(osg::LOD& lod);
|
||||
virtual void apply(osg::Switch& switchNode);
|
||||
|
||||
bool isOperationPermissible(osg::Node& node);
|
||||
|
||||
|
@ -360,6 +361,7 @@ class Optimizer
|
|||
|
||||
virtual void apply(osg::Group& group);
|
||||
virtual void apply(osg::LOD& lod);
|
||||
virtual void apply(osg::Switch& switchNode);
|
||||
};
|
||||
|
||||
class MergeGeometryVisitor : public BaseOptimizerVisitor
|
||||
|
|
Loading…
Reference in a new issue