ソースを参照

fix animation length

Jason0214 6 年 前
コミット
f48b10c8b9
21 ファイル変更31 行追加35 行削除
  1. 6 10
      io_scene_godot/converters/animation/serializer.py
  2. 1 1
      tests/reference_exports/action_animation/animation_bone_transform.escn
  3. 1 1
      tests/reference_exports/action_animation/animation_object_transform.escn
  4. 1 1
      tests/reference_exports/action_animation/animation_rotation_euler.escn
  5. 2 2
      tests/reference_exports/action_animation/animation_shared_action.escn
  6. 1 1
      tests/reference_exports/action_animation/physics_animation.escn
  7. 1 1
      tests/reference_exports/action_with_constraint/bone_attachment_ik.escn
  8. 2 2
      tests/reference_exports/action_with_constraint/constraint_external_IK.escn
  9. 1 1
      tests/reference_exports/action_with_constraint/constraint_internal_IK.escn
  10. 1 1
      tests/reference_exports/action_with_constraint/stashed_constraint.escn
  11. 1 1
      tests/reference_exports/armature/armature_illegal_bone_name.escn
  12. 2 2
      tests/reference_exports/armature/armature_with_non_deform_bone.escn
  13. 1 1
      tests/reference_exports/camera/animation_camera.escn
  14. 1 1
      tests/reference_exports/nla_animation/animation_multi_strip.escn
  15. 1 1
      tests/reference_exports/nla_animation/animation_with_empty_strip.escn
  16. 1 1
      tests/reference_exports/nla_animation/nla_with_active_action.escn
  17. 1 1
      tests/reference_exports/nla_animation/nla_with_no_active_action.escn
  18. 2 2
      tests/reference_exports/nla_animation/nla_with_stashed_action.escn
  19. 1 1
      tests/reference_exports/scene_animation/animation_parented_objects.escn
  20. 1 1
      tests/reference_exports/shape_key/animation_shapekey.escn
  21. 2 2
      tests/reference_exports/shape_key/animation_shapekey_with_transform.escn

+ 6 - 10
io_scene_godot/converters/animation/serializer.py

@@ -287,6 +287,7 @@ class TransformTrack(Track):
             values = self.values
 
         for frame, trans_frame in zip(frames, values):
+            # move animation first frame to scene.frame_start
             if frame < scene_frame_start:
                 continue
 
@@ -346,7 +347,6 @@ class ValueTrack(Track):
 
         for frame, frame_val in zip(frames, values):
             # move animation first frame to scene.frame_start
-            # and cut off frames exceed scene.frame_end
             if frame < scene_frame_start:
                 continue
 
@@ -434,21 +434,17 @@ class AnimationResource(InternalResource):
     def add_track(self, track):
         """add a track to animation resource"""
         node_path_str = track.path.to_string()
+        track_length = (
+            track.frame_end() - bpy.context.scene.frame_start) / self.fps
+        if track_length > self['length']:
+            self['length'] = track_length
+
         if node_path_str in self.tracks:
             updated_track = self.tracks[node_path_str]
             updated_track.blend(track)
-            track_length = updated_track.frame_end() / self.fps
-            if track_length > self['length']:
-                self['length'] = track_length
         else:
             track_id_str = 'tracks/{}'.format(len(self.tracks))
             self.tracks[node_path_str] = track
-            updated_track = track
-
-            track_length = track.frame_end() / self.fps
-            if track_length > self['length']:
-                self['length'] = track_length
-
             self[track_id_str + '/type'] = '"{}"'.format(track.type)
             self[track_id_str + '/path'] = node_path_str
             self[track_id_str + '/interp'] = track.interp

+ 1 - 1
tests/reference_exports/action_animation/animation_bone_transform.escn

@@ -4,7 +4,7 @@
 
 resource_name = "ArmatureAction001"
 step = 0.1
-length = 3.33333
+length = 3.29167
 tracks/0/type = "transform"
 tracks/0/path = NodePath(".:Bone.002")
 tracks/0/interp = 1

+ 1 - 1
tests/reference_exports/action_animation/animation_object_transform.escn

