forked from enlightenment/efl
EPhysics: add api to get the slice index based on its
evas object Patch by: Leandro Dorileo <dorileo@profusion.mobi> SVN revision: 79604
This commit is contained in:
parent
0e3e700e52
commit
ecd61b29af
|
@ -2386,6 +2386,24 @@ EAPI void ephysics_body_soft_body_dragging_unset(EPhysics_Body *body);
|
||||||
*/
|
*/
|
||||||
EAPI int ephysics_body_soft_body_triangle_index_get(EPhysics_Body *body, Evas_Coord x, Evas_Coord y);
|
EAPI int ephysics_body_soft_body_triangle_index_get(EPhysics_Body *body, Evas_Coord x, Evas_Coord y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* Get the slice index of a soft body based on its slice`s Evas Object.
|
||||||
|
*
|
||||||
|
* Registering a mouse event callback on an associated evas object one can get
|
||||||
|
* the clicked slice evas object. With that pointer the user can get the slice
|
||||||
|
* index based on its related evas object.
|
||||||
|
*
|
||||||
|
* @param body The body to get the slice index from.
|
||||||
|
* @param slice The slice evas object.
|
||||||
|
* @return The slice index on success, -1 otherwise.
|
||||||
|
*
|
||||||
|
* @see ephysics_body_soft_body_triangle_index_get().
|
||||||
|
*
|
||||||
|
* @ingroup EPhysics_Body
|
||||||
|
*/
|
||||||
|
EAPI int ephysics_body_soft_body_slice_index_get(EPhysics_Body *body, Evas_Object *slice);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
* Add a soft ellipsoid.
|
* Add a soft ellipsoid.
|
||||||
|
|
|
@ -205,6 +205,54 @@ _ephysics_body_soft_body_slice_new(EPhysics_Body *body, double delta, double max
|
||||||
return slice;
|
return slice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Eina_List *
|
||||||
|
_ephysics_body_soft_body_slices_get(EPhysics_Body *body)
|
||||||
|
{
|
||||||
|
Eina_List *l, *slices_list, *slices = NULL;
|
||||||
|
void *ldata, *slice_data;
|
||||||
|
EPhysics_Body_Face_Slice *face_slice;
|
||||||
|
|
||||||
|
EINA_LIST_FOREACH(body->faces_slices, l, ldata)
|
||||||
|
{
|
||||||
|
face_slice = (EPhysics_Body_Face_Slice *)ldata;
|
||||||
|
EINA_LIST_FOREACH(face_slice->slices, slices_list, slice_data)
|
||||||
|
slices = eina_list_append(slices, slice_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return slices;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI int
|
||||||
|
ephysics_body_soft_body_slice_index_get(EPhysics_Body *body, Evas_Object *slice)
|
||||||
|
{
|
||||||
|
Eina_List *slices;
|
||||||
|
void *ldata;
|
||||||
|
EPhysics_Body_Soft_Body_Slice *slice_data;
|
||||||
|
|
||||||
|
if (!body)
|
||||||
|
{
|
||||||
|
ERR("Can't get soft body slice index, body is null.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body->type == EPHYSICS_BODY_TYPE_RIGID)
|
||||||
|
{
|
||||||
|
ERR("Can't get soft body slice index, operation not allowed for rigid"
|
||||||
|
" bodies.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
slices = _ephysics_body_soft_body_slices_get(body);
|
||||||
|
EINA_LIST_FREE(slices, ldata)
|
||||||
|
{
|
||||||
|
slice_data = (EPhysics_Body_Soft_Body_Slice *)ldata;
|
||||||
|
if (slice_data->evas_obj == slice)
|
||||||
|
return slice_data->index;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ephysics_body_soft_body_slices_init(EPhysics_Body *body, Evas_Object *obj, Eina_List *slices)
|
_ephysics_body_soft_body_slices_init(EPhysics_Body *body, Evas_Object *obj, Eina_List *slices)
|
||||||
{
|
{
|
||||||
|
@ -333,23 +381,6 @@ _ephysics_body_evas_stacking_new(Evas_Object *obj, float index)
|
||||||
return stacking;
|
return stacking;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_List *
|
|
||||||
_ephysics_body_soft_body_slices_get(EPhysics_Body *body)
|
|
||||||
{
|
|
||||||
Eina_List *l, *slices_list, *slices = NULL;
|
|
||||||
void *ldata, *slice_data;
|
|
||||||
EPhysics_Body_Face_Slice *face_slice;
|
|
||||||
|
|
||||||
EINA_LIST_FOREACH(body->faces_slices, l, ldata)
|
|
||||||
{
|
|
||||||
face_slice = (EPhysics_Body_Face_Slice *)ldata;
|
|
||||||
EINA_LIST_FOREACH(face_slice->slices, slices_list, slice_data)
|
|
||||||
slices = eina_list_append(slices, slice_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return slices;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ephysics_body_evas_objects_restack(EPhysics_World *world)
|
ephysics_body_evas_objects_restack(EPhysics_World *world)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue