mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-30 16:20:21 +00:00
Merge branch 'rig-and-morph-geometry-state-fixes' into 'master'
Use Rig/MorphGeometry state for its child geometry, revert redundant fix Closes #7251 See merge request OpenMW/openmw!2802
This commit is contained in:
commit
cbd14833fd
@ -1,5 +1,7 @@
|
|||||||
#include "morphgeometry.hpp"
|
#include "morphgeometry.hpp"
|
||||||
|
|
||||||
|
#include <osgUtil/CullVisitor>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <components/resource/scenemanager.hpp>
|
#include <components/resource/scenemanager.hpp>
|
||||||
|
|
||||||
@ -89,7 +91,18 @@ namespace SceneUtil
|
|||||||
nv.pushOntoNodePath(this);
|
nv.pushOntoNodePath(this);
|
||||||
|
|
||||||
if (nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR)
|
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);
|
cull(&nv);
|
||||||
|
if (stateset)
|
||||||
|
cv->popStateSet();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
nv.apply(*this);
|
nv.apply(*this);
|
||||||
|
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
#include "riggeometry.hpp"
|
#include "riggeometry.hpp"
|
||||||
|
|
||||||
|
#include <osg/MatrixTransform>
|
||||||
|
|
||||||
|
#include <osgUtil/CullVisitor>
|
||||||
|
|
||||||
#include <components/debug/debuglog.hpp>
|
#include <components/debug/debuglog.hpp>
|
||||||
#include <components/resource/scenemanager.hpp>
|
#include <components/resource/scenemanager.hpp>
|
||||||
#include <osg/MatrixTransform>
|
|
||||||
|
|
||||||
#include "skeleton.hpp"
|
#include "skeleton.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
@ -393,7 +396,18 @@ namespace SceneUtil
|
|||||||
nv.pushOntoNodePath(this);
|
nv.pushOntoNodePath(this);
|
||||||
|
|
||||||
if (nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR)
|
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);
|
cull(&nv);
|
||||||
|
if (stateset)
|
||||||
|
cv->popStateSet();
|
||||||
|
}
|
||||||
else if (nv.getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR)
|
else if (nv.getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR)
|
||||||
updateBounds(&nv);
|
updateBounds(&nv);
|
||||||
else
|
else
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include <osg/Drawable>
|
#include <osg/Drawable>
|
||||||
#include <osg/NodeVisitor>
|
#include <osg/NodeVisitor>
|
||||||
|
|
||||||
|
#include <osgUtil/CullVisitor>
|
||||||
|
|
||||||
#include <components/debug/debuglog.hpp>
|
#include <components/debug/debuglog.hpp>
|
||||||
#include <components/resource/scenemanager.hpp>
|
#include <components/resource/scenemanager.hpp>
|
||||||
|
|
||||||
@ -236,6 +238,13 @@ namespace SceneUtil
|
|||||||
|
|
||||||
if (nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR && mSourceRigGeometry.get())
|
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();
|
unsigned int traversalNumber = nv.getTraversalNumber();
|
||||||
if (mLastFrameNumber == traversalNumber)
|
if (mLastFrameNumber == traversalNumber)
|
||||||
{
|
{
|
||||||
@ -273,6 +282,9 @@ namespace SceneUtil
|
|||||||
nv.apply(geom);
|
nv.apply(geom);
|
||||||
nv.popFromNodePath();
|
nv.popFromNodePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stateset)
|
||||||
|
cv->popStateSet();
|
||||||
}
|
}
|
||||||
else if (nv.getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR)
|
else if (nv.getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR)
|
||||||
{
|
{
|
||||||
|
@ -889,28 +889,21 @@ namespace Shader
|
|||||||
if (auto rig = dynamic_cast<SceneUtil::RigGeometry*>(&drawable))
|
if (auto rig = dynamic_cast<SceneUtil::RigGeometry*>(&drawable))
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Geometry> sourceGeometry = rig->getSourceGeometry();
|
osg::ref_ptr<osg::Geometry> sourceGeometry = rig->getSourceGeometry();
|
||||||
if (sourceGeometry)
|
if (sourceGeometry && adjustGeometry(*sourceGeometry, reqs))
|
||||||
{
|
|
||||||
sourceGeometry->accept(*this);
|
|
||||||
rig->setSourceGeometry(sourceGeometry);
|
rig->setSourceGeometry(sourceGeometry);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (auto morph = dynamic_cast<SceneUtil::MorphGeometry*>(&drawable))
|
else if (auto morph = dynamic_cast<SceneUtil::MorphGeometry*>(&drawable))
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Geometry> sourceGeometry = morph->getSourceGeometry();
|
osg::ref_ptr<osg::Geometry> sourceGeometry = morph->getSourceGeometry();
|
||||||
if (sourceGeometry)
|
if (sourceGeometry && adjustGeometry(*sourceGeometry, reqs))
|
||||||
{
|
|
||||||
sourceGeometry->accept(*this);
|
|
||||||
morph->setSourceGeometry(sourceGeometry);
|
morph->setSourceGeometry(sourceGeometry);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (auto osgaRig = dynamic_cast<SceneUtil::RigGeometryHolder*>(&drawable))
|
else if (auto osgaRig = dynamic_cast<SceneUtil::RigGeometryHolder*>(&drawable))
|
||||||
{
|
{
|
||||||
osg::ref_ptr<SceneUtil::OsgaRigGeometry> sourceOsgaRigGeometry = osgaRig->getSourceRigGeometry();
|
osg::ref_ptr<SceneUtil::OsgaRigGeometry> sourceOsgaRigGeometry = osgaRig->getSourceRigGeometry();
|
||||||
osg::ref_ptr<osg::Geometry> sourceGeometry = sourceOsgaRigGeometry->getSourceGeometry();
|
osg::ref_ptr<osg::Geometry> sourceGeometry = sourceOsgaRigGeometry->getSourceGeometry();
|
||||||
if (sourceGeometry)
|
if (sourceGeometry && adjustGeometry(*sourceGeometry, reqs))
|
||||||
{
|
{
|
||||||
sourceGeometry->accept(*this);
|
|
||||||
sourceOsgaRigGeometry->setSourceGeometry(sourceGeometry);
|
sourceOsgaRigGeometry->setSourceGeometry(sourceGeometry);
|
||||||
osgaRig->setSourceRigGeometry(sourceOsgaRigGeometry);
|
osgaRig->setSourceRigGeometry(sourceOsgaRigGeometry);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user