summaryrefslogtreecommitdiff
path: root/legacy/ephysics
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2012-10-10 19:17:01 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-10-10 19:17:01 +0000
commit8b9c28f003e65d0a68b1a7830d4e4f012dd32453 (patch)
treead3aff83d57cef5d86440dd6b3bc99f9bc2173fe /legacy/ephysics
parent32f03f55a4e4235143e528da39ed634b19a52ded (diff)
ephysics: support 3 axes on body geometry related
functions geometry set / get, move, resize SVN revision: 77777
Diffstat (limited to 'legacy/ephysics')
-rw-r--r--legacy/ephysics/src/bin/ephysics_logo.c5
-rw-r--r--legacy/ephysics/src/bin/test_bouncing_text.c2
-rw-r--r--legacy/ephysics/src/bin/test_camera.c2
-rw-r--r--legacy/ephysics/src/bin/test_camera_track.c2
-rw-r--r--legacy/ephysics/src/bin/test_collision_filter.c3
-rw-r--r--legacy/ephysics/src/bin/test_falling_letters.c2
-rw-r--r--legacy/ephysics/src/bin/test_grab.c2
-rw-r--r--legacy/ephysics/src/bin/test_win_resize.c2
-rw-r--r--legacy/ephysics/src/lib/EPhysics.h21
-rw-r--r--legacy/ephysics/src/lib/ephysics_body.cpp88
-rw-r--r--legacy/ephysics/src/lib/ephysics_camera.cpp2
-rw-r--r--legacy/ephysics/src/lib/ephysics_private.h1
12 files changed, 75 insertions, 57 deletions
diff --git a/legacy/ephysics/src/bin/ephysics_logo.c b/legacy/ephysics/src/bin/ephysics_logo.c
index 905b19160d..9a0dc927c1 100644
--- a/legacy/ephysics/src/bin/ephysics_logo.c
+++ b/legacy/ephysics/src/bin/ephysics_logo.c
@@ -99,7 +99,7 @@ _update_circle_cb(void *data __UNUSED__, EPhysics_Body *body, void *event_info)
99 evas_object_color_set(shadow, alpha, alpha, alpha, alpha); 99 evas_object_color_set(shadow, alpha, alpha, alpha, alpha);
100 100
101 if (x > E_THRESHOLD) 101 if (x > E_THRESHOLD)
102 ephysics_body_move(body, -w - 1, y); 102 ephysics_body_move(body, -w - 1, y, -15);
103} 103}
104 104
105static void 105static void
@@ -218,7 +218,8 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__)
218 218
219 ground_body = ephysics_body_box_add(world); 219 ground_body = ephysics_body_box_add(world);
220 ephysics_body_mass_set(ground_body, EPHYSICS_BODY_MASS_STATIC); 220 ephysics_body_mass_set(ground_body, EPHYSICS_BODY_MASS_STATIC);
221 ephysics_body_geometry_set(ground_body, -100, FLOOR_Y, WIDTH + 800, 10); 221 ephysics_body_geometry_set(ground_body, -100, FLOOR_Y, -15, WIDTH + 800, 10,
222 30);
222 ephysics_body_restitution_set(ground_body, 0.65); 223 ephysics_body_restitution_set(ground_body, 0.65);
223 ephysics_body_friction_set(ground_body, 0.8); 224 ephysics_body_friction_set(ground_body, 0.8);
224 225
diff --git a/legacy/ephysics/src/bin/test_bouncing_text.c b/legacy/ephysics/src/bin/test_bouncing_text.c
index ca8038d564..6170c8834d 100644
--- a/legacy/ephysics/src/bin/test_bouncing_text.c
+++ b/legacy/ephysics/src/bin/test_bouncing_text.c
@@ -22,7 +22,7 @@ _world_populate(Test_Data *test_data)
22 22
23 text_body = ephysics_body_box_add(test_data->world); 23 text_body = ephysics_body_box_add(test_data->world);
24 ephysics_body_evas_object_set(text_body, text, EINA_FALSE); 24 ephysics_body_evas_object_set(text_body, text, EINA_FALSE);
25 ephysics_body_geometry_set(text_body, x, y, w * 5 / 6, 46); 25 ephysics_body_geometry_set(text_body, x, y, -15, w * 5 / 6, 46, 30);
26 ephysics_body_restitution_set(text_body, 0.95); 26 ephysics_body_restitution_set(text_body, 0.95);
27 ephysics_body_friction_set(text_body, 0.1); 27 ephysics_body_friction_set(text_body, 0.1);
28 test_data->bodies = eina_list_append(test_data->bodies, text_body); 28 test_data->bodies = eina_list_append(test_data->bodies, text_body);
diff --git a/legacy/ephysics/src/bin/test_camera.c b/legacy/ephysics/src/bin/test_camera.c
index 98bb04c628..f542a1d9d2 100644
--- a/legacy/ephysics/src/bin/test_camera.c
+++ b/legacy/ephysics/src/bin/test_camera.c
@@ -227,7 +227,7 @@ test_camera(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
227 227
228 boundary = ephysics_body_box_add(camera_data->base.world); 228 boundary = ephysics_body_box_add(camera_data->base.world);
229 ephysics_body_mass_set(boundary, 0); 229 ephysics_body_mass_set(boundary, 0);
230 ephysics_body_geometry_set(boundary, 0, FLOOR_Y, WIDTH * 2, 10); 230 ephysics_body_geometry_set(boundary, 0, FLOOR_Y, -15, WIDTH * 2, 10, 30);
231 ephysics_body_restitution_set(boundary, 0.65); 231 ephysics_body_restitution_set(boundary, 0.65);
232 ephysics_body_friction_set(boundary, 4); 232 ephysics_body_friction_set(boundary, 4);
233 233
diff --git a/legacy/ephysics/src/bin/test_camera_track.c b/legacy/ephysics/src/bin/test_camera_track.c
index 594ad0df0c..2e482f1422 100644
--- a/legacy/ephysics/src/bin/test_camera_track.c
+++ b/legacy/ephysics/src/bin/test_camera_track.c
@@ -238,7 +238,7 @@ test_camera_track(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *even
238 238
239 boundary = ephysics_body_box_add(track_data->base.world); 239 boundary = ephysics_body_box_add(track_data->base.world);
240 ephysics_body_mass_set(boundary, 0); 240 ephysics_body_mass_set(boundary, 0);
241 ephysics_body_geometry_set(boundary, 0, FLOOR_Y, WIDTH * 4, 10); 241 ephysics_body_geometry_set(boundary, 0, FLOOR_Y, -15, WIDTH * 4, 10, 30);
242 ephysics_body_restitution_set(boundary, 0.65); 242 ephysics_body_restitution_set(boundary, 0.65);
243 ephysics_body_friction_set(boundary, 4); 243 ephysics_body_friction_set(boundary, 4);
244 244
diff --git a/legacy/ephysics/src/bin/test_collision_filter.c b/legacy/ephysics/src/bin/test_collision_filter.c
index 62e61ad5fb..5df2ea5112 100644
--- a/legacy/ephysics/src/bin/test_collision_filter.c
+++ b/legacy/ephysics/src/bin/test_collision_filter.c
@@ -75,7 +75,8 @@ test_collision_filter(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *
75 ephysics_body_friction_set(boundary, 2); 75 ephysics_body_friction_set(boundary, 2);
76 76
77 boundary = ephysics_body_box_add(test_data->world); 77 boundary = ephysics_body_box_add(test_data->world);
78 ephysics_body_geometry_set(boundary, 60, FLOOR_Y - 16, WIDTH - 120, 10); 78 ephysics_body_geometry_set(boundary, 60, FLOOR_Y - 16, -15, WIDTH - 120, 10,
79 30);
79 ephysics_body_restitution_set(boundary, 0.65); 80 ephysics_body_restitution_set(boundary, 0.65);
80 ephysics_body_friction_set(boundary, 2); 81 ephysics_body_friction_set(boundary, 2);
81 ephysics_body_mass_set(boundary, 0); 82 ephysics_body_mass_set(boundary, 0);
diff --git a/legacy/ephysics/src/bin/test_falling_letters.c b/legacy/ephysics/src/bin/test_falling_letters.c
index 749e415954..3fb8c3da89 100644
--- a/legacy/ephysics/src/bin/test_falling_letters.c
+++ b/legacy/ephysics/src/bin/test_falling_letters.c
@@ -30,7 +30,7 @@ _world_populate(Test_Data *test_data)
30 30
31 text_body = ephysics_body_box_add(test_data->world); 31 text_body = ephysics_body_box_add(test_data->world);
32 ephysics_body_evas_object_set(text_body, text, EINA_FALSE); 32 ephysics_body_evas_object_set(text_body, text, EINA_FALSE);
33 ephysics_body_geometry_set(text_body, x, y, w * 5 / 6, 40); 33 ephysics_body_geometry_set(text_body, x, y, -15, w * 5 / 6, 40, 30);
34 ephysics_body_friction_set(text_body, 0.1); 34 ephysics_body_friction_set(text_body, 0.1);
35 ephysics_body_restitution_set(text_body, 0.95); 35 ephysics_body_restitution_set(text_body, 0.95);
36 test_data->bodies = eina_list_append(test_data->bodies, text_body); 36 test_data->bodies = eina_list_append(test_data->bodies, text_body);
diff --git a/legacy/ephysics/src/bin/test_grab.c b/legacy/ephysics/src/bin/test_grab.c
index fae6e772b9..8da3da3cd1 100644
--- a/legacy/ephysics/src/bin/test_grab.c
+++ b/legacy/ephysics/src/bin/test_grab.c
@@ -62,7 +62,7 @@ _mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_inf
62 if (nx < 0 || ny < 0) return; 62 if (nx < 0 || ny < 0) return;
63 63
64 evas_object_geometry_get(obj, &x, &y, &w, &h); 64 evas_object_geometry_get(obj, &x, &y, &w, &h);
65 ephysics_body_move(dragging->body, nx, ny); 65 ephysics_body_move(dragging->body, nx, ny, -15);
66} 66}
67 67
68static void 68static void
diff --git a/legacy/ephysics/src/bin/test_win_resize.c b/legacy/ephysics/src/bin/test_win_resize.c
index f5bc037153..a1462f4558 100644
--- a/legacy/ephysics/src/bin/test_win_resize.c
+++ b/legacy/ephysics/src/bin/test_win_resize.c
@@ -62,7 +62,7 @@ _win_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_inf
62 evas_object_geometry_get(sphere, &x, &y, NULL, NULL); 62 evas_object_geometry_get(sphere, &x, &y, NULL, NULL);
63 63
64 ephysics_body_move(sphere_body, x * (ratew / old_rate->w), 64 ephysics_body_move(sphere_body, x * (ratew / old_rate->w),
65 y * (rateh / old_rate->h)); 65 y * (rateh / old_rate->h), -15);
66 evas_object_resize(sphere, 70 * ratew, 70 * rateh); 66 evas_object_resize(sphere, 70 * ratew, 70 * rateh);
67 67
68 old_rate->w = ratew; 68 old_rate->w = ratew;
diff --git a/legacy/ephysics/src/lib/EPhysics.h b/legacy/ephysics/src/lib/EPhysics.h
index b588efd87f..ce18b5474b 100644
--- a/legacy/ephysics/src/lib/EPhysics.h
+++ b/legacy/ephysics/src/lib/EPhysics.h
@@ -1945,9 +1945,8 @@ EAPI Evas_Object *ephysics_body_evas_object_get(const EPhysics_Body *body);
1945 * @brief 1945 * @brief
1946 * Set physics body size. 1946 * Set physics body size.
1947 * 1947 *
1948 * All the physics bodies are and with canonical dimensions. 1948 * By default circles have diameter equal to 1 meter * rate, boxes have
1949 * Circles have diameter 1, boxes have dimensions 1 1949 * dimensions 1 meter * rate on all the axes.
1950 * on all the axes.
1951 * 1950 *
1952 * There are three direct ways of modifying it's size: 1951 * There are three direct ways of modifying it's size:
1953 * @li With @ref ephysics_body_resize(); 1952 * @li With @ref ephysics_body_resize();
@@ -1960,6 +1959,7 @@ EAPI Evas_Object *ephysics_body_evas_object_get(const EPhysics_Body *body);
1960 * @param body The body to be resized. 1959 * @param body The body to be resized.
1961 * @param w The body width, in pixels. 1960 * @param w The body width, in pixels.
1962 * @param h The body height, in pixels. 1961 * @param h The body height, in pixels.
1962 * @param d The body depth, in pixels.
1963 * 1963 *
1964 * @see ephysics_body_geometry_get(). 1964 * @see ephysics_body_geometry_get().
1965 * @see ephysics_body_geometry_set(). 1965 * @see ephysics_body_geometry_set().
@@ -1967,13 +1967,13 @@ EAPI Evas_Object *ephysics_body_evas_object_get(const EPhysics_Body *body);
1967 * 1967 *
1968 * @ingroup EPhysics_Body 1968 * @ingroup EPhysics_Body
1969 */ 1969 */
1970EAPI void ephysics_body_resize(EPhysics_Body *body, Evas_Coord w, Evas_Coord h); 1970EAPI void ephysics_body_resize(EPhysics_Body *body, Evas_Coord w, Evas_Coord h, Evas_Coord d);
1971 1971
1972/** 1972/**
1973 * @brief 1973 * @brief
1974 * Set physics body position. 1974 * Set physics body position.
1975 * 1975 *
1976 * All the physics bodies are created centered on origin (0, 0). 1976 * All the physics bodies are created centered on origin (0, 0, 0).
1977 * 1977 *
1978 * There are three direct ways of modifying this position: 1978 * There are three direct ways of modifying this position:
1979 * @li With @ref ephysics_body_move(); 1979 * @li With @ref ephysics_body_move();
@@ -1989,6 +1989,7 @@ EAPI void ephysics_body_resize(EPhysics_Body *body, Evas_Coord w, Evas_Coord h);
1989 * @param body The body to be positioned. 1989 * @param body The body to be positioned.
1990 * @param x The position on axis x, in pixels. 1990 * @param x The position on axis x, in pixels.
1991 * @param y The position on axis y, in pixels. 1991 * @param y The position on axis y, in pixels.
1992 * @param z The position on axis z, in pixels.
1992 * 1993 *
1993 * @see ephysics_body_geometry_get(). 1994 * @see ephysics_body_geometry_get().
1994 * @see ephysics_body_geometry_set(). 1995 * @see ephysics_body_geometry_set().
@@ -1996,7 +1997,7 @@ EAPI void ephysics_body_resize(EPhysics_Body *body, Evas_Coord w, Evas_Coord h);
1996 * 1997 *
1997 * @ingroup EPhysics_Body 1998 * @ingroup EPhysics_Body
1998 */ 1999 */
1999EAPI void ephysics_body_move(EPhysics_Body *body, Evas_Coord x, Evas_Coord y); 2000EAPI void ephysics_body_move(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord z);
2000 2001
2001/** 2002/**
2002 * @brief 2003 * @brief
@@ -2025,8 +2026,10 @@ EAPI void ephysics_body_move(EPhysics_Body *body, Evas_Coord x, Evas_Coord y);
2025 * @param body The body to be modified. 2026 * @param body The body to be modified.
2026 * @param x The position on axis x, in pixels. 2027 * @param x The position on axis x, in pixels.
2027 * @param y The position on axis y, in pixels. 2028 * @param y The position on axis y, in pixels.
2029 * @param z The position on axis z, in pixels.
2028 * @param w The body width, in pixels. 2030 * @param w The body width, in pixels.
2029 * @param h The body height, in pixels. 2031 * @param h The body height, in pixels.
2032 * @param d The body depth, in pixels.
2030 * 2033 *
2031 * @see ephysics_body_geometry_get(). 2034 * @see ephysics_body_geometry_get().
2032 * @see ephysics_body_move(). 2035 * @see ephysics_body_move().
@@ -2034,7 +2037,7 @@ EAPI void ephysics_body_move(EPhysics_Body *body, Evas_Coord x, Evas_Coord y);
2034 * 2037 *
2035 * @ingroup EPhysics_Body 2038 * @ingroup EPhysics_Body
2036 */ 2039 */
2037EAPI void ephysics_body_geometry_set(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h); 2040EAPI void ephysics_body_geometry_set(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord z, Evas_Coord w, Evas_Coord h, Evas_Coord d);
2038 2041
2039/** 2042/**
2040 * @brief 2043 * @brief
@@ -2043,8 +2046,10 @@ EAPI void ephysics_body_geometry_set(EPhysics_Body *body, Evas_Coord x, Evas_Coo
2043 * @param body The physics body. 2046 * @param body The physics body.
2044 * @param x The position on axis x, in pixels. 2047 * @param x The position on axis x, in pixels.
2045 * @param y The position on axis y, in pixels. 2048 * @param y The position on axis y, in pixels.
2049 * @param z The position on axis z, in pixels.
2046 * @param w The body width, in pixels. 2050 * @param w The body width, in pixels.
2047 * @param h The body height, in pixels. 2051 * @param h The body height, in pixels.
2052 * @param d The body depth, in pixels.
2048 * 2053 *
2049 * @see ephysics_body_geometry_set() for more details. 2054 * @see ephysics_body_geometry_set() for more details.
2050 * @see ephysics_body_move(). 2055 * @see ephysics_body_move().
@@ -2052,7 +2057,7 @@ EAPI void ephysics_body_geometry_set(EPhysics_Body *body, Evas_Coord x, Evas_Coo
2052 * 2057 *
2053 * @ingroup EPhysics_Body 2058 * @ingroup EPhysics_Body
2054 */ 2059 */
2055EAPI void ephysics_body_geometry_get(const EPhysics_Body *body, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h); 2060EAPI void ephysics_body_geometry_get(const EPhysics_Body *body, Evas_Coord *x, Evas_Coord *y, Evas_Coord *z, Evas_Coord *w, Evas_Coord *h, Evas_Coord *d);
2056 2061
2057/** 2062/**
2058 * @brief 2063 * @brief
diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp
index 210ea8e5f0..a3eb2376f4 100644
--- a/legacy/ephysics/src/lib/ephysics_body.cpp
+++ b/legacy/ephysics/src/lib/ephysics_body.cpp
@@ -828,22 +828,23 @@ _ephysics_body_mass_set(EPhysics_Body *body, double mass)
828} 828}
829 829
830static void 830static void
831_ephysics_body_resize(EPhysics_Body *body, Evas_Coord w, Evas_Coord h) 831_ephysics_body_resize(EPhysics_Body *body, Evas_Coord w, Evas_Coord h, Evas_Coord d)
832{ 832{
833 double rate, sx, sy; 833 double rate, sx, sy, sz;
834 834
835 rate = ephysics_world_rate_get(body->world); 835 rate = ephysics_world_rate_get(body->world);
836 sx = w / rate; 836 sx = w / rate;
837 sy = h / rate; 837 sy = h / rate;
838 sz = d / rate;
838 839
839 if (body->soft_body) 840 if (body->soft_body)
840 { 841 {
841 body->soft_body->scale(btVector3(sx, sy, 1)); 842 body->soft_body->scale(btVector3(sx, sy, sz));
842 _ephysics_body_soft_body_constraints_rebuild(body); 843 _ephysics_body_soft_body_constraints_rebuild(body);
843 } 844 }
844 else 845 else
845 { 846 {
846 body->collision_shape->setLocalScaling(btVector3(sx, sy, 1)); 847 body->collision_shape->setLocalScaling(btVector3(sx, sy, sz));
847 848
848 if(!body->rigid_body->isStaticObject()) 849 if(!body->rigid_body->isStaticObject())
849 _ephysics_body_mass_set(body, ephysics_body_mass_get(body)); 850 _ephysics_body_mass_set(body, ephysics_body_mass_get(body));
@@ -851,16 +852,17 @@ _ephysics_body_resize(EPhysics_Body *body, Evas_Coord w, Evas_Coord h)
851 852
852 body->w = w; 853 body->w = w;
853 body->h = h; 854 body->h = h;
855 body->d = d;
854 856
855 ephysics_body_activate(body, EINA_TRUE); 857 ephysics_body_activate(body, EINA_TRUE);
856 858
857 DBG("Body %p scale changed to %lf, %lf.", body, sx, sy); 859 DBG("Body %p scale changed to (%lf, %lf, %lf).", body, sx, sy, sz);
858} 860}
859 861
860static void 862static void
861_ephysics_body_move(EPhysics_Body *body, Evas_Coord x, Evas_Coord y) 863_ephysics_body_move(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord z)
862{ 864{
863 double rate, mx, my; 865 double rate, mx, my, mz;
864 btTransform trans; 866 btTransform trans;
865 int wy, height; 867 int wy, height;
866 btVector3 body_scale; 868 btVector3 body_scale;
@@ -871,21 +873,22 @@ _ephysics_body_move(EPhysics_Body *body, Evas_Coord x, Evas_Coord y)
871 873
872 mx = (x + body->w * body->cm.x) / rate; 874 mx = (x + body->w * body->cm.x) / rate;
873 my = (height - (y + body->h * body->cm.y)) / rate; 875 my = (height - (y + body->h * body->cm.y)) / rate;
876 mz = z / rate;
874 877
875 trans = _ephysics_body_transform_get(body); 878 trans = _ephysics_body_transform_get(body);
876 trans.setOrigin(btVector3(mx, my, 0)); 879 trans.setOrigin(btVector3(mx, my, mz));
877 body->rigid_body->proceedToTransform(trans); 880 body->rigid_body->proceedToTransform(trans);
878 body->rigid_body->getMotionState()->setWorldTransform(trans); 881 body->rigid_body->getMotionState()->setWorldTransform(trans);
879 882
880 ephysics_body_activate(body, EINA_TRUE); 883 ephysics_body_activate(body, EINA_TRUE);
881 884
882 DBG("Body %p position changed to %lf, %lf.", body, mx, my); 885 DBG("Body %p position changed to (%lf, %lf, %lf).", body, mx, my, mz);
883} 886}
884 887
885static void 888static void
886_ephysics_body_geometry_set(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h, double rate) 889_ephysics_body_geometry_set(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord z, Evas_Coord w, Evas_Coord h, Evas_Coord d, double rate)
887{ 890{
888 double mx, my, sx, sy; 891 double mx, my, mz, sx, sy, sz;
889 btTransform trans; 892 btTransform trans;
890 int wy, height; 893 int wy, height;
891 btVector3 body_scale; 894 btVector3 body_scale;
@@ -895,12 +898,14 @@ _ephysics_body_geometry_set(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Eva
895 898
896 mx = (x + w * body->cm.x) / rate; 899 mx = (x + w * body->cm.x) / rate;
897 my = (height - (y + h * body->cm.y)) / rate; 900 my = (height - (y + h * body->cm.y)) / rate;
901 mz = z / rate;
898 sx = w / rate; 902 sx = w / rate;
899 sy = h / rate; 903 sy = h / rate;
904 sz = d / rate;
900 905
901 trans = _ephysics_body_transform_get(body); 906 trans = _ephysics_body_transform_get(body);
902 trans.setOrigin(btVector3(mx, my, trans.getOrigin().z())); 907 trans.setOrigin(btVector3(mx, my, mz));
903 body_scale = btVector3(sx, sy, 1); 908 body_scale = btVector3(sx, sy, sz);
904 909
905 if (body->type == EPHYSICS_BODY_TYPE_SOFT) 910 if (body->type == EPHYSICS_BODY_TYPE_SOFT)
906 { 911 {
@@ -929,9 +934,10 @@ _ephysics_body_geometry_set(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Eva
929 934
930 body->w = w; 935 body->w = w;
931 body->h = h; 936 body->h = h;
937 body->d = d;
932 938
933 DBG("Body %p position changed to %lf, %lf.", body, mx, my); 939 DBG("Body %p position changed to (%lf, %lf, %lf).", body, mx, my, mz);
934 DBG("Body %p scale changed to %lf, %lf.", body, sx, sy); 940 DBG("Body %p scale changed to (%lf, %lf, %lf).", body, sx, sy, sz);
935} 941}
936 942
937static void 943static void
@@ -944,9 +950,9 @@ _ephysics_body_evas_obj_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *o
944 if ((w == body->w) && (h == body->h)) 950 if ((w == body->w) && (h == body->h))
945 return; 951 return;
946 952
947 DBG("Resizing body %p to w=%i, h=%i", body, w, h); 953 DBG("Resizing body %p to w=%i, h=%i, d=%i", body, w, h, body->d);
948 ephysics_world_lock_take(body->world); 954 ephysics_world_lock_take(body->world);
949 _ephysics_body_resize(body, w, h); 955 _ephysics_body_resize(body, w, h, body->d);
950 ephysics_world_lock_release(body->world); 956 ephysics_world_lock_release(body->world);
951} 957}
952 958
@@ -1044,7 +1050,7 @@ _ephysics_body_outside_render_area_check(EPhysics_Body *body)
1044 int wx, wy, ww, wh, bx, by, bw, bh; 1050 int wx, wy, ww, wh, bx, by, bw, bh;
1045 1051
1046 ephysics_world_render_geometry_get(body->world, &wx, &wy, &ww, &wh); 1052 ephysics_world_render_geometry_get(body->world, &wx, &wy, &ww, &wh);
1047 ephysics_body_geometry_get(body, &bx, &by, &bw, &bh); 1053 ephysics_body_geometry_get(body, &bx, &by, NULL, &bw, &bh, NULL);
1048 1054
1049 // FIXME: check what should be done regarding rotated bodies 1055 // FIXME: check what should be done regarding rotated bodies
1050 if (((ephysics_world_bodies_outside_top_autodel_get(body->world)) && 1056 if (((ephysics_world_bodies_outside_top_autodel_get(body->world)) &&
@@ -1079,14 +1085,14 @@ ephysics_body_forces_apply(EPhysics_Body *body)
1079void 1085void
1080ephysics_body_recalc(EPhysics_Body *body, double rate) 1086ephysics_body_recalc(EPhysics_Body *body, double rate)
1081{ 1087{
1082 Evas_Coord x, y, w, h; 1088 Evas_Coord x, y, z, w, h, d;
1083 double vx, vy, lt, at; 1089 double vx, vy, lt, at;
1084 1090
1085 ephysics_body_geometry_get(body, &x, &y, &w, &h); 1091 ephysics_body_geometry_get(body, &x, &y, &z, &w, &h, &d);
1086 ephysics_body_linear_velocity_get(body, &vx, &vy); 1092 ephysics_body_linear_velocity_get(body, &vx, &vy);
1087 ephysics_body_sleeping_threshold_get(body, &lt, &at); 1093 ephysics_body_sleeping_threshold_get(body, &lt, &at);
1088 1094
1089 _ephysics_body_geometry_set(body, x, y, w, h, rate); 1095 _ephysics_body_geometry_set(body, x, y, z, w, h, d, rate);
1090 _ephysics_body_linear_velocity_set(body, vx, vy, rate); 1096 _ephysics_body_linear_velocity_set(body, vx, vy, rate);
1091 _ephysics_body_sleeping_threshold_set(body, lt, at, rate); 1097 _ephysics_body_sleeping_threshold_set(body, lt, at, rate);
1092} 1098}
@@ -1729,19 +1735,19 @@ ephysics_body_world_boundaries_resize(EPhysics_World *world)
1729 1735
1730 bottom = ephysics_world_boundary_get(world, EPHYSICS_WORLD_BOUNDARY_BOTTOM); 1736 bottom = ephysics_world_boundary_get(world, EPHYSICS_WORLD_BOUNDARY_BOTTOM);
1731 if (bottom) 1737 if (bottom)
1732 ephysics_body_geometry_set(bottom, x, y + height, width, 10); 1738 ephysics_body_geometry_set(bottom, x, y + height, -5, width, 10, 10);
1733 1739
1734 right = ephysics_world_boundary_get(world, EPHYSICS_WORLD_BOUNDARY_RIGHT); 1740 right = ephysics_world_boundary_get(world, EPHYSICS_WORLD_BOUNDARY_RIGHT);
1735 if (right) 1741 if (right)
1736 ephysics_body_geometry_set(right, x + width, 0, 10, y + height); 1742 ephysics_body_geometry_set(right, x + width, 0, -5, 10, y + height, 10);
1737 1743
1738 left = ephysics_world_boundary_get(world, EPHYSICS_WORLD_BOUNDARY_LEFT); 1744 left = ephysics_world_boundary_get(world, EPHYSICS_WORLD_BOUNDARY_LEFT);
1739 if (left) 1745 if (left)
1740 ephysics_body_geometry_set(left, x - 10, 0, 10, y + height); 1746 ephysics_body_geometry_set(left, x - 10, 0, -5, 10, y + height, 10);
1741 1747
1742 top = ephysics_world_boundary_get(world, EPHYSICS_WORLD_BOUNDARY_TOP); 1748 top = ephysics_world_boundary_get(world, EPHYSICS_WORLD_BOUNDARY_TOP);
1743 if (top) 1749 if (top)
1744 ephysics_body_geometry_set(top, 0, y - 10, x + width, 10); 1750 ephysics_body_geometry_set(top, 0, y - 10, -5, x + width, 10, 10);
1745} 1751}
1746 1752
1747static EPhysics_Body * 1753static EPhysics_Body *
@@ -1765,7 +1771,7 @@ _ephysics_body_boundary_add(EPhysics_World *world, EPhysics_World_Boundary bound
1765 1771
1766 ephysics_body_mass_set(body, 0); 1772 ephysics_body_mass_set(body, 0);
1767 ephysics_world_boundary_set(world, boundary, body); 1773 ephysics_world_boundary_set(world, boundary, body);
1768 ephysics_body_geometry_set(body, x, y, w, h); 1774 ephysics_body_geometry_set(body, x, y, -5, w, h, 10);
1769 1775
1770 return body; 1776 return body;
1771} 1777}
@@ -1847,6 +1853,7 @@ EAPI Evas_Object *
1847ephysics_body_evas_object_set(EPhysics_Body *body, Evas_Object *evas_obj, Eina_Bool use_obj_pos) 1853ephysics_body_evas_object_set(EPhysics_Body *body, Evas_Object *evas_obj, Eina_Bool use_obj_pos)
1848{ 1854{
1849 int obj_x, obj_y, obj_w, obj_h; 1855 int obj_x, obj_y, obj_w, obj_h;
1856 double rate;
1850 1857
1851 if (!body) 1858 if (!body)
1852 { 1859 {
@@ -1878,9 +1885,10 @@ ephysics_body_evas_object_set(EPhysics_Body *body, Evas_Object *evas_obj, Eina_B
1878 return evas_obj; 1885 return evas_obj;
1879 1886
1880 evas_object_geometry_get(body->evas_obj, &obj_x, &obj_y, &obj_w, &obj_h); 1887 evas_object_geometry_get(body->evas_obj, &obj_x, &obj_y, &obj_w, &obj_h);
1888 rate = ephysics_world_rate_get(body->world);
1881 ephysics_world_lock_take(body->world); 1889 ephysics_world_lock_take(body->world);
1882 _ephysics_body_geometry_set(body, obj_x, obj_y, obj_w, obj_h, 1890 _ephysics_body_geometry_set(body, obj_x, obj_y, - rate / 2,
1883 ephysics_world_rate_get(body->world)); 1891 obj_w, obj_h, rate, rate);
1884 1892
1885 if (body->soft_body) 1893 if (body->soft_body)
1886 { 1894 {
@@ -1946,7 +1954,7 @@ ephysics_body_evas_object_get(const EPhysics_Body *body)
1946} 1954}
1947 1955
1948EAPI void 1956EAPI void
1949ephysics_body_geometry_set(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) 1957ephysics_body_geometry_set(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord z, Evas_Coord w, Evas_Coord h, Evas_Coord d)
1950{ 1958{
1951 if (!body) 1959 if (!body)
1952 { 1960 {
@@ -1954,20 +1962,20 @@ ephysics_body_geometry_set(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas
1954 return; 1962 return;
1955 } 1963 }
1956 1964
1957 if ((w <= 0) || (h <= 0)) 1965 if ((w <= 0) || (h <= 0) || (d <= 0))
1958 { 1966 {
1959 ERR("Width and height must to be a non-null, positive value."); 1967 ERR("Width, height and depth must to be a non-null, positive value.");
1960 return; 1968 return;
1961 } 1969 }
1962 1970
1963 ephysics_world_lock_take(body->world); 1971 ephysics_world_lock_take(body->world);
1964 _ephysics_body_geometry_set(body, x, y, w, h, 1972 _ephysics_body_geometry_set(body, x, y, z, w, h, d,
1965 ephysics_world_rate_get(body->world)); 1973 ephysics_world_rate_get(body->world));
1966 ephysics_world_lock_release(body->world); 1974 ephysics_world_lock_release(body->world);
1967} 1975}
1968 1976
1969EAPI void 1977EAPI void
1970ephysics_body_resize(EPhysics_Body *body, Evas_Coord w, Evas_Coord h) 1978ephysics_body_resize(EPhysics_Body *body, Evas_Coord w, Evas_Coord h, Evas_Coord d)
1971{ 1979{
1972 if (!body) 1980 if (!body)
1973 { 1981 {
@@ -1975,19 +1983,19 @@ ephysics_body_resize(EPhysics_Body *body, Evas_Coord w, Evas_Coord h)
1975 return; 1983 return;
1976 } 1984 }
1977 1985
1978 if ((w <= 0) || (h <= 0)) 1986 if ((w <= 0) || (h <= 0) || (d <= 0))
1979 { 1987 {
1980 ERR("Width and height must to be a non-null, positive value."); 1988 ERR("Width, height and depth must to be a non-null, positive value.");
1981 return; 1989 return;
1982 } 1990 }
1983 1991
1984 ephysics_world_lock_take(body->world); 1992 ephysics_world_lock_take(body->world);
1985 _ephysics_body_resize(body, w, h); 1993 _ephysics_body_resize(body, w, h, d);
1986 ephysics_world_lock_release(body->world); 1994 ephysics_world_lock_release(body->world);
1987} 1995}
1988 1996
1989EAPI void 1997EAPI void
1990ephysics_body_move(EPhysics_Body *body, Evas_Coord x, Evas_Coord y) 1998ephysics_body_move(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord z)
1991{ 1999{
1992 if (!body) 2000 if (!body)
1993 { 2001 {
@@ -1996,12 +2004,12 @@ ephysics_body_move(EPhysics_Body *body, Evas_Coord x, Evas_Coord y)
1996 } 2004 }
1997 2005
1998 ephysics_world_lock_take(body->world); 2006 ephysics_world_lock_take(body->world);
1999 _ephysics_body_move(body, x, y); 2007 _ephysics_body_move(body, x, y, z);
2000 ephysics_world_lock_release(body->world); 2008 ephysics_world_lock_release(body->world);
2001} 2009}
2002 2010
2003EAPI void 2011EAPI void
2004ephysics_body_geometry_get(const EPhysics_Body *body, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) 2012ephysics_body_geometry_get(const EPhysics_Body *body, Evas_Coord *x, Evas_Coord *y, Evas_Coord *z, Evas_Coord *w, Evas_Coord *h, Evas_Coord *d)
2005{ 2013{
2006 btTransform trans; 2014 btTransform trans;
2007 btVector3 scale; 2015 btVector3 scale;
@@ -2024,8 +2032,10 @@ ephysics_body_geometry_get(const EPhysics_Body *body, Evas_Coord *x, Evas_Coord
2024 if (x) *x = round((trans.getOrigin().getX() - scale.x() / 2) * rate); 2032 if (x) *x = round((trans.getOrigin().getX() - scale.x() / 2) * rate);
2025 if (y) *y = height - round((trans.getOrigin().getY() + scale.y() / 2) 2033 if (y) *y = height - round((trans.getOrigin().getY() + scale.y() / 2)
2026 * rate); 2034 * rate);
2035 if (z) *z = round((trans.getOrigin().getZ() - scale.z() / 2) * rate);
2027 if (w) *w = body->w; 2036 if (w) *w = body->w;
2028 if (h) *h = body->h; 2037 if (h) *h = body->h;
2038 if (d) *d = body->d;
2029} 2039}
2030 2040
2031EAPI void 2041EAPI void
diff --git a/legacy/ephysics/src/lib/ephysics_camera.cpp b/legacy/ephysics/src/lib/ephysics_camera.cpp
index 0f8eda7b70..5d24cfe225 100644
--- a/legacy/ephysics/src/lib/ephysics_camera.cpp
+++ b/legacy/ephysics/src/lib/ephysics_camera.cpp
@@ -36,7 +36,7 @@ ephysics_camera_target_moved(EPhysics_Camera *camera, EPhysics_Body *body)
36{ 36{
37 int x, y, w, h, ww, wh, new_x, new_y; 37 int x, y, w, h, ww, wh, new_x, new_y;
38 38
39 ephysics_body_geometry_get(body, &x, &y, &w, &h); 39 ephysics_body_geometry_get(body, &x, &y, NULL, &w, &h, NULL);
40 ephysics_world_render_geometry_get(camera->world, NULL, NULL, &ww, &wh); 40 ephysics_world_render_geometry_get(camera->world, NULL, NULL, &ww, &wh);
41 41
42 if (camera->track_horizontal) 42 if (camera->track_horizontal)
diff --git a/legacy/ephysics/src/lib/ephysics_private.h b/legacy/ephysics/src/lib/ephysics_private.h
index 5fd51d54ea..1bdf50cd22 100644
--- a/legacy/ephysics/src/lib/ephysics_private.h
+++ b/legacy/ephysics/src/lib/ephysics_private.h
@@ -82,6 +82,7 @@ struct _EPhysics_Body {
82 int walking; 82 int walking;
83 Evas_Coord w; 83 Evas_Coord w;
84 Evas_Coord h; 84 Evas_Coord h;
85 Evas_Coord d;
85 void *data; 86 void *data;
86 Eina_Inlist *callbacks; 87 Eina_Inlist *callbacks;
87 Eina_List *collision_groups; 88 Eina_List *collision_groups;