mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 16:29:55 +00:00
Use Rig/MorphGeometry state for its child geometry
This commit is contained in:
parent
d33be39fb6
commit
ed44095cdc
3 changed files with 39 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
|||
#include "morphgeometry.hpp"
|
||||
|
||||
#include <osgUtil/CullVisitor>
|
||||
|
||||
#include <cassert>
|
||||
#include <components/resource/scenemanager.hpp>
|
||||
|
||||
|
@ -87,7 +89,18 @@ void MorphGeometry::accept(osg::NodeVisitor &nv)
|
|||
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);
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
#include "riggeometry.hpp"
|
||||
|
||||
#include <osg/MatrixTransform>
|
||||
|
||||
#include <osgUtil/CullVisitor>
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/resource/scenemanager.hpp>
|
||||
#include <osg/MatrixTransform>
|
||||
|
||||
#include "skeleton.hpp"
|
||||
#include "util.hpp"
|
||||
|
@ -387,7 +390,18 @@ void RigGeometry::accept(osg::NodeVisitor &nv)
|
|||
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 if (nv.getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR)
|
||||
updateBounds(&nv);
|
||||
else
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include <osg/Drawable>
|
||||
#include <osg/NodeVisitor>
|
||||
|
||||
#include <osgUtil/CullVisitor>
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/resource/scenemanager.hpp>
|
||||
|
||||
|
@ -220,6 +222,13 @@ void RigGeometryHolder::accept(osg::NodeVisitor &nv)
|
|||
|
||||
if (nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR && mSourceRigGeometry.get())
|
||||
{
|
||||
// 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);
|
||||
|
||||
unsigned int traversalNumber = nv.getTraversalNumber();
|
||||
if (mLastFrameNumber == traversalNumber)
|
||||
{
|
||||
|
@ -255,6 +264,8 @@ void RigGeometryHolder::accept(osg::NodeVisitor &nv)
|
|||
nv.apply(geom);
|
||||
nv.popFromNodePath();
|
||||
}
|
||||
if (stateset)
|
||||
cv->popStateSet();
|
||||
}
|
||||
else if (nv.getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue