Added osg::CollectOccludersVisitor which is a helper class for finding active
occluder in the view frustum, to be used as pre cull traversal.
This commit is contained in:
54
include/osg/CollectOccludersVisitor
Normal file
54
include/osg/CollectOccludersVisitor
Normal file
@@ -0,0 +1,54 @@
|
||||
//C++ header - Open Scene Graph - Copyright (C) 1998-2001 Robert Osfield
|
||||
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
||||
//as published by the Free Software Foundation.
|
||||
|
||||
#ifndef OSG_COLLECTOCCLUDERSVISITOR
|
||||
#define OSG_COLLECTOCCLUDERSVISITOR 1
|
||||
|
||||
#include <osg/NodeVisitor>
|
||||
#include <osg/CullStack>
|
||||
|
||||
namespace osg {
|
||||
|
||||
class SG_EXPORT CollectOccludersVisitor : public osg::NodeVisitor, public osg::CullStack
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
CollectOccludersVisitor();
|
||||
virtual ~CollectOccludersVisitor();
|
||||
|
||||
virtual CollectOccludersVisitor* cloneType() const { return new CollectOccludersVisitor(); }
|
||||
|
||||
virtual void reset();
|
||||
|
||||
virtual void apply(osg::Node&);
|
||||
virtual void apply(osg::Transform& node);
|
||||
virtual void apply(osg::Projection& node);
|
||||
|
||||
virtual void apply(osg::Switch& node);
|
||||
virtual void apply(osg::LOD& node);
|
||||
virtual void apply(osg::OccluderNode& node);
|
||||
|
||||
typedef std::vector<ShadowVolumeOccluder> OccluderList;
|
||||
|
||||
OccluderList& getOccluderList() { return _occluderList; }
|
||||
const OccluderList& getOccluderList() const { return _occluderList; }
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/** prevent unwanted copy construction.*/
|
||||
CollectOccludersVisitor(const CollectOccludersVisitor&):osg::NodeVisitor(),osg::CullStack() {}
|
||||
|
||||
/** prevent unwanted copy operator.*/
|
||||
CollectOccludersVisitor& operator = (const CollectOccludersVisitor&) { return *this; }
|
||||
|
||||
OccluderList _occluderList;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -141,6 +141,12 @@ class SG_EXPORT Node : public Object
|
||||
* 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(); }
|
||||
|
||||
/** Get the number of Children of this node which are or have OccluderNode's.*/
|
||||
inline const int getNumChildrenWithOccluderNodes() const { return _numChildrenWithOccluderNodes; }
|
||||
|
||||
|
||||
/** return true if this node is an OccluderNode or the subgraph below this node are OccluderNodes.*/
|
||||
inline const bool containsOccluderNodes() const;
|
||||
|
||||
/**
|
||||
* Set user data, data must be subclased from Referenced to allow
|
||||
@@ -248,6 +254,9 @@ class SG_EXPORT Node : public Object
|
||||
int _numChildrenWithCullingDisabled;
|
||||
void setNumChildrenWithCullingDisabled(const int num);
|
||||
|
||||
int _numChildrenWithOccluderNodes;
|
||||
void setNumChildrenWithOccluderNodes(const int num);
|
||||
|
||||
osg::ref_ptr<Referenced> _userData;
|
||||
|
||||
NodeMask _nodeMask;
|
||||
|
||||
Reference in New Issue
Block a user