Răsfoiți Sursa

*** empty log message ***

David Rose 24 ani în urmă
părinte
comite
4c301e522b

+ 2 - 2
panda/src/graph/allTransitionsWrapper.I

@@ -216,10 +216,10 @@ compare_to(const AllTransitionsWrapper &other) const {
     return 0;
     return 0;
   }
   }
   if (_cache == (NodeTransitionCache *)NULL) {
   if (_cache == (NodeTransitionCache *)NULL) {
-    return -1;
+    return other._cache->is_identity() ? 0 : -1;
   }
   }
   if (other._cache == (NodeTransitionCache *)NULL) {
   if (other._cache == (NodeTransitionCache *)NULL) {
-    return 1;
+    return _cache->is_identity() ? 0 : 1;
   }
   }
 
 
   return _cache->compare_to(*other._cache);
   return _cache->compare_to(*other._cache);

+ 6 - 4
panda/src/graph/nodeTransitionCache.cxx

@@ -8,6 +8,8 @@
 #include "config_graph.h"
 #include "config_graph.h"
 #include "setTransitionHelpers.h"
 #include "setTransitionHelpers.h"
 
 
+#include <indent.h>
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: NodeTransitionCache::Constructor
 //     Function: NodeTransitionCache::Constructor
 //       Access: Public
 //       Access: Public
