Parcourir la source

fix Deform Bind when rig is posed

The mesh and surface deformers were getting messed up when
trying to bind the rig if the rig is posed
re-setting the rest/pose position is a fast and efficient solution
Joseph Brandenburg il y a 3 mois
Parent
commit
5ea2339bb3
2 fichiers modifiés avec 12 ajouts et 8 suppressions
  1. 0 2
      deformer_socket_templates.py
  2. 12 6
      readtree.py

+ 0 - 2
deformer_socket_templates.py

@@ -8,7 +8,6 @@ Target = SockTemplate(name="Target", bl_idname='xFormSocket',
         is_input=True,
     )
 
-
 HookSockets= [
     DeformerInput := SockTemplate(name="Deformer", bl_idname='DeformerSocket',
         is_input=True,),
@@ -26,7 +25,6 @@ HookSockets= [
         is_input=False,), 
 ]
 
-
 SurfaceDeformSockets= [
     DeformerInput,
     SurfaceDeformTarget := replace(Target, name="Target",),

+ 12 - 6
readtree.py

@@ -578,9 +578,6 @@ def execute_tree(nodes, base_tree, context, error_popups = False):
         
 
         switch_mode(mode='POSE', objects=switch_me)
-        if (active):
-            with context.temp_override(**{'active_object':active, 'selected_objects':switch_me}):
-                bpy.ops.object.mode_set(mode='POSE')
 
         for n in executed:
             try:
@@ -596,11 +593,13 @@ def execute_tree(nodes, base_tree, context, error_popups = False):
 
 
         switch_mode(mode='OBJECT', objects=switch_me)
-        for ob in switch_me:
-            ob.data.pose_position = 'POSE'
         # switch to pose mode here so that the nodes can use the final pose data
         # this will require them to update the depsgraph.
         
+
+        for ob in switch_me:
+            ob.data.pose_position = 'POSE'
+
         for n in executed:
             try:
                 n.bFinalize(context)
@@ -609,7 +608,12 @@ def execute_tree(nodes, base_tree, context, error_popups = False):
                 if error_popups == False:
                     raise e
                 execution_failed = True; break
-            
+        
+        
+        # REST pose for deformer bind, so everything is in the rest position
+        for ob in switch_me:
+            ob.data.pose_position = 'REST'
+
         # finally, apply modifiers and bind stuff
         for n in executed:
             try:
@@ -620,6 +624,8 @@ def execute_tree(nodes, base_tree, context, error_popups = False):
                     raise e
                 execution_failed = True; break
                 
+        for ob in switch_me:
+            ob.data.pose_position = 'POSE'
         
         tot_time = (time() - start_execution_time)
         if not execution_failed: