瀏覽代碼

define allow-unrelated-wrt

David Rose 22 年之前
父節點
當前提交
3112850acc
共有 3 個文件被更改,包括 37 次插入3 次删除
  1. 6 0
      panda/src/pgraph/config_pgraph.cxx
  2. 1 0
      panda/src/pgraph/config_pgraph.h
  3. 30 3
      panda/src/pgraph/nodePath.cxx

+ 6 - 0
panda/src/pgraph/config_pgraph.cxx

@@ -100,6 +100,12 @@ const bool fake_view_frustum_cull = config_pgraph.GetBool("fake-view-frustum-cul
 // trapped with assert-abort).
 const bool unambiguous_graph = config_pgraph.GetBool("unambiguous-graph", false);
 
+// Set this true to allow unrelated NodePaths (that is, nodes which
+// have no common ancestor) to be adjusted relative to each other.  If
+// true, these will be treated as if they had a common node above
+// their top nodes.
+const bool allow_unrelated_wrt = config_pgraph.GetBool("allow-unrelated-wrt", true);
+
 // Set this true to double-check the componentwise transform compose
 // (or invert) operation against the equivalent matrix-based
 // operation.  This has no effect if NDEBUG is defined.

+ 1 - 0
panda/src/pgraph/config_pgraph.h

@@ -31,6 +31,7 @@ NotifyCategoryDecl(loader, EXPCL_PANDA, EXPTP_PANDA);
 
 extern const bool fake_view_frustum_cull;
 extern const bool unambiguous_graph;
+extern const bool allow_unrelated_wrt;
 extern const bool paranoid_compose;
 extern const bool compose_componentwise;
 

+ 30 - 3
panda/src/pgraph/nodePath.cxx

@@ -562,7 +562,16 @@ get_state(const NodePath &other) const {
   nassertr(other.verify_complete(), RenderState::make_empty());
 
   int a_count, b_count;
-  find_common_ancestor(*this, other, a_count, b_count);
+  if (find_common_ancestor(*this, other, a_count, b_count) == (NodePathComponent *)NULL) {
+    if (allow_unrelated_wrt) {
+      pgraph_cat.debug()
+        << *this << " is not related to " << other << "\n";
+    } else {
+      pgraph_cat.error()
+        << *this << " is not related to " << other << "\n";
+      nassertr(false, RenderState::make_empty());
+    }
+  }
 
   CPT(RenderState) a_state = r_get_partial_state(_head, a_count);
   CPT(RenderState) b_state = r_get_partial_state(other._head, b_count);
@@ -610,7 +619,16 @@ get_transform(const NodePath &other) const {
   nassertr(other.verify_complete(), TransformState::make_identity());
 
   int a_count, b_count;
-  find_common_ancestor(*this, other, a_count, b_count);
+  if (find_common_ancestor(*this, other, a_count, b_count) == (NodePathComponent *)NULL) {
+    if (allow_unrelated_wrt) {
+      pgraph_cat.debug()
+        << *this << " is not related to " << other << "\n";
+    } else {
+      pgraph_cat.error()
+        << *this << " is not related to " << other << "\n";
+      nassertr(false, TransformState::make_identity());
+    }
+  }
 
   CPT(TransformState) a_transform = r_get_partial_transform(_head, a_count);
   CPT(TransformState) b_transform = r_get_partial_transform(other._head, b_count);
@@ -663,7 +681,16 @@ get_prev_transform(const NodePath &other) const {
   nassertr(other.verify_complete(), TransformState::make_identity());
 
   int a_count, b_count;
-  find_common_ancestor(*this, other, a_count, b_count);
+  if (find_common_ancestor(*this, other, a_count, b_count) == (NodePathComponent *)NULL) {
+    if (allow_unrelated_wrt) {
+      pgraph_cat.debug()
+        << *this << " is not related to " << other << "\n";
+    } else {
+      pgraph_cat.error()
+        << *this << " is not related to " << other << "\n";
+      nassertr(false, TransformState::make_identity());
+    }
+  }
 
   CPT(TransformState) a_prev_transform = r_get_partial_prev_transform(_head, a_count);
   CPT(TransformState) b_prev_transform = r_get_partial_prev_transform(other._head, b_count);