@@ -23,7 +23,7 @@ surfaces/0 = {
 
 resource_name = "CubeAction"
 step = 0.1
-length = 6.0
+length = 5.95833
 tracks/0/type = "transform"
 tracks/0/path = NodePath(".:")
 tracks/0/interp = 1

+ 1 - 1
tests/reference_exports/action_animation/animation_rotation_euler.escn

@@ -23,7 +23,7 @@ surfaces/0 = {
 
 resource_name = "CubeAction"
 step = 0.1
-length = 7.08333
+length = 7.04167
 tracks/0/type = "transform"
 tracks/0/path = NodePath(".:")
 tracks/0/interp = 1

+ 2 - 2
tests/reference_exports/action_animation/animation_shared_action.escn

@@ -23,7 +23,7 @@ surfaces/0 = {
 
 resource_name = "Cube001Action"
 step = 0.1
-length = 0.833333
+length = 0.791667
 tracks/0/type = "transform"
 tracks/0/path = NodePath(".:")
 tracks/0/interp = 1
@@ -52,7 +52,7 @@ surfaces/0 = {
 
 resource_name = "Cube001Action"
 step = 0.1
-length = 0.833333
+length = 0.791667
 tracks/0/type = "transform"
 tracks/0/path = NodePath(".:")
 tracks/0/interp = 1

+ 1 - 1
tests/reference_exports/action_animation/physics_animation.escn

@@ -33,7 +33,7 @@ points = PoolVector3Array(1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, -1.0
 
 resource_name = "Cube003Action001"
 step = 0.1
-length = 1.04167
+length = 1.0
 tracks/0/type = "transform"
 tracks/0/path = NodePath(".:")
 tracks/0/interp = 1

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

@@ -4,7 +4,7 @@
 
 resource_name = "ArmatureAction"
 step = 0.1
-length = 2.5
+length = 2.45833
 tracks/0/type = "transform"
 tracks/0/path = NodePath(".:Bone")
 tracks/0/interp = 1

+ 2 - 2
tests/reference_exports/action_with_constraint/constraint_external_IK.escn

@@ -4,7 +4,7 @@
 
 resource_name = "EmptyAction001"
 step = 0.1
-length = 3.79167
+length = 3.75
 tracks/0/type = "transform"
 tracks/0/path = NodePath(".:")
 tracks/0/interp = 1
@@ -14,7 +14,7 @@ tracks/0/keys = [0.291667, 1.0, 0.0191494, 2.43195, 0.42693, 0.0, 0.0, 0.0, 1.0,
 
 resource_name = "ArmatureAction"
 step = 0.1
-length = 10.4167
+length = 10.375
 tracks/0/type = "transform"
 tracks/0/path = NodePath(".:Bone.001")
 tracks/0/interp = 1

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

@@ -4,7 +4,7 @@
 
 resource_name = "ArmatureAction"
 step = 0.1
-length = 2.5
+length = 2.45833
 tracks/0/type = "transform"
 tracks/0/path = NodePath(".:Bone")
 tracks/0/interp = 1

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

@@ -4,7 +4,7 @@
 
 resource_name = "ArmatureAction001"
 step = 0.1
-length = 10.4167
+length = 10.375
 tracks/0/type = "transform"
 tracks/0/path = NodePath(".:Bone")
 tracks/0/interp = 1

+ 1 - 1
tests/reference_exports/armature/armature_illegal_bone_name.escn

@@ -4,7 +4,7 @@
 
 resource_name = "ArmatureAction"
 step = 0.1
-length = 2.5
+length = 2.45833
 tracks/0/type = "transform"
 tracks/0/path = NodePath(".:bone")
 tracks/0/interp = 1

+ 2 - 2
tests/reference_exports/armature/armature_with_non_deform_bone.escn

@@ -4,7 +4,7 @@
 
 resource_name = "Armature001Action"
 step = 0.1
-length = 4.16667
+length = 4.125
 tracks/0/type = "transform"
 tracks/0/path = NodePath(".:Bone.003")
 tracks/0/interp = 1
@@ -41,7 +41,7 @@ surfaces/0 = {
 
 resource_name = "ArmatureAction"
 step = 0.1
-length = 4.20833
+length = 4.16667
 tracks/0/type = "transform"
 tracks/0/path = NodePath(".:Bone.001")
 tracks/0/interp = 1

+ 1 - 1
tests/reference_exports/camera/animation_camera.escn

@@ -23,7 +23,7 @@ surfaces/0 = {
 
 resource_name = "CameraAction"
 step = 0.1
-length = 2.91667
+length = 2.875
 tracks/0/type = "value"
 tracks/0/path = NodePath(".:far")
 tracks/0/interp = 1

+ 1 - 1
tests/reference_exports/nla_animation/animation_multi_strip.escn

@@ -23,7 +23,7 @@ surfaces/0 = {
 
 resource_name = "CubeAction"
 step = 0.1
-length = 3.83333
+length = 3.79167
 tracks/0/type = "transform"
 tracks/0/path = NodePath(".:")
 tracks/0/interp = 1

+ 1 - 1
tests/reference_exports/nla_animation/animation_with_empty_strip.escn

@@ -23,7 +23,7 @@ surfaces/0 = {
 
 resource_name = "CubeAction001"
 step = 0.1
-length = 1.66667
+length = 1.625
 tracks/0/type = "transform"
 tracks/0/path = NodePath(".:")
 tracks/0/interp = 1

+ 1 - 1
tests/reference_exports/nla_animation/nla_with_active_action.escn

@@ -23,7 +23,7 @@ surfaces/0 = {
 
 resource_name = "SuzanneAction001"
 step = 0.1
-length = 1.20833
+length = 1.16667
 tracks/0/type = "transform"
 tracks/0/path = NodePath(".:")
 tracks/0/interp = 1

+ 1 - 1
tests/reference_exports/nla_animation/nla_with_no_active_action.escn

@@ -46,7 +46,7 @@ surfaces/0 = {
 
 resource_name = "KeyAction"
 step = 0.1
-length = 2.08333
+length = 2.04167
 tracks/0/type = "value"
 tracks/0/path = NodePath(".:blend_shapes/Key 1")
 tracks/0/interp = 1

+ 2 - 2
tests/reference_exports/nla_animation/nla_with_stashed_action.escn

@@ -23,7 +23,7 @@ surfaces/0 = {
 
 resource_name = "SuzanneAction002"
 step = 0.1
-length = 1.25
+length = 1.20833
 tracks/0/type = "transform"
 tracks/0/path = NodePath(".:")
 tracks/0/interp = 1
@@ -33,7 +33,7 @@ tracks/0/keys = [0.0, 1.0, 0.374198, 0.122969, 0.0, -0.00014795, -0.000250295, -
 
 resource_name = "SuzanneAction"
 step = 0.1
-length = 1.20833
+length = 1.16667
 tracks/0/type = "transform"
 tracks/0/path = NodePath(".:")
 tracks/0/interp = 1

+ 1 - 1
tests/reference_exports/scene_animation/animation_parented_objects.escn

@@ -23,7 +23,7 @@ surfaces/0 = {
 
 resource_name = "CubeAction"
 step = 0.1
-length = 3.33333
+length = 3.29167
 tracks/0/type = "transform"
 tracks/0/path = NodePath("Cube:")
 tracks/0/interp = 1

+ 1 - 1
tests/reference_exports/shape_key/animation_shapekey.escn

@@ -35,7 +35,7 @@ surfaces/0 = {
 
 resource_name = "Key002Action"
 step = 0.1
-length = 2.5
+length = 2.45833
 tracks/0/type = "value"
 tracks/0/path = NodePath(".:blend_shapes/Key 1")
 tracks/0/interp = 1

+ 2 - 2
tests/reference_exports/shape_key/animation_shapekey_with_transform.escn

@@ -35,7 +35,7 @@ surfaces/0 = {
 
 resource_name = "KeyAction"
 step = 0.1
-length = 1.25
+length = 1.20833
 tracks/0/type = "value"
 tracks/0/path = NodePath(".:blend_shapes/Key 1")
 tracks/0/interp = 1
@@ -50,7 +50,7 @@ tracks/0/keys = {
 
 resource_name = "SuzanneAction"
 step = 0.1
-length = 1.25
+length = 1.20833
 tracks/0/type = "transform"
 tracks/0/path = NodePath(".:")
 tracks/0/interp = 1