mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-07 12:54:00 +00:00
minor objectpaging.cpp scene graph optimisations (#3155)
We now use PositionAttitudeTransform for unmerged nodes because I have been informed PositionAttitudeTransform's scene graph performance is measurably faster than MatrixTransform's. We still need to use MatrixTransform for merged nodes because the Optimizer has limited support for non-MatrixTransform nodes. These MatrixTransforms will be removed in the merging process anyway.
This commit is contained in:
parent
c2d836c6c4
commit
cbcdd705ee
@ -13,6 +13,7 @@
|
|||||||
#include <components/misc/resourcehelpers.hpp>
|
#include <components/misc/resourcehelpers.hpp>
|
||||||
#include <components/resource/scenemanager.hpp>
|
#include <components/resource/scenemanager.hpp>
|
||||||
#include <components/sceneutil/optimizer.hpp>
|
#include <components/sceneutil/optimizer.hpp>
|
||||||
|
#include <components/sceneutil/positionattitudetransform.hpp>
|
||||||
#include <components/sceneutil/clone.hpp>
|
#include <components/sceneutil/clone.hpp>
|
||||||
#include <components/sceneutil/util.hpp>
|
#include <components/sceneutil/util.hpp>
|
||||||
#include <components/vfs/manager.hpp>
|
#include <components/vfs/manager.hpp>
|
||||||
@ -590,14 +591,31 @@ namespace MWRender
|
|||||||
if (!activeGrid && minSizeMerged != minSize && cnode->getBound().radius2() * cref->mScale*cref->mScale < (viewPoint-pos).length2()*minSizeMerged*minSizeMerged)
|
if (!activeGrid && minSizeMerged != minSize && cnode->getBound().radius2() * cref->mScale*cref->mScale < (viewPoint-pos).length2()*minSizeMerged*minSizeMerged)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
osg::Matrixf matrix;
|
osg::Vec3f nodePos = pos - worldCenter;
|
||||||
matrix.preMultTranslate(pos - worldCenter);
|
osg::Quat nodeAttitude = osg::Quat(ref.mPos.rot[2], osg::Vec3f(0,0,-1)) *
|
||||||
matrix.preMultRotate( osg::Quat(ref.mPos.rot[2], osg::Vec3f(0,0,-1)) *
|
|
||||||
osg::Quat(ref.mPos.rot[1], osg::Vec3f(0,-1,0)) *
|
osg::Quat(ref.mPos.rot[1], osg::Vec3f(0,-1,0)) *
|
||||||
osg::Quat(ref.mPos.rot[0], osg::Vec3f(-1,0,0)) );
|
osg::Quat(ref.mPos.rot[0], osg::Vec3f(-1,0,0));
|
||||||
matrix.preMultScale(osg::Vec3f(ref.mScale, ref.mScale, ref.mScale));
|
osg::Vec3f nodeScale = osg::Vec3f(ref.mScale, ref.mScale, ref.mScale);
|
||||||
osg::ref_ptr<osg::MatrixTransform> trans = new osg::MatrixTransform(matrix);
|
|
||||||
trans->setDataVariance(osg::Object::STATIC);
|
osg::ref_ptr<osg::Group> trans;
|
||||||
|
if (merge)
|
||||||
|
{
|
||||||
|
// Optimizer currently supports only MatrixTransforms.
|
||||||
|
osg::Matrixf matrix;
|
||||||
|
matrix.preMultTranslate(nodePos);
|
||||||
|
matrix.preMultRotate(nodeAttitude);
|
||||||
|
matrix.preMultScale(nodeScale);
|
||||||
|
trans = new osg::MatrixTransform(matrix);
|
||||||
|
trans->setDataVariance(osg::Object::STATIC);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
trans = new SceneUtil::PositionAttitudeTransform;
|
||||||
|
SceneUtil::PositionAttitudeTransform* pat = static_cast<SceneUtil::PositionAttitudeTransform*>(trans.get());
|
||||||
|
pat->setPosition(nodePos);
|
||||||
|
pat->setScale(nodeScale);
|
||||||
|
pat->setAttitude(nodeAttitude);
|
||||||
|
}
|
||||||
|
|
||||||
copyop.setCopyFlags(merge ? osg::CopyOp::DEEP_COPY_NODES|osg::CopyOp::DEEP_COPY_DRAWABLES : osg::CopyOp::DEEP_COPY_NODES);
|
copyop.setCopyFlags(merge ? osg::CopyOp::DEEP_COPY_NODES|osg::CopyOp::DEEP_COPY_DRAWABLES : osg::CopyOp::DEEP_COPY_NODES);
|
||||||
copyop.mOptimizeBillboards = (size > 1/4.f);
|
copyop.mOptimizeBillboards = (size > 1/4.f);
|
||||||
|
Loading…
Reference in New Issue
Block a user