Fixes to the occluder culling code to properly disable occluders to prevent
self occlusion.
This commit is contained in:
@@ -85,9 +85,14 @@ class SG_EXPORT CullStack
|
||||
return pixelSize(bs.center(),bs.radius());
|
||||
}
|
||||
|
||||
inline void disableOccluder(NodePath& nodePath)
|
||||
inline void disableAndPushOccludersCurrentMask(NodePath& nodePath)
|
||||
{
|
||||
_modelviewCullingStack.back()->disableOccluder(nodePath);
|
||||
_modelviewCullingStack.back()->disableAndPushOccludersCurrentMask(nodePath);
|
||||
}
|
||||
|
||||
inline void popOccludersCurrentMask(NodePath& nodePath)
|
||||
{
|
||||
_modelviewCullingStack.back()->popOccludersCurrentMask(nodePath);
|
||||
}
|
||||
|
||||
inline bool isCulled(const std::vector<Vec3>& vertices)
|
||||
|
||||
@@ -77,7 +77,6 @@ class SG_EXPORT CullingSet : public Referenced
|
||||
/** Compute the pixel of an bounding sphere.*/
|
||||
float pixelSize(const BoundingSphere& bs) const { return bs.radius()/(bs.center()*_pixelSizeVector); }
|
||||
|
||||
void disableOccluder(NodePath& nodePath);
|
||||
|
||||
inline bool isCulled(const std::vector<Vec3>& vertices)
|
||||
{
|
||||
@@ -197,6 +196,9 @@ class SG_EXPORT CullingSet : public Referenced
|
||||
}
|
||||
}
|
||||
|
||||
void disableAndPushOccludersCurrentMask(NodePath& nodePath);
|
||||
|
||||
void popOccludersCurrentMask(NodePath& nodePath);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -19,7 +19,8 @@ class SG_EXPORT Polytope
|
||||
public:
|
||||
|
||||
typedef unsigned int ClippingMask;
|
||||
typedef std::vector<osg::Plane> PlaneList;
|
||||
typedef std::vector<Plane> PlaneList;
|
||||
typedef fast_back_stack<ClippingMask> MaskStack;
|
||||
|
||||
inline Polytope() {setupMask();}
|
||||
|
||||
@@ -94,6 +95,9 @@ class SG_EXPORT Polytope
|
||||
|
||||
inline ClippingMask getResultMask() const { return _resultMask; }
|
||||
|
||||
MaskStack& getMaskStack() { return _maskStack; }
|
||||
|
||||
const MaskStack& getMaskStack() const { return _maskStack; }
|
||||
|
||||
|
||||
inline void pushCurrentMask()
|
||||
@@ -305,7 +309,7 @@ class SG_EXPORT Polytope
|
||||
protected:
|
||||
|
||||
|
||||
fast_back_stack<ClippingMask> _maskStack;
|
||||
MaskStack _maskStack;
|
||||
ClippingMask _resultMask;
|
||||
PlaneList _planeList;
|
||||
|
||||
|
||||
@@ -103,6 +103,7 @@ typedef std::vector<ShadowVolumeOccluder> ShadowVolumeOccluderList;
|
||||
|
||||
inline void ShadowVolumeOccluder::disableResultMasks()
|
||||
{
|
||||
//std::cout<<"ShadowVolumeOccluder::disableResultMasks() - _occluderVolume.getMaskStack().size()="<<_occluderVolume.getMaskStack().size()<<" "<<_occluderVolume.getCurrentMask()<<std::endl;
|
||||
_occluderVolume.setResultMask(0);
|
||||
for(HoleList::iterator itr=_holeList.begin();
|
||||
itr!=_holeList.end();
|
||||
@@ -114,6 +115,7 @@ inline void ShadowVolumeOccluder::disableResultMasks()
|
||||
|
||||
inline void ShadowVolumeOccluder::pushCurrentMask()
|
||||
{
|
||||
//std::cout<<"ShadowVolumeOccluder::pushCurrentMasks() - _occluderVolume.getMaskStack().size()="<<_occluderVolume.getMaskStack().size()<<" "<<_occluderVolume.getCurrentMask()<<std::endl;
|
||||
_occluderVolume.pushCurrentMask();
|
||||
if (!_holeList.empty())
|
||||
{
|
||||
@@ -138,6 +140,7 @@ inline void ShadowVolumeOccluder::popCurrentMask()
|
||||
itr->popCurrentMask();
|
||||
}
|
||||
}
|
||||
//std::cout<<"ShadowVolumeOccluder::popCurrentMasks() - _occluderVolume.getMaskStack().size()="<<_occluderVolume.getMaskStack().size()<<" "<<_occluderVolume.getCurrentMask()<<std::endl;
|
||||
}
|
||||
|
||||
} // end of namespace
|
||||
|
||||
Reference in New Issue
Block a user