[Bf-extensions-cvs] [3e7209f9] blender-v2.92-release: glTF exporter: fix collection offset when rotated or scaled
Julien Duroure
noreply at git.blender.org
Sat Jan 30 18:47:31 CET 2021
Commit: 3e7209f9f2894d0203cf9697958a6bd946fa3b6b
Author: Julien Duroure
Date: Sat Jan 30 18:46:55 2021 +0100
Branches: blender-v2.92-release
https://developer.blender.org/rBA3e7209f9f2894d0203cf9697958a6bd946fa3b6b
glTF exporter: fix collection offset when rotated or scaled
===================================================================
M io_scene_gltf2/__init__.py
M io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py
===================================================================
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 9f50fc37..dd733b34 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, 5, 15),
+ "version": (1, 5, 16),
'blender': (2, 91, 0),
'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 35c2df00..702935fb 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py
@@ -423,8 +423,17 @@ def __gather_trans_rot_scale(blender_object, export_settings):
sca = __convert_swizzle_scale(sca, export_settings)
if blender_object.instance_type == 'COLLECTION' and blender_object.instance_collection:
- trans -= __convert_swizzle_location(
+ offset = -__convert_swizzle_location(
blender_object.instance_collection.instance_offset, export_settings)
+
+ s = Matrix.Diagonal(sca).to_4x4()
+ r = rot.to_matrix().to_4x4()
+ t = Matrix.Translation(trans).to_4x4()
+ o = Matrix.Translation(offset).to_4x4()
+ m = t @ r @ s @ o
+
+ trans = m.translation
+
translation, rotation, scale = (None, None, None)
trans[0], trans[1], trans[2] = gltf2_blender_math.round_if_near(trans[0], 0.0), gltf2_blender_math.round_if_near(trans[1], 0.0), \
gltf2_blender_math.round_if_near(trans[2], 0.0)
More information about the Bf-extensions-cvs
mailing list