[Bf-extensions-cvs] [2ee886c2] master: glTF importer: do not use same mesh instance if node has some animation on morph target

Julien Duroure noreply at git.blender.org
Thu Feb 21 22:39:01 CET 2019


Commit: 2ee886c25b107bd716591a12c74fb180997af2c8
Author: Julien Duroure
Date:   Thu Feb 21 22:38:15 2019 +0100
Branches: master
https://developer.blender.org/rBA2ee886c25b107bd716591a12c74fb180997af2c8

glTF importer: do not use same mesh instance if node has some animation on morph target

===================================================================

M	io_scene_gltf2/blender/imp/gltf2_blender_gltf.py
M	io_scene_gltf2/blender/imp/gltf2_blender_node.py

===================================================================

diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_gltf.py b/io_scene_gltf2/blender/imp/gltf2_blender_gltf.py
index 3f55f933..637cd72f 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_gltf.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_gltf.py
@@ -202,6 +202,10 @@ class BlenderGlTF():
 
             node.transform = mat
 
+            # Weight animation management
+            node.weight_animation = False
+
+
         # joint management
         for node_idx, node in enumerate(gltf.data.nodes):
             is_joint, skin_idx = gltf.is_node_joint(node_idx)
@@ -229,9 +233,13 @@ class BlenderGlTF():
                     if anim_idx not in gltf.data.nodes[channel.target.node].animations.keys():
                         gltf.data.nodes[channel.target.node].animations[anim_idx] = []
                     gltf.data.nodes[channel.target.node].animations[anim_idx].append(channel_idx)
+                    # Manage node with animation on weights, that are animated in meshes in Blender (ShapeKeys)
+                    if channel.target.path == "weights":
+                        gltf.data.nodes[channel.target.node].weight_animation = True
 
         # Meshes
         if gltf.data.meshes:
             for mesh in gltf.data.meshes:
                 mesh.blender_name = None
+                mesh.is_weight_animated = False
 
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_node.py b/io_scene_gltf2/blender/imp/gltf2_blender_node.py
index df5b5a42..0792b96d 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_node.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_node.py
@@ -39,9 +39,18 @@ class BlenderNode():
             instance = False
             if gltf.data.meshes[pynode.mesh].blender_name is not None:
                 # Mesh is already created, only create instance
-                instance = True
-                mesh = bpy.data.meshes[gltf.data.meshes[pynode.mesh].blender_name]
-            else:
+                # Except is current node is animated with path weight
+                # Or if previous instance is animation at node level
+                if pynode.weight_animation is True:
+                    instance = False
+                else:
+                    if gltf.data.meshes[pynode.mesh].is_weight_animated is True:
+                        instance = False
+                    else:
+                        instance = True
+                        mesh = bpy.data.meshes[gltf.data.meshes[pynode.mesh].blender_name]
+
+            if instance is False:
                 if pynode.name:
                     gltf.log.info("Blender create Mesh node " + pynode.name)
                 else:
@@ -49,6 +58,10 @@ class BlenderNode():
 
                 mesh = BlenderMesh.create(gltf, pynode.mesh, node_idx, parent)
 
+            if pynode.weight_animation is True:
+                # flag this mesh instance as created only for this node, because of weight animation
+                gltf.data.meshes[pynode.mesh].is_weight_animated = True
+
             if pynode.name:
                 name = pynode.name
             else:



More information about the Bf-extensions-cvs mailing list