Explorar o código

Fix Copy Weights in Armature Deformer

fixed the copy-weights feature not initializing the vertex groups, fixed the unnecesary error when there was no object to copy from and replaced it with a warning message, improved display update code.
Note: I may have Armature Deform (Copy Weights) apply the Data Transfer modifier and do some smart stuff about sampling topology  or UVs or something. This is not adressed here and is left for the future.
Joseph Brandenburg hai 9 meses
pai
achega
ee7c1c9c0f
Modificáronse 2 ficheiros con 9 adicións e 4 borrados
  1. 7 2
      deformer_containers.py
  2. 2 2
      deformer_definitions.py

+ 7 - 2
deformer_containers.py

@@ -135,7 +135,11 @@ class DeformerArmature:
         # we'll use modifiers for this, maybe use GN for it in the future tho
         import bpy
         ob = self.GetxForm().bGetObject()
-        copy_from = self.GetxForm(socket="Copy Skin Weights From")
+        try:
+            copy_from = self.GetxForm(socket="Copy Skin Weights From")
+        except GraphError:
+            copy_from = None
+            prRed(f"No object found for copying weights in {self}, continuing anyway.")
         m = ob.modifiers.new(type="DATA_TRANSFER", name="Mantis_temp_data_transfer")
         m.object = None; m.use_vert_data = True
         m.data_types_verts = {'VGROUP_WEIGHTS'}
@@ -143,6 +147,7 @@ class DeformerArmature:
         m.layers_vgroup_select_src = 'ALL'
         m.layers_vgroup_select_dst = 'NAME'
         m.object = copy_from
+        m.use_object_transform = False
         ob.modifiers.move(len(ob.modifiers)-1, 0)
 
         # ob.data = ob.data.copy()
@@ -218,8 +223,8 @@ class DeformerArmature:
         elif skin_method == "EXISTING_GROUPS":
             pass
         elif skin_method == "COPY_FROM_OBJECT":
+            self.initialize_vgroups()
             self.copy_weights()
-            # self.initialize_vgroups(use_existing = True)
 
 
 class DeformerMorphTarget:

+ 2 - 2
deformer_definitions.py

@@ -302,8 +302,8 @@ class DeformerArmatureNode(Node, DeformerNode):
         node_tree = context.space_data.path[0].node_tree
         nc = parsed_tree.get(get_signature_from_edited_tree(self, context))
         if nc:
-            if nc.evaluate_input("Skinning Method") == "COPY_FROM_OBJECT":
-                self.inputs["Copy Skin Weights From"].hide = False
+            self.inputs["Copy Skin Weights From"].hide = not (nc.evaluate_input("Skinning Method") == "COPY_FROM_OBJECT")
+                
 
 from .utilities import get_socket_maps, relink_socket_map