Removed CullViewState from the distribution, moved CullViewState::CullingMode
into CullVisitor, and then removed all references to CullViewState from other parts of the scene graph.
This commit is contained in:
@@ -1,89 +0,0 @@
|
||||
//C++ header - Open Scene Graph - Copyright (C) 1998-2001 Robert Osfield
|
||||
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
||||
//as published by the Free Software Foundation.
|
||||
|
||||
#ifndef OSGUTIL_CULLVIEWSTATE
|
||||
#define OSGUTIL_CULLVIEWSTATE 1
|
||||
|
||||
#include <osg/BoundingSphere>
|
||||
#include <osg/BoundingBox>
|
||||
#include <osg/Matrix>
|
||||
#include <osg/ClippingVolume>
|
||||
|
||||
#include <osgUtil/Export>
|
||||
|
||||
namespace osgUtil {
|
||||
|
||||
/** Container class for encapsulating the viewing state in local
|
||||
coordinates, during the cull traversal.
|
||||
*/
|
||||
class OSGUTIL_EXPORT CullViewState : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
|
||||
CullViewState();
|
||||
|
||||
osg::ref_ptr<osg::Matrix> _projection;
|
||||
osg::ref_ptr<osg::Matrix> _matrix;
|
||||
osg::ref_ptr<osg::Matrix> _inverse;
|
||||
osg::Vec3 _eyePoint;
|
||||
osg::Vec3 _centerPoint;
|
||||
osg::Vec3 _lookVector;
|
||||
osg::Vec3 _upVector;
|
||||
unsigned int _bbCornerFar;
|
||||
unsigned int _bbCornerNear;
|
||||
float _ratio2;
|
||||
|
||||
osg::ClippingVolume _clippingVolume;
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
NO_CULLING = 0x00,
|
||||
FRUSTUM_LEFT_CULLING = 0x01,
|
||||
FRUSTUM_RIGHT_CULLING = 0x02,
|
||||
FRUSTUM_BOTTOM_CULLING = 0x04,
|
||||
FRUSTUM_TOP_CULLING = 0x08,
|
||||
FRUSTUM_NEAR_CULLING = 0x10,
|
||||
FRUSTUM_FAR_CULLING = 0x20,
|
||||
VIEW_FRUSTUM_CULLING = 0x3F,
|
||||
SMALL_FEATURE_CULLING = 0x40,
|
||||
ENABLE_ALL_CULLING = 0x7F
|
||||
};
|
||||
|
||||
typedef unsigned int CullingMode;
|
||||
|
||||
inline bool isCulled(const osg::BoundingSphere& sp,CullingMode& mode) const
|
||||
{
|
||||
if (!sp.isValid()) return true;
|
||||
|
||||
if (!_clippingVolume.contains(sp,mode)) return true;
|
||||
|
||||
if (mode&SMALL_FEATURE_CULLING)
|
||||
{
|
||||
osg::Vec3 delta(sp._center-_eyePoint);
|
||||
if (sp.radius2()<delta.length2()*_ratio2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool isCulled(const osg::BoundingBox& bb,CullingMode mode) const
|
||||
{
|
||||
if (!bb.isValid()) return true;
|
||||
|
||||
return !_clippingVolume.contains(bb,mode);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
~CullViewState();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#include <osgUtil/RenderGraph>
|
||||
#include <osgUtil/RenderStage>
|
||||
#include <osgUtil/CullViewState>
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
@@ -39,6 +38,23 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
|
||||
enum
|
||||
{
|
||||
NO_CULLING = 0x00,
|
||||
FRUSTUM_LEFT_CULLING = 0x01,
|
||||
FRUSTUM_RIGHT_CULLING = 0x02,
|
||||
FRUSTUM_BOTTOM_CULLING = 0x04,
|
||||
FRUSTUM_TOP_CULLING = 0x08,
|
||||
FRUSTUM_NEAR_CULLING = 0x10,
|
||||
FRUSTUM_FAR_CULLING = 0x20,
|
||||
VIEW_FRUSTUM_CULLING = 0x3F,
|
||||
SMALL_FEATURE_CULLING = 0x40,
|
||||
ENABLE_ALL_CULLING = 0x7F
|
||||
};
|
||||
|
||||
typedef unsigned int CullingMode;
|
||||
|
||||
|
||||
CullVisitor();
|
||||
virtual ~CullVisitor();
|
||||
|
||||
@@ -105,10 +121,10 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor
|
||||
void setTransparencySortMode(TransparencySortMode tsm) { _tsm = tsm; }
|
||||
|
||||
/** Sets the current CullingMode.*/
|
||||
void setCullingMode(CullViewState::CullingMode mode);
|
||||
void setCullingMode(CullingMode mode);
|
||||
|
||||
/** Returns the current CullingMode.*/
|
||||
CullViewState::CullingMode getCullingMode() const;
|
||||
CullingMode getCullingMode() const;
|
||||
|
||||
|
||||
void pushViewport(osg::Viewport* viewport);
|
||||
@@ -216,13 +232,13 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor
|
||||
}
|
||||
|
||||
|
||||
inline bool isCulled(const osg::BoundingSphere& sp,CullViewState::CullingMode& mode) const
|
||||
inline bool isCulled(const osg::BoundingSphere& sp,CullingMode& mode) const
|
||||
{
|
||||
if (!sp.isValid()) return true;
|
||||
|
||||
if (!(_modelviewClippingVolumeStack.back().contains(sp,mode))) return true;
|
||||
|
||||
if (mode&CullViewState::SMALL_FEATURE_CULLING)
|
||||
if (mode&SMALL_FEATURE_CULLING)
|
||||
{
|
||||
const float _ratio2 = 0.002f*0.002f;
|
||||
osg::Vec3 delta(sp._center-getEyeLocal());
|
||||
@@ -234,7 +250,7 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor
|
||||
return false;
|
||||
}
|
||||
|
||||
inline const bool isCulled(const osg::BoundingBox& bb,CullViewState::CullingMode mode) const
|
||||
inline const bool isCulled(const osg::BoundingBox& bb,CullingMode mode) const
|
||||
{
|
||||
if (!bb.isValid()) return true;
|
||||
|
||||
@@ -370,7 +386,7 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor
|
||||
typedef std::vector<osg::Vec3> EyePointStack;
|
||||
EyePointStack _eyePointStack;
|
||||
|
||||
typedef std::vector<CullViewState::CullingMode> CullingModeStack;
|
||||
typedef std::vector<CullingMode> CullingModeStack;
|
||||
CullingModeStack _cullingModeStack;
|
||||
|
||||
unsigned int _bbCornerNear;
|
||||
|
||||
Reference in New Issue
Block a user