Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Duroure <julien.duroure@gmail.com>2021-04-19 21:13:38 +0300
committerJulien Duroure <julien.duroure@gmail.com>2021-04-19 21:13:38 +0300
commit0dc2141207dff62721023c73606a76a7a275488e (patch)
tree698acd0cf7159d6068f551b5b7323dac1a9e8bb5 /io_scene_gltf2/blender/imp
parent7521a4e27be9deb3fb0cf2eb2e61753dc66fec44 (diff)
glTF importer: fix shapekey import with negative weight
Diffstat (limited to 'io_scene_gltf2/blender/imp')
-rw-r--r--io_scene_gltf2/blender/imp/gltf2_blender_animation_weight.py7
-rwxr-xr-xio_scene_gltf2/blender/imp/gltf2_blender_node.py6
2 files changed, 12 insertions, 1 deletions
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):