Use Rig/MorphGeometry state for its child geometry

Cherry-pick of ed44095cdc from 0.48 branch
This commit is contained in:
Alexei Dobrohotov 2023-03-03 21:28:00 +03:00 committed by AnyOldName3
parent 8e36d5e704
commit 20e799dadc
3 changed files with 40 additions and 1 deletions

View file

@ -1,5 +1,7 @@
#include "morphgeometry.hpp"
#include <osgUtil/CullVisitor>
#include <cassert>
#include <components/resource/scenemanager.hpp>
@ -89,7 +91,18 @@ namespace SceneUtil
nv.pushOntoNodePath(this);
if (nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR)
{
// The cull visitor won't be applied to the node itself,
// but we want to use its state to render the child geometry.
osg::StateSet* stateset = getStateSet();
osgUtil::CullVisitor* cv = static_cast<osgUtil::CullVisitor*>(&nv);
if (stateset)
cv->pushStateSet(stateset);
cull(&nv);
if (stateset)
cv->popStateSet();
}
else
nv.apply(*this);