summaryrefslogtreecommitdiff
path: root/legacy/ephysics
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2012-10-10 19:16:48 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-10-10 19:16:48 +0000
commit290a7d8821f656a02033bfafd14d5bfbefcddbe7 (patch)
treea4ebd84cca8aa1fd6f1748510ae6f5a202da47b1 /legacy/ephysics
parent4ef1a74d4cff57d0bf3148d5f01bdbb8df4a352d (diff)
ephysics: allow to enable angular movement on all the
planes SVN revision: 77775
Diffstat (limited to 'legacy/ephysics')
-rw-r--r--legacy/ephysics/src/bin/ephysics_logo.c6
-rw-r--r--legacy/ephysics/src/bin/test_jumping_balls.c1
-rw-r--r--legacy/ephysics/src/lib/EPhysics.h32
-rw-r--r--legacy/ephysics/src/lib/ephysics_body.cpp18
4 files changed, 33 insertions, 24 deletions
diff --git a/legacy/ephysics/src/bin/ephysics_logo.c b/legacy/ephysics/src/bin/ephysics_logo.c
index faaff4e14e..905b19160d 100644
--- a/legacy/ephysics/src/bin/ephysics_logo.c
+++ b/legacy/ephysics/src/bin/ephysics_logo.c
@@ -143,7 +143,8 @@ _letter_body_setup_common(EPhysics_Body *body, Evas_Object *view)
143 ephysics_body_evas_object_set(body, view, EINA_TRUE); 143 ephysics_body_evas_object_set(body, view, EINA_TRUE);
144 ephysics_body_mass_set(body, 1.2); 144 ephysics_body_mass_set(body, 1.2);
145 ephysics_body_restitution_set(body, 0.6); 145 ephysics_body_restitution_set(body, 0.6);
146 ephysics_body_rotation_on_z_axis_enable_set(body, EINA_FALSE); 146 ephysics_body_angular_movement_enable_set(body, EINA_FALSE, EINA_FALSE,
147 EINA_FALSE);
147} 148}
148 149
149static EPhysics_Body * 150static EPhysics_Body *
@@ -260,7 +261,8 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__)
260 letter_body = _letter_body_circle_add(world, image); 261 letter_body = _letter_body_circle_add(world, image);
261 ephysics_body_friction_set(letter_body, 1); 262 ephysics_body_friction_set(letter_body, 1);
262 ephysics_body_mass_set(letter_body, 1); 263 ephysics_body_mass_set(letter_body, 1);
263 ephysics_body_rotation_on_z_axis_enable_set(letter_body, EINA_TRUE); 264 ephysics_body_angular_movement_enable_set(letter_body, EINA_FALSE,
265 EINA_FALSE, EINA_TRUE);
264 266
265 /* make the "E" logo get into the viewport by applying an horizontal force */ 267 /* make the "E" logo get into the viewport by applying an horizontal force */
266 ephysics_body_central_impulse_apply(letter_body, 390, 0); 268 ephysics_body_central_impulse_apply(letter_body, 390, 0);
diff --git a/legacy/ephysics/src/bin/test_jumping_balls.c b/legacy/ephysics/src/bin/test_jumping_balls.c
index 084d9586b3..3d6a54dad2 100644
--- a/legacy/ephysics/src/bin/test_jumping_balls.c
+++ b/legacy/ephysics/src/bin/test_jumping_balls.c
@@ -60,6 +60,7 @@ _add_sphere(Test_Data *test_data, int i)
60 test_data->evas_objs = eina_list_append(test_data->evas_objs, sphere); 60 test_data->evas_objs = eina_list_append(test_data->evas_objs, sphere);
61 61
62 fall_body = ephysics_body_circle_add(test_data->world); 62 fall_body = ephysics_body_circle_add(test_data->world);
63 ephysics_body_linear_movement_enable_set(fall_body, EINA_TRUE, EINA_TRUE, EINA_TRUE);
63 ephysics_body_evas_object_set(fall_body, sphere, EINA_TRUE); 64 ephysics_body_evas_object_set(fall_body, sphere, EINA_TRUE);
64 ephysics_body_event_callback_add(fall_body, EPHYSICS_CALLBACK_BODY_UPDATE, 65 ephysics_body_event_callback_add(fall_body, EPHYSICS_CALLBACK_BODY_UPDATE,
65 update_object_cb, shadow); 66 update_object_cb, shadow);
diff --git a/legacy/ephysics/src/lib/EPhysics.h b/legacy/ephysics/src/lib/EPhysics.h
index febc01a3fa..aa53d4aba8 100644
--- a/legacy/ephysics/src/lib/EPhysics.h
+++ b/legacy/ephysics/src/lib/EPhysics.h
@@ -2693,33 +2693,39 @@ EAPI void ephysics_body_impulse_apply(EPhysics_Body *body, double x, double y, E
2693 * @brief 2693 * @brief
2694 * Enable or disable body's rotation on z axis. 2694 * Enable or disable body's rotation on z axis.
2695 * 2695 *
2696 * Enabled by default. 2696 * Enabled by default for z axis, so the body only will rotate on x-y plane.
2697 *
2698 * If disabled, body won't rotate on x-y plane.
2699 * 2697 *
2700 * @param body The physics body. 2698 * @param body The physics body.
2701 * @param enable If @c EINA_TRUE enable rotation on z axis, if @c EINA_FALSE 2699 * @param enable_x If @c EINA_TRUE allow rotation on x axis (y-z plane),
2702 * disable it. 2700 * if @c EINA_FALSE disallow it.
2701 * @param enable_y If @c EINA_TRUE allow rotation on y axis (x-z plane),
2702 *if @c EINA_FALSE disallow it.
2703 * @param enable_z If @c EINA_TRUE allow rotation on z axis (x-y plane),
2704 * if @c EINA_FALSE disallow it.
2703 * 2705 *
2704 * @see ephysics_body_rotation_on_z_axis_enable_get(). 2706 * @see ephysics_body_angular_movement_enable_get().
2705 * 2707 *
2706 * @ingroup EPhysics_Body 2708 * @ingroup EPhysics_Body
2707 */ 2709 */
2708EAPI void ephysics_body_rotation_on_z_axis_enable_set(EPhysics_Body *body, Eina_Bool enable); 2710EAPI void ephysics_body_angular_movement_enable_set(EPhysics_Body *body, Eina_Bool enable_x, Eina_Bool enable_y, Eina_Bool enable_z);
2709 2711
2710/** 2712/**
2711 * @brief 2713 * @brief
2712 * Return body's rotation on z axis state. 2714 * Return body's rotation on z axis state.
2713 * 2715 *
2714 * @param body The physics body. 2716 * @param body The physics body.
2715 * @return @c EINA_TRUE if rotation on z axis is enabled, or @c EINA_FALSE 2717 * @param enable_x @c EINA_TRUE if rotation on x axis (y-z plane) is allowed, or
2716 * if disabled (or on error). 2718 * @c EINA_FALSE if it's not.
2719 * @param enable_y @c EINA_TRUE if rotation on y axis (x-z plane) is allowed, or
2720 * @c EINA_FALSE if it's not.
2721 * @param enable_z @c EINA_TRUE if rotation on z axis (x-y plane) is allowed, or
2722 * @c EINA_FALSE if it's not.
2717 * 2723 *
2718 * @see ephysics_body_rotation_on_z_axis_enable_set() for more details. 2724 * @see ephysics_body_angular_movement_enable_set() for more details.
2719 * 2725 *
2720 * @ingroup EPhysics_Body 2726 * @ingroup EPhysics_Body
2721 */ 2727 */
2722EAPI Eina_Bool ephysics_body_rotation_on_z_axis_enable_get(const EPhysics_Body *body); 2728EAPI void ephysics_body_angular_movement_enable_get(const EPhysics_Body *body, Eina_Bool *enable_x, Eina_Bool *enable_y, Eina_Bool *enable_z);
2723 2729
2724/** 2730/**
2725 * @brief 2731 * @brief
@@ -2736,7 +2742,7 @@ EAPI Eina_Bool ephysics_body_rotation_on_z_axis_enable_get(const EPhysics_Body *
2736 * disallow it. 2742 * disallow it.
2737 * 2743 *
2738 * @see ephysics_body_linear_movement_enable_get(). 2744 * @see ephysics_body_linear_movement_enable_get().
2739 * @see ephysics_body_rotation_on_z_axis_enable_set(). 2745 * @see ephysics_body_angular_movement_enable_set().
2740 * 2746 *
2741 * @ingroup EPhysics_Body 2747 * @ingroup EPhysics_Body
2742 */ 2748 */
@@ -2755,7 +2761,7 @@ EAPI void ephysics_body_linear_movement_enable_set(EPhysics_Body *body, Eina_Boo
2755 * @c EINA_FALSE if it's not. 2761 * @c EINA_FALSE if it's not.
2756 * 2762 *
2757 * @see ephysics_body_linear_movement_enable_set(). 2763 * @see ephysics_body_linear_movement_enable_set().
2758 * @see ephysics_body_rotation_on_z_axis_enable_get(). 2764 * @see ephysics_body_angular_movement_enable_get().
2759 * 2765 *
2760 * @ingroup EPhysics_Body 2766 * @ingroup EPhysics_Body
2761 */ 2767 */
diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp
index 23120d5959..dbf26d83ea 100644
--- a/legacy/ephysics/src/lib/ephysics_body.cpp
+++ b/legacy/ephysics/src/lib/ephysics_body.cpp
@@ -2483,7 +2483,7 @@ ephysics_body_torque_impulse_apply(EPhysics_Body *body, double roll)
2483} 2483}
2484 2484
2485EAPI void 2485EAPI void
2486ephysics_body_rotation_on_z_axis_enable_set(EPhysics_Body *body, Eina_Bool enable) 2486ephysics_body_angular_movement_enable_set(EPhysics_Body *body, Eina_Bool enable_x, Eina_Bool enable_y, Eina_Bool enable_z)
2487{ 2487{
2488 if (!body) 2488 if (!body)
2489 { 2489 {
@@ -2492,23 +2492,23 @@ ephysics_body_rotation_on_z_axis_enable_set(EPhysics_Body *body, Eina_Bool enabl
2492 } 2492 }
2493 2493
2494 ephysics_world_lock_take(body->world); 2494 ephysics_world_lock_take(body->world);
2495 if (!enable) 2495 body->rigid_body->setAngularFactor(btVector3(!!enable_x, !!enable_y,
2496 body->rigid_body->setAngularFactor(btVector3(0, 0, 0)); 2496 !!enable_z));
2497 else
2498 body->rigid_body->setAngularFactor(btVector3(0, 0, 1));
2499 ephysics_world_lock_release(body->world); 2497 ephysics_world_lock_release(body->world);
2500} 2498}
2501 2499
2502EAPI Eina_Bool 2500EAPI void
2503ephysics_body_rotation_on_z_axis_enable_get(const EPhysics_Body *body) 2501ephysics_body_angular_movement_enable_get(const EPhysics_Body *body, Eina_Bool *enable_x, Eina_Bool *enable_y, Eina_Bool *enable_z)
2504{ 2502{
2505 if (!body) 2503 if (!body)
2506 { 2504 {
2507 ERR("Can't check if rotation is enabled, body is null."); 2505 ERR("Can't check if rotation is enabled, body is null.");
2508 return EINA_FALSE; 2506 return;
2509 } 2507 }
2510 2508
2511 return !!body->rigid_body->getAngularFactor().z(); 2509 if (enable_x) *enable_x = !!body->rigid_body->getAngularFactor().x();
2510 if (enable_y) *enable_y = !!body->rigid_body->getAngularFactor().y();
2511 if (enable_z) *enable_z = !!body->rigid_body->getAngularFactor().z();
2512} 2512}
2513 2513
2514EAPI double 2514EAPI double