diff --git a/AUTHORS b/AUTHORS index 0c6449599..481b1853d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -47,6 +47,7 @@ Ben Discoe Maroc Jez - osgParticle + - IO support for osgText. Byan Woods - Port to MacOS, various code changes to support this. diff --git a/include/osg/CullStack b/include/osg/CullStack index 1d2890b55..02e315a9c 100644 --- a/include/osg/CullStack +++ b/include/osg/CullStack @@ -54,6 +54,9 @@ class SG_EXPORT CullStack void pushModelViewMatrix(osg::Matrix* matrix); void popModelViewMatrix(); + void setLODBias(const float bias) { _LODBias = bias; } + const float getLODBias() const { return _LODBias; } + void setSmallFeatureCullingPixelSize(float value) { _smallFeatureCullingPixelSize=value; } float& getSmallFeatureCullingPixelSize() { return _smallFeatureCullingPixelSize; } float getSmallFeatureCullingPixelSize() const { return _smallFeatureCullingPixelSize; } @@ -128,6 +131,7 @@ class SG_EXPORT CullStack void popCullingSet(); CullingMode _cullingMode; + float _LODBias; float _smallFeatureCullingPixelSize; typedef fast_back_stack< ref_ptr > MatrixStack; diff --git a/include/osgUtil/CullVisitor b/include/osgUtil/CullVisitor index 55991ee4b..9b1eb7454 100644 --- a/include/osgUtil/CullVisitor +++ b/include/osgUtil/CullVisitor @@ -67,9 +67,6 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac const osg::EarthSky* getEarthSky() const { return _earthSky.get(); } - void setLODBias(const float bias) { _LODBias = bias; } - const float getLODBias() const { return _LODBias; } - /** Switch the creation of Impostors on or off. * Setting active to false forces the CullVisitor to use the Impostor * LOD children for rendering. Setting active to true forces the @@ -233,8 +230,6 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac RenderBin* _currentRenderBin; - float _LODBias; - ComputeNearFarMode _computeNearFar; float _computed_znear; float _computed_zfar; diff --git a/src/osg/CollectOccludersVisitor.cpp b/src/osg/CollectOccludersVisitor.cpp index d9fe287eb..a640061fe 100644 --- a/src/osg/CollectOccludersVisitor.cpp +++ b/src/osg/CollectOccludersVisitor.cpp @@ -1,9 +1,16 @@ #include +#include +#include +#include +#include +#include using namespace osg; CollectOccludersVisitor::CollectOccludersVisitor() { + // overide the default node visitor mode. + setTraversalMode(NodeVisitor::TRAVERSE_ACTIVE_CHILDREN); } CollectOccludersVisitor::~CollectOccludersVisitor() @@ -15,28 +22,96 @@ void CollectOccludersVisitor::reset() CullStack::reset(); } -void CollectOccludersVisitor::apply(osg::Node&) +void CollectOccludersVisitor::apply(osg::Node& node) { + if (isCulled(node)) return; + + // push the culling mode. + pushCurrentMask(); + + traverse(node); + + // pop the culling mode. + popCurrentMask(); } void CollectOccludersVisitor::apply(osg::Transform& node) { + if (isCulled(node)) return; + + // push the culling mode. + pushCurrentMask(); + + ref_ptr matrix = createOrReuseMatrix(getModelViewMatrix()); + node.getLocalToWorldMatrix(*matrix,this); + pushModelViewMatrix(matrix.get()); + + traverse(node); + + popModelViewMatrix(); + + // pop the culling mode. + popCurrentMask(); } void CollectOccludersVisitor::apply(osg::Projection& node) { + if (isCulled(node)) return; + + // push the culling mode. + pushCurrentMask(); + + ref_ptr matrix = createOrReuseMatrix(node.getMatrix()); + pushProjectionMatrix(matrix.get()); + + traverse(node); + + popProjectionMatrix(); + + // pop the culling mode. + popCurrentMask(); } void CollectOccludersVisitor::apply(osg::Switch& node) { + apply((Group&)node); } void CollectOccludersVisitor::apply(osg::LOD& node) { + if (isCulled(node)) return; + + int eval = node.evaluate(getEyeLocal(),_LODBias); + if (eval<0) return; + + // push the culling mode. + pushCurrentMask(); + + //notify(INFO) << "selecting child "<accept(*this); + + // pop the culling mode. + popCurrentMask(); } void CollectOccludersVisitor::apply(osg::OccluderNode& node) { + // need to check if occlusion node is in the occluder + // list, if so disable the appropriate ShadowOccluderVolume + disableOccluder(_nodePath); + + std::cout<<"CollectOccludersVisitor:: We have found an Occlusion node in frustum"<<&node<