diff options
Diffstat (limited to 'io_scene_gltf2/blender/imp/gltf2_blender_animation.py')
-rwxr-xr-x | io_scene_gltf2/blender/imp/gltf2_blender_animation.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_animation.py b/io_scene_gltf2/blender/imp/gltf2_blender_animation.py index 93014d00..6394145d 100755 --- a/io_scene_gltf2/blender/imp/gltf2_blender_animation.py +++ b/io_scene_gltf2/blender/imp/gltf2_blender_animation.py @@ -12,8 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +import bpy + from .gltf2_blender_animation_bone import BlenderBoneAnim from .gltf2_blender_animation_node import BlenderNodeAnim +from .gltf2_blender_animation_weight import BlenderWeightAnim +from .gltf2_blender_animation_utils import restore_animation_on_object class BlenderAnimation(): @@ -28,32 +32,28 @@ class BlenderAnimation(): BlenderBoneAnim.anim(gltf, anim_idx, node_idx) else: BlenderNodeAnim.anim(gltf, anim_idx, node_idx) + BlenderWeightAnim.anim(gltf, anim_idx, node_idx) if gltf.data.nodes[node_idx].children: for child in gltf.data.nodes[node_idx].children: BlenderAnimation.anim(gltf, anim_idx, child) @staticmethod - def stash_action(gltf, anim_idx, node_idx, action_name): + def restore_animation(gltf, node_idx, animation_name): + """Restores the actions for an animation by its track name on + the subtree starting at node_idx.""" + node = gltf.data.nodes[node_idx] - if gltf.data.nodes[node_idx].is_joint: - BlenderBoneAnim.stash_action(gltf, anim_idx, node_idx, action_name) + if node.is_joint: + obj = bpy.data.objects[gltf.data.skins[node.skin_id].blender_armature_name] else: - BlenderNodeAnim.stash_action(gltf, anim_idx, node_idx, action_name) - - if gltf.data.nodes[node_idx].children: - for child in gltf.data.nodes[node_idx].children: - BlenderAnimation.stash_action(gltf, anim_idx, child, action_name) + obj = bpy.data.objects[node.blender_object] - @staticmethod - def restore_last_action(gltf, node_idx): - - if gltf.data.nodes[node_idx].is_joint: - BlenderBoneAnim.restore_last_action(gltf, node_idx) - else: - BlenderNodeAnim.restore_last_action(gltf, node_idx) + restore_animation_on_object(obj, animation_name) + if obj.data and hasattr(obj.data, 'shape_keys'): + restore_animation_on_object(obj.data.shape_keys, animation_name) if gltf.data.nodes[node_idx].children: for child in gltf.data.nodes[node_idx].children: - BlenderAnimation.restore_last_action(gltf, child) + BlenderAnimation.restore_animation(gltf, child, animation_name) |