summaryrefslogtreecommitdiff
path: root/legacy/ephysics
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2012-10-10 19:17:13 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-10-10 19:17:13 +0000
commitf7c20099107400f6fa6c8424b6fd0be3735fe242 (patch)
tree79f90ea707ec91c8e2302d5af49af362ceb9f071 /legacy/ephysics
parent8b9c28f003e65d0a68b1a7830d4e4f012dd32453 (diff)
ephysics: collision detection inform z coordinate
SVN revision: 77778
Diffstat (limited to 'legacy/ephysics')
-rw-r--r--legacy/ephysics/src/bin/test_collision_detection.c6
-rw-r--r--legacy/ephysics/src/lib/EPhysics.h7
-rw-r--r--legacy/ephysics/src/lib/ephysics_body.cpp5
3 files changed, 11 insertions, 7 deletions
diff --git a/legacy/ephysics/src/bin/test_collision_detection.c b/legacy/ephysics/src/bin/test_collision_detection.c
index 31409dbbed..6aa8d83beb 100644
--- a/legacy/ephysics/src/bin/test_collision_detection.c
+++ b/legacy/ephysics/src/bin/test_collision_detection.c
@@ -19,18 +19,18 @@ _collision_cb(void *data, EPhysics_Body *body __UNUSED__, void *event_info)
19 EPhysics_Body *contact_body; 19 EPhysics_Body *contact_body;
20 Collision_Data *collision_data = data; 20 Collision_Data *collision_data = data;
21 EPhysics_Body_Collision *collision = event_info; 21 EPhysics_Body_Collision *collision = event_info;
22 int x, y; 22 int x, y, z;
23 23
24 contact_body = ephysics_body_collision_contact_body_get(collision); 24 contact_body = ephysics_body_collision_contact_body_get(collision);
25 if (contact_body != collision_data->sphere2) return; 25 if (contact_body != collision_data->sphere2) return;
26 26
27 ephysics_body_collision_position_get(collision, &x, &y); 27 ephysics_body_collision_position_get(collision, &x, &y, &z);
28 28
29 evas_object_move(collision_data->impact, x - 10, y - 40); 29 evas_object_move(collision_data->impact, x - 10, y - 40);
30 elm_object_signal_emit(collision_data->impact, "impact,show", 30 elm_object_signal_emit(collision_data->impact, "impact,show",
31 "ephysics_test"); 31 "ephysics_test");
32 32
33 INF("Collision Detected at (%i, %i)", x, y); 33 INF("Collision Detected at (%i, %i, %i)", x, y, z);
34} 34}
35 35
36static void 36static void
diff --git a/legacy/ephysics/src/lib/EPhysics.h b/legacy/ephysics/src/lib/EPhysics.h
index ce18b5474b..1c1e90c5c2 100644
--- a/legacy/ephysics/src/lib/EPhysics.h
+++ b/legacy/ephysics/src/lib/EPhysics.h
@@ -2489,14 +2489,15 @@ EAPI void *ephysics_body_event_callback_del_full(EPhysics_Body *body, EPhysics_C
2489 * where the collision occurred. 2489 * where the collision occurred.
2490 * 2490 *
2491 * @param collision The body collision data of interest. 2491 * @param collision The body collision data of interest.
2492 * @param x The x pointer to set the x coordinate to. 2492 * @param x The x coordinate of collision point, in pixels.
2493 * @param y The y pointer to set the y coordinate to. 2493 * @param y The y coordinate of collision point, in pixels.
2494 * @param z The z coordinate of collision point, in pixels.
2494 * 2495 *
2495 * @see EPHYSICS_CALLBACK_BODY_COLLISION and @ref 2496 * @see EPHYSICS_CALLBACK_BODY_COLLISION and @ref
2496 * ephysics_body_event_callback_add() for collision callback. 2497 * ephysics_body_event_callback_add() for collision callback.
2497 * @ingroup EPhysics_Body 2498 * @ingroup EPhysics_Body
2498 */ 2499 */
2499EAPI void ephysics_body_collision_position_get(const EPhysics_Body_Collision *collision, Evas_Coord *x, Evas_Coord *y); 2500EAPI void ephysics_body_collision_position_get(const EPhysics_Body_Collision *collision, Evas_Coord *x, Evas_Coord *y, Evas_Coord *z);
2500 2501
2501/** 2502/**
2502 * @brief 2503 * @brief
diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp
index a3eb2376f4..7ed117bca4 100644
--- a/legacy/ephysics/src/lib/ephysics_body.cpp
+++ b/legacy/ephysics/src/lib/ephysics_body.cpp
@@ -30,6 +30,7 @@ struct _EPhysics_Body_Collision {
30 EPhysics_Body *contact_body; 30 EPhysics_Body *contact_body;
31 Evas_Coord x; 31 Evas_Coord x;
32 Evas_Coord y; 32 Evas_Coord y;
33 Evas_Coord z;
33}; 34};
34 35
35typedef struct _EPhysics_Body_Soft_Body_Slice 36typedef struct _EPhysics_Body_Soft_Body_Slice
@@ -1116,7 +1117,7 @@ ephysics_body_evas_object_update_select(EPhysics_Body *body)
1116} 1117}
1117 1118
1118EAPI void 1119EAPI void
1119ephysics_body_collision_position_get(const EPhysics_Body_Collision *collision, Evas_Coord *x, Evas_Coord *y) 1120ephysics_body_collision_position_get(const EPhysics_Body_Collision *collision, Evas_Coord *x, Evas_Coord *y, Evas_Coord *z)
1120{ 1121{
1121 if (!collision) 1122 if (!collision)
1122 { 1123 {
@@ -1126,6 +1127,7 @@ ephysics_body_collision_position_get(const EPhysics_Body_Collision *collision, E
1126 1127
1127 if (x) *x = collision->x; 1128 if (x) *x = collision->x;
1128 if (y) *y = collision->y; 1129 if (y) *y = collision->y;
1130 if (z) *z = collision->z;
1129} 1131}
1130 1132
1131EAPI EPhysics_Body * 1133EAPI EPhysics_Body *
@@ -1167,6 +1169,7 @@ ephysics_body_contact_processed(EPhysics_Body *body, EPhysics_Body *contact_body
1167 collision->contact_body = contact_body; 1169 collision->contact_body = contact_body;
1168 collision->x = position.getX() * rate; 1170 collision->x = position.getX() * rate;
1169 collision->y = wh + wy - (position.getY() * rate); 1171 collision->y = wh + wy - (position.getY() * rate);
1172 collision->z = position.getZ() * rate;
1170 1173
1171 _ephysics_body_event_callback_call(body, EPHYSICS_CALLBACK_BODY_COLLISION, 1174 _ephysics_body_event_callback_call(body, EPHYSICS_CALLBACK_BODY_COLLISION,
1172 (void *) collision); 1175 (void *) collision);