Browse Source

Fix Schema Nodes culling nodes of same-name schema with a more robust signature check

Joseph Brandenburg 9 months ago
parent
commit
e4f5152b27
1 changed files with 14 additions and 1 deletions
  1. 14 1
      readtree.py

+ 14 - 1
readtree.py

@@ -232,6 +232,18 @@ def delete_nc(nc):
             if l is not None:
                 l.__del__()
 
+def is_signature_in_other_signature(sig_a, sig_b):
+    # this is the easiest but not the best way to do this:
+    # this function is hideous but it does not seem to have any significant effect on timing
+    #    tested it with profiling on a full character rig.
+    sig_a = list(sig_a)
+    sig_a = ['MANTIS_NONE' if val is None else val for val in sig_a]
+    sig_b = list(sig_b)
+    sig_b = ['MANTIS_NONE' if val is None else val for val in sig_b]
+    string_a = "".join(sig_a)
+    string_b = "".join(sig_b)
+    return string_a in string_b
+
 def solve_schema_to_tree(nc, all_nc, roots=[]):
     from .utilities import get_node_prototype
     np = get_node_prototype(nc.signature, nc.base_tree)
@@ -255,7 +267,8 @@ def solve_schema_to_tree(nc, all_nc, roots=[]):
     del_me = []
     for k, v in all_nc.items():
         # delete all the schema's internal nodes. The links have already been deleted by the solver.
-        if v.signature[0] not in ['MANTIS_AUTOGENERATED'] and nc.signature[-1] in k:
+        if v.signature[0] not in ['MANTIS_AUTOGENERATED'] and is_signature_in_other_signature(nc.signature, k):
+            print (wrapOrange("Culling: ")+wrapRed(v))
             delete_nc(v)
             del_me.append(k)
     for k in del_me: