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>2020-02-29 18:11:30 +0300
committerJulien Duroure <julien.duroure@gmail.com>2020-02-29 18:11:30 +0300
commit8db785ea740bcb64b613aee3fa6d8519c9e543ae (patch)
tree0448b50f8651bfef4a3d6c6003bffcb32e79cf5f
parent0e2a855c40c60c8669ffd4f7d56a5ad78c7c6ee9 (diff)
glTF exporter: avoid error when parent scale is 0
-rwxr-xr-xio_scene_gltf2/__init__.py2
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py20
2 files changed, 19 insertions, 3 deletions
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 4ea83c25..e7a6c212 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, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
- "version": (1, 2, 32),
+ "version": (1, 2, 33),
'blender': (2, 82, 7),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py
index 22a5e492..2eaf56f5 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py
@@ -29,6 +29,7 @@ from ..com.gltf2_blender_extras import generate_extras
from io_scene_gltf2.io.com import gltf2_io
from io_scene_gltf2.io.com import gltf2_io_extensions
from io_scene_gltf2.io.exp.gltf2_io_user_extensions import export_user_extensions
+from io_scene_gltf2.io.com.gltf2_io_debug import print_console
def gather_node(blender_object, blender_scene, export_settings):
@@ -188,7 +189,10 @@ def __gather_children(blender_object, blender_scene, export_settings):
if trans is None:
trans = [0, 0, 0]
# bones go down their local y axis
- bone_tail = [0, blender_bone.length / blender_bone.matrix.to_scale()[1], 0]
+ if blender_bone.matrix.to_scale()[1] >= 1e-6:
+ bone_tail = [0, blender_bone.length / blender_bone.matrix.to_scale()[1], 0]
+ else:
+ bone_tail = [0,0,0] # If scale is 0, tail == head
child_node.translation = [trans[idx] + bone_tail[idx] for idx in range(3)]
parent_joint.children.append(child_node)
@@ -341,7 +345,19 @@ def __gather_trans_rot_scale(blender_object, export_settings):
else:
# matrix_local = matrix_parent_inverse*location*rotation*scale
# Decomposing matrix_local gives less accuracy, but is needed if matrix_parent_inverse is not the identity.
- trans, rot, sca = gltf2_blender_extract.decompose_transition(blender_object.matrix_local, export_settings)
+
+
+ if blender_object.matrix_local[3][3] != 0.0:
+ trans, rot, sca = gltf2_blender_extract.decompose_transition(blender_object.matrix_local, export_settings)
+ else:
+ # Some really weird cases, scale is null (if parent is null when evaluation is done)
+ print_console('WARNING', 'Some nodes are 0 scaled during evaluation. Result can be wrong')
+ trans = blender_object.location
+ if blender_object.rotation_mode in ['QUATERNION', 'AXIS_ANGLE']:
+ rot = blender_object.rotation_quaternion
+ else:
+ rot = blender_object.rotation_euler.to_quaternion()
+ sca = blender_object.scale
trans = gltf2_blender_extract.convert_swizzle_location(trans, None, None, export_settings)
rot = gltf2_blender_extract.convert_swizzle_rotation(rot, export_settings)