summaryrefslogtreecommitdiff
path: root/legacy/ephysics/src/lib/ephysics_body.cpp
diff options
context:
space:
mode:
authorLeandro Dorileo <dorileo@profusion.mobi>2012-11-23 21:51:44 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-11-23 21:51:44 +0000
commitecd61b29afe35de33bf6430ac8277435c2713a10 (patch)
tree72b9ba4a25d2fda002ba3804f79de1e6baef1159 /legacy/ephysics/src/lib/ephysics_body.cpp
parent0e3e700e5278df23ea1aa7914c6a4199951bb0d6 (diff)
EPhysics: add api to get the slice index based on its
evas object Patch by: Leandro Dorileo <dorileo@profusion.mobi> SVN revision: 79604
Diffstat (limited to '')
-rw-r--r--legacy/ephysics/src/lib/ephysics_body.cpp65
1 files changed, 48 insertions, 17 deletions
diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp
index 8085df9446..6119d4fa25 100644
--- a/legacy/ephysics/src/lib/ephysics_body.cpp
+++ b/legacy/ephysics/src/lib/ephysics_body.cpp
@@ -205,6 +205,54 @@ _ephysics_body_soft_body_slice_new(EPhysics_Body *body, double delta, double max
205 return slice; 205 return slice;
206} 206}
207 207
208static Eina_List *
209_ephysics_body_soft_body_slices_get(EPhysics_Body *body)
210{
211 Eina_List *l, *slices_list, *slices = NULL;
212 void *ldata, *slice_data;
213 EPhysics_Body_Face_Slice *face_slice;
214
215 EINA_LIST_FOREACH(body->faces_slices, l, ldata)
216 {
217 face_slice = (EPhysics_Body_Face_Slice *)ldata;
218 EINA_LIST_FOREACH(face_slice->slices, slices_list, slice_data)
219 slices = eina_list_append(slices, slice_data);
220 }
221
222 return slices;
223}
224
225EAPI int
226ephysics_body_soft_body_slice_index_get(EPhysics_Body *body, Evas_Object *slice)
227{
228 Eina_List *slices;
229 void *ldata;
230 EPhysics_Body_Soft_Body_Slice *slice_data;
231
232 if (!body)
233 {
234 ERR("Can't get soft body slice index, body is null.");
235 return -1;
236 }
237
238 if (body->type == EPHYSICS_BODY_TYPE_RIGID)
239 {
240 ERR("Can't get soft body slice index, operation not allowed for rigid"
241 " bodies.");
242 return -1;
243 }
244
245 slices = _ephysics_body_soft_body_slices_get(body);
246 EINA_LIST_FREE(slices, ldata)
247 {
248 slice_data = (EPhysics_Body_Soft_Body_Slice *)ldata;
249 if (slice_data->evas_obj == slice)
250 return slice_data->index;
251 }
252
253 return -1;
254}
255
208static void 256static void
209_ephysics_body_soft_body_slices_init(EPhysics_Body *body, Evas_Object *obj, Eina_List *slices) 257_ephysics_body_soft_body_slices_init(EPhysics_Body *body, Evas_Object *obj, Eina_List *slices)
210{ 258{
@@ -333,23 +381,6 @@ _ephysics_body_evas_stacking_new(Evas_Object *obj, float index)
333 return stacking; 381 return stacking;
334} 382}
335 383
336static Eina_List *
337_ephysics_body_soft_body_slices_get(EPhysics_Body *body)
338{
339 Eina_List *l, *slices_list, *slices = NULL;
340 void *ldata, *slice_data;
341 EPhysics_Body_Face_Slice *face_slice;
342
343 EINA_LIST_FOREACH(body->faces_slices, l, ldata)
344 {
345 face_slice = (EPhysics_Body_Face_Slice *)ldata;
346 EINA_LIST_FOREACH(face_slice->slices, slices_list, slice_data)
347 slices = eina_list_append(slices, slice_data);
348 }
349
350 return slices;
351}
352
353void 384void
354ephysics_body_evas_objects_restack(EPhysics_World *world) 385ephysics_body_evas_objects_restack(EPhysics_World *world)
355{ 386{