Added support for cullable state, that uses a polytope to define the extents
of objects that will be influenced by it.
This commit is contained in:
@@ -28,7 +28,9 @@ class OSG_EXPORT CullingSet : public Referenced
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
typedef std::pair< osg::ref_ptr<osg::StateSet>, osg::Polytope > StateFrustumPair;
|
||||
typedef std::vector< StateFrustumPair > StateFrustumList;
|
||||
|
||||
CullingSet();
|
||||
|
||||
@@ -36,6 +38,7 @@ class OSG_EXPORT CullingSet : public Referenced
|
||||
Referenced(),
|
||||
_mask(cs._mask),
|
||||
_frustum(cs._frustum),
|
||||
_stateFrustumList(cs._stateFrustumList),
|
||||
_occluderList(cs._occluderList),
|
||||
_pixelSizeVector(cs._pixelSizeVector),
|
||||
_smallFeatureCullingPixelSize(cs._smallFeatureCullingPixelSize)
|
||||
@@ -45,6 +48,7 @@ class OSG_EXPORT CullingSet : public Referenced
|
||||
CullingSet(const CullingSet& cs,const Matrix& matrix, const Vec4& pixelSizeVector):
|
||||
_mask(cs._mask),
|
||||
_frustum(cs._frustum),
|
||||
_stateFrustumList(cs._stateFrustumList),
|
||||
_occluderList(cs._occluderList),
|
||||
_pixelSizeVector(pixelSizeVector),
|
||||
_smallFeatureCullingPixelSize(cs._smallFeatureCullingPixelSize)
|
||||
@@ -64,6 +68,7 @@ class OSG_EXPORT CullingSet : public Referenced
|
||||
|
||||
_mask = cs._mask;
|
||||
_frustum = cs._frustum;
|
||||
_stateFrustumList = cs._stateFrustumList;
|
||||
_occluderList = cs._occluderList;
|
||||
_pixelSizeVector = cs._pixelSizeVector;
|
||||
_smallFeatureCullingPixelSize = cs._smallFeatureCullingPixelSize;
|
||||
@@ -76,6 +81,7 @@ class OSG_EXPORT CullingSet : public Referenced
|
||||
{
|
||||
_mask = cs._mask;
|
||||
_frustum = cs._frustum;
|
||||
_stateFrustumList = cs._stateFrustumList;
|
||||
_occluderList = cs._occluderList;
|
||||
_pixelSizeVector = cs._pixelSizeVector;
|
||||
_smallFeatureCullingPixelSize = cs._smallFeatureCullingPixelSize;
|
||||
@@ -84,6 +90,7 @@ class OSG_EXPORT CullingSet : public Referenced
|
||||
inline void set(const CullingSet& cs,const Matrix& matrix, const Vec4& pixelSizeVector)
|
||||
{
|
||||
_mask = cs._mask;
|
||||
_stateFrustumList = cs._stateFrustumList;
|
||||
_occluderList = cs._occluderList;
|
||||
_pixelSizeVector = pixelSizeVector;
|
||||
_smallFeatureCullingPixelSize = cs._smallFeatureCullingPixelSize;
|
||||
@@ -93,6 +100,13 @@ class OSG_EXPORT CullingSet : public Referenced
|
||||
|
||||
_frustum.setAndTransformProvidingInverse(cs._frustum,matrix);
|
||||
|
||||
for(StateFrustumList::iterator itr=_stateFrustumList.begin();
|
||||
itr!=_stateFrustumList.end();
|
||||
++itr)
|
||||
{
|
||||
itr->second.transformProvidingInverse(matrix);
|
||||
}
|
||||
|
||||
for(OccluderList::iterator itr=_occluderList.begin();
|
||||
itr!=_occluderList.end();
|
||||
++itr)
|
||||
@@ -133,8 +147,12 @@ class OSG_EXPORT CullingSet : public Referenced
|
||||
Polytope& getFrustum() { return _frustum; }
|
||||
const Polytope& getFrustum() const { return _frustum; }
|
||||
|
||||
void addOccluder(ShadowVolumeOccluder& cv) { _occluderList.push_back(cv); }
|
||||
void addStateFrustum(StateSet* stateset, Polytope& polytope) { _stateFrustumList.push_back(StateFrustumPair(stateset,polytope)); }
|
||||
|
||||
void getStateFrustumList(StateFrustumList& sfl) { _stateFrustumList = sfl; }
|
||||
StateFrustumList& getStateFrustumList() { return _stateFrustumList; }
|
||||
|
||||
void addOccluder(ShadowVolumeOccluder& cv) { _occluderList.push_back(cv); }
|
||||
|
||||
void setPixelSizeVector(const Vec4& v) { _pixelSizeVector = v; }
|
||||
|
||||
@@ -247,6 +265,17 @@ class OSG_EXPORT CullingSet : public Referenced
|
||||
{
|
||||
_frustum.pushCurrentMask();
|
||||
|
||||
if (!_stateFrustumList.empty())
|
||||
{
|
||||
for(StateFrustumList::iterator itr=_stateFrustumList.begin();
|
||||
itr!=_stateFrustumList.end();
|
||||
++itr)
|
||||
{
|
||||
itr->second.pushCurrentMask();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef COMPILE_WITH_SHADOW_OCCLUSION_CULLING
|
||||
if (!_occluderList.empty())
|
||||
{
|
||||
@@ -264,6 +293,16 @@ class OSG_EXPORT CullingSet : public Referenced
|
||||
{
|
||||
_frustum.popCurrentMask();
|
||||
|
||||
if (!_stateFrustumList.empty())
|
||||
{
|
||||
for(StateFrustumList::iterator itr=_stateFrustumList.begin();
|
||||
itr!=_stateFrustumList.end();
|
||||
++itr)
|
||||
{
|
||||
itr->second.popCurrentMask();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef COMPILE_WITH_SHADOW_OCCLUSION_CULLING
|
||||
if (!_occluderList.empty())
|
||||
{
|
||||
@@ -286,11 +325,12 @@ class OSG_EXPORT CullingSet : public Referenced
|
||||
protected:
|
||||
|
||||
|
||||
Mask _mask;
|
||||
Polytope _frustum;
|
||||
OccluderList _occluderList;
|
||||
Vec4 _pixelSizeVector;
|
||||
float _smallFeatureCullingPixelSize;
|
||||
Mask _mask;
|
||||
Polytope _frustum;
|
||||
StateFrustumList _stateFrustumList;
|
||||
OccluderList _occluderList;
|
||||
Vec4 _pixelSizeVector;
|
||||
float _smallFeatureCullingPixelSize;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <osg/buffered_value>
|
||||
#include <osg/CameraNode>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/TexGenNode>
|
||||
|
||||
#include <osgSim/Export>
|
||||
@@ -92,7 +93,7 @@ class OSGSIM_EXPORT OverlayNode : public osg::Group
|
||||
osg::ref_ptr<osg::Texture2D> _texture;
|
||||
|
||||
bool _continousUpdate;
|
||||
osg::BoundingSphere _overlaySubgraphBound;
|
||||
osg::Polytope _textureFrustum;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user