Added support for occluders occluding other occluders, which helps reduce
the number of occluder that will be used in cull traversal to only the ones that will be effective. Note. Holes in occluders arn't handled in this occluder occlusion test, will implement this later.
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
#include <osg/NodeVisitor>
|
||||
#include <osg/CullStack>
|
||||
|
||||
#include <set>
|
||||
|
||||
namespace osg {
|
||||
|
||||
class SG_EXPORT CollectOccludersVisitor : public osg::NodeVisitor, public osg::CullStack
|
||||
@@ -15,6 +17,8 @@ class SG_EXPORT CollectOccludersVisitor : public osg::NodeVisitor, public osg::C
|
||||
public:
|
||||
|
||||
|
||||
typedef std::set<ShadowVolumeOccluder> ShadowVolumeOccluderSet;
|
||||
|
||||
CollectOccludersVisitor();
|
||||
virtual ~CollectOccludersVisitor();
|
||||
|
||||
@@ -37,9 +41,12 @@ class SG_EXPORT CollectOccludersVisitor : public osg::NodeVisitor, public osg::C
|
||||
void setCreateDrawablesOnOccludeNodes(bool flag) { _createDrawables=flag; }
|
||||
bool getCreateDrawablesOnOccludeNodes() const { return _createDrawables; }
|
||||
|
||||
void setCollectedOcculderList(const ShadowVolumeOccluderList& svol) { _occluderList = svol; }
|
||||
ShadowVolumeOccluderList& getCollectedOccluderList() { return _occluderList; }
|
||||
const ShadowVolumeOccluderList& getCollectedOccluderList() const { return _occluderList; }
|
||||
void setCollectedOcculderList(const ShadowVolumeOccluderSet& svol) { _occluderSet = svol; }
|
||||
ShadowVolumeOccluderSet& getCollectedOccluderSet() { return _occluderSet; }
|
||||
const ShadowVolumeOccluderSet& getCollectedOccluderSet() const { return _occluderSet; }
|
||||
|
||||
/** remove occluded occluders for the collected occluders list.*/
|
||||
void removeOccludedOccluders();
|
||||
|
||||
|
||||
protected:
|
||||
@@ -66,7 +73,7 @@ class SG_EXPORT CollectOccludersVisitor : public osg::NodeVisitor, public osg::C
|
||||
|
||||
float _minimumShadowOccluderVolume;
|
||||
bool _createDrawables;
|
||||
ShadowVolumeOccluderList _collectedOccluderList;
|
||||
ShadowVolumeOccluderSet _occluderSet;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -18,16 +18,18 @@ class SG_EXPORT Polytope
|
||||
|
||||
public:
|
||||
|
||||
typedef unsigned int ClippingMask;
|
||||
typedef std::vector<Plane> PlaneList;
|
||||
typedef fast_back_stack<ClippingMask> MaskStack;
|
||||
typedef unsigned int ClippingMask;
|
||||
typedef std::vector<Plane> PlaneList;
|
||||
typedef std::vector<Vec3> VertexList;
|
||||
typedef fast_back_stack<ClippingMask> MaskStack;
|
||||
|
||||
inline Polytope() {setupMask();}
|
||||
|
||||
inline Polytope(const Polytope& cv) :
|
||||
_maskStack(cv._maskStack),
|
||||
_resultMask(cv._resultMask),
|
||||
_planeList(cv._planeList) {}
|
||||
_planeList(cv._planeList),
|
||||
_referenceVertexList(cv._referenceVertexList) {}
|
||||
|
||||
inline Polytope(const PlaneList& pl) : _planeList(pl) {setupMask();}
|
||||
|
||||
@@ -41,6 +43,7 @@ class SG_EXPORT Polytope
|
||||
_maskStack = cv._maskStack;
|
||||
_resultMask = cv._resultMask;
|
||||
_planeList = cv._planeList;
|
||||
_referenceVertexList = cv._referenceVertexList;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -77,6 +80,14 @@ class SG_EXPORT Polytope
|
||||
|
||||
inline const PlaneList& getPlaneList() const { return _planeList; }
|
||||
|
||||
|
||||
inline void setReferenceVertexList(VertexList& vertices) { _referenceVertexList=vertices; }
|
||||
|
||||
inline VertexList& getReferenceVertexList() { return _referenceVertexList; }
|
||||
|
||||
inline const VertexList& getReferenceVertexList() const { return _referenceVertexList; }
|
||||
|
||||
|
||||
inline void setupMask()
|
||||
{
|
||||
_resultMask = 0;
|
||||
@@ -312,6 +323,7 @@ class SG_EXPORT Polytope
|
||||
MaskStack _maskStack;
|
||||
ClippingMask _resultMask;
|
||||
PlaneList _planeList;
|
||||
VertexList _referenceVertexList;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ class SG_EXPORT ShadowVolumeOccluder
|
||||
_volume(0.0f) {}
|
||||
|
||||
|
||||
bool operator < (const ShadowVolumeOccluder& svo) const { return getVolume()>svo.getVolume(); } // not greater volume first.
|
||||
|
||||
/** compute the shadow volume occluder. */
|
||||
bool computeOccluder(const NodePath& nodePath,const ConvexPlanerOccluder& occluder,CullStack& cullStack,bool createDrawables=false);
|
||||
|
||||
@@ -86,7 +88,7 @@ class SG_EXPORT ShadowVolumeOccluder
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
// protected:
|
||||
|
||||
float _volume;
|
||||
NodePath _nodePath;
|
||||
|
||||
Reference in New Issue
Block a user