add ArcChain to app_traverse(), etc.

This commit is contained in:
David Rose 2001-07-30 20:54:55 +00:00
parent b34f02a899
commit bdf804a6ac
18 changed files with 174 additions and 108 deletions

View File

@ -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);

View File

@ -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();

View File

@ -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);

View File

@ -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:

View File

@ -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.

View File

@ -18,32 +18,29 @@
#include "lensFlareNode.h"
#include "config_effects.h"
#include <sequenceNode.h>
#include <geomNode.h>
#include <geomSprite.h>
#include <textureTransition.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>
#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

View File

@ -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

View File

@ -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.

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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;

View File

@ -16,52 +16,6 @@
//
////////////////////////////////////////////////////////////////////
#include <transformTransition.h>
#include <nodeTransitionWrapper.h>
#include <wrt.h>
////////////////////////////////////////////////////////////////////
// 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

View File

@ -18,9 +18,77 @@
#include "get_rel_pos.h"
#include <transformTransition.h>
#include <nodeTransitionWrapper.h>
#include <wrt.h>
#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

View File

@ -19,23 +19,30 @@
#ifndef GET_REL_POS_H
#define GET_REL_POS_H
#include <pandabase.h>
#include "pandabase.h"
#include "luse.h"
#include "lmatrix.h"
#include "coordinateSystem.h"
#include "renderRelation.h"
#include <luse.h>
#include <lmatrix.h>
#include <coordinateSystem.h>
#include <renderRelation.h>
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());

View File

@ -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.

View File

@ -19,15 +19,17 @@
#include "projectionNode.h"
#include "config_switchnode.h"
#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 <renderTraverser.h>
#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