Skip to content

Commit 7f44fbb

Browse files
committed
Fix export with mirrored objects dfki-ric#377
1 parent 4e37f7f commit 7f44fbb

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

phobos/blender/io/blender2phobos.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def deriveGeometry(obj, duplicate_mesh=False, fast_init=True, **kwargs):
119119
elif gtype == 'mesh':
120120
blender_mesh = obj.data.copy() if duplicate_mesh else obj.data
121121
return representation.Mesh(
122-
scale=list(obj.matrix_world.to_scale()),
122+
scale=list(obj.scale),
123123
mesh=blender_mesh,
124124
meshname=blender_mesh.name,
125125
fast_init=fast_init

phobos/utils/transform.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,13 @@ def rpy_to_matrix(rpy):
4949

5050

5151
def matrix_to_rpy(R):
52-
try:
53-
angles = Rot.from_matrix(R).as_euler(EULER_CONVENTION)
54-
except:
55-
angles = Rot.from_dcm(R).as_euler(EULER_CONVENTION)
52+
determinant = np.linalg.det(R)
53+
if determinant < 0: # This is a reflection matrix
54+
scale = np.sign(np.diag(R))
55+
scaling_matrix = np.diag(scale)
56+
R = np.dot(R, np.linalg.inv(scaling_matrix))
57+
angles = Rot.from_matrix(R).as_euler(EULER_CONVENTION)
58+
5659
return order_angles(angles, EULER_CONVENTION, RPY_CONVENTION)
5760

5861

0 commit comments

Comments
 (0)