Skip to content

Commit b46b703

Browse files
committed
Use origin's full transform when offsetting export
1 parent 698f70a commit b46b703

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

exporter/export_collection.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,16 @@ def export(self):
192192
return result
193193

194194
def _pre_export(self, origin_objects):
195-
"""Move the objects based on the origin."""
195+
"""Transform the objects based on the origin."""
196196
for obj in origin_objects:
197197
self.objects.unlink(obj) # pylint: disable=no-member
198198

199199
bpy.ops.object.select_all(action='DESELECT')
200200

201+
inverse_origin_matrix = origin_objects[0].matrix_world.copy()
202+
inverse_origin_matrix.invert_safe()
201203
for obj in self.top_level_objects:
202-
obj.location -= origin_objects[0].location # TODO: Do a full transform based on the origin object?
204+
obj.matrix_world = inverse_origin_matrix @ obj.matrix_world
203205

204206
for obj in self.objects:
205207
obj.select_set(True)
@@ -208,9 +210,10 @@ def _pre_export(self, origin_objects):
208210
obj.name = trimmed_name
209211

210212
def _post_export(self, origin_objects):
211-
"""Reset object locations."""
213+
"""Reset object transforms."""
214+
origin_matrix = origin_objects[0].matrix_world.copy()
212215
for obj in self.top_level_objects:
213-
obj.location += origin_objects[0].location
216+
obj.matrix_world = origin_matrix @ obj.matrix_world
214217

215218
for obj in origin_objects:
216219
self.objects.link(obj) # pylint: disable=no-member

0 commit comments

Comments
 (0)