diff --git a/apps/opencs/view/render/cameracontroller.cpp b/apps/opencs/view/render/cameracontroller.cpp index 518db2076a..bfdb000899 100644 --- a/apps/opencs/view/render/cameracontroller.cpp +++ b/apps/opencs/view/render/cameracontroller.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -541,4 +542,31 @@ namespace CSVRender getCamera()->setViewMatrixAsLookAt(mCenter + offset, mCenter, up); } + + CameraComputeBoundsVisitor::CameraComputeBoundsVisitor(unsigned int mask) + : mMask(mask) + { + } + + unsigned int CameraComputeBoundsVisitor::getMask() const + { + return mMask; + } + + void CameraComputeBoundsVisitor::setMask(unsigned int value) + { + mMask = value; + } + + void CameraComputeBoundsVisitor::apply(osg::Drawable& drawable) + { + if (drawable.getNodeMask() & mMask) + ComputeBoundsVisitor::apply(drawable); + } + + void CameraComputeBoundsVisitor::apply(osg::Transform& transform) + { + if (transform.getNodeMask() & mMask) + ComputeBoundsVisitor::apply(transform); + } } diff --git a/apps/opencs/view/render/cameracontroller.hpp b/apps/opencs/view/render/cameracontroller.hpp index 97a5ef2b26..fefa3a4221 100644 --- a/apps/opencs/view/render/cameracontroller.hpp +++ b/apps/opencs/view/render/cameracontroller.hpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -144,6 +145,21 @@ namespace CSVRender double mOrbitSpeed; double mOrbitSpeedMult; }; + + class CameraComputeBoundsVisitor : public osg::ComputeBoundsVisitor + { + public: + CameraComputeBoundsVisitor(unsigned int mask); + + unsigned int getMask() const; + void setMask(unsigned int mask); + + void apply(osg::Drawable& drawable); + void apply(osg::Transform& transform); + + private: + unsigned int mMask; + }; } #endif diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 5c565cd2f5..fe8de40e7b 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -315,7 +314,7 @@ void SceneWidget::update(double dt) } else { - osg::ComputeBoundsVisitor boundsVisitor; + CameraComputeBoundsVisitor boundsVisitor(Mask_Reference | Mask_Terrain); osg::BoundingBox &boundingBox(boundsVisitor.getBoundingBox()); mRootNode->accept(boundsVisitor);