Эх сурвалжийг харах

force a transform clear after an armature action being exporter

Jason0214 6 жил өмнө
parent
commit
4dfff1b89c

+ 15 - 0
io_scene_godot/converters/animation/animation_data.py

@@ -2,6 +2,8 @@
 AnimationPlayer as well as distribute Blender action into various
 action exporting functions"""
 
+import bpy
+import mathutils
 from .action import (
     export_camera_action,
     export_shapekey_action,
@@ -94,6 +96,7 @@ class ObjectAnimationExporter:
             ActionStrip(active_action),
             self.animation_player.active_animation
         )
+        self.clear_action_effect()
 
         if not self.need_baking:
             # here export unmuted nla_tracks into animation resource,
@@ -109,6 +112,7 @@ class ObjectAnimationExporter:
                             ActionStrip(strip),
                             self.animation_player.active_animation
                         )
+                        self.clear_action_effect()
 
     def export_active_action_from_nla(self, escn_file, export_settings):
         """Export all unmute nla_tracks into an active action.
@@ -128,6 +132,7 @@ class ObjectAnimationExporter:
                         ActionStrip(strip),
                         self.animation_player.active_animation
                     )
+                    self.clear_action_effect()
 
     def export_stashed_track(self, escn_file, export_settings, stashed_track):
         """Export a muted nla_track, track with all its contained action
@@ -160,6 +165,7 @@ class ObjectAnimationExporter:
                     ActionStrip(strip),
                     anim_resource
                 )
+                self.clear_action_effect()
 
         if self.need_baking:
             stashed_track.mute = True
@@ -175,6 +181,15 @@ class ObjectAnimationExporter:
                             ActionStrip(strip),
                             anim_resource
                         )
+                        self.clear_action_effect()
+
+    def clear_action_effect(self):
+        """Clear side effect of exporting an action"""
+        if (isinstance(self.blender_object, bpy.types.Object) and
+                self.blender_object.pose is not None):
+            for pose_bone in self.blender_object.pose.bones:
+                rest_bone = pose_bone.bone
+                pose_bone.matrix_basis = mathutils.Matrix.Identity(4)
 
 
 def export_animation_data(escn_file, export_settings, godot_node,

+ 1 - 1
tests/reference_exports/action_with_constraint/constraint_with_undeform_bone.escn

@@ -59,7 +59,7 @@ bones/0/bound_children = []
 bones/1/name = "Bone.002"
 bones/1/parent = -1
 bones/1/rest = Transform(-0.454064, -0.868627, -0.198275, -0.0311123, 0.23786, -0.970801, 0.890426, -0.434637, -0.135029, 0.00854362, 2.58513, -0.0545189)
-bones/1/pose = Transform(0.999995, 0.00328448, 0.000475731, -0.00328036, 0.999959, -0.00841181, -0.00050334, 0.0084102, 0.999965, 0.0, 0.0, 0.0)
+bones/1/pose = Transform(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0)
 bones/1/enabled = true
 bones/1/bound_children = []