This commit is contained in:
parent
12a737ae02
commit
4174d72a52
@ -443,6 +443,9 @@ MARK_AS_ADVANCED(OSG_USE_FLOAT_BOUNDINGSPHERE)
|
||||
OPTION(OSG_USE_FLOAT_BOUNDINGBOX "Set to ON to build OpenSceneGraph with float BoundingBox instead of double." ON)
|
||||
MARK_AS_ADVANCED(OSG_USE_FLOAT_BOUNDINGBOX)
|
||||
|
||||
OPTION(OSG_USE_BOUND "Set to ON to build OpenSceneGraph with Bound adapter class to help with porting applications between OSG-3.2 and 3.4 and later." ON)
|
||||
MARK_AS_ADVANCED(OSG_USE_BOUND)
|
||||
|
||||
IF (WIN32)
|
||||
OPTION(OSG_USE_UTF8_FILENAME "Set to ON to use a UTF8 locale for filenames instead of the default locale." OFF)
|
||||
MARK_AS_ADVANCED(OSG_USE_UTF8_FILENAME)
|
||||
|
@ -812,9 +812,9 @@ class ShaderGeometry : public osg::Drawable
|
||||
}
|
||||
}
|
||||
|
||||
virtual osg::BoundingBox computeBound() const
|
||||
virtual osg::BoundingBox computeBoundingBox() const
|
||||
{
|
||||
osg::BoundingBox geom_box = _geometry->getBound();
|
||||
osg::BoundingBox geom_box = _geometry->getBoundingBox();
|
||||
osg::BoundingBox bb;
|
||||
for(PositionSizeList::const_iterator itr = _trees.begin();
|
||||
itr != _trees.end();
|
||||
|
@ -104,7 +104,7 @@ public:
|
||||
pitr != parents.end();
|
||||
++pitr)
|
||||
{
|
||||
osg::Group* parent = *pitr;
|
||||
osg::Node* parent = *pitr;
|
||||
parent->removeChild(node);
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
|
||||
// an attempt to return a reasonable bounding box. Still does not prevent clipping of the heat map.
|
||||
virtual const osg::BoundingBox& getBoundingBox() const {return m_bounds;}
|
||||
virtual osg::BoundingBox computeBound() const {return m_bounds;}
|
||||
virtual osg::BoundingBox computeBoundingBox() const {return m_bounds;}
|
||||
virtual const osg::BoundingSphere& getBound() const {return m_bsphere;}
|
||||
|
||||
protected:
|
||||
|
@ -334,7 +334,7 @@ public:
|
||||
// particle effect can be inserted into this.
|
||||
osg::ref_ptr<osg::Node> hitNode = hit.nodePath.back();
|
||||
osg::Node::ParentList parents = hitNode->getParents();
|
||||
osg::Group* insertGroup = 0;
|
||||
osg::Node* insertGroup = 0;
|
||||
unsigned int numGroupsFound = 0;
|
||||
for(osg::Node::ParentList::iterator itr=parents.begin();
|
||||
itr!=parents.end();
|
||||
|
@ -246,7 +246,7 @@ class Teapot : public osg::Drawable
|
||||
|
||||
// we need to set up the bounding box of the data too, so that the scene graph knows where this
|
||||
// objects is, for both positioning the camera at start up, and most importantly for culling.
|
||||
virtual osg::BoundingBox computeBound() const
|
||||
virtual osg::BoundingBox computeBoundingBox() const
|
||||
{
|
||||
osg::BoundingBox bbox;
|
||||
|
||||
|
@ -271,6 +271,12 @@ class OSG_EXPORT CullingSet : public Referenced
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool isCulled(const Bound& bound)
|
||||
{
|
||||
if (bound.bb) return isCulled(*bound.bb);
|
||||
else return isCulled(*bound.bs);
|
||||
}
|
||||
|
||||
inline void pushCurrentMask()
|
||||
{
|
||||
_frustum.pushCurrentMask();
|
||||
|
@ -59,7 +59,7 @@ class OSG_EXPORT DrawPixels : public Drawable
|
||||
|
||||
virtual void drawImplementation(RenderInfo& renderInfo) const;
|
||||
|
||||
virtual BoundingBox computeBound() const;
|
||||
virtual BoundingBox computeBoundingBox() const;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <osg/BufferObject>
|
||||
#include <osg/PrimitiveSet>
|
||||
#include <osg/RenderInfo>
|
||||
#include <osg/Node>
|
||||
|
||||
|
||||
#ifndef GL_NV_occlusion_query
|
||||
@ -90,7 +91,7 @@ class ArrayDispatchers;
|
||||
* <tt>Geode</tt>s, so that the same geometry (loaded to memory just once) can
|
||||
* be used in different parts of the scene graph.
|
||||
*/
|
||||
class OSG_EXPORT Drawable : public Object
|
||||
class OSG_EXPORT Drawable : public Node
|
||||
{
|
||||
public:
|
||||
|
||||
@ -103,9 +104,7 @@ class OSG_EXPORT Drawable : public Object
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
||||
Drawable(const Drawable& drawable,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
||||
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Drawable*>(obj)!=NULL; }
|
||||
virtual const char* libraryName() const { return "osg"; }
|
||||
virtual const char* className() const { return "Drawable"; }
|
||||
META_Node(osg, Drawable);
|
||||
|
||||
/** Convert 'this' into a Geometry pointer if Drawable is a Geometry, otherwise return 0.
|
||||
* Equivalent to dynamic_cast<Geometry*>(this).*/
|
||||
@ -115,94 +114,44 @@ class OSG_EXPORT Drawable : public Object
|
||||
* Equivalent to dynamic_cast<const Geometry*>(this).*/
|
||||
virtual const Geometry* asGeometry() const { return 0; }
|
||||
|
||||
/** Visitor Pattern : calls the apply method of a NodeVisitor with this drawable's type.*/
|
||||
virtual void accept(NodeVisitor& nv);
|
||||
|
||||
/** Compute the DataVariance based on an assessment of callback etc.*/
|
||||
virtual void computeDataVariance();
|
||||
|
||||
|
||||
/** A vector of osg::Node pointers which is used to store the parent(s) of drawable.*/
|
||||
typedef std::vector<Node*> ParentList;
|
||||
|
||||
/** Get the parent list of drawable. */
|
||||
inline const ParentList& getParents() const { return _parents; }
|
||||
|
||||
/** Get the a copy of parent list of node. A copy is returned to
|
||||
* prevent modification of the parent list.*/
|
||||
inline ParentList getParents() { return _parents; }
|
||||
|
||||
/** Get a single parent of Drawable.
|
||||
* @param i index of the parent to get.
|
||||
* @return the parent i.
|
||||
*/
|
||||
inline Node* getParent(unsigned int i) { return _parents[i]; }
|
||||
/** Get a single const parent of Drawable.
|
||||
* @param i index of the parent to get.
|
||||
* @return the parent i.
|
||||
*/
|
||||
inline const Node* getParent(unsigned int i) const { return _parents[i]; }
|
||||
|
||||
/**
|
||||
* Get the number of parents of node.
|
||||
* @return the number of parents of this node.
|
||||
*/
|
||||
inline unsigned int getNumParents() const { return static_cast<unsigned int>(_parents.size()); }
|
||||
|
||||
/** Get the list of matrices that transform this node from local coordinates to world coordinates.
|
||||
* The optional Node* haltTraversalAtNode allows the user to prevent traversal beyond a specifed node. */
|
||||
MatrixList getWorldMatrices(const osg::Node* haltTraversalAtNode=0) const;
|
||||
|
||||
|
||||
/** Set the StateSet attached to the Drawable.
|
||||
Previously attached StateSet are automatically unreferenced on
|
||||
assignment of a new drawstate.*/
|
||||
void setStateSet(StateSet* stateset);
|
||||
|
||||
/** Get the attached StateSet.*/
|
||||
inline StateSet* getStateSet() { return _stateset.get();}
|
||||
|
||||
/** Get the attached const StateSet.*/
|
||||
inline const StateSet* getStateSet() const { return _stateset.get();}
|
||||
|
||||
/** Get the attached const StateSet,
|
||||
* if one is not already attached create one,
|
||||
* attach it to the drawable and return a pointer to it.*/
|
||||
StateSet* getOrCreateStateSet();
|
||||
|
||||
|
||||
/** Set the initial bounding volume to use when computing the overall bounding volume.*/
|
||||
void setInitialBound(const osg::BoundingBox& bbox) { _initialBound = bbox; dirtyBound(); }
|
||||
|
||||
/** Set the initial bounding volume to use when computing the overall bounding volume.*/
|
||||
const BoundingBox& getInitialBound() const { return _initialBound; }
|
||||
|
||||
/** Dirty the bounding box, forcing a computeBound() on the next call
|
||||
* to getBound(). Should be called in the internal geometry of the Drawable
|
||||
* is modified.*/
|
||||
void dirtyBound();
|
||||
|
||||
/** Get BoundingBox of Drawable.
|
||||
* If the BoundingBox is not up to date then its updated via an internal call to computeBond().
|
||||
*/
|
||||
inline const BoundingBox& getBound() const
|
||||
inline const BoundingBox& getBoundingBox() const
|
||||
{
|
||||
if(!_boundingBoxComputed)
|
||||
if(!_boundingSphereComputed)
|
||||
{
|
||||
_boundingBox = _initialBound;
|
||||
if (_computeBoundCallback.valid())
|
||||
_boundingBox.expandBy(_computeBoundCallback->computeBound(*this));
|
||||
else
|
||||
_boundingBox.expandBy(computeBound());
|
||||
_boundingBox.expandBy(computeBoundingBox());
|
||||
|
||||
_boundingBoxComputed = true;
|
||||
_boundingSphereComputed = true;
|
||||
}
|
||||
return _boundingBox;
|
||||
}
|
||||
|
||||
|
||||
/** Compute the bounding sphere around Drawables's geometry.*/
|
||||
virtual BoundingSphere computeBound() const;
|
||||
|
||||
/** Compute the bounding box around Drawables's geometry.*/
|
||||
virtual BoundingBox computeBound() const;
|
||||
virtual BoundingBox computeBoundingBox() const;
|
||||
|
||||
/** Callback to allow users to override the default computation of bounding volume. */
|
||||
struct ComputeBoundingBoxCallback : public osg::Object
|
||||
@ -418,7 +367,7 @@ class OSG_EXPORT Drawable : public Object
|
||||
* drawImplementation(RenderInfo&) is called from the draw(RenderInfo&) method, with the draw method handling management of OpenGL display lists,
|
||||
* and drawImplementation(RenderInfo&) handling the actual drawing itself.
|
||||
* @param renderInfo The osg::RenderInfo object that encapsulates the current rendering information including the osg::State OpenGL state for the current graphics context. */
|
||||
virtual void drawImplementation(RenderInfo& renderInfo) const = 0;
|
||||
virtual void drawImplementation(RenderInfo& /*renderInfo*/) const {}
|
||||
|
||||
|
||||
/** Return a OpenGL display list handle a newly generated or reused from display list cache. */
|
||||
@ -810,20 +759,13 @@ class OSG_EXPORT Drawable : public Object
|
||||
|
||||
virtual ~Drawable();
|
||||
|
||||
|
||||
/** set the bounding box .*/
|
||||
void setBound(const BoundingBox& bb) const;
|
||||
|
||||
void addParent(osg::Node* node);
|
||||
void removeParent(osg::Node* node);
|
||||
|
||||
ParentList _parents;
|
||||
friend class Node;
|
||||
friend class Geode;
|
||||
friend class StateSet;
|
||||
|
||||
ref_ptr<StateSet> _stateset;
|
||||
|
||||
BoundingBox _initialBound;
|
||||
ref_ptr<ComputeBoundingBoxCallback> _computeBoundCallback;
|
||||
mutable BoundingBox _boundingBox;
|
||||
@ -840,14 +782,7 @@ class OSG_EXPORT Drawable : public Object
|
||||
mutable GLObjectList _globjList;
|
||||
|
||||
ref_ptr<UpdateCallback> _updateCallback;
|
||||
unsigned int _numChildrenRequiringUpdateTraversal;
|
||||
void setNumChildrenRequiringUpdateTraversal(unsigned int num);
|
||||
unsigned int getNumChildrenRequiringUpdateTraversal() const { return _numChildrenRequiringUpdateTraversal; }
|
||||
|
||||
ref_ptr<EventCallback> _eventCallback;
|
||||
unsigned int _numChildrenRequiringEventTraversal;
|
||||
void setNumChildrenRequiringEventTraversal(unsigned int num);
|
||||
unsigned int getNumChildrenRequiringEventTraversal() const { return _numChildrenRequiringEventTraversal; }
|
||||
|
||||
ref_ptr<CullCallback> _cullCallback;
|
||||
ref_ptr<DrawCallback> _drawCallback;
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <osg/Object>
|
||||
#include <osg/StateSet>
|
||||
#include <osg/BoundingSphere>
|
||||
#include <osg/BoundingBox>
|
||||
#include <osg/NodeCallback>
|
||||
|
||||
#include <string>
|
||||
@ -49,6 +50,46 @@ typedef std::vector< NodePath > NodePathList;
|
||||
/** A vector of NodePath, typically used to describe all the paths from a node to the potential root nodes it has.*/
|
||||
typedef std::vector< Matrix > MatrixList;
|
||||
|
||||
#ifdef OSG_USE_BOUND
|
||||
struct Bound
|
||||
{
|
||||
Bound():
|
||||
bb(0),
|
||||
bs(0) {}
|
||||
|
||||
Bound(const osg::BoundingSphere& bs):
|
||||
bb(0),
|
||||
bs(&bs) {}
|
||||
|
||||
Bound(const osg::BoundingBox& bb):
|
||||
bb(&bb),
|
||||
bs(0) {}
|
||||
|
||||
Bound(const osg::BoundingSphere& bs, const osg::BoundingBox& bb):
|
||||
bb(&bb),
|
||||
bs(&bs) {}
|
||||
|
||||
const osg::BoundingBox* bb;
|
||||
const osg::BoundingSphere* bs;
|
||||
|
||||
bool valid() const { return bs ? bs->valid() : false; }
|
||||
|
||||
const osg::Vec3& center() const { return bs->center(); }
|
||||
float radius() const { return bs->radius(); }
|
||||
|
||||
float xMin() const { return bb->xMin(); }
|
||||
float yMin() const { return bb->yMin(); }
|
||||
float zMin() const { return bb->zMin(); }
|
||||
|
||||
float xMax() const { return bb->xMax(); }
|
||||
float yMax() const { return bb->yMax(); }
|
||||
float zMax() const { return bb->zMax(); }
|
||||
|
||||
operator const osg::BoundingBox& () const { return *bb; }
|
||||
operator const osg::BoundingSphere& () const { return *bs; }
|
||||
};
|
||||
#endif
|
||||
|
||||
/** META_Node macro define the standard clone, isSameKindAs, className
|
||||
* and accept methods. Use when subclassing from Node to make it
|
||||
* more convenient to define the required pure virtual methods.*/
|
||||
@ -395,7 +436,23 @@ class OSG_EXPORT Node : public Object
|
||||
|
||||
/** Get the bounding sphere of node.
|
||||
Using lazy evaluation computes the bounding sphere if it is 'dirty'.*/
|
||||
inline const BoundingSphere& getBound() const
|
||||
#ifdef OSG_USE_BOUND
|
||||
inline Bound getBound() const
|
||||
{
|
||||
if(!_boundingSphereComputed)
|
||||
{
|
||||
_boundingSphere = _initialBound;
|
||||
if (_computeBoundCallback.valid())
|
||||
_boundingSphere.expandBy(_computeBoundCallback->computeBound(*this));
|
||||
else
|
||||
_boundingSphere.expandBy(computeBound());
|
||||
|
||||
_boundingSphereComputed = true;
|
||||
}
|
||||
return Bound(_boundingSphere);
|
||||
}
|
||||
#else
|
||||
inline BoundingSphere getBound() const
|
||||
{
|
||||
if(!_boundingSphereComputed)
|
||||
{
|
||||
@ -409,7 +466,7 @@ class OSG_EXPORT Node : public Object
|
||||
}
|
||||
return _boundingSphere;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/** Compute the bounding sphere around Node's geometry or children.
|
||||
This method is automatically called by getBound() when the bounding
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <osg/Matrix>
|
||||
#include <osg/BoundingSphere>
|
||||
#include <osg/BoundingBox>
|
||||
#include <osg/Node>
|
||||
|
||||
#include <vector>
|
||||
|
||||
@ -321,6 +322,13 @@ class OSG_EXPORT Plane
|
||||
|
||||
}
|
||||
|
||||
#ifdef OSG_USE_BOUND
|
||||
inline int intersect(const Bound& bound) const
|
||||
{
|
||||
if (bound.bb) return intersect(*bound.bb);
|
||||
else return intersect(*bound.bs);
|
||||
}
|
||||
#endif
|
||||
/** Transform the plane by matrix. Note, this operation carries out
|
||||
* the calculation of the inverse of the matrix since a plane
|
||||
* must be multiplied by the inverse transposed to transform it. This
|
||||
|
@ -289,6 +289,14 @@ class OSG_EXPORT Polytope
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef OSG_USE_BOUND
|
||||
inline bool contains(const osg::Bound& bound)
|
||||
{
|
||||
if (bound.bb) return contains(*bound.bb);
|
||||
else return contains(*bound.bs);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Check whether all of vertex list is contained with clipping set.*/
|
||||
inline bool containsAllOf(const std::vector<Vec3>& vertices)
|
||||
{
|
||||
|
@ -181,7 +181,7 @@ class OSG_EXPORT ShapeDrawable : public Drawable
|
||||
/** Accept a PrimitiveFunctor and call its methods to tell it about the internal primitives that this Drawable has.*/
|
||||
virtual void accept(PrimitiveFunctor& pf) const;
|
||||
|
||||
virtual BoundingBox computeBound() const;
|
||||
virtual BoundingBox computeBoundingBox() const;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -243,7 +243,7 @@ namespace osgParticle
|
||||
|
||||
virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
|
||||
|
||||
virtual osg::BoundingBox computeBound() const;
|
||||
virtual osg::BoundingBox computeBoundingBox() const;
|
||||
|
||||
#ifdef OSGPARTICLE_USE_ReadWriteMutex
|
||||
typedef OpenThreads::ReadWriteMutex ReadWriterMutex;
|
||||
|
@ -69,7 +69,7 @@ class OSGSHADOW_EXPORT OccluderGeometry : public osg::Drawable
|
||||
virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
|
||||
|
||||
/** Compute the bounding box around occluder geometry.*/
|
||||
virtual osg::BoundingBox computeBound() const;
|
||||
virtual osg::BoundingBox computeBoundingBox() const;
|
||||
|
||||
typedef std::vector<osg::Vec3> Vec3List;
|
||||
typedef std::vector<GLuint> UIntList;
|
||||
@ -240,7 +240,7 @@ class OSGSHADOW_EXPORT ShadowVolumeGeometry : public osg::Drawable
|
||||
virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
|
||||
|
||||
/** Compute the bounding box around occluder geometry.*/
|
||||
virtual osg::BoundingBox computeBound() const;
|
||||
virtual osg::BoundingBox computeBoundingBox() const;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -149,7 +149,7 @@ class OSGSIM_EXPORT ImpostorSprite : public osg::Drawable
|
||||
// for debugging purposes.
|
||||
osg::Vec4 _color;
|
||||
|
||||
virtual osg::BoundingBox computeBound() const;
|
||||
virtual osg::BoundingBox computeBoundingBox() const;
|
||||
|
||||
/** Set the camera node to use for pre rendering the impostor sprite's texture.*/
|
||||
void setCamera(osg::Camera* camera) { _camera = camera; }
|
||||
|
@ -113,7 +113,7 @@ class OSGTEXT_EXPORT Text3D : public osgText::TextBase
|
||||
// // forcefully unloaded.
|
||||
friend class Font;
|
||||
|
||||
virtual osg::BoundingBox computeBound() const;
|
||||
virtual osg::BoundingBox computeBoundingBox() const;
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -264,7 +264,7 @@ public:
|
||||
virtual void releaseGLObjects(osg::State* state=0) const;
|
||||
|
||||
|
||||
virtual osg::BoundingBox computeBound() const;
|
||||
virtual osg::BoundingBox computeBoundingBox() const;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
#cmakedefine OSG_USE_FLOAT_BOUNDINGBOX
|
||||
#cmakedefine OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION
|
||||
#cmakedefine OSG_USE_UTF8_FILENAME
|
||||
#cmakedefine OSG_USE_BOUND
|
||||
#cmakedefine OSG_DISABLE_MSVC_WARNINGS
|
||||
|
||||
#endif
|
||||
|
@ -69,7 +69,7 @@ void DrawPixels::getSubImageDimensions(unsigned int& offsetX,unsigned int& offse
|
||||
}
|
||||
|
||||
|
||||
BoundingBox DrawPixels::computeBound() const
|
||||
BoundingBox DrawPixels::computeBoundingBox() const
|
||||
{
|
||||
// really needs to be dependent of view position and projection... will implement simple version right now.
|
||||
BoundingBox bbox;
|
||||
|
@ -217,7 +217,6 @@ void Drawable::flushDeletedDisplayLists(unsigned int contextID, double& availabl
|
||||
}
|
||||
|
||||
Drawable::Drawable()
|
||||
:Object(true)
|
||||
{
|
||||
_boundingBoxComputed = false;
|
||||
|
||||
@ -237,14 +236,10 @@ Drawable::Drawable()
|
||||
_supportsVertexBufferObjects = false;
|
||||
_useVertexBufferObjects = false;
|
||||
// _useVertexBufferObjects = true;
|
||||
|
||||
_numChildrenRequiringUpdateTraversal = 0;
|
||||
_numChildrenRequiringEventTraversal = 0;
|
||||
}
|
||||
|
||||
Drawable::Drawable(const Drawable& drawable,const CopyOp& copyop):
|
||||
Object(drawable,copyop),
|
||||
_parents(), // leave empty as parentList is managed by Geode
|
||||
Node(drawable,copyop),
|
||||
_initialBound(drawable._initialBound),
|
||||
_computeBoundCallback(drawable._computeBoundCallback),
|
||||
_boundingBox(drawable._boundingBox),
|
||||
@ -255,9 +250,7 @@ Drawable::Drawable(const Drawable& drawable,const CopyOp& copyop):
|
||||
_supportsVertexBufferObjects(drawable._supportsVertexBufferObjects),
|
||||
_useVertexBufferObjects(drawable._useVertexBufferObjects),
|
||||
_updateCallback(drawable._updateCallback),
|
||||
_numChildrenRequiringUpdateTraversal(drawable._numChildrenRequiringUpdateTraversal),
|
||||
_eventCallback(drawable._eventCallback),
|
||||
_numChildrenRequiringEventTraversal(drawable._numChildrenRequiringEventTraversal),
|
||||
_cullCallback(drawable._cullCallback),
|
||||
_drawCallback(drawable._drawCallback)
|
||||
{
|
||||
@ -266,17 +259,9 @@ Drawable::Drawable(const Drawable& drawable,const CopyOp& copyop):
|
||||
|
||||
Drawable::~Drawable()
|
||||
{
|
||||
// cleanly detatch any associated stateset (include remove parent links)
|
||||
setStateSet(0);
|
||||
|
||||
dirtyDisplayList();
|
||||
}
|
||||
|
||||
void Drawable::accept(NodeVisitor& nv)
|
||||
{
|
||||
nv.apply(*this);
|
||||
}
|
||||
|
||||
osg::MatrixList Drawable::getWorldMatrices(const osg::Node* haltTraversalAtNode) const
|
||||
{
|
||||
osg::MatrixList matrices;
|
||||
@ -306,168 +291,6 @@ void Drawable::computeDataVariance()
|
||||
setDataVariance(dynamic ? DYNAMIC : STATIC);
|
||||
}
|
||||
|
||||
void Drawable::addParent(osg::Node* node)
|
||||
{
|
||||
OpenThreads::ScopedPointerLock<OpenThreads::Mutex> lock(getRefMutex());
|
||||
|
||||
_parents.push_back(node);
|
||||
}
|
||||
|
||||
void Drawable::removeParent(osg::Node* node)
|
||||
{
|
||||
OpenThreads::ScopedPointerLock<OpenThreads::Mutex> lock(getRefMutex());
|
||||
|
||||
ParentList::iterator pitr = std::find(_parents.begin(),_parents.end(),node);
|
||||
if (pitr!=_parents.end()) _parents.erase(pitr);
|
||||
}
|
||||
|
||||
|
||||
void Drawable::setStateSet(osg::StateSet* stateset)
|
||||
{
|
||||
// do nothing if nothing changed.
|
||||
if (_stateset==stateset) return;
|
||||
|
||||
// track whether we need to account for the need to do a update or event traversal.
|
||||
int delta_update = 0;
|
||||
int delta_event = 0;
|
||||
|
||||
// remove this node from the current statesets parent list
|
||||
if (_stateset.valid())
|
||||
{
|
||||
_stateset->removeParent(this);
|
||||
if (_stateset->requiresUpdateTraversal()) --delta_update;
|
||||
if (_stateset->requiresEventTraversal()) --delta_event;
|
||||
}
|
||||
|
||||
// set the stateset.
|
||||
_stateset = stateset;
|
||||
|
||||
// add this node to the new stateset to the parent list.
|
||||
if (_stateset.valid())
|
||||
{
|
||||
_stateset->addParent(this);
|
||||
if (_stateset->requiresUpdateTraversal()) ++delta_update;
|
||||
if (_stateset->requiresEventTraversal()) ++delta_event;
|
||||
}
|
||||
|
||||
|
||||
// only inform parents if change occurs and drawable doesn't already have an update callback
|
||||
if (delta_update!=0 && !_updateCallback)
|
||||
{
|
||||
for(ParentList::iterator itr=_parents.begin();
|
||||
itr!=_parents.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->setNumChildrenRequiringUpdateTraversal( (*itr)->getNumChildrenRequiringUpdateTraversal()+delta_update );
|
||||
}
|
||||
}
|
||||
|
||||
// only inform parents if change occurs and drawable doesn't already have an event callback
|
||||
if (delta_event!=0 && !_eventCallback)
|
||||
{
|
||||
for(ParentList::iterator itr=_parents.begin();
|
||||
itr!=_parents.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->setNumChildrenRequiringEventTraversal( (*itr)->getNumChildrenRequiringEventTraversal()+delta_event );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Drawable::setNumChildrenRequiringUpdateTraversal(unsigned int num)
|
||||
{
|
||||
// if no changes just return.
|
||||
if (_numChildrenRequiringUpdateTraversal==num) return;
|
||||
|
||||
// note, if _updateCallback is set then the
|
||||
// parents won't be affected by any changes to
|
||||
// _numChildrenRequiringUpdateTraversal so no need to inform them.
|
||||
if (!_updateCallback && !_parents.empty())
|
||||
{
|
||||
// need to pass on changes to parents.
|
||||
int delta = 0;
|
||||
if (_numChildrenRequiringUpdateTraversal>0) --delta;
|
||||
if (num>0) ++delta;
|
||||
if (delta!=0)
|
||||
{
|
||||
// the number of callbacks has changed, need to pass this
|
||||
// on to parents so they know whether app traversal is
|
||||
// required on this subgraph.
|
||||
for(ParentList::iterator itr =_parents.begin();
|
||||
itr != _parents.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->setNumChildrenRequiringUpdateTraversal( (*itr)->getNumChildrenRequiringUpdateTraversal()+delta );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// finally update this objects value.
|
||||
_numChildrenRequiringUpdateTraversal=num;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Drawable::setNumChildrenRequiringEventTraversal(unsigned int num)
|
||||
{
|
||||
// if no changes just return.
|
||||
if (_numChildrenRequiringEventTraversal==num) return;
|
||||
|
||||
// note, if _eventCallback is set then the
|
||||
// parents won't be affected by any changes to
|
||||
// _numChildrenRequiringEventTraversal so no need to inform them.
|
||||
if (!_eventCallback && !_parents.empty())
|
||||
{
|
||||
// need to pass on changes to parents.
|
||||
int delta = 0;
|
||||
if (_numChildrenRequiringEventTraversal>0) --delta;
|
||||
if (num>0) ++delta;
|
||||
if (delta!=0)
|
||||
{
|
||||
// the number of callbacks has changed, need to pass this
|
||||
// on to parents so they know whether app traversal is
|
||||
// required on this subgraph.
|
||||
for(ParentList::iterator itr =_parents.begin();
|
||||
itr != _parents.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->setNumChildrenRequiringEventTraversal( (*itr)->getNumChildrenRequiringEventTraversal()+delta );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// finally Event this objects value.
|
||||
_numChildrenRequiringEventTraversal=num;
|
||||
|
||||
}
|
||||
|
||||
osg::StateSet* Drawable::getOrCreateStateSet()
|
||||
{
|
||||
if (!_stateset) setStateSet(new StateSet);
|
||||
return _stateset.get();
|
||||
}
|
||||
|
||||
void Drawable::dirtyBound()
|
||||
{
|
||||
if (_boundingBoxComputed)
|
||||
{
|
||||
_boundingBoxComputed = false;
|
||||
|
||||
// dirty parent bounding sphere's to ensure that all are valid.
|
||||
for(ParentList::iterator itr=_parents.begin();
|
||||
itr!=_parents.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->dirtyBound();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Drawable::compileGLObjects(RenderInfo& renderInfo) const
|
||||
{
|
||||
if (!_useDisplayList) return;
|
||||
@ -790,7 +613,12 @@ struct ComputeBound : public PrimitiveFunctor
|
||||
BoundingBox _bb;
|
||||
};
|
||||
|
||||
BoundingBox Drawable::computeBound() const
|
||||
BoundingSphere Drawable::computeBound() const
|
||||
{
|
||||
return BoundingSphere(getBoundingBox());
|
||||
}
|
||||
|
||||
BoundingBox Drawable::computeBoundingBox() const
|
||||
{
|
||||
ComputeBound cb;
|
||||
|
||||
|
@ -387,7 +387,8 @@ BoundingSphere Group::computeBound() const
|
||||
const osg::Transform* transform = (*itr)->asTransform();
|
||||
if (!transform || transform->getReferenceFrame()==osg::Transform::RELATIVE_RF)
|
||||
{
|
||||
bsphere.expandRadiusBy((*itr)->getBound());
|
||||
const BoundingSphere& bs = (*itr)->getBound();
|
||||
bsphere.expandRadiusBy(bs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1987,7 +1987,7 @@ void ShapeDrawable::accept(PrimitiveFunctor& pf) const
|
||||
}
|
||||
|
||||
|
||||
BoundingBox ShapeDrawable::computeBound() const
|
||||
BoundingBox ShapeDrawable::computeBoundingBox() const
|
||||
{
|
||||
BoundingBox bbox;
|
||||
if (_shape.valid())
|
||||
|
@ -213,7 +213,7 @@ BoundingSphere Switch::computeBound() const
|
||||
if (!transform || transform->getReferenceFrame()==osg::Transform::RELATIVE_RF)
|
||||
{
|
||||
if( _values[pos] == true )
|
||||
bsphere.expandRadiusBy(_children[pos]->getBound());
|
||||
bsphere.expandRadiusBy(static_cast<const BoundingSphere&>(_children[pos]->getBound()));
|
||||
}
|
||||
}
|
||||
return bsphere;
|
||||
|
@ -34,7 +34,7 @@ osg::BoundingBox RigComputeBoundingBoxCallback::computeBound(const osg::Drawable
|
||||
|
||||
// if the computing of bb is invalid (like no geometry inside)
|
||||
// then dont tag the bounding box as computed
|
||||
osg::BoundingBox bb = rig.computeBound();
|
||||
osg::BoundingBox bb = rig.computeBoundingBox();
|
||||
if (!bb.valid())
|
||||
return bb;
|
||||
|
||||
|
@ -528,7 +528,7 @@ void osgParticle::ParticleSystem::render_vertex_array(osg::RenderInfo& renderInf
|
||||
glDrawArrays(GL_POINTS, 0, _particles.size());
|
||||
}
|
||||
|
||||
osg::BoundingBox osgParticle::ParticleSystem::computeBound() const
|
||||
osg::BoundingBox osgParticle::ParticleSystem::computeBoundingBox() const
|
||||
{
|
||||
if (!_bounds_computed)
|
||||
{
|
||||
|
@ -200,7 +200,7 @@ class Logos: public osg::Drawable
|
||||
return (n != 0);
|
||||
}
|
||||
|
||||
virtual osg::BoundingBox computeBound() const
|
||||
virtual osg::BoundingBox computeBoundingBox() const
|
||||
{
|
||||
return osg::BoundingBox( -1, -1, -1, 1, 1, 1);
|
||||
}
|
||||
|
@ -904,7 +904,7 @@ void OccluderGeometry::drawImplementation(osg::RenderInfo& renderInfo) const
|
||||
}
|
||||
}
|
||||
|
||||
osg::BoundingBox OccluderGeometry::computeBound() const
|
||||
osg::BoundingBox OccluderGeometry::computeBoundingBox() const
|
||||
{
|
||||
osg::BoundingBox bb;
|
||||
for(Vec3List::const_iterator itr = _vertices.begin();
|
||||
@ -989,7 +989,7 @@ void ShadowVolumeGeometry::drawImplementation(osg::RenderInfo& renderInfo) const
|
||||
}
|
||||
}
|
||||
|
||||
osg::BoundingBox ShadowVolumeGeometry::computeBound() const
|
||||
osg::BoundingBox ShadowVolumeGeometry::computeBoundingBox() const
|
||||
{
|
||||
osg::BoundingBox bb;
|
||||
for(Vec3List::const_iterator itr = _vertices.begin();
|
||||
|
@ -114,7 +114,7 @@ void ImpostorSprite::drawImplementation(osg::RenderInfo& renderInfo) const
|
||||
gl.End();
|
||||
}
|
||||
|
||||
osg::BoundingBox ImpostorSprite::computeBound() const
|
||||
osg::BoundingBox ImpostorSprite::computeBoundingBox() const
|
||||
{
|
||||
osg::BoundingBox bbox;
|
||||
bbox.expandBy(_coords[0]);
|
||||
|
@ -174,7 +174,7 @@ void LightPointDrawable::drawImplementation(osg::RenderInfo& renderInfo) const
|
||||
#endif
|
||||
}
|
||||
|
||||
osg::BoundingBox LightPointDrawable::computeBound() const
|
||||
osg::BoundingBox LightPointDrawable::computeBoundingBox() const
|
||||
{
|
||||
osg::BoundingBox bbox;
|
||||
|
||||
|
@ -98,7 +98,7 @@ class OSGSIM_EXPORT LightPointDrawable : public osg::Drawable
|
||||
double getSimulationTime() const { return _simulationTime; }
|
||||
double getSimulationTimeInterval() const { return _simulationTimeInterval; }
|
||||
|
||||
virtual osg::BoundingBox computeBound() const;
|
||||
virtual osg::BoundingBox computeBoundingBox() const;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -1248,7 +1248,7 @@ void OverlayNode::traverse_OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY(osg::NodeV
|
||||
osg::BoundingSphere bs;
|
||||
for(unsigned int i=0; i<camera->getNumChildren(); ++i)
|
||||
{
|
||||
bs.expandBy(camera->getChild(i)->getBound());
|
||||
bs.expandBy(static_cast<const osg::BoundingSphere&>(camera->getChild(i)->getBound()));
|
||||
}
|
||||
|
||||
if (bs.valid())
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
|
||||
void drawImplementation(osg::RenderInfo& renderInfo) const;
|
||||
|
||||
virtual osg::BoundingBox computeBound() const;
|
||||
virtual osg::BoundingBox computeBoundingBox() const;
|
||||
|
||||
protected:
|
||||
|
||||
@ -69,7 +69,7 @@ void SphereSegment::Surface::drawImplementation(osg::RenderInfo& renderInfo) con
|
||||
_ss->Surface_drawImplementation(*renderInfo.getState());
|
||||
}
|
||||
|
||||
osg:: BoundingBox SphereSegment::Surface::computeBound() const
|
||||
osg:: BoundingBox SphereSegment::Surface::computeBoundingBox() const
|
||||
{
|
||||
osg:: BoundingBox bbox;
|
||||
_ss->Surface_computeBound(bbox);
|
||||
@ -114,7 +114,7 @@ protected:
|
||||
}
|
||||
|
||||
|
||||
virtual osg::BoundingBox computeBound() const;
|
||||
virtual osg::BoundingBox computeBoundingBox() const;
|
||||
|
||||
private:
|
||||
|
||||
@ -126,7 +126,7 @@ void SphereSegment::EdgeLine::drawImplementation(osg::RenderInfo& renderInfo) co
|
||||
_ss->EdgeLine_drawImplementation(*renderInfo.getState());
|
||||
}
|
||||
|
||||
osg::BoundingBox SphereSegment::EdgeLine::computeBound() const
|
||||
osg::BoundingBox SphereSegment::EdgeLine::computeBoundingBox() const
|
||||
{
|
||||
osg::BoundingBox bbox;
|
||||
_ss->EdgeLine_computeBound(bbox);
|
||||
@ -167,7 +167,7 @@ protected:
|
||||
"Warning: unexpected call to osgSim::SphereSegment::Side() copy constructor"<<std::endl;
|
||||
}
|
||||
|
||||
virtual osg::BoundingBox computeBound() const;
|
||||
virtual osg::BoundingBox computeBoundingBox() const;
|
||||
|
||||
private:
|
||||
SphereSegment* _ss;
|
||||
@ -181,7 +181,7 @@ void SphereSegment::Side::drawImplementation(osg::RenderInfo& renderInfo) const
|
||||
_ss->Side_drawImplementation(*renderInfo.getState(), _planeOrientation, _BoundaryAngle);
|
||||
}
|
||||
|
||||
osg::BoundingBox SphereSegment::Side::computeBound() const
|
||||
osg::BoundingBox SphereSegment::Side::computeBoundingBox() const
|
||||
{
|
||||
osg::BoundingBox bbox;
|
||||
_ss->Side_computeBound(bbox, _planeOrientation, _BoundaryAngle);
|
||||
@ -230,7 +230,7 @@ protected:
|
||||
//getOrCreateStateSet()->setAttributeAndModes(new osg::LineWidth(2.0),osg::StateAttribute::OFF);
|
||||
}
|
||||
|
||||
virtual osg::BoundingBox computeBound() const;
|
||||
virtual osg::BoundingBox computeBoundingBox() const;
|
||||
|
||||
private:
|
||||
SphereSegment* _ss;
|
||||
@ -242,7 +242,7 @@ void SphereSegment::Spoke::drawImplementation(osg::RenderInfo& renderInfo) const
|
||||
_ss->Spoke_drawImplementation(*renderInfo.getState(), _azAngle, _elevAngle);
|
||||
}
|
||||
|
||||
osg::BoundingBox SphereSegment::Spoke::computeBound() const
|
||||
osg::BoundingBox SphereSegment::Spoke::computeBoundingBox() const
|
||||
{
|
||||
osg::BoundingBox bbox;
|
||||
_ss->Spoke_computeBound(bbox, _azAngle, _elevAngle);
|
||||
@ -1049,7 +1049,7 @@ class PolytopeVisitor : public osg::NodeVisitor
|
||||
{
|
||||
for(unsigned int i=0; i<node.getNumDrawables(); ++i)
|
||||
{
|
||||
if (_polytopeStack.back().second.contains(node.getDrawable(i)->getBound()))
|
||||
if (_polytopeStack.back().second.contains(node.getDrawable(i)->getBoundingBox()))
|
||||
{
|
||||
_hits.push_back(Hit(_polytopeStack.back().first,getNodePath(),node.getDrawable(i)));
|
||||
}
|
||||
|
@ -409,7 +409,7 @@ void Text3D::computeGlyphRepresentation()
|
||||
TextBase::computePositions();
|
||||
}
|
||||
|
||||
osg::BoundingBox Text3D::computeBound() const
|
||||
osg::BoundingBox Text3D::computeBoundingBox() const
|
||||
{
|
||||
osg::BoundingBox bbox;
|
||||
|
||||
|
@ -268,7 +268,7 @@ void TextBase::setBoundingBoxMargin(float margin)
|
||||
}
|
||||
|
||||
|
||||
osg::BoundingBox TextBase::computeBound() const
|
||||
osg::BoundingBox TextBase::computeBoundingBox() const
|
||||
{
|
||||
osg::BoundingBox bbox;
|
||||
|
||||
|
@ -656,8 +656,8 @@ void PlaneIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Drawable
|
||||
// OSG_NOTICE<<"PlaneIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Drawable* drawable)"<<std::endl;
|
||||
|
||||
if (reachedLimit()) return;
|
||||
if ( _plane.intersect( drawable->getBound() )!=0 ) return;
|
||||
if ( !_polytope.contains( drawable->getBound() ) ) return;
|
||||
if ( _plane.intersect( drawable->getBoundingBox() )!=0 ) return;
|
||||
if ( !_polytope.contains( drawable->getBoundingBox() ) ) return;
|
||||
|
||||
// OSG_NOTICE<<"Succed PlaneIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Drawable* drawable)"<<std::endl;
|
||||
|
||||
|
@ -559,7 +559,7 @@ void PolytopeIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Drawa
|
||||
{
|
||||
if (reachedLimit()) return;
|
||||
|
||||
if ( !_polytope.contains( drawable->getBound() ) ) return;
|
||||
if ( !_polytope.contains( drawable->getBoundingBox() ) ) return;
|
||||
|
||||
osg::TemplatePrimitiveFunctor<PolytopeIntersectorUtils::PolytopePrimitiveIntersector> func;
|
||||
func.setPolytope( _polytope, _referencePlane );
|
||||
|
Loading…
Reference in New Issue
Block a user