14 #ifndef OSGUTIL_CULLVISITOR
15 #define OSGUTIL_CULLVISITOR 1
20 #include <osg/NodeVisitor>
21 #include <osg/BoundingSphere>
22 #include <osg/BoundingBox>
24 #include <osg/Drawable>
25 #include <osg/StateSet>
27 #include <osg/ClearNode>
31 #include <osg/CullStack>
33 #include <osgUtil/StateGraph>
34 #include <osgUtil/RenderStage>
86 virtual float getDistanceToEyePoint(
const osg::Vec3& pos,
bool withLODScale)
const;
87 virtual float getDistanceFromEyePoint(
const osg::Vec3& pos,
bool withLODScale)
const;
89 virtual float getDistanceToViewPoint(
const osg::Vec3& pos,
bool withLODScale)
const;
118 _currentStateGraph = _currentStateGraph->find_or_insert(ss);
123 if (useRenderBinDetails)
125 _renderBinStack.push_back(_currentRenderBin);
134 ++_numberOfEncloseOverrideRenderBinDetails;
147 --_numberOfEncloseOverrideRenderBinDetails;
153 if (useRenderBinDetails)
155 if (_renderBinStack.empty())
157 _currentRenderBin = _currentRenderBin->getStage();
161 _currentRenderBin = _renderBinStack.back();
162 _renderBinStack.pop_back();
165 _currentStateGraph = _currentStateGraph->_parent;
170 _rootStateGraph = rg;
171 _currentStateGraph = rg;
176 return _rootStateGraph.get();
181 return _currentStateGraph;
186 _rootRenderStage = rg;
187 _currentRenderBin = rg;
192 return _rootRenderStage.get();
197 return _currentRenderBin->
getStage();
202 return getCurrentRenderStage()->getCamera();
207 return _currentRenderBin;
212 _currentRenderBin = rb;
228 void updateCalculatedNearFar(
const osg::Vec3& pos);
245 void computeNearPlane();
249 virtual void popProjectionMatrix();
254 virtual bool clampProjectionMatrixImplementation(
osg::Matrixf& projection,
double& znear,
double& zfar)
const;
258 virtual bool clampProjectionMatrixImplementation(
osg::Matrixd& projection,
double& znear,
double& zfar)
const;
267 if (_clampProjectionMatrixCallback.valid()) result = _clampProjectionMatrixCallback->clampProjectionMatrixImplementation(projection, zn, zf);
268 else result = clampProjectionMatrixImplementation(projection, zn, zf);
288 if (_clampProjectionMatrixCallback.valid()) result = _clampProjectionMatrixCallback->clampProjectionMatrixImplementation(projection, zn, zf);
289 else result = clampProjectionMatrixImplementation(projection, zn, zf);
320 if (callback) callback->
run(&node,
this);
327 if (callback) callback->
run(&node,
this);
328 else acceptNode->
accept(*
this);
365 _drawable = drawable;
366 if (!_planes.empty()) _planes.clear();
371 for(osg::Polytope::PlaneList::const_iterator itr=frustum.
getPlaneList().begin();
375 if (result_mask&selector_mask) _planes.push_back(*itr);
381 _matrix(mpd._matrix),
382 _drawable(mpd._drawable),
383 _planes(mpd._planes) {}
450 osg::notify(
osg::NOTICE)<<
"Warning:createOrReuseRenderLeaf() skipping multiply refrenced entry."<< std::endl;
void set(osg::Drawable *drawable, osg::RefMatrix *projection, osg::RefMatrix *modelview, float depth=0.0f, unsigned int traversalNumber=0)
void setCalculatedNearPlane(value_type value)
std::vector< osg::ref_ptr< RenderLeaf > > RenderLeafList
StateGraph * getRootStateGraph()
osg::Matrix::value_type value_type
MatrixPlanesDrawables(const MatrixPlanesDrawables &mpd)
META_NodeVisitor(osgUtil, CullVisitor) virtual CullVisitor *clone() const
const osg::RenderInfo & getRenderInfo() const
virtual osg::Vec3 getEyePoint() const
RenderBinMode getRenderBinMode() const
value_type _computed_zfar
std::vector< RenderBin * > _renderBinStack
unsigned int ClippingMask
PlaneList & getPlaneList()
void addPositionedTextureAttribute(unsigned int textureUnit, osg::RefMatrix *matrix, const osg::StateAttribute *attr)
GLint GLenum GLsizei GLsizei GLsizei depth
void setRenderInfo(osg::RenderInfo &renderInfo)
void setCalculatedFarPlane(value_type value)
void setStateGraph(StateGraph *rg)
virtual osg::Vec3 getViewPoint() const
Identifier * getIdentifier()
ClippingMask getResultMask() const
RenderLeafList _reuseRenderLeafList
void addPositionedAttribute(osg::RefMatrix *matrix, const osg::StateAttribute *attr)
DistanceMatrixDrawableMap _farPlaneCandidateMap
Callback * getCullCallback()
void set(const osg::Matrix &matrix, const osg::Drawable *drawable, const osg::Polytope &frustum)
osg::ref_ptr< StateGraph > _rootStateGraph
unsigned int _traversalNumber
RenderStage * getRenderStage()
osg::Camera * getCurrentCamera()
T * clone(const T *t, const osg::CopyOp ©op=osg::CopyOp::SHALLOW_COPY)
bool clampProjectionMatrix(osg::Matrixf &projection, value_type &znear, value_type &zfar) const
std::multimap< value_type, MatrixPlanesDrawables > DistanceMatrixDrawableMap
value_type getCalculatedFarPlane() const
MatrixStack _projectionStack
void handle_cull_callbacks_and_traverse(osg::Node &node)
bool clampProjectionMatrix(osg::Matrixd &projection, value_type &znear, value_type &zfar) const
void pushStateSet(const osg::StateSet *ss)
virtual bool run(osg::Object *object, osg::Object *data)
const std::string & getBinName() const
void addDrawableAndDepth(osg::Drawable *drawable, osg::RefMatrix *matrix, float depth)
StateGraph * getCurrentStateGraph()
value_type _computed_znear
const osg::State * getState() const
virtual void accept(NodeVisitor &nv)
bool getNestRenderBins() const
osg::Polytope::PlaneList _planes
const osg::Drawable * _drawable
bool useRenderBinDetails() const
void addStateGraph(StateGraph *rg)
RenderBin * _currentRenderBin
DistanceMatrixDrawableMap _nearPlaneCandidateMap
virtual void addPositionedTextureAttribute(unsigned int textureUnit, osg::RefMatrix *matrix, const osg::StateAttribute *attr)
unsigned int _currentReuseRenderLeafIndex
void addDrawable(osg::Drawable *drawable, osg::RefMatrix *matrix)
void setIdentifier(Identifier *identifier)
void setState(osg::State *state)
RenderBin * getCurrentRenderBin()
osg::ref_ptr< RenderStage > _rootRenderStage
StateGraph * _currentStateGraph
void addLeaf(RenderLeaf *leaf)
bool leaves_empty() const
OSG_EXPORT std::ostream & notify(const NotifySeverity severity)
unsigned int _numberOfEncloseOverrideRenderBinDetails
const Identifier * getIdentifier() const
std::vector< Plane > PlaneList
value_type getCalculatedNearPlane() const
virtual void addPositionedAttribute(osg::RefMatrix *matrix, const osg::StateAttribute *attr)
void handle_cull_callbacks_and_accept(osg::Node &node, osg::Node *acceptNode)
osg::RenderInfo _renderInfo
RenderStage * getCurrentRenderStage()
osg::RenderInfo & getRenderInfo()
void setRenderStage(RenderStage *rg)
void setCurrentRenderBin(RenderBin *rb)
osg::ref_ptr< Identifier > _identifier
RenderLeaf * createOrReuseRenderLeaf(osg::Drawable *drawable, osg::RefMatrix *projection, osg::RefMatrix *matrix, float depth=0.0f)
Shader generator framework.