[Bf-extensions-cvs] [0dc21412] blender-v2.93-release: glTF importer: fix shapekey import with negative weight

Julien Duroure noreply at git.blender.org
Mon Apr 19 20:14:10 CEST 2021


Commit: 0dc2141207dff62721023c73606a76a7a275488e
Author: Julien Duroure
Date:   Mon Apr 19 20:13:38 2021 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rBA0dc2141207dff62721023c73606a76a7a275488e

glTF importer: fix shapekey import with negative weight

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

M	io_scene_gltf2/__init__.py
M	io_scene_gltf2/blender/imp/gltf2_blender_animation_weight.py
M	io_scene_gltf2/blender/imp/gltf2_blender_node.py

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

diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 92fb129c..21922061 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -15,7 +15,7 @@
 bl_info = {
     'name': 'glTF 2.0 format',
     'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
-    "version": (1, 6, 12),
+    "version": (1, 6, 13),
     'blender': (2, 91, 0),
     'location': 'File > Import-Export',
     'description': 'Import-Export as glTF 2.0',
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_animation_weight.py b/io_scene_gltf2/blender/imp/gltf2_blender_animation_weight.py
index ab324853..19723ed9 100644
--- a/io_scene_gltf2/blender/imp/gltf2_blender_animation_weight.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_animation_weight.py
@@ -83,3 +83,10 @@ class BlenderWeightAnim():
                     group_name="ShapeKeys",
                     interpolation=animation.samplers[channel.sampler].interpolation,
                 )
+
+                # Expand weight range if needed
+                kb = obj.data.shape_keys.key_blocks[kb_name]
+                min_weight = min(coords[1:2])
+                max_weight = max(coords[1:2])
+                if min_weight < kb.slider_min: kb.slider_min = min_weight
+                if max_weight > kb.slider_max: kb.slider_max = max_weight
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_node.py b/io_scene_gltf2/blender/imp/gltf2_blender_node.py
index df59cd06..ef410ad5 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_node.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_node.py
@@ -225,7 +225,11 @@ class BlenderNode():
         weights = pynode.weights or pymesh.weights or []
         for i, weight in enumerate(weights):
             if pymesh.shapekey_names[i] is not None:
-                obj.data.shape_keys.key_blocks[pymesh.shapekey_names[i]].value = weight
+                kb = obj.data.shape_keys.key_blocks[pymesh.shapekey_names[i]]
+                # extend range if needed
+                if weight < kb.slider_min: kb.slider_min = weight
+                if weight > kb.slider_max: kb.slider_max = weight
+                kb.value = weight
 
     @staticmethod
     def setup_skinning(gltf, pynode, obj):



More information about the Bf-extensions-cvs mailing list