Additions for the support for ConvexPlaneOccluder. Work still underway.
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
#include <osg/Referenced>
|
||||
#include <osg/Matrix>
|
||||
#include <osg/Quat>
|
||||
#include <osg/ClippingVolume>
|
||||
#include <osg/Viewport>
|
||||
#include <osg/DisplaySettings>
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace osg {
|
||||
|
||||
class OccluderVolume;
|
||||
|
||||
/** A ClippingVolume class for representing convex clipping volumes made up.
|
||||
/** A class for representing convex clipping volumes made up.
|
||||
* When adding planes, their normals should point inwards (into the volume) */
|
||||
class SG_EXPORT ConvexPlanerOccluder : public Referenced
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace osg {
|
||||
class BoundingBox;
|
||||
class BoundingSphere;
|
||||
|
||||
/** A ClippingVolume class for representing convex clipping volumes made up.
|
||||
/** A class for representing convex clipping volumes made up.
|
||||
* When adding planes, their normals should point inwards (into the volume) */
|
||||
class SG_EXPORT ConvexPlanerPolygon
|
||||
{
|
||||
|
||||
@@ -126,13 +126,17 @@ class SG_EXPORT Node : public Object
|
||||
* to the cull traversal.*/
|
||||
void setCullingActive(const bool active);
|
||||
|
||||
/** Get the view frustum/small feature _cullingActive flag. Used a guide
|
||||
/** Get the view frustum/small feature _cullingActive flag for this node. Used a guide
|
||||
* to the cull traversal.*/
|
||||
inline const bool getCullingActive() const { return _cullingActive; }
|
||||
|
||||
/** Get the number of Children of this node which have culling disabled.*/
|
||||
inline const int getNumChildrenWithCullingDisabled() const { return _numChildrenWithCullingDisabled; }
|
||||
|
||||
/** Return true if this node can be culled by view frustum, occlusion or small feature culling during the cull traversal.
|
||||
* note, return true only if no children have culling disabled, and the local _cullingActive flag is true.*/
|
||||
inline const bool isCullingActive() const { return _numChildrenWithCullingDisabled==0 && _cullingActive && _bsphere.isValid(); }
|
||||
|
||||
|
||||
/**
|
||||
* Set user data, data must be subclased from Referenced to allow
|
||||
|
||||
@@ -2,48 +2,48 @@
|
||||
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
||||
//as published by the Free Software Foundation.
|
||||
|
||||
#ifndef OSG_CLIPPINGVOLUME
|
||||
#define OSG_CLIPPINGVOLUME 1
|
||||
#ifndef OSG_POLYTOPE
|
||||
#define OSG_POLYTOPE 1
|
||||
|
||||
#include <osg/Plane>
|
||||
|
||||
#include <vector>
|
||||
#include <osg/fast_back_stack>
|
||||
|
||||
namespace osg {
|
||||
|
||||
/** A ClippingVolume class for representing convex clipping volumes made up.
|
||||
|
||||
/** A Polytope class for representing convex clipping volumes made up.
|
||||
* When adding planes, their normals should point inwards (into the volume) */
|
||||
class SG_EXPORT ClippingVolume
|
||||
class SG_EXPORT Polytope
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
typedef unsigned int ClippingMask;
|
||||
typedef std::vector<osg::Plane> PlaneList;
|
||||
|
||||
inline ClippingVolume() {setupMask();}
|
||||
inline Polytope() {setupMask();}
|
||||
|
||||
inline ClippingVolume(const ClippingVolume& cs, const unsigned int mask)
|
||||
{
|
||||
set(cs,mask);
|
||||
}
|
||||
|
||||
inline ClippingVolume(const ClippingVolume& cv) : _localMask(cv._localMask), _planeList(cv._planeList) {}
|
||||
inline Polytope(const Polytope& cv) :
|
||||
_maskStack(cv._maskStack),
|
||||
_resultsMask(cv._resultsMask),
|
||||
_planeList(cv._planeList) {}
|
||||
|
||||
inline ClippingVolume(const PlaneList& pl) : _planeList(pl) {setupMask();}
|
||||
inline Polytope(const PlaneList& pl) : _planeList(pl) {setupMask();}
|
||||
|
||||
inline ~ClippingVolume() {}
|
||||
inline ~Polytope() {}
|
||||
|
||||
inline void clear() { _planeList.clear(); setupMask(); }
|
||||
|
||||
inline ClippingVolume& operator = (const ClippingVolume& cv)
|
||||
inline Polytope& operator = (const Polytope& cv)
|
||||
{
|
||||
if (&cv==this) return *this;
|
||||
_localMask = cv._localMask;
|
||||
_planeList = cv._planeList;
|
||||
return *this;
|
||||
_maskStack = cv._maskStack;
|
||||
_resultsMask = cv._resultsMask;
|
||||
_planeList = cv._planeList;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** Create a ClippingVolume with is cube, centered at 0,0,0, with sides of 2 units.*/
|
||||
/** Create a Polytope with is cube, centered at 0,0,0, with sides of 2 units.*/
|
||||
void setToUnitFrustum()
|
||||
{
|
||||
_planeList.erase(_planeList.begin(),_planeList.end());
|
||||
@@ -66,22 +66,6 @@ class SG_EXPORT ClippingVolume
|
||||
setupMask();
|
||||
}
|
||||
|
||||
inline void set(const ClippingVolume& cs, const unsigned int mask)
|
||||
{
|
||||
_planeList.erase(_planeList.begin(),_planeList.end());
|
||||
unsigned int selector_mask = 0x1;
|
||||
for(PlaneList::const_iterator itr=cs._planeList.begin();
|
||||
itr!=cs._planeList.end();
|
||||
++itr)
|
||||
{
|
||||
if (mask&selector_mask) _planeList.push_back(*itr);
|
||||
selector_mask <<= 1;
|
||||
}
|
||||
setupMask();
|
||||
}
|
||||
|
||||
inline void set(const ClippingVolume& cs) { _planeList = cs._planeList; setupMask(); }
|
||||
|
||||
inline void set(const PlaneList& pl) { _planeList = pl; setupMask(); }
|
||||
|
||||
inline void add(const osg::Plane& pl) { _planeList.push_back(pl); setupMask(); }
|
||||
@@ -92,37 +76,44 @@ class SG_EXPORT ClippingVolume
|
||||
|
||||
inline void setupMask()
|
||||
{
|
||||
_localMask = 0;
|
||||
_resultsMask = 0;
|
||||
for(unsigned int i=0;i<_planeList.size();++i)
|
||||
{
|
||||
_localMask = (_localMask<<1) | 1;
|
||||
_resultsMask = (_resultsMask<<1) | 1;
|
||||
}
|
||||
_maskStack.back() = _resultsMask;
|
||||
}
|
||||
|
||||
unsigned int getLocalMask() const { return _localMask; }
|
||||
|
||||
inline ClippingMask& getCurrentMask() { return _maskStack.back(); }
|
||||
|
||||
inline ClippingMask getCurrentMask() const { return _maskStack.back(); }
|
||||
|
||||
inline ClippingMask getResultsMask() const
|
||||
{
|
||||
return _resultsMask;
|
||||
}
|
||||
|
||||
inline void pushCurrentMask()
|
||||
{
|
||||
_maskStack.push_back(_resultsMask);
|
||||
}
|
||||
|
||||
inline void popCurrentMask()
|
||||
{
|
||||
_maskStack.pop_back();
|
||||
}
|
||||
|
||||
/** Check whether a vertex is contained with clipping set.*/
|
||||
inline const bool contains(const osg::Vec3& v) const
|
||||
{
|
||||
for(PlaneList::const_iterator itr=_planeList.begin();
|
||||
itr!=_planeList.end();
|
||||
++itr)
|
||||
{
|
||||
if (itr->distance(v)<0.0f) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
inline const bool contains(const osg::Vec3& v,const unsigned int mask) const
|
||||
{
|
||||
if (!(mask & _localMask)) return true;
|
||||
if (!_maskStack.back()) return true;
|
||||
|
||||
unsigned int selector_mask = 0x1;
|
||||
for(PlaneList::const_iterator itr=_planeList.begin();
|
||||
itr!=_planeList.end();
|
||||
++itr)
|
||||
{
|
||||
if (mask&selector_mask && (itr->distance(v)<0.0f)) return false;
|
||||
if ((_maskStack.back()&selector_mask) && (itr->distance(v)<0.0f)) return false;
|
||||
selector_mask <<= 1;
|
||||
}
|
||||
return true;
|
||||
@@ -133,95 +124,97 @@ class SG_EXPORT ClippingVolume
|
||||
modifying the mask to turn off planes which wouldn't contribute to clipping
|
||||
of any internal objects. This feature is used in osgUtil::CullVisitor
|
||||
to prevent redundant plane checking.*/
|
||||
inline const bool contains(const osg::BoundingSphere& bs,unsigned int& mask) const
|
||||
inline const bool contains(const osg::BoundingSphere& bs)
|
||||
{
|
||||
if (!(mask & _localMask)) return true;
|
||||
if (!_maskStack.back()) return true;
|
||||
|
||||
_resultsMask = _maskStack.back();
|
||||
ClippingMask selector_mask = 0x1;
|
||||
|
||||
unsigned int selector_mask = 0x1;
|
||||
for(PlaneList::const_iterator itr=_planeList.begin();
|
||||
itr!=_planeList.end();
|
||||
++itr)
|
||||
{
|
||||
if (mask&selector_mask)
|
||||
if (_resultsMask&selector_mask)
|
||||
{
|
||||
int res=itr->intersect(bs);
|
||||
if (res<0) return false; // outside clipping set.
|
||||
else if (res>0) mask ^= selector_mask; // subsequent checks against this plane not required.
|
||||
else if (res>0) _resultsMask ^= selector_mask; // subsequent checks against this plane not required.
|
||||
}
|
||||
selector_mask <<= 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Check whether any part of a bounding sphere is contained within clipping set.*/
|
||||
inline const bool contains(const osg::BoundingSphere& bs) const
|
||||
{
|
||||
for(PlaneList::const_iterator itr=_planeList.begin();
|
||||
itr!=_planeList.end();
|
||||
++itr)
|
||||
{
|
||||
if (itr->intersect(bs)<0) return false; // outside clipping set.
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Check whether any part of a bounding box is contained within clipping set.
|
||||
Using a mask to determine which planes should be used for the check, and
|
||||
modifying the mask to turn off planes which wouldn't contribute to clipping
|
||||
of any internal objects. This feature is used in osgUtil::CullVisitor
|
||||
to prevent redundant plane checking.*/
|
||||
inline const bool contains(const osg::BoundingBox& bb,unsigned int& mask) const
|
||||
inline const bool contains(const osg::BoundingBox& bb)
|
||||
{
|
||||
if (!(mask & _localMask)) return true;
|
||||
if (!_maskStack.back()) return true;
|
||||
|
||||
_resultsMask = _maskStack.back();
|
||||
ClippingMask selector_mask = 0x1;
|
||||
|
||||
unsigned int selector_mask = 0x1;
|
||||
for(PlaneList::const_iterator itr=_planeList.begin();
|
||||
itr!=_planeList.end();
|
||||
++itr)
|
||||
{
|
||||
if (mask&selector_mask)
|
||||
if (_resultsMask&selector_mask)
|
||||
{
|
||||
int res=itr->intersect(bb);
|
||||
if (res<0) return false; // outside clipping set.
|
||||
else if (res>0) mask ^= selector_mask; // subsequent checks against this plane not required.
|
||||
else if (res>0) _resultsMask ^= selector_mask; // subsequent checks against this plane not required.
|
||||
}
|
||||
selector_mask <<= 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Check whether any part of a bounding box is contained within clipping set.*/
|
||||
inline const bool contains(const osg::BoundingBox& bb) const
|
||||
{
|
||||
for(PlaneList::const_iterator itr=_planeList.begin();
|
||||
itr!=_planeList.end();
|
||||
++itr)
|
||||
{
|
||||
if (itr->intersect(bb)<0) return false; // outside clipping set.
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Check whether the entire bounding sphere is contained within clipping set.*/
|
||||
inline const bool containsAllOf(const osg::BoundingSphere& bs) const
|
||||
inline const bool containsAllOf(const osg::BoundingSphere& bs)
|
||||
{
|
||||
if (!_maskStack.back()) return false;
|
||||
|
||||
_resultsMask = _maskStack.back();
|
||||
ClippingMask selector_mask = 0x1;
|
||||
|
||||
for(PlaneList::const_iterator itr=_planeList.begin();
|
||||
itr!=_planeList.end();
|
||||
++itr)
|
||||
{
|
||||
if (itr->intersect(bs)<1) return false; // intersects, or is below plane.
|
||||
if (_resultsMask&selector_mask)
|
||||
{
|
||||
int res=itr->intersect(bs);
|
||||
if (res<1) return false; // intersects, or is below plane.
|
||||
_resultsMask ^= selector_mask; // subsequent checks against this plane not required.
|
||||
}
|
||||
selector_mask <<= 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Check whether the entire bounding box is contained within clipping set.*/
|
||||
inline const bool containsAllOf(const osg::BoundingBox& bb) const
|
||||
inline const bool containsAllOf(const osg::BoundingBox& bb)
|
||||
{
|
||||
if (!_maskStack.back()) return false;
|
||||
|
||||
_resultsMask = _maskStack.back();
|
||||
ClippingMask selector_mask = 0x1;
|
||||
|
||||
for(PlaneList::const_iterator itr=_planeList.begin();
|
||||
itr!=_planeList.end();
|
||||
++itr)
|
||||
{
|
||||
if (itr->intersect(bb)<1) return false; // intersects, or is below plane.
|
||||
if (_resultsMask&selector_mask)
|
||||
{
|
||||
int res=itr->intersect(bb);
|
||||
if (res<1) return false; // intersects, or is below plane.
|
||||
_resultsMask ^= selector_mask; // subsequent checks against this plane not required.
|
||||
}
|
||||
selector_mask <<= 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -244,19 +237,28 @@ class SG_EXPORT ClippingVolume
|
||||
* see transform for details. */
|
||||
inline void transformProvidingInverse(const osg::Matrix& matrix)
|
||||
{
|
||||
if (!_maskStack.back()) return;
|
||||
|
||||
_resultsMask = _maskStack.back();
|
||||
ClippingMask selector_mask = 0x1;
|
||||
for(PlaneList::iterator itr=_planeList.begin();
|
||||
itr!=_planeList.end();
|
||||
++itr)
|
||||
{
|
||||
itr->transformProvidingInverse(matrix);
|
||||
if (_resultsMask&selector_mask)
|
||||
{
|
||||
itr->transformProvidingInverse(matrix);
|
||||
selector_mask <<= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
unsigned int _localMask;
|
||||
PlaneList _planeList;
|
||||
fast_back_stack<ClippingMask> _maskStack;
|
||||
ClippingMask _resultsMask;
|
||||
PlaneList _planeList;
|
||||
|
||||
};
|
||||
|
||||
@@ -6,24 +6,27 @@
|
||||
#define OSG_SHADOWOCCLUDERVOLUME 1
|
||||
|
||||
#include <osg/ref_ptr>
|
||||
#include <osg/ClippingVolume>
|
||||
#include <osg/Polytope>
|
||||
#include <osg/ConvexPlanerOccluder>
|
||||
|
||||
namespace osg {
|
||||
|
||||
/** ShadowOccluderVolume is a helper class for implementating shadow occlusion culling. */
|
||||
class SG_EXPORT ShadowOccluderVolume : public Referenced
|
||||
class SG_EXPORT ShadowOccluderVolume
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
typedef std::vector<Polytope> HoleList;
|
||||
|
||||
ShadowOccluderVolume(const ShadowOccluderVolume& soc,Matrix& MVP);
|
||||
|
||||
ShadowOccluderVolume(const ConvexPlanerOccluder& occluder,Matrix& MVP);
|
||||
|
||||
typedef std::vector<ClippingVolume> ClippingHoleList;
|
||||
|
||||
inline void pushCurrentMask();
|
||||
inline void popCurrentMask();
|
||||
|
||||
/** Convert shadow occluder into local coords by multiplying the
|
||||
* clip space occluder by the ModelViewProjectionMatrix.*/
|
||||
void set(const ShadowOccluderVolume& soc,Matrix& MVP);
|
||||
@@ -34,23 +37,46 @@ class SG_EXPORT ShadowOccluderVolume : public Referenced
|
||||
|
||||
/** return true if the specified bounding sphere is contaned entirely
|
||||
* within this shadow occluder volume.*/
|
||||
bool contains(const BoundingSphere& bs);
|
||||
bool contains(const BoundingSphere& bound);
|
||||
|
||||
/** return true if the specified bounding box is contained entirely
|
||||
* within this shadow occluder volume.*/
|
||||
bool contains(const BoundingBox& bs);
|
||||
|
||||
|
||||
bool contains(const BoundingBox& bound);
|
||||
|
||||
protected:
|
||||
|
||||
// the original shadow occluder computed in clip space
|
||||
ref_ptr<ShadowOccluderVolume> _clipSpaceOccluder;
|
||||
|
||||
ClippingVolume _occluderVolume;
|
||||
ClippingHoleList _clippingHoleList;
|
||||
Polytope _occluderVolume;
|
||||
HoleList _holeList;
|
||||
};
|
||||
|
||||
inline void ShadowOccluderVolume::pushCurrentMask()
|
||||
{
|
||||
_occluderVolume.pushCurrentMask();
|
||||
if (!_holeList.empty())
|
||||
{
|
||||
for(HoleList::iterator itr=_holeList.begin();
|
||||
itr!=_holeList.end();
|
||||
++itr)
|
||||
{
|
||||
itr->pushCurrentMask();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void ShadowOccluderVolume::popCurrentMask()
|
||||
{
|
||||
_occluderVolume.popCurrentMask();
|
||||
if (!_holeList.empty())
|
||||
{
|
||||
for(HoleList::iterator itr=_holeList.begin();
|
||||
itr!=_holeList.end();
|
||||
++itr)
|
||||
{
|
||||
itr->popCurrentMask();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // end of namespace
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include <osg/FrameStamp>
|
||||
#include <osg/DisplaySettings>
|
||||
#include <osg/ClippingVolume>
|
||||
#include <osg/Polytope>
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
@@ -100,8 +100,7 @@ class SG_EXPORT State : public Referenced
|
||||
}
|
||||
|
||||
|
||||
ClippingVolume getClippingVolume() const;
|
||||
|
||||
Polytope getViewFrustum() const;
|
||||
|
||||
|
||||
/** Apply stateset.*/
|
||||
|
||||
@@ -82,7 +82,6 @@ class SG_EXPORT Texture : public StateAttribute
|
||||
StateAttribute(text,copyop),
|
||||
_handleList(),
|
||||
_modifiedTag(),
|
||||
_textureObjectSize(text._textureObjectSize),
|
||||
_image(copyop(text._image.get())),
|
||||
_target(text._target),
|
||||
_textureUnit(text._textureUnit),
|
||||
@@ -232,11 +231,6 @@ class SG_EXPORT Texture : public StateAttribute
|
||||
/** return the OpenGL texture object for specified context.*/
|
||||
inline const uint getTextureObject(const uint contextID) const { if (contextID<_handleList.size()) return _handleList[contextID]; else return 0;}
|
||||
|
||||
/** return the memory size of texture object.
|
||||
* Texture object size can be used for estimating the cost of
|
||||
* uploading the texture to graphics hardware, which in turn can
|
||||
* be used for setting texture residence priorities. */
|
||||
inline const uint getTextureObjectSize() const { return _textureObjectSize; }
|
||||
|
||||
enum SubloadMode {
|
||||
OFF,
|
||||
@@ -339,9 +333,6 @@ class SG_EXPORT Texture : public StateAttribute
|
||||
typedef std::vector<uint> ImageModifiedTag;
|
||||
mutable ImageModifiedTag _modifiedTag;
|
||||
|
||||
// size of the created OpenGL texture object, may be estimated.
|
||||
mutable uint _textureObjectSize;
|
||||
|
||||
|
||||
// not ideal that _image is mutable, but its required since
|
||||
// Image::ensureDimensionsArePowerOfTwo() can only be called
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef OSG_FAST_BACK_STACK
|
||||
#define OSG_FAST_BACK_STACK 1
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace osg {
|
||||
|
||||
/** Simple stack implementation that keeps the back() cached locally for fast access
|
||||
@@ -22,8 +24,17 @@ class fast_back_stack
|
||||
|
||||
inline fast_back_stack():_value(),_stack(),_size(0) {}
|
||||
|
||||
inline fast_back_stack(const fast_back_stack& fbs):_value(fbs._value),_stack(fbs._stack),_size(fbs._size) {}
|
||||
|
||||
inline fast_back_stack(const T& value):_value(value),_stack(),_size(1) {}
|
||||
|
||||
fast_back_stack& operator = (const fast_back_stack& fbs)
|
||||
{
|
||||
_value = fbs._value;
|
||||
_stack = fbs._stack;
|
||||
_size = fbs._size;
|
||||
}
|
||||
|
||||
inline void clear() { _stack.clear(); _size = 0; }
|
||||
|
||||
inline bool empty() const { return _size==0; }
|
||||
@@ -34,6 +45,15 @@ class fast_back_stack
|
||||
|
||||
inline const T& back() const { return _value; }
|
||||
|
||||
inline void push_back()
|
||||
{
|
||||
if (_size>0)
|
||||
{
|
||||
_stack.push_back(_value);
|
||||
}
|
||||
++_size;
|
||||
}
|
||||
|
||||
inline void push_back(const T& value)
|
||||
{
|
||||
if (_size>0)
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
#include <osg/Impostor>
|
||||
#include <osg/EarthSky>
|
||||
#include <osg/Notify>
|
||||
#include <osg/Notify>
|
||||
|
||||
#include <osg/CullingSet>
|
||||
#include <osg/fast_back_stack>
|
||||
|
||||
#include <osgUtil/RenderGraph>
|
||||
@@ -240,31 +242,50 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor
|
||||
v.y()*mvpw(1,3)+
|
||||
v.z()*mvpw(2,3)+
|
||||
mvpw(3,3);
|
||||
|
||||
|
||||
return fabs(radius*_windowToModelFactor/W);
|
||||
|
||||
}
|
||||
|
||||
|
||||
osg::ClippingVolume& getCurrentClippingVolume() { return _modelviewClippingVolumeStack.back(); }
|
||||
|
||||
inline bool isCulled(const osg::BoundingSphere& sp,CullingMode& mode)
|
||||
inline float pixelSize2(const osg::Vec3& v, float const radius)
|
||||
{
|
||||
if (!sp.isValid()) return true;
|
||||
const float R2 = osg::square(_viewportStack.back()->width()/osg::DegreesToRadians(38.0f))*1.15f;
|
||||
|
||||
if (!(_modelviewClippingVolumeStack.back().contains(sp,mode))) return true;
|
||||
//float p1 = fabs(radius*_windowToModelFactor/W);
|
||||
return R2*radius*radius/(v-getEyeLocal()).length2();
|
||||
|
||||
if (mode&SMALL_FEATURE_CULLING)
|
||||
}
|
||||
|
||||
inline bool isCulled(const osg::Node& node)
|
||||
{
|
||||
if (node.isCullingActive())
|
||||
{
|
||||
if (pixelSize(sp.center(),sp.radius())<_smallFeatureCullingPixelSize) return true;
|
||||
const osg::BoundingSphere& sp = node.getBound();
|
||||
if (!(_modelviewPolytopeStack.back().contains(sp))) return true;
|
||||
// if (pixelSize(sp.center(),sp.radius())<_smallFeatureCullingPixelSize) return true;
|
||||
if (pixelSize2(sp.center(),sp.radius())<osg::square(_smallFeatureCullingPixelSize)) return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
inline const bool isCulled(const osg::BoundingBox& bb,CullingMode mode)
|
||||
inline const bool isCulled(const osg::BoundingBox& bb)
|
||||
{
|
||||
if (!bb.isValid()) return true;
|
||||
|
||||
return !_modelviewClippingVolumeStack.back().contains(bb,mode);
|
||||
//return !_modelviewPolytopeStack.back().contains(bb,mode);
|
||||
return !_modelviewPolytopeStack.back().contains(bb);
|
||||
//return false;
|
||||
}
|
||||
|
||||
inline void pushCurrentMask()
|
||||
{
|
||||
_modelviewPolytopeStack.back().pushCurrentMask();
|
||||
}
|
||||
|
||||
inline void popCurrentMask()
|
||||
{
|
||||
_modelviewPolytopeStack.back().popCurrentMask();
|
||||
}
|
||||
|
||||
const CullingMode getCurrentCullingMode() const { return _cullingModeStack.back(); }
|
||||
@@ -327,23 +348,23 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor
|
||||
|
||||
|
||||
|
||||
void pushClippingVolume();
|
||||
void popClippingVolume();
|
||||
void pushPolytope();
|
||||
void popPolytope();
|
||||
|
||||
|
||||
// typedef std::vector<osg::ClippingVolume> ClippingVolumeStack;
|
||||
// typedef std::vector<osg::Polytope> PolytopeStack;
|
||||
// typedef std::vector<osg::ref_ptr<osg::Matrix> > MatrixStack;
|
||||
|
||||
typedef osg::fast_back_stack<osg::ClippingVolume> ClippingVolumeStack;
|
||||
typedef osg::fast_back_stack<osg::Polytope> PolytopeStack;
|
||||
typedef osg::fast_back_stack< osg::ref_ptr<osg::Matrix> > MatrixStack;
|
||||
|
||||
MatrixStack _projectionStack;
|
||||
MatrixStack _PW_Stack;
|
||||
ClippingVolumeStack _projectionClippingVolumeStack;
|
||||
PolytopeStack _projectionPolytopeStack;
|
||||
|
||||
MatrixStack _modelviewStack;
|
||||
MatrixStack _MVPW_Stack;
|
||||
ClippingVolumeStack _modelviewClippingVolumeStack;
|
||||
PolytopeStack _modelviewPolytopeStack;
|
||||
|
||||
bool _windowToModelFactorDirty;
|
||||
float _windowToModelFactor;
|
||||
@@ -358,6 +379,10 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor
|
||||
|
||||
typedef osg::fast_back_stack<CullingMode> CullingModeStack;
|
||||
CullingModeStack _cullingModeStack;
|
||||
|
||||
typedef osg::fast_back_stack<osg::ref_ptr<osg::CullingSet> > ClippingStack;
|
||||
ClippingStack _clippingSet;
|
||||
|
||||
|
||||
unsigned int _bbCornerNear;
|
||||
unsigned int _bbCornerFar;
|
||||
|
||||
Reference in New Issue
Block a user