From aacd1fe81ab701908b3ca42522891f202ef7ddb1 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 18 Jul 2001 02:46:06 +0000 Subject: [PATCH] *** empty log message *** --- panda/src/sgmanip/nodePath.I | 28 +++++++++++++++------------- panda/src/sgmanip/nodePath.cxx | 34 ++++++++++++++++++++++++++++++++-- panda/src/sgmanip/nodePath.h | 3 ++- 3 files changed, 49 insertions(+), 16 deletions(-) diff --git a/panda/src/sgmanip/nodePath.I b/panda/src/sgmanip/nodePath.I index d963b0c339..d229c6d2a7 100644 --- a/panda/src/sgmanip/nodePath.I +++ b/panda/src/sgmanip/nodePath.I @@ -428,22 +428,24 @@ ls(ostream &out, int indent_level) const { //////////////////////////////////////////////////////////////////// INLINE void NodePath:: ls_transitions() const { - ls_transitions(nout); -} - -//////////////////////////////////////////////////////////////////// -// Function: NodePath::ls_transitions -// Access: Published -// Description: Lists all the nodes at and below the current path -// hierarchically, along with all the transitions on the -// arcs between them. -//////////////////////////////////////////////////////////////////// -INLINE void NodePath:: -ls_transitions(ostream &out, int indent_level) const { nassertv(verify_connectivity()); nassertv(!is_empty()); - r_list_transitions(out, indent_level); + r_list_transitions(nout, 0); +} + +//////////////////////////////////////////////////////////////////// +// Function: NodePath::ls_transforms +// Access: Published +// Description: Lists only the nodes at and below this path that have +// transform matrices set, and the matrices they have. +//////////////////////////////////////////////////////////////////// +INLINE void NodePath:: +ls_transforms() const { + nassertv(verify_connectivity()); + nassertv(!is_empty()); + + r_list_transforms(nout, 0); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/sgmanip/nodePath.cxx b/panda/src/sgmanip/nodePath.cxx index b797376125..ed9b815807 100644 --- a/panda/src/sgmanip/nodePath.cxx +++ b/panda/src/sgmanip/nodePath.cxx @@ -392,9 +392,13 @@ find_singular_transform() const { nassertr(!is_empty(), NodePath::fail()); if (has_mat()) { - LMatrix4f mat; - if (!mat.invert_from(get_mat())) { + LMatrix4f mat = get_mat(); + LMatrix4f inv_mat; + bool ok = inv_mat.invert_from(mat); + if (!ok) { // Here's a singular matrix! + sgmanip_cat.info() + << "Singular transform at: " << *this << "\n"; return *this; } } @@ -3132,6 +3136,32 @@ r_list_transitions(ostream &out, int indent_level) const { } } +//////////////////////////////////////////////////////////////////// +// Function: NodePath::r_list_transforms +// Access: Private +// Description: The recursive implementation of ls_transforms(). +//////////////////////////////////////////////////////////////////// +void NodePath:: +r_list_transforms(ostream &out, int indent_level) const { + if (has_mat()) { + indent(out, indent_level) << *this << ":\n"; + get_mat().write(out, indent_level + 2); + indent_level += 4; + } + + Node *bottom_node = node(); + nassertv(bottom_node != (Node *)NULL); + + int num_children = bottom_node->get_num_children(_graph_type); + for (int i = 0; i < num_children; i++) { + NodeRelation *child_arc = bottom_node->get_child(_graph_type, i); + NodePath next(*this); + next.extend_by(child_arc); + + next.r_list_transforms(out, indent_level); + } +} + //////////////////////////////////////////////////////////////////// // Function: NodePath::r_adjust_all_priorities // Access: Private diff --git a/panda/src/sgmanip/nodePath.h b/panda/src/sgmanip/nodePath.h index f2957d281a..df2b7570bb 100644 --- a/panda/src/sgmanip/nodePath.h +++ b/panda/src/sgmanip/nodePath.h @@ -248,7 +248,7 @@ PUBLISHED: INLINE void ls() const; INLINE void ls(ostream &out, int indent_level = 0) const; INLINE void ls_transitions() const; - INLINE void ls_transitions(ostream &out, int indent_level = 0) const; + INLINE void ls_transforms() const; void analyze() const; int flatten_light(); @@ -541,6 +541,7 @@ private: void r_list_descendants(ostream &out, int indent_level) const; void r_list_transitions(ostream &out, int indent_level) const; + void r_list_transforms(ostream &out, int indent_level) const; void r_adjust_all_priorities(NodeRelation *arc, int adjustment); void r_clear_wrt_cache(NodeRelation *arc);