glTF exporter: avoid error when parent scale is 0
This commit is contained in:
parent
0e2a855c40
commit
8db785ea74
|
@ -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',
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue