diff --git a/panda/src/char/characterJoint.h b/panda/src/char/characterJoint.h index 69ba5f9c3d..83d81e31c5 100644 --- a/panda/src/char/characterJoint.h +++ b/panda/src/char/characterJoint.h @@ -12,6 +12,7 @@ #include #include #include +#include //////////////////////////////////////////////////////////////////// // Class : CharacterJoint @@ -44,7 +45,7 @@ PUBLISHED: void clear_local_transforms(); private: - typedef set< PT(NodeRelation) > ArcList; + typedef set< PT_NodeRelation > ArcList; ArcList _net_transform_arcs; ArcList _local_transform_arcs; diff --git a/panda/src/collide/collisionHandlerPhysical.h b/panda/src/collide/collisionHandlerPhysical.h index 3664161c02..3ecf31dde2 100644 --- a/panda/src/collide/collisionHandlerPhysical.h +++ b/panda/src/collide/collisionHandlerPhysical.h @@ -13,6 +13,7 @@ #include #include +#include /////////////////////////////////////////////////////////////////// // Class : CollisionHandlerPhysical @@ -54,7 +55,7 @@ protected: void set_mat(const LMatrix4f &mat) const; PT(DriveInterface) _drive_interface; - PT(NodeRelation) _arc; + PT_NodeRelation _arc; }; typedef map Colliders; diff --git a/panda/src/collide/collisionSolid.h b/panda/src/collide/collisionSolid.h index a509f836f8..9b4ecf246a 100644 --- a/panda/src/collide/collisionSolid.h +++ b/panda/src/collide/collisionSolid.h @@ -13,6 +13,8 @@ #include #include #include +#include +#include class CollisionHandler; class CollisionEntry; @@ -85,7 +87,7 @@ protected: virtual void recompute_viz(Node *parent)=0; - typedef vector< PT(NodeRelation) > VizArcs; + typedef vector_PT_NodeRelation VizArcs; VizArcs _solid_viz_arcs; VizArcs _wireframe_viz_arcs; VizArcs _other_viz_arcs; diff --git a/panda/src/cull/cullStateLookup.cxx b/panda/src/cull/cullStateLookup.cxx index 04808bf215..d504dcf36d 100644 --- a/panda/src/cull/cullStateLookup.cxx +++ b/panda/src/cull/cullStateLookup.cxx @@ -106,7 +106,7 @@ find_node(Node *node, // CullStateSubtree is always returned. //////////////////////////////////////////////////////////////////// CullStateSubtree *CullStateLookup:: -get_subtree(const PT(NodeRelation) &arc, +get_subtree(const PT_NodeRelation &arc, const AllTransitionsWrapper &trans, Node *top_subtree, UpdateSeq now) { diff --git a/panda/src/cull/cullStateLookup.h b/panda/src/cull/cullStateLookup.h index 62979e0a61..1cc6ab8d4f 100644 --- a/panda/src/cull/cullStateLookup.h +++ b/panda/src/cull/cullStateLookup.h @@ -11,6 +11,7 @@ #include #include #include +#include #include @@ -42,7 +43,7 @@ public: CullState *find_node(Node *node, const AllTransitionsWrapper &trans, UpdateSeq now); - CullStateSubtree *get_subtree(const PT(NodeRelation) &arc, + CullStateSubtree *get_subtree(const PT_NodeRelation &arc, const AllTransitionsWrapper &trans, Node *top_subtree, UpdateSeq now); @@ -63,7 +64,7 @@ private: typedef map CullStates; CullStates _cull_states; - typedef map Subtrees; + typedef map Subtrees; Subtrees _subtrees; }; diff --git a/panda/src/graph/Sources.pp b/panda/src/graph/Sources.pp index f2b859834e..0e0b26ef29 100644 --- a/panda/src/graph/Sources.pp +++ b/panda/src/graph/Sources.pp @@ -47,9 +47,15 @@ onOffTransition.I onOffTransition.cxx onOffTransition.h \ onTransition.I onTransition.cxx onTransition.h pointerNameClass.h \ pt_NamedNode.N pt_NamedNode.cxx pt_NamedNode.h pt_Node.N \ - pt_Node.cxx pt_Node.h setTransitionHelpers.T \ + pt_Node.cxx pt_Node.h \ + pt_NodeRelation.cxx pt_NodeRelation.h \ + setTransitionHelpers.T \ setTransitionHelpers.h transitionDirection.h traverserVisitor.T \ - traverserVisitor.h vector_PT_Node.cxx vector_PT_Node.h wrt.I \ + traverserVisitor.h \ + vector_PT_Node.cxx vector_PT_Node.h \ + vector_PT_NodeRelation.cxx vector_PT_NodeRelation.h \ + vector_NodeRelation_star.cxx vector_NodeRelation_star.h \ + wrt.I \ wrt.cxx wrt.h #define INSTALL_HEADERS \ @@ -79,9 +85,11 @@ nullTransitionWrapper.h onAttribute.h onOffAttribute.I \ onOffAttribute.h onOffTransition.I onOffTransition.h \ onTransition.I onTransition.h pointerNameClass.h pt_NamedNode.h \ - pt_Node.h setTransitionHelpers.T setTransitionHelpers.h \ + pt_Node.h pt_NodeRelation.h \ + setTransitionHelpers.T setTransitionHelpers.h \ transitionDirection.h traverserVisitor.T traverserVisitor.h \ - vector_PT_Node.h wrt.I wrt.h + vector_PT_Node.h vector_PT_NodeRelation.h vector_NodeRelation_star.h \ + wrt.I wrt.h #define IGATESCAN all diff --git a/panda/src/graph/node.h b/panda/src/graph/node.h index c0e6f0e9d3..6640489db9 100644 --- a/panda/src/graph/node.h +++ b/panda/src/graph/node.h @@ -83,13 +83,11 @@ PUBLISHED: virtual void write(ostream &out, int indent_level = 0) const; public: - // We reference-count the child pointer, but not the parent pointer, - // to avoid circular reference counting. + // These members define the actual connection of arcs to the nodes. + // Generally, you should not monkey with them, unless you know what + // you're doing; the get_parent()/get_child() interface above is + // simpler to use. - // The following members are public to allow low-overhead traversal - // through the scene graph when necessary, but beware! It is not - // safe to access these members directly outside of PANDA.DLL. - // Instead, use the get_parent()/get_child() interface, above. INLINE_GRAPH const NodeConnection &find_connection(TypeHandle graph_type) const; INLINE_GRAPH NodeConnection *update_connection(TypeHandle graph_type); diff --git a/panda/src/graph/nodeConnection.h b/panda/src/graph/nodeConnection.h index bfd7ad07ec..442169a34c 100644 --- a/panda/src/graph/nodeConnection.h +++ b/panda/src/graph/nodeConnection.h @@ -10,6 +10,11 @@ #include "nodeRelation.h" #include "config_graph.h" +#include "vector_PT_NodeRelation.h" +#include "vector_NodeRelation_star.h" + +typedef vector_PT_NodeRelation DownRelationPointers; +typedef vector_NodeRelation_star UpRelationPointers; /////////////////////////////////////////////////////////////////// @@ -17,12 +22,8 @@ // Description : This class represents the table, stored within each // Node, of all the connected NodeRelations (arcs) of a // particular graph type. -// -// Node that this class is not exported from PANDA.DLL. -// You should use the get_parent()/get_child() interface -// to Node for code outside of PANDA.DLL. //////////////////////////////////////////////////////////////////// -class NodeConnection { +class EXPCL_PANDA NodeConnection { public: INLINE_GRAPH NodeConnection(TypeHandle graph_type = TypeHandle::none()); INLINE_GRAPH ~NodeConnection(); diff --git a/panda/src/graph/nodeRelation.I b/panda/src/graph/nodeRelation.I index c40cdb828d..8bc1179524 100644 --- a/panda/src/graph/nodeRelation.I +++ b/panda/src/graph/nodeRelation.I @@ -11,7 +11,7 @@ //////////////////////////////////////////////////////////////////// EXPCL_PANDA INLINE_GRAPH void remove_arc(NodeRelation *arc) { - PT(NodeRelation) hold_arc = arc->detach(); + PT(TypedWriteableReferenceCount) hold_ptr = arc->detach(); arc->_parent = NULL; arc->_child = NULL; } @@ -88,7 +88,7 @@ get_graph_type() const { //////////////////////////////////////////////////////////////////// INLINE_GRAPH void NodeRelation:: change_parent(Node *parent) { - PT(NodeRelation) hold_arc = detach(); + PT(TypedWriteableReferenceCount) hold_ptr = detach(); _parent = parent; attach(); } @@ -101,7 +101,7 @@ change_parent(Node *parent) { //////////////////////////////////////////////////////////////////// INLINE_GRAPH void NodeRelation:: change_parent(Node *parent, int sort) { - PT(NodeRelation) hold_arc = detach(); + PT(TypedWriteableReferenceCount) hold_ptr = detach(); _parent = parent; _sort = sort; attach(); @@ -114,7 +114,7 @@ change_parent(Node *parent, int sort) { //////////////////////////////////////////////////////////////////// INLINE_GRAPH void NodeRelation:: change_child(Node *child) { - PT(NodeRelation) hold_arc = detach(); + PT(TypedWriteableReferenceCount) hold_ptr = detach(); _child = child; attach(); } @@ -127,7 +127,7 @@ change_child(Node *child) { //////////////////////////////////////////////////////////////////// INLINE_GRAPH void NodeRelation:: change_parent_and_child(Node *parent, Node *child) { - PT(NodeRelation) hold_arc = detach(); + PT(TypedWriteableReferenceCount) hold_ptr = detach(); _parent = parent; _child = child; attach(); @@ -141,7 +141,7 @@ change_parent_and_child(Node *parent, Node *child) { //////////////////////////////////////////////////////////////////// INLINE_GRAPH void NodeRelation:: set_sort(int sort) { - PT(NodeRelation) hold_arc = detach(); + PT(TypedWriteableReferenceCount) hold_ptr = detach(); _sort = sort; attach(); } @@ -155,7 +155,7 @@ set_sort(int sort) { //////////////////////////////////////////////////////////////////// INLINE_GRAPH void NodeRelation:: set_graph_type(TypeHandle graph_type) { - PT(NodeRelation) hold_arc = detach(); + PT(TypedWriteableReferenceCount) hold_ptr = detach(); _graph_type = graph_type; attach(); } diff --git a/panda/src/graph/nodeRelation.cxx b/panda/src/graph/nodeRelation.cxx index a718f10e6b..0fc2a4bd13 100644 --- a/panda/src/graph/nodeRelation.cxx +++ b/panda/src/graph/nodeRelation.cxx @@ -670,10 +670,14 @@ attach() { // when its last reference count is removed, and it is // generally a bad idea to destruct a class within its // own method. + +// It must be a PT(TypedWriteableReferenceCount), and +// not PT_NodeRelation, because of circularity problems +// trying to export the template class PT_NodeRelation. //////////////////////////////////////////////////////////////////// -PT(NodeRelation) NodeRelation:: +PT(TypedWriteableReferenceCount) NodeRelation:: detach() { - PT(NodeRelation) result = this; + PT(TypedWriteableReferenceCount) result = this; nassertr(_parent != (Node*)NULL, result); nassertr(_child != (Node*)NULL, result); @@ -726,9 +730,9 @@ detach() { // remove it from its parent's arc list, which is // presumably about to be destroyed anyway. //////////////////////////////////////////////////////////////////// -PT(NodeRelation) NodeRelation:: +PT(TypedWriteableReferenceCount) NodeRelation:: detach_below() { - PT(NodeRelation) result = this; + PT(TypedWriteableReferenceCount) result = this; nassertr(_parent != (Node*)NULL, result); nassertr(_child != (Node*)NULL, result); diff --git a/panda/src/graph/nodeRelation.h b/panda/src/graph/nodeRelation.h index ef20a690cc..60dfee6383 100644 --- a/panda/src/graph/nodeRelation.h +++ b/panda/src/graph/nodeRelation.h @@ -134,8 +134,8 @@ private: protected: void attach(); - PT(NodeRelation) detach(); - PT(NodeRelation) detach_below(); + PT(TypedWriteableReferenceCount) detach(); + PT(TypedWriteableReferenceCount) detach_below(); private: // We reference-count the child pointer, but not the parent pointer, @@ -222,9 +222,6 @@ private: EXPCL_PANDA INLINE_GRAPH ostream & operator << (ostream &out, const NodeRelation &arc); -typedef vector< PT(NodeRelation) > DownRelationPointers; -typedef vector UpRelationPointers; - #include "nodeRelation.T" #ifndef DONT_INLINE_GRAPH diff --git a/panda/src/graph/pt_NodeRelation.cxx b/panda/src/graph/pt_NodeRelation.cxx new file mode 100644 index 0000000000..36294e99a8 --- /dev/null +++ b/panda/src/graph/pt_NodeRelation.cxx @@ -0,0 +1,12 @@ +// Filename: pt_NodeRelation.cxx +// Created by: drose (07May01) +// +//////////////////////////////////////////////////////////////////// + +#include "nodeRelation.h" +#include "pt_NodeRelation.h" + +// Tell GCC that we'll take care of the instantiation explicitly here. +#ifdef __GNUC__ +#pragma implementation +#endif diff --git a/panda/src/graph/pt_NodeRelation.h b/panda/src/graph/pt_NodeRelation.h new file mode 100644 index 0000000000..6321d61318 --- /dev/null +++ b/panda/src/graph/pt_NodeRelation.h @@ -0,0 +1,33 @@ +// Filename: pt_NodeRelation.h +// Created by: drose (07May01) +// +//////////////////////////////////////////////////////////////////// + +#ifndef PT_NODERELATION_H +#define PT_NODERELATION_H + +#include + +#include "nodeRelation.h" +#include + +//////////////////////////////////////////////////////////////////// +// Class : PT_NodeRelation +// Description : PT(NodeRelation). This is defined here solely we can +// explicitly export the template class. It's not +// strictly necessary, but it doesn't hurt. +//////////////////////////////////////////////////////////////////// + +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA, EXPTP_PANDA, PointerToBase) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA, EXPTP_PANDA, PointerTo) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA, EXPTP_PANDA, ConstPointerTo) + +typedef PointerTo PT_NodeRelation; +typedef ConstPointerTo CPT_NodeRelation; + +// Tell GCC that we'll take care of the instantiation explicitly here. +#ifdef __GNUC__ +#pragma interface +#endif + +#endif diff --git a/panda/src/graph/vector_NodeRelation_star.cxx b/panda/src/graph/vector_NodeRelation_star.cxx new file mode 100644 index 0000000000..759853b376 --- /dev/null +++ b/panda/src/graph/vector_NodeRelation_star.cxx @@ -0,0 +1,11 @@ +// Filename: vector_NodeRelation_star.cxx +// Created by: drose (07May01) +// +//////////////////////////////////////////////////////////////////// + +#include "vector_NodeRelation_star.h" + +// Tell GCC that we'll take care of the instantiation explicitly here. +#ifdef __GNUC__ +#pragma implementation +#endif diff --git a/panda/src/graph/vector_NodeRelation_star.h b/panda/src/graph/vector_NodeRelation_star.h new file mode 100644 index 0000000000..4a1950dca8 --- /dev/null +++ b/panda/src/graph/vector_NodeRelation_star.h @@ -0,0 +1,32 @@ +// Filename: vector_NodeRelation_star.h +// Created by: drose (07May01) +// +//////////////////////////////////////////////////////////////////// + +#ifndef VECTOR_NODERELATION_STAR_H +#define VECTOR_NODERELATION_STAR_H + +#include + +#include + +class NodeRelation; + +//////////////////////////////////////////////////////////////////// +// Class : vector_NodeRelation_star +// Description : A vector of NodeRelation*'s. This class is defined +// once here, and exported to PANDA.DLL; other packages +// that want to use a vector of this type (whether they +// need to export it or not) should include this header +// file, rather than defining the vector again. +//////////////////////////////////////////////////////////////////// + +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA, EXPTP_PANDA, std::vector) +typedef vector vector_NodeRelation_star; + +// Tell GCC that we'll take care of the instantiation explicitly here. +#ifdef __GNUC__ +#pragma interface +#endif + +#endif diff --git a/panda/src/graph/vector_PT_NodeRelation.cxx b/panda/src/graph/vector_PT_NodeRelation.cxx new file mode 100644 index 0000000000..468507b283 --- /dev/null +++ b/panda/src/graph/vector_PT_NodeRelation.cxx @@ -0,0 +1,12 @@ +// Filename: vector_PT_NodeRelation.cxx +// Created by: drose (07May01) +// +//////////////////////////////////////////////////////////////////// + +#include "node.h" +#include "vector_PT_NodeRelation.h" + +// Tell GCC that we'll take care of the instantiation explicitly here. +#ifdef __GNUC__ +#pragma implementation +#endif diff --git a/panda/src/graph/vector_PT_NodeRelation.h b/panda/src/graph/vector_PT_NodeRelation.h new file mode 100644 index 0000000000..83e9a4390d --- /dev/null +++ b/panda/src/graph/vector_PT_NodeRelation.h @@ -0,0 +1,33 @@ +// Filename: vector_PT_NodeRelation.h +// Created by: drose (07May01) +// +//////////////////////////////////////////////////////////////////// + +#ifndef VECTOR_PT_NODERELATION_H +#define VECTOR_PT_NODERELATION_H + +#include + +#include "nodeRelation.h" +#include "pt_NodeRelation.h" + +#include + +//////////////////////////////////////////////////////////////////// +// Class : vector_PT_NodeRelation +// Description : A vector of PT(NodeRelation)'s. This class is defined once +// here, and exported to PANDA.DLL; other packages that +// want to use a vector of this type (whether they need +// to export it or not) should include this header file, +// rather than defining the vector again. +//////////////////////////////////////////////////////////////////// + +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA, EXPTP_PANDA, std::vector) +typedef vector vector_PT_NodeRelation; + +// Tell GCC that we'll take care of the instantiation explicitly here. +#ifdef __GNUC__ +#pragma interface +#endif + +#endif diff --git a/panda/src/graph/wrt.I b/panda/src/graph/wrt.I index 872b99d1a5..7a9e6e8a9e 100644 --- a/panda/src/graph/wrt.I +++ b/panda/src/graph/wrt.I @@ -858,7 +858,8 @@ cached_wrt_subtree(NodeRelation *arc, Node *to, UpdateSeq as_of, UpdateSeq now, top_subtree = top_subtree_3; } - if (check_trans.compare_to(result) != 0) { + int compare = check_trans.compare_to(result); + if (compare != 0) { wrt_cat.warning() << "WRT subtree cache from " << *arc->get_child() << " to "; if (to == (Node *)NULL) { @@ -874,6 +875,12 @@ cached_wrt_subtree(NodeRelation *arc, Node *to, UpdateSeq as_of, UpdateSeq now, << " should be:\n"; check_trans.write(wrt_cat.warning(false), 4); result = check_trans; + + /* + cerr << "Begin recheck.\n"; + int num = check_trans.compare_to(result); + cerr << "Done recheck, result = " << num << "\n"; + */ } } #endif diff --git a/panda/src/parametrics/parametricCurve.h b/panda/src/parametrics/parametricCurve.h index 42a4e2f530..178e832a0f 100644 --- a/panda/src/parametrics/parametricCurve.h +++ b/panda/src/parametrics/parametricCurve.h @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -129,7 +130,7 @@ private: typedef list DrawerList; DrawerList _drawers; ParametricCurveDrawer *_implicit_drawer; - PT(NodeRelation) _viz_arc; + PT_NodeRelation _viz_arc; // TypedWriteable stuff protected: diff --git a/panda/src/parametrics/parametricCurveDrawer.h b/panda/src/parametrics/parametricCurveDrawer.h index 3eb738802c..88b0d012ac 100644 --- a/panda/src/parametrics/parametricCurveDrawer.h +++ b/panda/src/parametrics/parametricCurveDrawer.h @@ -10,6 +10,7 @@ #include #include +#include #include @@ -71,7 +72,7 @@ private: float _num_ticks; float _tick_scale; - typedef vector< PT(NodeRelation) > TickArcs; + typedef vector_PT_NodeRelation TickArcs; TickArcs _tick_arcs; public: diff --git a/panda/src/sgmanip/nodePath.cxx b/panda/src/sgmanip/nodePath.cxx index bc4ded2fb4..5063585bf6 100644 --- a/panda/src/sgmanip/nodePath.cxx +++ b/panda/src/sgmanip/nodePath.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -884,7 +885,7 @@ remove_node() { nassertv(verify_connectivity()); nassertv(has_arcs()); - PT(NodeRelation) darc = arc(); + PT_NodeRelation darc = arc(); // Set the chain to stop here, so that any NodePaths sharing this // one will now begin at this "deleted" node. diff --git a/panda/src/tform/mouseWatcher.h b/panda/src/tform/mouseWatcher.h index cb2937bf4e..c2e7a20c42 100644 --- a/panda/src/tform/mouseWatcher.h +++ b/panda/src/tform/mouseWatcher.h @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -106,7 +107,7 @@ private: string _enter_pattern; string _leave_pattern; - PT(NodeRelation) _geometry; + PT_NodeRelation _geometry; EventHandler* _eh;