summaryrefslogtreecommitdiff
path: root/legacy/ephysics
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2012-07-04 22:05:52 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-07-04 22:05:52 +0000
commit9258827a932e9d0324ad4575f416b324b7f4c809 (patch)
tree0086d7f1cd2ec8a83a1e2cf7cb702af52b60491a /legacy/ephysics
parentc45cfc3be1b1ac89e2be27e524ac6a69fafa9828 (diff)
EPhysics: expose linear factor
Makes it possible to restrict movement on specific axises. SVN revision: 73313
Diffstat (limited to 'legacy/ephysics')
-rw-r--r--legacy/ephysics/src/lib/EPhysics.h36
-rw-r--r--legacy/ephysics/src/lib/ephysics_body.cpp25
2 files changed, 61 insertions, 0 deletions
diff --git a/legacy/ephysics/src/lib/EPhysics.h b/legacy/ephysics/src/lib/EPhysics.h
index 4870c2373d..1c966ce43e 100644
--- a/legacy/ephysics/src/lib/EPhysics.h
+++ b/legacy/ephysics/src/lib/EPhysics.h
@@ -1522,6 +1522,42 @@ EAPI Eina_Bool ephysics_body_rotation_on_z_axis_enable_get(EPhysics_Body *body);
1522 1522
1523/** 1523/**
1524 * @brief 1524 * @brief
1525 * Enable or disable body's movement on x and y axises.
1526 *
1527 * Enabled by default on both axises.
1528 *
1529 * @param body The physics body.
1530 * @param enable_x If @c EINA_TRUE allow movement on x axis, if @c EINA_FALSE
1531 * disallow it.
1532 * @param enable_y If @c EINA_TRUE allow movement on y axis, if @c EINA_FALSE
1533 * disallow it.
1534 *
1535 * @see ephysics_body_linear_movement_enable_set().
1536 * @see ephysics_body_rotation_on_z_axis_enable_set().
1537 *
1538 * @ingroup EPhysics_Body
1539 */
1540EAPI void ephysics_body_linear_movement_enable_set(EPhysics_Body *body, Eina_Bool enable_x, Eina_Bool enable_y);
1541
1542/**
1543 * @brief
1544 * Get body's movement on x and y axises behavior.
1545 *
1546 * @param body The physics body.
1547 * @param enable_x @c EINA_TRUE if movement on x axis is allowed, or
1548 * @c EINA_FALSE if it's not.
1549 * @param enable_y @c EINA_TRUE if movement on y axis is allowed, or
1550 * @c EINA_FALSE if it's not.
1551 *
1552 * @see ephysics_body_linear_movement_enable_get().
1553 * @see ephysics_body_rotation_on_z_axis_enable_get().
1554 *
1555 * @ingroup EPhysics_Body
1556 */
1557EAPI void ephysics_body_linear_movement_enable_get(EPhysics_Body *body, Eina_Bool *enable_x, Eina_Bool *enable_y);
1558
1559/**
1560 * @brief
1525 * Return body's rotation on z axis. 1561 * Return body's rotation on z axis.
1526 * 1562 *
1527 * By default rotation is 0 degrees. 1563 * By default rotation is 0 degrees.
diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp
index 41ef18620b..0353212f8f 100644
--- a/legacy/ephysics/src/lib/ephysics_body.cpp
+++ b/legacy/ephysics/src/lib/ephysics_body.cpp
@@ -821,6 +821,31 @@ ephysics_body_central_impulse_apply(EPhysics_Body *body, double x, double y)
821} 821}
822 822
823EAPI void 823EAPI void
824ephysics_body_linear_movement_enable_set(EPhysics_Body *body, Eina_Bool enable_x, Eina_Bool enable_y)
825{
826 if (!body)
827 {
828 ERR("Can't set linear factor on a null body.");
829 return;
830 }
831
832 body->rigid_body->setLinearFactor(btVector3(!!enable_x, !!enable_y, 0));
833}
834
835EAPI void
836ephysics_body_linear_movement_enable_get(EPhysics_Body *body, Eina_Bool *enable_x, Eina_Bool *enable_y)
837{
838 if (!body)
839 {
840 ERR("Can't check if linear factor is enabled, body is null.");
841 return;
842 }
843
844 if (enable_x) *enable_x = !!body->rigid_body->getLinearFactor().x();
845 if (enable_y) *enable_y = !!body->rigid_body->getLinearFactor().y();
846}
847
848EAPI void
824ephysics_body_torque_impulse_apply(EPhysics_Body *body, double roll) 849ephysics_body_torque_impulse_apply(EPhysics_Body *body, double roll)
825{ 850{
826 if (!body) 851 if (!body)