diff --git a/panda/src/collide/collisionNode.cxx b/panda/src/collide/collisionNode.cxx index 03076d2bae..7ee30e02ac 100644 --- a/panda/src/collide/collisionNode.cxx +++ b/panda/src/collide/collisionNode.cxx @@ -209,11 +209,11 @@ output(ostream &out) const { // Access: Protected, Virtual // Description: Recomputes the dynamic bounding volume for this node. //////////////////////////////////////////////////////////////////// -void CollisionNode:: +BoundingVolume *CollisionNode:: recompute_bound() { // First, get ourselves a fresh, empty bounding volume. - BoundedObject::recompute_bound(); - nassertv(_bound != (BoundingVolume *)NULL); + BoundingVolume *bound = BoundedObject::recompute_bound(); + nassertr(bound != (BoundingVolume *)NULL, bound); // Now actually compute the bounding volume by putting it around all // of our solids' bounding volumes. @@ -226,20 +226,23 @@ recompute_bound() { const BoundingVolume **child_begin = &child_volumes[0]; const BoundingVolume **child_end = child_begin + child_volumes.size(); + bool success = - _bound->around(child_begin, child_end); + bound->around(child_begin, child_end); #ifdef NOTIFY_DEBUG if (!success) { collide_cat.error() << "Unable to generate bounding volume for " << *this << ":\n" - << "Cannot put " << _bound->get_type() << " around:\n"; + << "Cannot put " << bound->get_type() << " around:\n"; for (int i = 0; i < (int)child_volumes.size(); i++) { collide_cat.error(false) << " " << *child_volumes[i] << "\n"; } } #endif + + return bound; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/collide/collisionNode.h b/panda/src/collide/collisionNode.h index d898912341..09c38411a9 100644 --- a/panda/src/collide/collisionNode.h +++ b/panda/src/collide/collisionNode.h @@ -67,7 +67,7 @@ public: virtual void output(ostream &out) const; protected: - virtual void recompute_bound(); + virtual BoundingVolume *recompute_bound(); private: CollideMask _from_collide_mask; diff --git a/panda/src/collide/collisionPlane.cxx b/panda/src/collide/collisionPlane.cxx index e22f6710b8..c529156a97 100644 --- a/panda/src/collide/collisionPlane.cxx +++ b/panda/src/collide/collisionPlane.cxx @@ -104,13 +104,13 @@ output(ostream &out) const { // Access: Protected, Virtual // Description: //////////////////////////////////////////////////////////////////// -void CollisionPlane:: +BoundingVolume *CollisionPlane:: recompute_bound() { - // Planes have an infinite bounding volume. + // Planes always have an infinite bounding volume. BoundedObject::recompute_bound(); // Less than ideal: we throw away whatever we just allocated in // BoundedObject. - _bound = new OmniBoundingVolume; + return set_bound_ptr(new OmniBoundingVolume); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/collide/collisionPlane.h b/panda/src/collide/collisionPlane.h index 7886ad6aa7..323c48e5f8 100644 --- a/panda/src/collide/collisionPlane.h +++ b/panda/src/collide/collisionPlane.h @@ -59,7 +59,7 @@ PUBLISHED: INLINE const Planef &get_plane() const; protected: - virtual void recompute_bound(); + virtual BoundingVolume *recompute_bound(); protected: virtual int diff --git a/panda/src/collide/collisionPolygon.cxx b/panda/src/collide/collisionPolygon.cxx index 14f029e287..39e31798bd 100644 --- a/panda/src/collide/collisionPolygon.cxx +++ b/panda/src/collide/collisionPolygon.cxx @@ -202,13 +202,13 @@ output(ostream &out) const { // Access: Protected, Virtual // Description: //////////////////////////////////////////////////////////////////// -void CollisionPolygon:: +BoundingVolume *CollisionPolygon:: recompute_bound() { // First, get ourselves a fresh, empty bounding volume. - BoundedObject::recompute_bound(); - assert(_bound != (BoundingVolume*)0L); + BoundingVolume *bound = BoundedObject::recompute_bound(); + nassertr(bound != (BoundingVolume*)0L, bound); - GeometricBoundingVolume *gbv = DCAST(GeometricBoundingVolume, _bound); + GeometricBoundingVolume *gbv = DCAST(GeometricBoundingVolume, bound); // Now actually compute the bounding volume by putting it around all // of our vertices. @@ -221,6 +221,8 @@ recompute_bound() { const LPoint3f *vertices_begin = &vertices[0]; const LPoint3f *vertices_end = vertices_begin + vertices.size(); gbv->around(vertices_begin, vertices_end); + + return bound; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/collide/collisionPolygon.h b/panda/src/collide/collisionPolygon.h index 2fa734bee1..5f1bc6bc29 100644 --- a/panda/src/collide/collisionPolygon.h +++ b/panda/src/collide/collisionPolygon.h @@ -61,7 +61,7 @@ public: protected: INLINE CollisionPolygon(void); - virtual void recompute_bound(); + virtual BoundingVolume *recompute_bound(); protected: virtual int diff --git a/panda/src/collide/collisionRay.cxx b/panda/src/collide/collisionRay.cxx index b1deca34f4..6790ac36c6 100644 --- a/panda/src/collide/collisionRay.cxx +++ b/panda/src/collide/collisionRay.cxx @@ -125,12 +125,12 @@ set_from_lens(LensNode *camera, const LPoint2f &point) { // Access: Protected, Virtual // Description: //////////////////////////////////////////////////////////////////// -void CollisionRay:: +BoundingVolume *CollisionRay:: recompute_bound() { BoundedObject::recompute_bound(); // Less than ideal: we throw away whatever we just allocated in // BoundedObject. - _bound = new BoundingLine(_origin, _origin + _direction); + return set_bound_ptr(new BoundingLine(_origin, _origin + _direction)); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/collide/collisionRay.h b/panda/src/collide/collisionRay.h index 6f40215f48..986dc7785c 100644 --- a/panda/src/collide/collisionRay.h +++ b/panda/src/collide/collisionRay.h @@ -67,7 +67,7 @@ PUBLISHED: INLINE bool set_from_lens(LensNode *camera, float px, float py); protected: - virtual void recompute_bound(); + virtual BoundingVolume *recompute_bound(); protected: virtual void recompute_viz(Node *parent); diff --git a/panda/src/collide/collisionSegment.cxx b/panda/src/collide/collisionSegment.cxx index 871c619661..300983c681 100644 --- a/panda/src/collide/collisionSegment.cxx +++ b/panda/src/collide/collisionSegment.cxx @@ -124,20 +124,22 @@ set_from_lens(LensNode *camera, const LPoint2f &point) { // Access: Protected, Virtual // Description: //////////////////////////////////////////////////////////////////// -void CollisionSegment:: +BoundingVolume *CollisionSegment:: recompute_bound() { - BoundedObject::recompute_bound(); + BoundingVolume *bound = BoundedObject::recompute_bound(); - if (_bound->is_of_type(GeometricBoundingVolume::get_class_type())) { + if (bound->is_of_type(GeometricBoundingVolume::get_class_type())) { GeometricBoundingVolume *gbound; - DCAST_INTO_V(gbound, _bound); + DCAST_INTO_R(gbound, bound, bound); // This makes the assumption that _a and _b are laid out // sequentially in memory. It works because that's they way // they're defined in the class. - nassertv(&_a + 1 == &_b); + nassertr(&_a + 1 == &_b, bound); gbound->around(&_a, &_b + 1); } + + return bound; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/collide/collisionSegment.h b/panda/src/collide/collisionSegment.h index 417edf59d5..3cef75edc9 100644 --- a/panda/src/collide/collisionSegment.h +++ b/panda/src/collide/collisionSegment.h @@ -70,7 +70,7 @@ PUBLISHED: INLINE bool set_from_lens(LensNode *camera, float px, float py); protected: - virtual void recompute_bound(); + virtual BoundingVolume *recompute_bound(); protected: virtual void recompute_viz(Node *parent); diff --git a/panda/src/collide/collisionSphere.cxx b/panda/src/collide/collisionSphere.cxx index d249a70d23..2397b9c523 100644 --- a/panda/src/collide/collisionSphere.cxx +++ b/panda/src/collide/collisionSphere.cxx @@ -103,13 +103,15 @@ output(ostream &out) const { // Access: Protected, Virtual // Description: //////////////////////////////////////////////////////////////////// -void CollisionSphere:: +BoundingVolume *CollisionSphere:: recompute_bound() { - BoundedObject::recompute_bound(); - nassertv(_bound != (BoundingVolume*)0L); - nassertv(!_center.is_nan() && !cnan(_radius)); + BoundingVolume *bound = BoundedObject::recompute_bound(); + nassertr(bound != (BoundingVolume*)0L, bound); + nassertr(!_center.is_nan() && !cnan(_radius), bound); BoundingSphere sphere(_center, _radius); - _bound->extend_by(&sphere); + bound->extend_by(&sphere); + + return bound; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/collide/collisionSphere.h b/panda/src/collide/collisionSphere.h index a1596e1017..72e1a59229 100644 --- a/panda/src/collide/collisionSphere.h +++ b/panda/src/collide/collisionSphere.h @@ -56,7 +56,7 @@ PUBLISHED: protected: INLINE CollisionSphere(void); - virtual void recompute_bound(); + virtual BoundingVolume *recompute_bound(); protected: virtual int diff --git a/panda/src/gobj/geom.cxx b/panda/src/gobj/geom.cxx index 0aa40aa088..37a80e469d 100644 --- a/panda/src/gobj/geom.cxx +++ b/panda/src/gobj/geom.cxx @@ -613,13 +613,13 @@ init() { // Description: Recomputes the dynamic bounding volume for this Geom. // This includes all of the vertices. //////////////////////////////////////////////////////////////////// -void Geom:: +BoundingVolume *Geom:: recompute_bound() { // First, get ourselves a fresh, empty bounding volume. - BoundedObject::recompute_bound(); - assert(_bound != (BoundingVolume*)0L); + BoundingVolume *bound = BoundedObject::recompute_bound(); + nassertr(bound != (BoundingVolume*)0L, bound); - GeometricBoundingVolume *gbv = DCAST(GeometricBoundingVolume, _bound); + GeometricBoundingVolume *gbv = DCAST(GeometricBoundingVolume, bound); // Now actually compute the bounding volume by putting it around all // of our vertices. @@ -636,6 +636,8 @@ recompute_bound() { const LPoint3f *vertices_end = vertices_begin + vertices.size(); gbv->around(vertices_begin, vertices_end); + + return bound; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/gobj/geom.h b/panda/src/gobj/geom.h index f13847bc6f..7aca16956f 100644 --- a/panda/src/gobj/geom.h +++ b/panda/src/gobj/geom.h @@ -232,7 +232,7 @@ public: protected: void init(); - virtual void recompute_bound(); + virtual BoundingVolume *recompute_bound(); protected: diff --git a/panda/src/graph/boundedObject.I b/panda/src/graph/boundedObject.I index 827c8966ab..4f00e56393 100644 --- a/panda/src/graph/boundedObject.I +++ b/panda/src/graph/boundedObject.I @@ -19,23 +19,17 @@ #include //////////////////////////////////////////////////////////////////// -// Function: BoundedObject::is_bound_stale -// Access: Published -// Description: Returns true if the bound is currently marked stale -// and will be recomputed the next time get_bound() is -// called. -// -// This function is defined up at the top of this file, -// because several of the inline functions below -// reference it. +// Function: BoundedObject::CData::Constructor +// Access: Public +// Description: //////////////////////////////////////////////////////////////////// -INLINE_GRAPH bool BoundedObject:: -is_bound_stale() const { - return (_flags & F_bound_stale) != 0; +INLINE_GRAPH BoundedObject::CData:: +CData() { + _bound_type = BoundedObject::BVT_dynamic_sphere; + _flags = F_bound_stale; } - //////////////////////////////////////////////////////////////////// // Function: BoundedObject::Constructor // Access: Published @@ -43,8 +37,6 @@ is_bound_stale() const { //////////////////////////////////////////////////////////////////// INLINE_GRAPH BoundedObject:: BoundedObject() { - _bound_type = BVT_dynamic_sphere; - _flags = F_bound_stale; } //////////////////////////////////////////////////////////////////// @@ -57,8 +49,9 @@ BoundedObject() { INLINE_GRAPH void BoundedObject:: set_bound(BoundedObject::BoundingVolumeType type) { nassertv(type != BVT_static); + CDWriter cdata(_cycler); mark_bound_stale(); - _bound_type = type; + cdata->_bound_type = type; } //////////////////////////////////////////////////////////////////// @@ -70,10 +63,11 @@ set_bound(BoundedObject::BoundingVolumeType type) { //////////////////////////////////////////////////////////////////// INLINE_GRAPH void BoundedObject:: set_bound(const BoundingVolume &bound) { + CDWriter cdata(_cycler); mark_bound_stale(); - _bound_type = BVT_static; - _flags &= ~F_bound_stale; - _bound = bound.make_copy(); + cdata->_bound_type = BVT_static; + cdata->_flags &= ~F_bound_stale; + cdata->_bound = bound.make_copy(); } //////////////////////////////////////////////////////////////////// @@ -88,12 +82,14 @@ set_bound(const BoundingVolume &bound) { //////////////////////////////////////////////////////////////////// INLINE_GRAPH const BoundingVolume &BoundedObject:: get_bound() const { - if (_bound_type == BVT_static) { - ((BoundedObject *)this)->_flags &= ~F_bound_stale; - } else if (is_bound_stale() || _bound == (BoundingVolume *)NULL) { + CDReader cdata(_cycler); + if (cdata->_bound_type == BVT_static) { + CDWriter cdata_w(((BoundedObject *)this)->_cycler); + cdata_w->_flags &= ~F_bound_stale; + } else if (is_bound_stale() || cdata->_bound == (BoundingVolume *)NULL) { ((BoundedObject *)this)->recompute_bound(); } - return *_bound; + return *cdata->_bound; } //////////////////////////////////////////////////////////////////// @@ -111,7 +107,8 @@ mark_bound_stale() { if (is_bound_stale()) { return false; } - _flags |= F_bound_stale; + CDWriter cdata(_cycler); + cdata->_flags |= F_bound_stale; propagate_stale_bound(); return true; @@ -126,10 +123,29 @@ mark_bound_stale() { //////////////////////////////////////////////////////////////////// INLINE_GRAPH void BoundedObject:: force_bound_stale() { - _flags |= F_bound_stale; + CDWriter cdata(_cycler); + cdata->_flags |= F_bound_stale; propagate_stale_bound(); } +//////////////////////////////////////////////////////////////////// +// Function: BoundedObject::is_bound_stale +// Access: Published +// Description: Returns true if the bound is currently marked stale +// and will be recomputed the next time get_bound() is +// called. +// +// This function is defined up at the top of this file, +// because several of the inline functions below +// reference it. +//////////////////////////////////////////////////////////////////// +INLINE_GRAPH bool BoundedObject:: +is_bound_stale() const { + CDReader cdata(_cycler); + return (cdata->_flags & F_bound_stale) != 0; +} + + //////////////////////////////////////////////////////////////////// // Function: BoundedObject::set_final // Access: Published @@ -149,10 +165,11 @@ force_bound_stale() { //////////////////////////////////////////////////////////////////// INLINE_GRAPH void BoundedObject:: set_final(bool flag) { + CDWriter cdata(_cycler); if (flag) { - _flags |= F_final; + cdata->_flags |= F_final; } else { - _flags &= ~F_final; + cdata->_flags &= ~F_final; } } @@ -166,5 +183,45 @@ set_final(bool flag) { //////////////////////////////////////////////////////////////////// INLINE_GRAPH bool BoundedObject:: is_final() const { - return (_flags & F_final) != 0; + CDReader cdata(_cycler); + return (cdata->_flags & F_final) != 0; +} + +//////////////////////////////////////////////////////////////////// +// Function: BoundedObject::get_bound_ptr +// Access: Protected +// Description: Returns the state of the _bound pointer. To be used +// only internally by derived classes. +// +// This returns a const pointer only; the bounding +// volume should not be modified directly, because that +// might interfere with pipelining. Instead, create a +// new copy with make_copy(), modify the copy, and +// set_bound_ptr() with the copy. +// +// Alternatively, if you have just called +// recompute_bound(), which is guaranteed to reset the +// pointer, just use the return value from that as a +// non-const BoundingVolume pointer. +//////////////////////////////////////////////////////////////////// +INLINE_GRAPH const BoundingVolume *BoundedObject:: +get_bound_ptr() const { + CDReader cdata(_cycler); + return cdata->_bound; +} + +//////////////////////////////////////////////////////////////////// +// Function: BoundedObject::set_bound_ptr +// Access: Protected +// Description: Changes the _bound pointer. To be used only +// internally by derived classes, usually in +// recompute_bound(). The return value is the same +// pointer passed in, as a convenience (it will now be +// reference counted). +//////////////////////////////////////////////////////////////////// +INLINE_GRAPH BoundingVolume *BoundedObject:: +set_bound_ptr(BoundingVolume *bound) { + CDWriter cdata(_cycler); + cdata->_bound = bound; + return bound; } diff --git a/panda/src/graph/boundedObject.cxx b/panda/src/graph/boundedObject.cxx index b14a570374..523d60db2f 100644 --- a/panda/src/graph/boundedObject.cxx +++ b/panda/src/graph/boundedObject.cxx @@ -23,6 +23,19 @@ TypeHandle BoundedObject::_type_handle; +//////////////////////////////////////////////////////////////////// +// Function: BoundedObject::CData::Copy Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +BoundedObject::CData:: +CData(const BoundedObject::CData ©) : + _flags(copy._flags), + _bound_type(copy._bound_type), + _bound(copy._bound) +{ +} + //////////////////////////////////////////////////////////////////// // Function: BoundedObject::Destructor // Access: Public, Virtual @@ -32,6 +45,16 @@ BoundedObject:: ~BoundedObject() { } +//////////////////////////////////////////////////////////////////// +// Function: BoundedObject::CData::make_copy +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +CycleData *BoundedObject::CData:: +make_copy() const { + return new CData(*this); +} + //////////////////////////////////////////////////////////////////// // Function: BoundedObject::propagate_stale_bound // Access: Protected, Virtual @@ -49,22 +72,29 @@ propagate_stale_bound() { // Description: Recomputes the dynamic bounding volume for this // object. The default behavior is the compute an empty // bounding volume; this may be overridden to extend it -// to create a nonempty bounding volume. +// to create a nonempty bounding volume. However, after +// calling this function, it is guaranteed that the +// _bound pointer will not be shared with any other +// stage of the pipeline, and this new pointer is +// returned. //////////////////////////////////////////////////////////////////// -void BoundedObject:: +BoundingVolume *BoundedObject:: recompute_bound() { - switch (_bound_type) { + CDWriter cdata(_cycler); + switch (cdata->_bound_type) { case BVT_dynamic_sphere: - _bound = new BoundingSphere; + cdata->_bound = new BoundingSphere; break; default: graph_cat.error() - << "Unexpected _bound_type: " << (int)_bound_type + << "Unexpected _bound_type: " << (int)cdata->_bound_type << " in BoundedObject::recompute_bound()\n"; - _bound = NULL; + cdata->_bound = new BoundingSphere; } - _flags &= ~F_bound_stale; - // By default, the bound is empty. + cdata->_flags &= ~F_bound_stale; + + // Now the _bound is new and empty. + return cdata->_bound; } diff --git a/panda/src/graph/boundedObject.h b/panda/src/graph/boundedObject.h index f4eb097975..295fbd4837 100644 --- a/panda/src/graph/boundedObject.h +++ b/panda/src/graph/boundedObject.h @@ -19,12 +19,15 @@ #ifndef BOUNDEDOBJECT_H #define BOUNDEDOBJECT_H -#include +#include "pandabase.h" #include "boundingVolume.h" - -#include -#include +#include "cycleData.h" +#include "cycleDataReader.h" +#include "cycleDataWriter.h" +#include "pipelineCycler.h" +#include "typedObject.h" +#include "pointerTo.h" //////////////////////////////////////////////////////////////////// // Class : BoundedObject @@ -58,18 +61,32 @@ PUBLISHED: protected: virtual void propagate_stale_bound(); - virtual void recompute_bound(); + virtual BoundingVolume *recompute_bound(); + + INLINE_GRAPH const BoundingVolume *get_bound_ptr() const; + INLINE_GRAPH BoundingVolume *set_bound_ptr(BoundingVolume *bound); private: enum Flags { F_bound_stale = 0x0001, F_final = 0x0002, }; - int _flags; - BoundingVolumeType _bound_type; -protected: - PT(BoundingVolume) _bound; + // This is the data that must be cycled between pipeline stages. + class EXPCL_PANDA CData : public CycleData { + public: + INLINE_GRAPH CData(); + CData(const CData ©); + virtual CycleData *make_copy() const; + + int _flags; + BoundingVolumeType _bound_type; + PT(BoundingVolume) _bound; + }; + + PipelineCycler _cycler; + typedef CycleDataReader CDReader; + typedef CycleDataWriter CDWriter; public: static TypeHandle get_class_type() { diff --git a/panda/src/graph/nodeRelation.cxx b/panda/src/graph/nodeRelation.cxx index c6c2420bc2..b90ab4539a 100644 --- a/panda/src/graph/nodeRelation.cxx +++ b/panda/src/graph/nodeRelation.cxx @@ -817,18 +817,18 @@ propagate_stale_bound() { // Description: Recomputes the dynamic bounding volume for this arc // (and all of its descendants). //////////////////////////////////////////////////////////////////// -void NodeRelation:: +BoundingVolume *NodeRelation:: recompute_bound() { // First, get ourselves a fresh, empty bounding volume. - BoundedObject::recompute_bound(); - nassertv(_bound != (BoundingVolume*)NULL); + BoundingVolume *bound = BoundedObject::recompute_bound(); + nassertr(bound != (BoundingVolume*)NULL, bound); // Now actually compute the bounding volume by putting it around all // of our child bounding volumes. pvector child_volumes; Node *node = _child; - nassertv(node != (Node*)NULL); + nassertr(node != (Node*)NULL, bound); child_volumes.push_back(&node->get_bound()); @@ -841,21 +841,23 @@ recompute_bound() { const BoundingVolume **child_begin = &child_volumes[0]; const BoundingVolume **child_end = child_begin + child_volumes.size(); - bool success = - _bound->around(child_begin, child_end); + bool success = + bound->around(child_begin, child_end); #ifndef NDEBUG if (!success) { graph_cat.error() << "Unable to recompute bounding volume for " << *this << ":\n" - << "Cannot put " << _bound->get_type() << " around:\n"; + << "Cannot put " << bound->get_type() << " around:\n"; for (int i = 0; i < (int)child_volumes.size(); i++) { graph_cat.error(false) << " " << *child_volumes[i] << "\n"; } } #endif + + return bound; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/graph/nodeRelation.h b/panda/src/graph/nodeRelation.h index 581a6d20ea..07dc94fc6f 100644 --- a/panda/src/graph/nodeRelation.h +++ b/panda/src/graph/nodeRelation.h @@ -211,7 +211,7 @@ public: protected: virtual void propagate_stale_bound(); - virtual void recompute_bound(); + virtual BoundingVolume *recompute_bound(); PUBLISHED: INLINE_GRAPH static TypeHandle get_class_type(); diff --git a/panda/src/pgraph/Sources.pp b/panda/src/pgraph/Sources.pp index 7b2059a691..dc73bf4dd7 100644 --- a/panda/src/pgraph/Sources.pp +++ b/panda/src/pgraph/Sources.pp @@ -20,17 +20,11 @@ cullHandler.h \ cullResult.h \ qpcullTraverser.h qpcullTraverser.I \ - cycleData.h cycleData.I \ - cycleDataReader.h cycleDataReader.I \ - cycleDataWriter.h cycleDataWriter.I \ qpgeomNode.h qpgeomNode.I \ qplensNode.h qplensNode.I \ nodeChain.h nodeChain.I \ nodeChainComponent.h nodeChainComponent.I \ pandaNode.h pandaNode.I \ - pipeline.h pipeline.I \ - pipelineCycler.h pipelineCycler.I \ - pipelineCyclerBase.h pipelineCyclerBase.I \ renderAttrib.h renderAttrib.I \ renderState.h renderState.I \ textureAttrib.h textureAttrib.I \ @@ -53,17 +47,11 @@ cullHandler.cxx \ cullResult.cxx \ qpcullTraverser.cxx \ - cycleData.cxx \ - cycleDataReader.cxx \ - cycleDataWriter.cxx \ qpgeomNode.cxx \ qplensNode.cxx \ nodeChain.cxx \ nodeChainComponent.cxx \ pandaNode.cxx \ - pipeline.cxx \ - pipelineCycler.cxx \ - pipelineCyclerBase.cxx \ renderAttrib.cxx \ renderState.cxx \ textureAttrib.cxx \ @@ -91,17 +79,11 @@ cullHandler.h \ cullResult.h \ qpcullTraverser.h qpcullTraverser.I \ - cycleData.h cycleData.I \ - cycleDataReader.h cycleDataReader.I \ - cycleDataWriter.h cycleDataWriter.I \ qpgeomNode.h qpgeomNode.I \ qplensNode.h qplensNode.I \ nodeChain.h nodeChain.I \ nodeChainComponent.h nodeChainComponent.I \ pandaNode.h pandaNode.I \ - pipeline.h pipeline.I \ - pipelineCycler.h pipelineCycler.I \ - pipelineCyclerBase.h pipelineCyclerBase.I \ renderAttrib.h renderAttrib.I \ renderState.h renderState.I \ textureAttrib.h textureAttrib.I \ diff --git a/panda/src/pgraph/pgraph_composite2.cxx b/panda/src/pgraph/pgraph_composite2.cxx index 50699060c9..4e1a634895 100644 --- a/panda/src/pgraph/pgraph_composite2.cxx +++ b/panda/src/pgraph/pgraph_composite2.cxx @@ -1,14 +1,8 @@ -#include "cycleData.cxx" -#include "cycleDataReader.cxx" -#include "cycleDataWriter.cxx" #include "qpgeomNode.cxx" #include "qplensNode.cxx" #include "nodeChain.cxx" #include "nodeChainComponent.cxx" #include "pandaNode.cxx" -#include "pipeline.cxx" -#include "pipelineCycler.cxx" -#include "pipelineCyclerBase.cxx" #include "renderAttrib.cxx" #include "renderState.cxx" #include "test_pgraph.cxx" diff --git a/panda/src/putil/Sources.pp b/panda/src/putil/Sources.pp index 7218e1ca4b..afae7d8bfa 100644 --- a/panda/src/putil/Sources.pp +++ b/panda/src/putil/Sources.pp @@ -1,5 +1,5 @@ #define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \ - dtoolutil:c dtoolbase:c dtool:m + dtoolutil:c dtoolbase:c dtool:m #define LOCAL_LIBS express pandabase #begin lib_target @@ -8,59 +8,72 @@ #define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx #define SOURCES \ - bam.h bamReader.I bamReader.N bamReader.h bamReaderParam.I \ - bamReaderParam.h bamWriter.I bamWriter.h bitMask.I \ - bitMask.h buttonEvent.I buttonEvent.h buttonHandle.I \ - buttonHandle.h buttonRegistry.I buttonRegistry.h \ - collideMask.h \ - compareTo.I compareTo.h \ - config_util.N config_util.h configurable.h \ - factoryBase.I factoryBase.h \ - factoryParam.I factoryParam.h factoryParams.I \ - factoryParams.h \ - firstOfPairCompare.I firstOfPairCompare.h \ - firstOfPairLess.I firstOfPairLess.h \ - globPattern.I globPattern.h \ - globalPointerRegistry.I globalPointerRegistry.h \ - indirectCompareNames.I indirectCompareNames.h \ - indirectCompareTo.I indirectCompareTo.h \ - indirectLess.I indirectLess.h \ - ioPtaDatagramFloat.h ioPtaDatagramInt.h \ - ioPtaDatagramShort.h keyboardButton.h lineStream.I \ - lineStream.h lineStreamBuf.I lineStreamBuf.h \ - modifierButtons.I modifierButtons.h mouseButton.h \ - mouseData.h nameUniquifier.I nameUniquifier.h \ - ordered_vector.h ordered_vector.I ordered_vector.T \ - pta_double.h \ - pta_float.h pta_int.h \ - string_utils.I string_utils.N string_utils.h \ - timedCycle.I timedCycle.h typedWritable.I \ - typedWritable.h typedWritableReferenceCount.I \ - typedWritableReferenceCount.h updateSeq.I updateSeq.h \ - vector_double.h vector_float.h vector_typedWritable.h \ - vector_ushort.h vector_writable.h \ - writable.I writable.h writableConfigurable.h \ - writableParam.I writableParam.h + bam.h bamReader.I bamReader.N bamReader.h bamReaderParam.I \ + bamReaderParam.h bamWriter.I bamWriter.h bitMask.I \ + bitMask.h buttonEvent.I buttonEvent.h buttonHandle.I \ + buttonHandle.h buttonRegistry.I buttonRegistry.h \ + collideMask.h \ + compareTo.I compareTo.h \ + config_util.N config_util.h configurable.h \ + cycleData.h cycleData.I \ + cycleDataReader.h cycleDataReader.I \ + cycleDataWriter.h cycleDataWriter.I \ + factoryBase.I factoryBase.h \ + factoryParam.I factoryParam.h factoryParams.I \ + factoryParams.h \ + firstOfPairCompare.I firstOfPairCompare.h \ + firstOfPairLess.I firstOfPairLess.h \ + globPattern.I globPattern.h \ + globalPointerRegistry.I globalPointerRegistry.h \ + indirectCompareNames.I indirectCompareNames.h \ + indirectCompareTo.I indirectCompareTo.h \ + indirectLess.I indirectLess.h \ + ioPtaDatagramFloat.h ioPtaDatagramInt.h \ + ioPtaDatagramShort.h keyboardButton.h lineStream.I \ + lineStream.h lineStreamBuf.I lineStreamBuf.h \ + modifierButtons.I modifierButtons.h mouseButton.h \ + mouseData.h nameUniquifier.I nameUniquifier.h \ + ordered_vector.h ordered_vector.I ordered_vector.T \ + pipeline.h pipeline.I \ + pipelineCycler.h pipelineCycler.I \ + pipelineCyclerBase.h pipelineCyclerBase.I \ + pta_double.h \ + pta_float.h pta_int.h \ + string_utils.I string_utils.N string_utils.h \ + timedCycle.I timedCycle.h typedWritable.I \ + typedWritable.h typedWritableReferenceCount.I \ + typedWritableReferenceCount.h updateSeq.I updateSeq.h \ + vector_double.h vector_float.h vector_typedWritable.h \ + vector_ushort.h vector_writable.h \ + writable.I writable.h writableConfigurable.h \ + writableParam.I writableParam.h #define INCLUDED_SOURCES \ - bamReader.cxx bamReaderParam.cxx bamWriter.cxx bitMask.cxx \ - buttonEvent.cxx buttonHandle.cxx buttonRegistry.cxx \ - config_util.cxx configurable.cxx factoryBase.cxx \ - factoryParam.cxx factoryParams.cxx globPattern.cxx \ - globalPointerRegistry.cxx ioPtaDatagramFloat.cxx \ - ioPtaDatagramInt.cxx ioPtaDatagramShort.cxx \ - keyboardButton.cxx lineStream.cxx lineStreamBuf.cxx \ - modifierButtons.cxx mouseButton.cxx mouseData.cxx \ - nameUniquifier.cxx \ - ordered_vector.cxx \ - pta_double.cxx pta_float.cxx \ - pta_int.cxx pta_ushort.cxx \ - string_utils.cxx timedCycle.cxx typedWritable.cxx \ - typedWritableReferenceCount.cxx updateSeq.cxx \ - vector_double.cxx vector_float.cxx \ - vector_typedWritable.cxx \ - vector_ushort.cxx vector_writable.cxx writable.cxx \ - writableConfigurable.cxx writableParam.cxx + bamReader.cxx bamReaderParam.cxx bamWriter.cxx bitMask.cxx \ + buttonEvent.cxx buttonHandle.cxx buttonRegistry.cxx \ + config_util.cxx configurable.cxx \ + cycleData.cxx \ + cycleDataReader.cxx \ + cycleDataWriter.cxx \ + factoryBase.cxx \ + factoryParam.cxx factoryParams.cxx globPattern.cxx \ + globalPointerRegistry.cxx ioPtaDatagramFloat.cxx \ + ioPtaDatagramInt.cxx ioPtaDatagramShort.cxx \ + keyboardButton.cxx lineStream.cxx lineStreamBuf.cxx \ + modifierButtons.cxx mouseButton.cxx mouseData.cxx \ + nameUniquifier.cxx \ + ordered_vector.cxx \ + pipeline.cxx \ + pipelineCycler.cxx \ + pipelineCyclerBase.cxx \ + pta_double.cxx pta_float.cxx \ + pta_int.cxx pta_ushort.cxx \ + string_utils.cxx timedCycle.cxx typedWritable.cxx \ + typedWritableReferenceCount.cxx updateSeq.cxx \ + vector_double.cxx vector_float.cxx \ + vector_typedWritable.cxx \ + vector_ushort.cxx vector_writable.cxx writable.cxx \ + writableConfigurable.cxx writableParam.cxx #define INSTALL_HEADERS \ bam.h bamReader.I bamReader.h bamReaderParam.I bamReaderParam.h \ @@ -69,6 +82,9 @@ buttonRegistry.h collideMask.h \ compareTo.I compareTo.h \ config_util.h configurable.h factory.I factory.h \ + cycleData.h cycleData.I \ + cycleDataReader.h cycleDataReader.I \ + cycleDataWriter.h cycleDataWriter.I \ factoryBase.I factoryBase.h factoryParam.I factoryParam.h \ factoryParams.I factoryParams.h \ firstOfPairCompare.I firstOfPairCompare.h \ @@ -83,6 +99,9 @@ modifierButtons.h mouseButton.h mouseData.h nameUniquifier.I \ nameUniquifier.h \ ordered_vector.h ordered_vector.I ordered_vector.T \ + pipeline.h pipeline.I \ + pipelineCycler.h pipelineCycler.I \ + pipelineCyclerBase.h pipelineCyclerBase.I \ pta_double.h \ pta_float.h pta_int.h pta_ushort.h string_utils.I \ string_utils.h timedCycle.I timedCycle.h typedWritable.I \ diff --git a/panda/src/pgraph/cycleData.I b/panda/src/putil/cycleData.I similarity index 100% rename from panda/src/pgraph/cycleData.I rename to panda/src/putil/cycleData.I diff --git a/panda/src/pgraph/cycleData.cxx b/panda/src/putil/cycleData.cxx similarity index 100% rename from panda/src/pgraph/cycleData.cxx rename to panda/src/putil/cycleData.cxx diff --git a/panda/src/pgraph/cycleData.h b/panda/src/putil/cycleData.h similarity index 100% rename from panda/src/pgraph/cycleData.h rename to panda/src/putil/cycleData.h diff --git a/panda/src/pgraph/cycleDataReader.I b/panda/src/putil/cycleDataReader.I similarity index 100% rename from panda/src/pgraph/cycleDataReader.I rename to panda/src/putil/cycleDataReader.I diff --git a/panda/src/pgraph/cycleDataReader.cxx b/panda/src/putil/cycleDataReader.cxx similarity index 100% rename from panda/src/pgraph/cycleDataReader.cxx rename to panda/src/putil/cycleDataReader.cxx diff --git a/panda/src/pgraph/cycleDataReader.h b/panda/src/putil/cycleDataReader.h similarity index 100% rename from panda/src/pgraph/cycleDataReader.h rename to panda/src/putil/cycleDataReader.h diff --git a/panda/src/pgraph/cycleDataWriter.I b/panda/src/putil/cycleDataWriter.I similarity index 100% rename from panda/src/pgraph/cycleDataWriter.I rename to panda/src/putil/cycleDataWriter.I diff --git a/panda/src/pgraph/cycleDataWriter.cxx b/panda/src/putil/cycleDataWriter.cxx similarity index 100% rename from panda/src/pgraph/cycleDataWriter.cxx rename to panda/src/putil/cycleDataWriter.cxx diff --git a/panda/src/pgraph/cycleDataWriter.h b/panda/src/putil/cycleDataWriter.h similarity index 100% rename from panda/src/pgraph/cycleDataWriter.h rename to panda/src/putil/cycleDataWriter.h diff --git a/panda/src/pgraph/pipeline.I b/panda/src/putil/pipeline.I similarity index 100% rename from panda/src/pgraph/pipeline.I rename to panda/src/putil/pipeline.I diff --git a/panda/src/pgraph/pipeline.cxx b/panda/src/putil/pipeline.cxx similarity index 100% rename from panda/src/pgraph/pipeline.cxx rename to panda/src/putil/pipeline.cxx diff --git a/panda/src/pgraph/pipeline.h b/panda/src/putil/pipeline.h similarity index 100% rename from panda/src/pgraph/pipeline.h rename to panda/src/putil/pipeline.h diff --git a/panda/src/pgraph/pipelineCycler.I b/panda/src/putil/pipelineCycler.I similarity index 100% rename from panda/src/pgraph/pipelineCycler.I rename to panda/src/putil/pipelineCycler.I diff --git a/panda/src/pgraph/pipelineCycler.cxx b/panda/src/putil/pipelineCycler.cxx similarity index 100% rename from panda/src/pgraph/pipelineCycler.cxx rename to panda/src/putil/pipelineCycler.cxx diff --git a/panda/src/pgraph/pipelineCycler.h b/panda/src/putil/pipelineCycler.h similarity index 100% rename from panda/src/pgraph/pipelineCycler.h rename to panda/src/putil/pipelineCycler.h diff --git a/panda/src/pgraph/pipelineCyclerBase.I b/panda/src/putil/pipelineCyclerBase.I similarity index 100% rename from panda/src/pgraph/pipelineCyclerBase.I rename to panda/src/putil/pipelineCyclerBase.I diff --git a/panda/src/pgraph/pipelineCyclerBase.cxx b/panda/src/putil/pipelineCyclerBase.cxx similarity index 100% rename from panda/src/pgraph/pipelineCyclerBase.cxx rename to panda/src/putil/pipelineCyclerBase.cxx diff --git a/panda/src/pgraph/pipelineCyclerBase.h b/panda/src/putil/pipelineCyclerBase.h similarity index 100% rename from panda/src/pgraph/pipelineCyclerBase.h rename to panda/src/putil/pipelineCyclerBase.h diff --git a/panda/src/putil/putil_composite1.cxx b/panda/src/putil/putil_composite1.cxx index 41ecdcd7a4..2fb75b2d55 100644 --- a/panda/src/putil/putil_composite1.cxx +++ b/panda/src/putil/putil_composite1.cxx @@ -1,4 +1,3 @@ - #include "bamReader.cxx" #include "bamReaderParam.cxx" #include "bamWriter.cxx" @@ -8,6 +7,9 @@ #include "buttonRegistry.cxx" #include "config_util.cxx" #include "configurable.cxx" +#include "cycleData.cxx" +#include "cycleDataReader.cxx" +#include "cycleDataWriter.cxx" #include "factoryBase.cxx" #include "factoryParam.cxx" #include "factoryParams.cxx" diff --git a/panda/src/putil/putil_composite2.cxx b/panda/src/putil/putil_composite2.cxx index 24e5b24d73..e6ae445fe0 100644 --- a/panda/src/putil/putil_composite2.cxx +++ b/panda/src/putil/putil_composite2.cxx @@ -1,6 +1,8 @@ - #include "nameUniquifier.cxx" #include "ordered_vector.cxx" +#include "pipeline.cxx" +#include "pipelineCycler.cxx" +#include "pipelineCyclerBase.cxx" #include "pta_double.cxx" #include "pta_float.cxx" #include "pta_int.cxx" diff --git a/panda/src/sgattrib/renderRelation.cxx b/panda/src/sgattrib/renderRelation.cxx index f6ecb53c0a..0d534d1b57 100644 --- a/panda/src/sgattrib/renderRelation.cxx +++ b/panda/src/sgattrib/renderRelation.cxx @@ -54,21 +54,23 @@ changed_transition(TypeHandle trans_type) { // Description: Recomputes the dynamic bounding volume for this arc // (and all of its descendants). //////////////////////////////////////////////////////////////////// -void RenderRelation:: +BoundingVolume *RenderRelation:: recompute_bound() { // First, compute the bounding volume around all of our children. - NodeRelation::recompute_bound(); - nassertv(_bound != (BoundingVolume *)NULL); + BoundingVolume *bound = NodeRelation::recompute_bound(); + nassertr(bound != (BoundingVolume *)NULL, bound); // Now, if we have a transform transition on the arc, apply it to // the bounding volume. GeometricBoundingVolume *gbv; - DCAST_INTO_V(gbv, _bound); + DCAST_INTO_R(gbv, bound, bound); const TransformTransition *tt; if (get_transition_into(tt, this)) { gbv->xform(tt->get_matrix()); } + + return bound; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/sgattrib/renderRelation.h b/panda/src/sgattrib/renderRelation.h index 11fe3b0f45..37c72bae31 100644 --- a/panda/src/sgattrib/renderRelation.h +++ b/panda/src/sgattrib/renderRelation.h @@ -41,7 +41,7 @@ public: virtual void changed_transition(TypeHandle transition_type); protected: - virtual void recompute_bound(); + virtual BoundingVolume *recompute_bound(); public: // This is just to be called at initialization time; don't try to diff --git a/panda/src/sgraph/geomNode.cxx b/panda/src/sgraph/geomNode.cxx index 1d441b41e7..e1a3f3730d 100644 --- a/panda/src/sgraph/geomNode.cxx +++ b/panda/src/sgraph/geomNode.cxx @@ -414,11 +414,11 @@ add_geoms_from(const GeomNode *other) { // Access: Protected, Virtual // Description: Recomputes the dynamic bounding volume for this node. //////////////////////////////////////////////////////////////////// -void GeomNode:: +BoundingVolume *GeomNode:: recompute_bound() { // First, get ourselves a fresh, empty bounding volume. - BoundedObject::recompute_bound(); - assert(_bound != (BoundingVolume *)NULL); + BoundingVolume *bound = BoundedObject::recompute_bound(); + nassertr(bound != (BoundingVolume *)NULL, bound); // Now actually compute the bounding volume by putting it around all // of our drawable's bounding volumes. @@ -431,7 +431,9 @@ recompute_bound() { const BoundingVolume **child_begin = &child_volumes[0]; const BoundingVolume **child_end = child_begin + child_volumes.size(); - _bound->around(child_begin, child_end); + + bound->around(child_begin, child_end); + return bound; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/sgraph/geomNode.h b/panda/src/sgraph/geomNode.h index 58488a31fe..4eb7f19ad3 100644 --- a/panda/src/sgraph/geomNode.h +++ b/panda/src/sgraph/geomNode.h @@ -73,7 +73,7 @@ PUBLISHED: void add_geoms_from(const GeomNode *other); protected: - virtual void recompute_bound(); + virtual BoundingVolume *recompute_bound(); private: typedef PTA(PT(dDrawable)) Geoms;