diff --git a/panda/src/char/character.cxx b/panda/src/char/character.cxx index 999c574442..abf5fa581f 100644 --- a/panda/src/char/character.cxx +++ b/panda/src/char/character.cxx @@ -115,7 +115,7 @@ safe_to_transform() const { // character node's being present in the scene graph. //////////////////////////////////////////////////////////////////// void Character:: -app_traverse() { +app_traverse(const ArcChain &) { double now = ClockObject::get_global_clock()->get_frame_time(); get_bundle()->advance_time(now); diff --git a/panda/src/char/character.h b/panda/src/char/character.h index 048f78673b..f929338ac5 100644 --- a/panda/src/char/character.h +++ b/panda/src/char/character.h @@ -60,7 +60,7 @@ PUBLISHED: INLINE void write_part_values(ostream &out) const; public: - virtual void app_traverse(); + virtual void app_traverse(const ArcChain &chain); PUBLISHED: void update(); diff --git a/panda/src/collide/collisionNode.cxx b/panda/src/collide/collisionNode.cxx index ff87e6d696..03076d2bae 100644 --- a/panda/src/collide/collisionNode.cxx +++ b/panda/src/collide/collisionNode.cxx @@ -182,7 +182,7 @@ preserve_name() const { // geometry is up-to-date. //////////////////////////////////////////////////////////////////// void CollisionNode:: -draw_traverse() { +draw_traverse(const ArcChain &) { Solids::iterator si; for (si = _solids.begin(); si != _solids.end(); ++si) { (*si)->update_viz(this); diff --git a/panda/src/collide/collisionNode.h b/panda/src/collide/collisionNode.h index fee2070c86..d898912341 100644 --- a/panda/src/collide/collisionNode.h +++ b/panda/src/collide/collisionNode.h @@ -63,7 +63,7 @@ PUBLISHED: INLINE int add_solid(CollisionSolid *solid); public: - virtual void draw_traverse(); + virtual void draw_traverse(const ArcChain &chain); virtual void output(ostream &out) const; protected: diff --git a/panda/src/cull/cullTraverser.cxx b/panda/src/cull/cullTraverser.cxx index 844803ec1e..47643e0a12 100644 --- a/panda/src/cull/cullTraverser.cxx +++ b/panda/src/cull/cullTraverser.cxx @@ -586,9 +586,9 @@ forward_arc(NodeRelation *arc, NullTransitionWrapper &, Node *node = arc->get_child(); if (implicit_app_traversal) { - node->app_traverse(); + node->app_traverse(_arc_chain); } - node->draw_traverse(); + node->draw_traverse(_arc_chain); // We have to get a new _now timestamp, just in case either of the // above traversals changed it. diff --git a/panda/src/effects/lensFlareNode.cxx b/panda/src/effects/lensFlareNode.cxx index 50414bc05a..687005b31d 100644 --- a/panda/src/effects/lensFlareNode.cxx +++ b/panda/src/effects/lensFlareNode.cxx @@ -18,32 +18,29 @@ #include "lensFlareNode.h" #include "config_effects.h" -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include +#include "sequenceNode.h" +#include "geomNode.h" +#include "geomSprite.h" +#include "textureTransition.h" +#include "transformTransition.h" +#include "billboardTransition.h" +#include "transformAttribute.h" +#include "transparencyTransition.h" +#include "renderTraverser.h" +#include "orthoProjection.h" +#include "perspectiveProjection.h" +#include "get_rel_pos.h" +#include "clockObject.h" +#include "allAttributesWrapper.h" +#include "allTransitionsWrapper.h" +#include "graphicsStateGuardian.h" +#include "datagram.h" +#include "datagramIterator.h" +#include "bamReader.h" +#include "bamWriter.h" +#include "ioPtaDatagramFloat.h" +#include "ioPtaDatagramLinMath.h" //////////////////////////////////////////////////////////////////// // Static variables diff --git a/panda/src/graph/node.cxx b/panda/src/graph/node.cxx index b50b02cee3..504ea8b986 100644 --- a/panda/src/graph/node.cxx +++ b/panda/src/graph/node.cxx @@ -287,6 +287,42 @@ get_child(TypeHandle type, int index) const { return drp[index]; } +//////////////////////////////////////////////////////////////////// +// Function: Node::app_traverse +// Access: Public, Virtual +// Description: This hook function is called on each node visited +// during the App traversal. The ArcChain passed in +// represents the complete chain from the root of the +// graph to this node, if it is known. +//////////////////////////////////////////////////////////////////// +void Node:: +app_traverse(const ArcChain &) { +} + +//////////////////////////////////////////////////////////////////// +// Function: Node::draw_traverse +// Access: Public, Virtual +// Description: This hook function is called on each node visited +// during the Draw traversal. The ArcChain passed in +// represents the complete chain from the root of the +// graph to this node, if it is known. +//////////////////////////////////////////////////////////////////// +void Node:: +draw_traverse(const ArcChain &) { +} + +//////////////////////////////////////////////////////////////////// +// Function: Node::dgraph_traverse +// Access: Public, Virtual +// Description: This hook function is called on each node visited +// during the data graph traversal. The ArcChain passed +// in represents the complete chain from the root of the +// graph to this node, if it is known. +//////////////////////////////////////////////////////////////////// +void Node:: +dgraph_traverse(const ArcChain &) { +} + //////////////////////////////////////////////////////////////////// // Function: Node::sub_render // Access: Public, Virtual diff --git a/panda/src/graph/node.h b/panda/src/graph/node.h index 8931e5dcd9..68be1ae66f 100644 --- a/panda/src/graph/node.h +++ b/panda/src/graph/node.h @@ -37,6 +37,7 @@ class BamWriter; class BamReader; class Datagram; class DatagramIterator; +class ArcChain; // This is the maximum number of graph types a node may simultaneously // exist in. @@ -83,9 +84,9 @@ PUBLISHED: public: // These functions will be called when the node is visited during // the indicated traversal. - virtual void app_traverse() { } - virtual void draw_traverse() { } - virtual void dgraph_traverse() { } + virtual void app_traverse(const ArcChain &chain); + virtual void draw_traverse(const ArcChain &chain); + virtual void dgraph_traverse(const ArcChain &chain); // This function is similar to another function in NodeTransition. // It may or may not intercept the render traversal. diff --git a/panda/src/parametrics/parametricCurve.cxx b/panda/src/parametrics/parametricCurve.cxx index 3aaf922eda..bb5ae22fa8 100644 --- a/panda/src/parametrics/parametricCurve.cxx +++ b/panda/src/parametrics/parametricCurve.cxx @@ -619,7 +619,7 @@ convert_to_nurbs(ParametricCurve *nc) const { // geometry is up-to-date. //////////////////////////////////////////////////////////////////// void ParametricCurve:: -draw_traverse() { +draw_traverse(const ArcChain &) { if (_implicit_drawer == (ParametricCurveDrawer *)NULL) { _implicit_drawer = new ParametricCurveDrawer(); _implicit_drawer->set_curve(this); diff --git a/panda/src/parametrics/parametricCurve.h b/panda/src/parametrics/parametricCurve.h index 8d9a01ec37..d9e919ebec 100644 --- a/panda/src/parametrics/parametricCurve.h +++ b/panda/src/parametrics/parametricCurve.h @@ -114,7 +114,7 @@ public: virtual bool convert_to_hermite(HermiteCurve *hc) const; virtual bool convert_to_nurbs(ParametricCurve *nc) const; - virtual void draw_traverse(); + virtual void draw_traverse(const ArcChain &chain); void register_drawer(ParametricCurveDrawer *drawer); void unregister_drawer(ParametricCurveDrawer *drawer); diff --git a/panda/src/pgui/pgTop.cxx b/panda/src/pgui/pgTop.cxx index 42825c6640..555788dc93 100644 --- a/panda/src/pgui/pgTop.cxx +++ b/panda/src/pgui/pgTop.cxx @@ -166,9 +166,9 @@ set_mouse_watcher(MouseWatcher *watcher) { void PGTop:: r_traverse(Node *node, const ArcChain &chain) { if (implicit_app_traversal) { - node->app_traverse(); + node->app_traverse(chain); } - node->draw_traverse(); + node->draw_traverse(chain); _gsg->_nodes_pcollector.add_level(1); diff --git a/panda/src/sgraphutil/appTraverser.cxx b/panda/src/sgraphutil/appTraverser.cxx index 8444345819..51dbba9454 100644 --- a/panda/src/sgraphutil/appTraverser.cxx +++ b/panda/src/sgraphutil/appTraverser.cxx @@ -41,7 +41,8 @@ traverse(Node *root) { //////////////////////////////////////////////////////////////////// bool AppTraverser:: reached_node(Node *node, NullAttributeWrapper &, NullLevelState &) { - node->app_traverse(); + ArcChain bogus; + node->app_traverse(bogus); return true; } diff --git a/panda/src/sgraphutil/directRenderTraverser.cxx b/panda/src/sgraphutil/directRenderTraverser.cxx index 902619b304..46ef1b7d2e 100644 --- a/panda/src/sgraphutil/directRenderTraverser.cxx +++ b/panda/src/sgraphutil/directRenderTraverser.cxx @@ -148,9 +148,9 @@ bool DirectRenderTraverser:: reached_node(Node *node, AllAttributesWrapper &render_state, DirectRenderLevelState &level_state) { if (implicit_app_traversal) { - node->app_traverse(); + node->app_traverse(_arc_chain); } - node->draw_traverse(); + node->draw_traverse(_arc_chain); level_state._decal_mode = false; diff --git a/panda/src/sgraphutil/get_rel_pos.I b/panda/src/sgraphutil/get_rel_pos.I index 72c57fd05c..199abab26c 100644 --- a/panda/src/sgraphutil/get_rel_pos.I +++ b/panda/src/sgraphutil/get_rel_pos.I @@ -16,52 +16,6 @@ // //////////////////////////////////////////////////////////////////// -#include -#include -#include - -//////////////////////////////////////////////////////////////////// -// Function: get_pos -// Description: Returns the position in space of the node's origin, -// relative to another node (such as render). -//////////////////////////////////////////////////////////////////// -INLINE LPoint3f -get_rel_pos(const Node *node, const Node *relative_to, - TypeHandle graph_type) { - NodeTransitionWrapper ntw(TransformTransition::get_class_type()); - wrt(node, relative_to, ntw, graph_type); - const TransformTransition *tt; - - if (!get_transition_into(tt, ntw)) { - // No relative transform. - return LPoint3f(0.0, 0.0, 0.0); - } - - LVector3f pos; - tt->get_matrix().get_row3(pos,3); - return pos; -} - -//////////////////////////////////////////////////////////////////// -// Function: get_mat -// Description: Returns the net transform of the node, relative to -// another node (such as render). -//////////////////////////////////////////////////////////////////// -INLINE void -get_rel_mat(const Node *node, const Node *relative_to, - LMatrix4f &mat, TypeHandle graph_type) { - NodeTransitionWrapper ntw(TransformTransition::get_class_type()); - wrt(node, relative_to, ntw, graph_type); - const TransformTransition *tt; - if (!get_transition_into(tt, ntw)) { - // No relative transform. - mat = LMatrix4f::ident_mat(); - return; - } - - mat = tt->get_matrix(); -} - //////////////////////////////////////////////////////////////////// // Function: get_up diff --git a/panda/src/sgraphutil/get_rel_pos.cxx b/panda/src/sgraphutil/get_rel_pos.cxx index 3ca30dafd6..5a5e7eecfb 100644 --- a/panda/src/sgraphutil/get_rel_pos.cxx +++ b/panda/src/sgraphutil/get_rel_pos.cxx @@ -18,9 +18,77 @@ #include "get_rel_pos.h" -#include -#include -#include +#include "transformTransition.h" +#include "nodeTransitionWrapper.h" +#include "wrt.h" +#include "arcChain.h" + +//////////////////////////////////////////////////////////////////// +// Function: get_rel_pos +// Description: Returns the position in space of the node's origin, +// relative to another node (such as render). +//////////////////////////////////////////////////////////////////// +LPoint3f +get_rel_pos(const Node *node, const Node *relative_to, + TypeHandle graph_type) { + NodeTransitionWrapper ntw(TransformTransition::get_class_type()); + wrt(node, relative_to, ntw, graph_type); + const TransformTransition *tt; + + if (!get_transition_into(tt, ntw)) { + // No relative transform. + return LPoint3f(0.0, 0.0, 0.0); + } + + LVector3f pos; + tt->get_matrix().get_row3(pos,3); + return pos; +} + +//////////////////////////////////////////////////////////////////// +// Function: get_rel_mat +// Description: Returns the net transform of the node, relative to +// another node (such as render). +//////////////////////////////////////////////////////////////////// +void +get_rel_mat(const Node *node, const Node *relative_to, + LMatrix4f &mat, TypeHandle graph_type) { + NodeTransitionWrapper ntw(TransformTransition::get_class_type()); + wrt(node, relative_to, ntw, graph_type); + const TransformTransition *tt; + if (!get_transition_into(tt, ntw)) { + // No relative transform. + mat = LMatrix4f::ident_mat(); + return; + } + + mat = tt->get_matrix(); +} + +//////////////////////////////////////////////////////////////////// +// Function: get_rel_mat +// Description: Returns the net transform of the node, relative to +// another node (such as render). This flavor of +// get_rel_mat() uses ArcChains to resolve ambiguities +// due to instancing. +//////////////////////////////////////////////////////////////////// +void +get_rel_mat(const Node *from, const ArcChain &from_arcs, + const Node *to, const ArcChain &to_arcs, + LMatrix4f &mat, TypeHandle graph_type) { + NodeTransitionWrapper ntw(TransformTransition::get_class_type()); + wrt(from, from_arcs.begin(), from_arcs.end(), + to, to_arcs.begin(), to_arcs.end(), + ntw, graph_type); + const TransformTransition *tt; + if (!get_transition_into(tt, ntw)) { + // No relative transform. + mat = LMatrix4f::ident_mat(); + return; + } + + mat = tt->get_matrix(); +} //////////////////////////////////////////////////////////////////// // Function: get_rot_mat diff --git a/panda/src/sgraphutil/get_rel_pos.h b/panda/src/sgraphutil/get_rel_pos.h index 76c15b52f3..dcb7672429 100644 --- a/panda/src/sgraphutil/get_rel_pos.h +++ b/panda/src/sgraphutil/get_rel_pos.h @@ -19,23 +19,30 @@ #ifndef GET_REL_POS_H #define GET_REL_POS_H -#include +#include "pandabase.h" + +#include "luse.h" +#include "lmatrix.h" +#include "coordinateSystem.h" +#include "renderRelation.h" -#include -#include -#include -#include class Node; +class ArcChain; -INLINE LPoint3f EXPCL_PANDA +LPoint3f EXPCL_PANDA get_rel_pos(const Node *node, const Node *relative_to, TypeHandle graph_type = RenderRelation::get_class_type()); -INLINE void EXPCL_PANDA +void EXPCL_PANDA get_rel_mat(const Node *node, const Node *relative_to, LMatrix4f &mat, TypeHandle graph_type = RenderRelation::get_class_type()); void EXPCL_PANDA +get_rel_mat(const Node *from, const ArcChain &from_arcs, + const Node *to, const ArcChain &to_arcs, + LMatrix4f &mat, + TypeHandle graph_type = RenderRelation::get_class_type()); +void EXPCL_PANDA get_rel_rot_mat(const Node *node, const Node *relative_to, LMatrix4f &mat, TypeHandle graph_type = RenderRelation::get_class_type()); diff --git a/panda/src/sgraphutil/quickRenderTraverser.cxx b/panda/src/sgraphutil/quickRenderTraverser.cxx index b4ae3a7a99..243799c45f 100644 --- a/panda/src/sgraphutil/quickRenderTraverser.cxx +++ b/panda/src/sgraphutil/quickRenderTraverser.cxx @@ -127,9 +127,9 @@ forward_arc(NodeRelation *arc, NullTransitionWrapper &, } if (implicit_app_traversal) { - node->app_traverse(); + node->app_traverse(_arc_chain); } - node->draw_traverse(); + node->draw_traverse(_arc_chain); // We have to get a new _now timestamp, just in case either of the // above traversals changed it. diff --git a/panda/src/switchnode/LODNode.cxx b/panda/src/switchnode/LODNode.cxx index edb3178a98..30ed3c8283 100644 --- a/panda/src/switchnode/LODNode.cxx +++ b/panda/src/switchnode/LODNode.cxx @@ -19,15 +19,17 @@ #include "projectionNode.h" #include "config_switchnode.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "graphicsStateGuardian.h" +#include "displayRegion.h" +#include "get_rel_pos.h" +#include "luse.h" +#include "renderRelation.h" +#include "transformTransition.h" +#include "allAttributesWrapper.h" +#include "allTransitionsWrapper.h" +#include "nodeTransitionWrapper.h" +#include "renderTraverser.h" +#include "wrt.h" //////////////////////////////////////////////////////////////////// // Static variables