Parcourir la source

Armature Node handles array inputs

finishing the implementation I started in
    295ead344fe6196c129e13f52bb01d31d16dc638
except actually this may still be broken, so I'll probably follow it up
with a fix
Joseph Brandenburg il y a 1 mois
Parent
commit
5220714e33
3 fichiers modifiés avec 18 ajouts et 12 suppressions
  1. 2 2
      base_definitions.py
  2. 4 6
      link_nodes.py
  3. 12 4
      versioning.py

+ 2 - 2
base_definitions.py

@@ -942,9 +942,9 @@ class MantisNode:
         return
 
     # gets targets for constraints and deformers and should handle all cases
-    def get_target_and_subtarget(self, constraint_or_deformer, input_name = "Target"):
+    def get_target_and_subtarget(self, constraint_or_deformer, input_name = "Target", index = 0,):
         from bpy.types import PoseBone, Object, SplineIKConstraint
-        subtarget = ''; target = self.evaluate_input(input_name)
+        subtarget = ''; target = self.evaluate_input(input_name, index)
         if target:
             if not hasattr(target, "bGetObject"):
                 if hasattr(constraint_or_deformer, 'name'):

+ 4 - 6
link_nodes.py

@@ -807,7 +807,7 @@ class LinkArmature(MantisLinkNode):
                 c.name = constraint_name
             self.bObject.append(c)
             # get number of targets
-            num_targets = len( list(self.inputs.values())[6:] )//2
+            num_targets = len( self.inputs['Targets'].links )
 
             props_sockets = self.gen_property_socket_map()
             # TODO: currently this will only work if the constraint bones
@@ -817,14 +817,12 @@ class LinkArmature(MantisLinkNode):
             targets_weights = {}
             for i in range(num_targets):
                 target = c.targets.new()
-                target_input_name = list(self.inputs.keys())[i*2+6  ]
-                weight_input_name = list(self.inputs.keys())[i*2+6+1]
-                self.get_target_and_subtarget(target, target_input_name)
-                weight_value=self.evaluate_input(weight_input_name)
+                self.get_target_and_subtarget(target, 'Targets', i)
+                weight_value=self.evaluate_input("Weights", i)
                 if not isinstance(weight_value, float):
                     weight_value=0
                 targets_weights[i]=weight_value
-                props_sockets["targets[%d].weight" % i] = (weight_input_name, 0)
+                props_sockets["targets[%d].weight" % i] = ("Weights", i)
             evaluate_sockets(self, c, props_sockets)
             for target, value in targets_weights.items():
                 c.targets[target].weight=value

+ 12 - 4
versioning.py

@@ -361,16 +361,16 @@ def update_fcurve_and_armature_node_to_multi_socket(*args, **kwargs):
     node.id_data.do_live_update = False
     # First we have to get the socket maps and re-init the sockets
     from .utilities import get_socket_maps, do_relink
+    convert_keys = {'UtilityFCurve' : [ 'Keyframe', ],
+                    'LinkArmature'  : [ 'Target', 'Weight', ], }
+    my_convert_keys = convert_keys[node.bl_idname]
     sockets_in, _sockets_out = get_socket_maps(node,)
     node.inputs.clear()
     input_templates = [st for st in node.socket_templates if st.is_input == True]
     node.init_sockets(input_templates)
-    convert_keys = {'UtilityFCurve' : [ 'Keyframe', ],
-                    'LinkArmature'  : [ 'Target', 'Weight', ], }
     try:
         new_sockets_in = {}
-        print (convert_keys[node.bl_idname])
-        for convert_key in convert_keys[node.bl_idname]:
+        for convert_key in my_convert_keys:
             for socket_name, links in sockets_in.items():
                 if links is None: continue
                 if convert_key+'.' in socket_name:
@@ -383,6 +383,14 @@ def update_fcurve_and_armature_node_to_multi_socket(*args, **kwargs):
                         new_sockets_in[convert_key+'s'] = sockets_in[socket_name]
                     prWhite (new_sockets_in[convert_key+'s'])
             do_relink(node, node.inputs[convert_key+'s'], new_sockets_in, in_out="INPUT",)
+        for socket_name, links in sockets_in.items():
+            proceed = True
+            for convert_key in my_convert_keys:
+                if convert_key in socket_name:
+                    proceed = False
+            if proceed:
+                do_relink(node, node.inputs[socket_name], sockets_in, in_out='INPUT')
+
     finally:
         node.id_data.do_live_update = live_updates