@@ -73,9 +75,8 @@ is_identity() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 int NodeTransitionCache::
 int NodeTransitionCache::
 compare_to(const NodeTransitionCache &other) const {
 compare_to(const NodeTransitionCache &other) const {
-   int result = tmap_compare_cache(_cache.begin(), _cache.end(),
-				   other._cache.begin(), other._cache.end());
-   return result;
+   return tmap_compare_cache(_cache.begin(), _cache.end(),
+			     other._cache.begin(), other._cache.end());
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -496,6 +497,7 @@ void NodeTransitionCache::
 write(ostream &out, int indent_level) const {
 write(ostream &out, int indent_level) const {
   Cache::const_iterator ci;
   Cache::const_iterator ci;
   for (ci = _cache.begin(); ci != _cache.end(); ++ci) {
   for (ci = _cache.begin(); ci != _cache.end(); ++ci) {
-    (*ci).second.write(out, indent_level);
+    indent(out, indent_level) << (*ci).first << "\n";
+    (*ci).second.write(out, indent_level + 2);
   }
   }
 }
 }

+ 20 - 21
panda/src/graph/wrt.I

@@ -17,18 +17,19 @@ describe_ambiguous_wrt(const Node *node,
 		       InputIterator arc_list_end,
 		       InputIterator arc_list_end,
 		       TypeHandle graph_type) {
 		       TypeHandle graph_type) {
   if (wrt_cat.is_warning()) {
   if (wrt_cat.is_warning()) {
-    int num_parents = node->get_num_parents(graph_type);
+    const UpRelationPointers &urp = node->find_connection(graph_type).get_up();
+    int num_parents = urp.size();
     wrt_cat.warning()
     wrt_cat.warning()
       << *node << " has " << num_parents << " parents; wrt() ambiguous.\n"
       << *node << " has " << num_parents << " parents; wrt() ambiguous.\n"
       << "  parents are: ";
       << "  parents are: ";
     nassertv(num_parents > 1);
     nassertv(num_parents > 1);
 
 
-    NodeRelation *parent_arc = node->get_parent(graph_type, 0);
+    NodeRelation *parent_arc = urp[0];
     wrt_cat.warning(false) << *parent_arc->get_parent();
     wrt_cat.warning(false) << *parent_arc->get_parent();
     for (int i = 1; i < num_parents; i++) {
     for (int i = 1; i < num_parents; i++) {
-      parent_arc = node->get_parent(graph_type, 0);
+      parent_arc = urp[i];
       wrt_cat.warning(false) 
       wrt_cat.warning(false) 
-	<< ", " << *node->get_parent(graph_type, i)->get_parent();
+	<< ", " << *parent_arc->get_parent();
     }
     }
     wrt_cat.warning(false) << "\n";
     wrt_cat.warning(false) << "\n";
     
     
@@ -131,7 +132,8 @@ get_cached_net_transition(NodeRelation *arc, Node *&root,
     // Get the node above the arc.
     // Get the node above the arc.
     Node *node = arc->get_parent();
     Node *node = arc->get_parent();
 
 
-    int num_parents = node->get_num_parents(graph_type);
+    const UpRelationPointers &urp = node->find_connection(graph_type).get_up();
+    int num_parents = urp.size();
 
 
     if (num_parents != 1) {
     if (num_parents != 1) {
       // The node has zero or multiple parents.  It's thus either the
       // The node has zero or multiple parents.  It's thus either the
@@ -155,7 +157,7 @@ get_cached_net_transition(NodeRelation *arc, Node *&root,
     } else {
     } else {
       // The node has exactly one parent.  Carry on.
       // The node has exactly one parent.  Carry on.
 
 
-      NodeRelation *parent_arc = node->get_parent(graph_type, 0);
+      NodeRelation *parent_arc = urp[0];
       get_cached_net_transition(parent_arc, root, as_of, now, net, graph_type);
       get_cached_net_transition(parent_arc, root, as_of, now, net, graph_type);
 
 
       // Now recompute our own cache.
       // Now recompute our own cache.
@@ -223,14 +225,15 @@ get_cached_net_transition(const Node *node,
     return;
     return;
   }
   }
 
 
-  int num_parents = node->get_num_parents(graph_type);
+  const UpRelationPointers &urp = node->find_connection(graph_type).get_up();
+  int num_parents = urp.size();
 
 
   const NodeRelation *parent_arc = (const NodeRelation *)NULL;
   const NodeRelation *parent_arc = (const NodeRelation *)NULL;
 
 
   if (num_parents == 1) {
   if (num_parents == 1) {
     // There is only one parent, so there's no doubt as to which arc
     // There is only one parent, so there's no doubt as to which arc
     // to choose.
     // to choose.
-    parent_arc = node->get_parent(graph_type, 0);
+    parent_arc = urp[0];
 
 
   } else if (num_parents == 0) {
   } else if (num_parents == 0) {
     // This node has no parents.  Stop here.
     // This node has no parents.  Stop here.
@@ -262,7 +265,7 @@ get_cached_net_transition(const Node *node,
       // one.
       // one.
       describe_ambiguous_wrt(node, arc_list_begin, arc_list_end, graph_type);
       describe_ambiguous_wrt(node, arc_list_begin, arc_list_end, graph_type);
 #endif
 #endif
-      parent_arc = node->get_parent(graph_type, 0);
+      parent_arc = urp[0];
     }
     }
   }
   }
 
 
@@ -317,14 +320,15 @@ get_uncached_net_transition(const Node *node,
     return;
     return;
   }
   }
 
 
-  int num_parents = node->get_num_parents(graph_type);
+  const UpRelationPointers &urp = node->find_connection(graph_type).get_up();
+  int num_parents = urp.size();
 
 
   const NodeRelation *parent_arc = (const NodeRelation *)NULL;
   const NodeRelation *parent_arc = (const NodeRelation *)NULL;
 
 
   if (num_parents == 1) {
   if (num_parents == 1) {
     // There is only one parent, so there's no doubt as to which arc
     // There is only one parent, so there's no doubt as to which arc
     // to choose.
     // to choose.
-    parent_arc = node->get_parent(graph_type, 0);
+    parent_arc = urp[0];
 
 
   } else if (num_parents == 0) {
   } else if (num_parents == 0) {
     // This node has no parents.  Stop here.
     // This node has no parents.  Stop here.
@@ -353,7 +357,7 @@ get_uncached_net_transition(const Node *node,
       // one. 
       // one. 
       describe_ambiguous_wrt(node, arc_list_begin, arc_list_end, graph_type);
       describe_ambiguous_wrt(node, arc_list_begin, arc_list_end, graph_type);
 #endif
 #endif
-      parent_arc = node->get_parent(graph_type, 0);
+      parent_arc = urp[0];
     }
     }
   }
   }
 
 
@@ -620,7 +624,8 @@ get_uncached_wrt_subtree(Node *node, Node *to, TransitionWrapper &result,
 			 TypeHandle graph_type) {
 			 TypeHandle graph_type) {
   nassertr(node != (Node *)NULL, to);
   nassertr(node != (Node *)NULL, to);
 
 
-  int num_parents = node->get_num_parents(graph_type);
+  const UpRelationPointers &urp = node->find_connection(graph_type).get_up();
+  int num_parents = urp.size();
 
 
   if (num_parents == 0) {
   if (num_parents == 0) {
     // This node has no parents.  Stop here.
     // This node has no parents.  Stop here.
@@ -654,7 +659,7 @@ get_uncached_wrt_subtree(Node *node, Node *to, TransitionWrapper &result,
     // Actually, we do need to keep walking up till we find the actual
     // Actually, we do need to keep walking up till we find the actual
     // top of the instanced subtree, so we can return the correct
     // top of the instanced subtree, so we can return the correct
     // pointer.
     // pointer.
-    int num_parents = node->get_num_parents(graph_type);
+    num_parents = node->get_num_parents(graph_type);
     while (num_parents == 1) {
     while (num_parents == 1) {
       node = node->get_parent(graph_type, 0)->get_parent();
       node = node->get_parent(graph_type, 0)->get_parent();
       num_parents = node->get_num_parents(graph_type);
       num_parents = node->get_num_parents(graph_type);
@@ -667,7 +672,7 @@ get_uncached_wrt_subtree(Node *node, Node *to, TransitionWrapper &result,
     }
     }
   }
   }
 
 
-  const NodeRelation *parent_arc = node->get_parent(graph_type, 0);
+  const NodeRelation *parent_arc = urp[0];
 
 
   Node *stop = 
   Node *stop = 
     get_uncached_wrt_subtree(parent_arc->get_parent(), to,
     get_uncached_wrt_subtree(parent_arc->get_parent(), to,
@@ -875,12 +880,6 @@ cached_wrt_subtree(NodeRelation *arc, Node *to, UpdateSeq as_of, UpdateSeq now,
 	<< "  should be:\n";
 	<< "  should be:\n";
       check_trans.write(wrt_cat.warning(false), 4);
       check_trans.write(wrt_cat.warning(false), 4);
       result = check_trans;
       result = check_trans;
-
-      /*
-      cerr << "Begin recheck.\n";
-      int num = check_trans.compare_to(result);
-      cerr << "Done recheck, result = " << num << "\n";
-      */
     }
     }
   }
   }
 #endif
 #endif