aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2012-11-13 22:18:03 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-11-13 22:18:03 +0000
commitc1e3f6a5749276c89c9803efb2931127c7227a16 (patch)
treedfdcab79d19770c9f1a58b6a2b1da6dd19b08554
parentephysics: fix docs regarding torque axis. (diff)
downloadefl-c1e3f6a5749276c89c9803efb2931127c7227a16.tar.gz
ephysics: fix body rotation set / get
There was a inversion on setter and getter wasn't calculating euler angles correctly. SVN revision: 79250
-rw-r--r--legacy/ephysics/src/lib/ephysics_body.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp
index f2cdc8e1eb..472ce80099 100644
--- a/legacy/ephysics/src/lib/ephysics_body.cpp
+++ b/legacy/ephysics/src/lib/ephysics_body.cpp
@@ -3269,6 +3269,7 @@ ephysics_body_angular_movement_enable_get(const EPhysics_Body *body, Eina_Bool *
EAPI void
ephysics_body_rotation_get(const EPhysics_Body *body, double *rot_x, double *rot_y, double *rot_z)
{
+ btScalar yaw, pitch, roll;
btTransform trans;
if (!body)
@@ -3279,12 +3280,10 @@ ephysics_body_rotation_get(const EPhysics_Body *body, double *rot_x, double *rot
trans = _ephysics_body_transform_get(body);
- if (rot_x) *rot_x = - trans.getRotation().getAngle() * RAD_TO_DEG *
- trans.getRotation().getAxis().getX();
- if (rot_y) *rot_y = - trans.getRotation().getAngle() * RAD_TO_DEG *
- trans.getRotation().getAxis().getY();
- if (rot_z) *rot_z = - trans.getRotation().getAngle() * RAD_TO_DEG *
- trans.getRotation().getAxis().getZ();
+ trans.getBasis().getEulerYPR(yaw, pitch, roll);
+ if (rot_x) *rot_x = -roll * RAD_TO_DEG;
+ if (rot_y) *rot_y = -pitch * RAD_TO_DEG;
+ if (rot_z) *rot_z = -yaw * RAD_TO_DEG;
}
EAPI void
@@ -3302,7 +3301,7 @@ ephysics_body_rotation_set(EPhysics_Body *body, double rot_x, double rot_y, doub
ephysics_world_lock_take(body->world);
ephysics_body_activate(body, EINA_TRUE);
- quat.setEuler(-rot_x / RAD_TO_DEG, -rot_y / RAD_TO_DEG, -rot_z / RAD_TO_DEG);
+ quat.setEuler(-rot_y / RAD_TO_DEG, -rot_x / RAD_TO_DEG, -rot_z / RAD_TO_DEG);
if (body->soft_body)
body->soft_body->rotate(quat);