diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2021-04-19 21:13:38 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2021-04-19 21:13:38 +0300 |
commit | 0dc2141207dff62721023c73606a76a7a275488e (patch) | |
tree | 698acd0cf7159d6068f551b5b7323dac1a9e8bb5 /io_scene_gltf2 | |
parent | 7521a4e27be9deb3fb0cf2eb2e61753dc66fec44 (diff) |
glTF importer: fix shapekey import with negative weight
Diffstat (limited to 'io_scene_gltf2')
-rwxr-xr-x | io_scene_gltf2/__init__.py | 2 | ||||
-rw-r--r-- | io_scene_gltf2/blender/imp/gltf2_blender_animation_weight.py | 7 | ||||
-rwxr-xr-x | io_scene_gltf2/blender/imp/gltf2_blender_node.py | 6 |
3 files changed, 13 insertions, 2 deletions
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): |