瀏覽代碼

*** empty log message ***

David Rose 24 年之前
父節點
當前提交
aacd1fe81a
共有 3 個文件被更改,包括 43 次插入10 次删除
  1. 9 7
      panda/src/sgmanip/nodePath.I
  2. 32 2
      panda/src/sgmanip/nodePath.cxx
  3. 2 1
      panda/src/sgmanip/nodePath.h

+ 9 - 7
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);
+  nassertv(verify_connectivity());
+  nassertv(!is_empty());
+
+  r_list_transitions(nout, 0);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: NodePath::ls_transitions
+//     Function: NodePath::ls_transforms
 //       Access: Published
-//  Description: Lists all the nodes at and below the current path
-//               hierarchically, along with all the transitions on the
-//               arcs between them.
+//  Description: Lists only the nodes at and below this path that have
+//               transform matrices set, and the matrices they have.
 ////////////////////////////////////////////////////////////////////
 INLINE void NodePath::
-ls_transitions(ostream &out, int indent_level) const {
+ls_transforms() const {
   nassertv(verify_connectivity());
   nassertv(!is_empty());
 
-  r_list_transitions(out, indent_level);
+  r_list_transforms(nout, 0);
 }
 
 ////////////////////////////////////////////////////////////////////

+ 32 - 2
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

+ 2 - 1
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);