ephysics: use a common API to add faces for all types

of body




SVN revision: 79042
This commit is contained in:
Bruno Dilly 2012-11-09 18:52:49 +00:00
parent 61d7e5e30e
commit 530c8b4310
2 changed files with 134 additions and 340 deletions

View File

@ -1842,16 +1842,16 @@ typedef enum _EPhysics_Body_Cloth_Anchor_Side
} EPhysics_Body_Cloth_Anchor_Side;
/**
* @enum _EPhysics_Body_Box_Face
* @typedef EPhysics_Body_Box_Face
* @enum _EPhysics_Body_Face
* @typedef EPhysics_Body_Face
*
* Define in wich box's face the evas object should be set.
* Define in wich body's face the evas object should be set.
*
* @see ephysics_body_box_face_evas_object_set()
* @see ephysics_body_face_evas_object_set()
*
* @ingroup EPhysics_Body
*/
typedef enum _EPhysics_Body_Box_Face
typedef enum _EPhysics_Body_Face
{
EPHYSICS_BODY_BOX_FACE_MIDDLE_FRONT,
EPHYSICS_BODY_BOX_FACE_MIDDLE_BACK,
@ -1861,45 +1861,18 @@ typedef enum _EPhysics_Body_Box_Face
EPHYSICS_BODY_BOX_FACE_RIGHT,
EPHYSICS_BODY_BOX_FACE_TOP,
EPHYSICS_BODY_BOX_FACE_BOTTOM,
EPHYSICS_BODY_BOX_FACE_LAST,
} EPhysics_Body_Box_Face;
/**
* @enum _EPhysics_Body_Cylinder_Face
* @typedef EPhysics_Body_Cylinder_Face
*
* Define in wich cylinder's face the evas object should be set.
*
* @see ephysics_body_cylinder_face_evas_object_set()
*
* @ingroup EPhysics_Body
*/
typedef enum _EPhysics_Body_Cylinder_Face
{
EPHYSICS_BODY_CYLINDER_FACE_MIDDLE_FRONT,
EPHYSICS_BODY_CYLINDER_FACE_MIDDLE_BACK,
EPHYSICS_BODY_CYLINDER_FACE_FRONT,
EPHYSICS_BODY_CYLINDER_FACE_BACK,
EPHYSICS_BODY_CYLINDER_FACE_CURVED,
EPHYSICS_BODY_CYLINDER_FACE_LAST,
} EPhysics_Body_Cylinder_Face;
/**
* @enum _EPhysics_Body_Cloth_Face
* @typedef EPhysics_Body_Cloth_Face
*
* Define in wich cloth's face the evas object should be set.
*
* @see ephysics_body_cloth_face_evas_object_set()
*
* @ingroup EPhysics_Body
*/
typedef enum _EPhysics_Body_Cloth_Face
{
EPHYSICS_BODY_CLOTH_FACE_FRONT,
EPHYSICS_BODY_CLOTH_FACE_BACK,
EPHYSICS_BODY_CLOTH_FACE_LAST,
} EPhysics_Body_Cloth_Face;
EPHYSICS_BODY_FACE_LAST,
} EPhysics_Body_Face;
/**
* @typedef EPhysics_Body_Collision
@ -2145,7 +2118,7 @@ EAPI void ephysics_body_soft_body_triangle_move(EPhysics_Body *body, int idx, Ev
*
* @see ephysics_body_del().
* @see ephysics_body_evas_object_set().
* @see ephysics_body_cylinder_face_evas_object_set().
* @see ephysics_body_face_evas_object_set().
*
* @ingroup EPhysics_Body
*/
@ -2176,7 +2149,7 @@ EAPI EPhysics_Body *ephysics_body_circle_add(EPhysics_World *world);
*
* @see ephysics_body_del().
* @see ephysics_body_evas_object_set().
* @see ephysics_body_cylinder_face_evas_object_set().
* @see ephysics_body_face_evas_object_set().
* @see ephysics_world_simulation_set().
*
* @ingroup EPhysics_Body
@ -2198,7 +2171,7 @@ EAPI EPhysics_Body *ephysics_body_soft_circle_add(EPhysics_World *world);
*
* @see ephysics_body_del().
* @see ephysics_body_evas_object_set().
* @see ephysics_body_box_face_evas_object_set().
* @see ephysics_body_face_evas_object_set().
*
* @ingroup EPhysics_Body
*/
@ -2224,7 +2197,7 @@ EAPI EPhysics_Body *ephysics_body_box_add(EPhysics_World *world);
*
* @see ephysics_body_del().
* @see ephysics_body_evas_object_set().
* @see ephysics_body_box_face_evas_object_set().
* @see ephysics_body_face_evas_object_set().
* @see ephysics_world_simulation_set().
*
* @ingroup EPhysics_Body
@ -2254,7 +2227,7 @@ EAPI EPhysics_Body *ephysics_body_soft_box_add(EPhysics_World *world);
*
* @see ephysics_body_del().
* @see ephysics_body_evas_object_set().
* @see ephysics_body_cloth_face_evas_object_set().
* @see ephysics_body_face_evas_object_set().
* @see ephysics_world_simulation_set().
* @see ephysics_body_cloth_anchor_add().
* @see ephysics_body_cloth_anchor_full_add().
@ -2497,10 +2470,7 @@ EAPI EPhysics_World *ephysics_body_world_get(const EPhysics_Body *body);
* evas objects properties under certain conditions of position or rotation.
*
* If it's required to associate evas object to specific faces of the body,
* the following functions could be used, depending on the body's shape:
* @li @ref ephysics_body_box_face_evas_object_set();
* @li @ref ephysics_body_cylinder_face_evas_object_set();
* @li @ref ephysics_body_cloth_face_evas_object_set().
* function @ref ephysics_body_face_evas_object_set() could be used.
*
* @param body The body to associate to an evas object.
* @param evas_obj The evas object that will be associated to this @p body.
@ -2548,7 +2518,7 @@ EAPI Evas_Object *ephysics_body_evas_object_get(const EPhysics_Body *body);
/**
* @brief
* Set an evas object to a physics box body face.
* Set an evas object to a physics body face.
*
* It will create a direct association between a specific face of the physics
* body and an evas object.
@ -2565,165 +2535,44 @@ EAPI Evas_Object *ephysics_body_evas_object_get(const EPhysics_Body *body);
* @param use_obj_pos If @c EINA_TRUE it will set the physics body position
* to match evas object position taking world rate on consideration.
*
* @see ephysics_body_box_face_evas_object_unset().
* @see ephysics_body_box_face_evas_object_get().
* @see ephysics_body_box_add().
* @see ephysics_body_soft_box_add().
* @see ephysics_body_face_evas_object_unset().
* @see ephysics_body_face_evas_object_get().
* @see ephysics_body_evas_object_set().
* @see ephysics_world_rate_set().
*
* @ingroup EPhysics_Body
*/
EAPI void ephysics_body_box_face_evas_object_set(EPhysics_Body *body, EPhysics_Body_Box_Face face, Evas_Object *evas_obj, Eina_Bool use_obj_pos);
EAPI void ephysics_body_face_evas_object_set(EPhysics_Body *body, EPhysics_Body_Face face, Evas_Object *evas_obj, Eina_Bool use_obj_pos);
/**
* @brief
* Get the evas object associated to a physics box body face.
* Get the evas object associated to a physics body face.
*
* @param body The body to get an evas object from.
* @param face The specific face of @p body where the evas object was placed.
* @return The associated evas object, or @c NULL if no object is associated
* or on error.
*
* @see ephysics_body_box_face_evas_object_set() for more details.
* @see ephysics_body_face_evas_object_set() for more details.
*
* @ingroup EPhysics_Body
*/
EAPI Evas_Object *ephysics_body_box_face_evas_object_get(const EPhysics_Body *body, EPhysics_Body_Box_Face face);
EAPI Evas_Object *ephysics_body_face_evas_object_get(const EPhysics_Body *body, EPhysics_Body_Face face);
/**
* @brief
* Unset the evas object associated to a physics box body face.
* Unset the evas object associated to a physics body face.
*
* @param body The body to unset an evas object from.
* @param face The specific face of @p body where the evas object was placed.
* @return The associated evas object, or @c NULL if no object is associated
* or on error.
*
* @see ephysics_body_box_face_evas_object_set() for more details.
* @see ephysics_body_face_evas_object_set() for more details.
*
* @ingroup EPhysics_Body
*/
EAPI Evas_Object *ephysics_body_box_face_evas_object_unset(EPhysics_Body *body, EPhysics_Body_Box_Face face);
/**
* @brief
* Set an evas object to a physics cylinder body face.
*
* It will create a direct association between a specific face of the physics
* body and an evas object.
* With that EPhysics will be able to update evas object
* position and rotation automatically.
*
* If it's required to associate only one evas object to this body, a more
* generic function @see ephysics_body_evas_object_set() can be used.
*
* @param body The body to associate to an evas object.
* @param face The specific face of @p body where the evas object will be
* placed.
* @param evas_obj The evas object that will be associated to this @p body.
* @param use_obj_pos If @c EINA_TRUE it will set the physics body position
* to match evas object position taking world rate on consideration.
*
* @see ephysics_body_cylinder_face_evas_object_unset().
* @see ephysics_body_cylinder_face_evas_object_get().
* @see ephysics_body_circle_add().
* @see ephysics_body_soft_circle_add().
* @see ephysics_body_evas_object_set().
* @see ephysics_world_rate_set().
*
* @ingroup EPhysics_Body
*/
EAPI void ephysics_body_cylinder_face_evas_object_set(EPhysics_Body *body, EPhysics_Body_Cylinder_Face face, Evas_Object *evas_obj, Eina_Bool use_obj_pos);
/**
* @brief
* Get the evas object associated to a physics cylinder body face.
*
* @param body The body to get an evas object from.
* @param face The specific face of @p body where the evas object was placed.
* @return The associated evas object, or @c NULL if no object is associated
* or on error.
*
* @see ephysics_body_cylinder_face_evas_object_set() for more details.
*
* @ingroup EPhysics_Body
*/
EAPI Evas_Object *ephysics_body_cylinder_face_evas_object_get(const EPhysics_Body *body, EPhysics_Body_Cylinder_Face face);
/**
* @brief
* Unset the evas object associated to a physics cylinder body face.
*
* @param body The body to unset an evas object from.
* @param face The specific face of @p body where the evas object was placed.
* @return The associated evas object, or @c NULL if no object is associated
* or on error.
*
* @see ephysics_body_cylinder_face_evas_object_set() for more details.
*
* @ingroup EPhysics_Body
*/
EAPI Evas_Object *ephysics_body_cylinder_face_evas_object_unset(EPhysics_Body *body, EPhysics_Body_Cylinder_Face face);
/**
* @brief
* Set an evas object to a physics cloth body face.
*
* It will create a direct association between a specific face of the physics
* body and an evas object.
* With that EPhysics will be able to update evas object
* position and rotation automatically.
*
* If it's required to associate only one evas object to this body, a more
* generic function @see ephysics_body_evas_object_set() can be used.
*
* @param body The body to associate to an evas object.
* @param face The specific face of @p body where the evas object will be
* placed.
* @param evas_obj The evas object that will be associated to this @p body.
* @param use_obj_pos If @c EINA_TRUE it will set the physics body position
* to match evas object position taking world rate on consideration.
*
* @see ephysics_body_cloth_face_evas_object_unset().
* @see ephysics_body_cloth_face_evas_object_get().
* @see ephysics_body_cloth_add().
* @see ephysics_body_evas_object_set().
* @see ephysics_world_rate_set().
*
* @ingroup EPhysics_Body
*/
EAPI void ephysics_body_cloth_face_evas_object_set(EPhysics_Body *body, EPhysics_Body_Cloth_Face face, Evas_Object *evas_obj, Eina_Bool use_obj_pos);
/**
* @brief
* Get the evas object associated to a physics cloth body face.
*
* @param body The body to get an evas object from.
* @param face The specific face of @p body where the evas object was placed.
* @return The associated evas object, or @c NULL if no object is associated
* or on error.
*
* @see ephysics_body_cloth_face_evas_object_set() for more details.
*
* @ingroup EPhysics_Body
*/
EAPI Evas_Object *ephysics_body_cloth_face_evas_object_get(const EPhysics_Body *body, EPhysics_Body_Cloth_Face face);
/**
* @brief
* Unset the evas object associated to a physics cloth body face.
*
* @param body The body to unset an evas object from.
* @param face The specific face of @p body where the evas object was placed.
* @return The associated evas object, or @c NULL if no object is associated
* or on error.
*
* @see ephysics_body_cloth_face_evas_object_set() for more details.
*
* @ingroup EPhysics_Body
*/
EAPI Evas_Object *ephysics_body_cloth_face_evas_object_unset(EPhysics_Body *body, EPhysics_Body_Cloth_Face face);
EAPI Evas_Object *ephysics_body_face_evas_object_unset(EPhysics_Body *body, EPhysics_Body_Face face);
/**
* @brief

View File

@ -57,7 +57,7 @@ struct _EPhysics_Body_Soft_Body_Slice
};
struct _EPhysics_Body_Face_Obj {
int face;
EPhysics_Body_Face face;
Evas_Object *obj;
};
@ -3444,7 +3444,7 @@ _ephysics_body_face_obj_unset(Evas_Object *obj, Evas_Object_Event_Cb resize_func
}
static void
_ephysics_body_face_evas_object_add(EPhysics_Body *body, int face, Evas_Object *evas_obj, Evas_Object_Event_Cb resize_func)
_ephysics_body_face_evas_object_add(EPhysics_Body *body, EPhysics_Body_Face face, Evas_Object *evas_obj, Evas_Object_Event_Cb resize_func)
{
EPhysics_Body_Face_Obj *face_obj;
Eina_List *l;
@ -3477,7 +3477,7 @@ _ephysics_body_face_evas_object_add(EPhysics_Body *body, int face, Evas_Object *
static void
_ephysics_body_box_face_obj_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
{
EPhysics_Body_Box_Face face = EPHYSICS_BODY_BOX_FACE_LAST;
EPhysics_Body_Face face = EPHYSICS_BODY_FACE_LAST;
EPhysics_Body *body = (EPhysics_Body *) data;
EPhysics_Body_Face_Obj *face_obj;
int w, h, bw, bh, bd;
@ -3490,7 +3490,7 @@ _ephysics_body_box_face_obj_resize_cb(void *data, Evas *e __UNUSED__, Evas_Objec
face_obj = (EPhysics_Body_Face_Obj *)ldata;
if (face_obj->obj == obj)
{
face = (EPhysics_Body_Box_Face) face_obj->face;
face = face_obj->face;
break;
}
}
@ -3531,31 +3531,14 @@ _ephysics_body_box_face_obj_resize_cb(void *data, Evas *e __UNUSED__, Evas_Objec
ephysics_world_lock_release(body->world);
}
EAPI void
ephysics_body_box_face_evas_object_set(EPhysics_Body *body, EPhysics_Body_Box_Face face, Evas_Object *evas_obj, Eina_Bool use_obj_pos)
static void
_ephysics_body_box_face_evas_object_set(EPhysics_Body *body, EPhysics_Body_Face face, Evas_Object *evas_obj, Eina_Bool use_obj_pos)
{
int obj_x, obj_y, obj_w, obj_h, bx, by, bz, bw, bh, bd;
double rate;
if (!body)
{
ERR("Can't set evas object to body, the last wasn't provided.");
return;
}
if (!evas_obj)
{
ERR("Can't set evas object to body, the first wasn't provided.");
return;
}
if ((strcmp(body->collision_shape->getName(), SHAPE_BOX)))
{
ERR("Can't set evas object to body, it's not a box.");
return;
}
if ((face < 0) || (face >= EPHYSICS_BODY_BOX_FACE_LAST))
if ((face < EPHYSICS_BODY_BOX_FACE_MIDDLE_FRONT) ||
(face > EPHYSICS_BODY_BOX_FACE_BOTTOM))
{
ERR("Can't set evas object to body, face is invalid.");
return;
@ -3608,26 +3591,15 @@ ephysics_body_box_face_evas_object_set(EPhysics_Body *body, EPhysics_Body_Box_Fa
body);
}
EAPI Evas_Object *
ephysics_body_box_face_evas_object_get(const EPhysics_Body *body, EPhysics_Body_Box_Face face)
static Evas_Object *
_ephysics_body_box_face_evas_object_get(const EPhysics_Body *body, EPhysics_Body_Face face)
{
EPhysics_Body_Face_Obj *face_obj;
Eina_List *l;
void *ldata;
if (!body)
{
ERR("Can't get evas object from body, it wasn't provided.");
return NULL;
}
if (strcmp(body->collision_shape->getName(), SHAPE_BOX))
{
ERR("Can't get evas object from body, it's not a box.");
return NULL;
}
if ((face < 0) || (face >= EPHYSICS_BODY_BOX_FACE_LAST))
if ((face < EPHYSICS_BODY_BOX_FACE_MIDDLE_FRONT) ||
(face > EPHYSICS_BODY_BOX_FACE_BOTTOM))
{
ERR("Can't get evas object from body, face is invalid.");
return NULL;
@ -3644,26 +3616,15 @@ ephysics_body_box_face_evas_object_get(const EPhysics_Body *body, EPhysics_Body_
return NULL;
}
EAPI Evas_Object *
ephysics_body_box_face_evas_object_unset(EPhysics_Body *body, EPhysics_Body_Box_Face face)
static Evas_Object *
_ephysics_body_box_face_evas_object_unset(EPhysics_Body *body, EPhysics_Body_Face face)
{
EPhysics_Body_Face_Obj *face_obj;
Eina_List *l;
void *ldata;
if (!body)
{
ERR("Can't unset evas object from body, it wasn't provided.");
return NULL;
}
if (strcmp(body->collision_shape->getName(), SHAPE_BOX))
{
ERR("Can't unset evas object from body, it's not a box.");
return NULL;
}
if ((face < 0) || (face >= EPHYSICS_BODY_BOX_FACE_LAST))
if ((face < EPHYSICS_BODY_BOX_FACE_MIDDLE_FRONT) ||
(face > EPHYSICS_BODY_BOX_FACE_BOTTOM))
{
ERR("Can't unset evas object from body, face is invalid.");
return NULL;
@ -3690,7 +3651,7 @@ ephysics_body_box_face_evas_object_unset(EPhysics_Body *body, EPhysics_Body_Box_
static void
_ephysics_body_cylinder_face_obj_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
{
EPhysics_Body_Cylinder_Face face = EPHYSICS_BODY_CYLINDER_FACE_LAST;
EPhysics_Body_Face face = EPHYSICS_BODY_FACE_LAST;
EPhysics_Body *body = (EPhysics_Body *) data;
EPhysics_Body_Face_Obj *face_obj;
int w, h, bw, bh, bd;
@ -3703,7 +3664,7 @@ _ephysics_body_cylinder_face_obj_resize_cb(void *data, Evas *e __UNUSED__, Evas_
face_obj = (EPhysics_Body_Face_Obj *)ldata;
if (face_obj->obj == obj)
{
face = (EPhysics_Body_Cylinder_Face) face_obj->face;
face = face_obj->face;
break;
}
}
@ -3736,31 +3697,14 @@ _ephysics_body_cylinder_face_obj_resize_cb(void *data, Evas *e __UNUSED__, Evas_
ephysics_world_lock_release(body->world);
}
EAPI void
ephysics_body_cylinder_face_evas_object_set(EPhysics_Body *body, EPhysics_Body_Cylinder_Face face, Evas_Object *evas_obj, Eina_Bool use_obj_pos)
static void
_ephysics_body_cylinder_face_evas_object_set(EPhysics_Body *body, EPhysics_Body_Face face, Evas_Object *evas_obj, Eina_Bool use_obj_pos)
{
int obj_x, obj_y, obj_w, obj_h, bx, by, bz, bw, bh, bd;
double rate;
if (!body)
{
ERR("Can't set evas object to body, the last wasn't provided.");
return;
}
if (!evas_obj)
{
ERR("Can't set evas object to body, the first wasn't provided.");
return;
}
if (strcmp(body->collision_shape->getName(), SHAPE_CYLINDER))
{
ERR("Can't set evas object to body, it's not a cylinder.");
return;
}
if ((face < 0) || (face >= EPHYSICS_BODY_CYLINDER_FACE_LAST))
if ((face < EPHYSICS_BODY_CYLINDER_FACE_MIDDLE_FRONT) ||
(face > EPHYSICS_BODY_CYLINDER_FACE_CURVED))
{
ERR("Can't set evas object to body, face is invalid.");
return;
@ -3808,26 +3752,15 @@ ephysics_body_cylinder_face_evas_object_set(EPhysics_Body *body, EPhysics_Body_C
body);
}
EAPI Evas_Object *
ephysics_body_cylinder_face_evas_object_get(const EPhysics_Body *body, EPhysics_Body_Cylinder_Face face)
static Evas_Object *
_ephysics_body_cylinder_face_evas_object_get(const EPhysics_Body *body, EPhysics_Body_Face face)
{
EPhysics_Body_Face_Obj *face_obj;
Eina_List *l;
void *ldata;
if (!body)
{
ERR("Can't get evas object from body, it wasn't provided.");
return NULL;
}
if (strcmp(body->collision_shape->getName(), SHAPE_CYLINDER))
{
ERR("Can't get evas object from body, it's not a cylinder.");
return NULL;
}
if ((face < 0) || (face >= EPHYSICS_BODY_CYLINDER_FACE_LAST))
if ((face < EPHYSICS_BODY_CYLINDER_FACE_MIDDLE_FRONT) ||
(face > EPHYSICS_BODY_CYLINDER_FACE_CURVED))
{
ERR("Can't get evas object from body, face is invalid.");
return NULL;
@ -3844,26 +3777,15 @@ ephysics_body_cylinder_face_evas_object_get(const EPhysics_Body *body, EPhysics_
return NULL;
}
EAPI Evas_Object *
ephysics_body_cylinder_face_evas_object_unset(EPhysics_Body *body, EPhysics_Body_Cylinder_Face face)
static Evas_Object *
_ephysics_body_cylinder_face_evas_object_unset(EPhysics_Body *body, EPhysics_Body_Face face)
{
EPhysics_Body_Face_Obj *face_obj;
Eina_List *l;
void *ldata;
if (!body)
{
ERR("Can't unset evas object from body, it wasn't provided.");
return NULL;
}
if (strcmp(body->collision_shape->getName(), SHAPE_CYLINDER))
{
ERR("Can't unset evas object from body, it's not a cylinder.");
return NULL;
}
if ((face < 0) || (face >= EPHYSICS_BODY_CYLINDER_FACE_LAST))
if ((face < EPHYSICS_BODY_CYLINDER_FACE_MIDDLE_FRONT) ||
(face > EPHYSICS_BODY_CYLINDER_FACE_CURVED))
{
ERR("Can't unset evas object from body, face is invalid.");
return NULL;
@ -3887,42 +3809,19 @@ ephysics_body_cylinder_face_evas_object_unset(EPhysics_Body *body, EPhysics_Body
return NULL;
}
EAPI void
ephysics_body_cloth_face_evas_object_set(EPhysics_Body *body, EPhysics_Body_Cloth_Face face, Evas_Object *evas_obj, Eina_Bool use_obj_pos)
static void
_ephysics_body_cloth_face_evas_object_set(EPhysics_Body *body, EPhysics_Body_Face face, Evas_Object *evas_obj, Eina_Bool use_obj_pos)
{
int obj_x, obj_y, obj_w, obj_h, bz, bd;
double rate;
if (!body)
{
ERR("Can't set evas object to body, the last wasn't provided.");
return;
}
if (!evas_obj)
{
ERR("Can't set evas object to body, the first wasn't provided.");
return;
}
if (body->type != EPHYSICS_BODY_TYPE_CLOTH)
{
ERR("Can't set evas object to body, it's not a cloth.");
return;
}
if ((face < 0) || (face >= EPHYSICS_BODY_CLOTH_FACE_LAST))
if ((face < EPHYSICS_BODY_CLOTH_FACE_FRONT) ||
(face > EPHYSICS_BODY_CLOTH_FACE_BACK))
{
ERR("Can't set evas object to body, face is invalid.");
return;
}
if (body->soft_body)
{
ERR("Not implemented for soft bodies yet.");
return;
}
_ephysics_body_face_evas_object_add(body, face, evas_obj,
_ephysics_body_evas_obj_resize_cb);
evas_object_event_callback_add(evas_obj, EVAS_CALLBACK_DEL,
@ -3943,26 +3842,15 @@ ephysics_body_cloth_face_evas_object_set(EPhysics_Body *body, EPhysics_Body_Clot
body);
}
EAPI Evas_Object *
ephysics_body_cloth_face_evas_object_get(const EPhysics_Body *body, EPhysics_Body_Cloth_Face face)
static Evas_Object *
_ephysics_body_cloth_face_evas_object_get(const EPhysics_Body *body, EPhysics_Body_Face face)
{
EPhysics_Body_Face_Obj *face_obj;
Eina_List *l;
void *ldata;
if (!body)
{
ERR("Can't get evas object from body, it wasn't provided.");
return NULL;
}
if (body->type != EPHYSICS_BODY_TYPE_CLOTH)
{
ERR("Can't get evas object from body, it's not a cloth.");
return NULL;
}
if ((face < 0) || (face >= EPHYSICS_BODY_CLOTH_FACE_LAST))
if ((face < EPHYSICS_BODY_CLOTH_FACE_FRONT) ||
(face > EPHYSICS_BODY_CLOTH_FACE_BACK))
{
ERR("Can't get evas object from body, face is invalid.");
return NULL;
@ -3979,26 +3867,15 @@ ephysics_body_cloth_face_evas_object_get(const EPhysics_Body *body, EPhysics_Bod
return NULL;
}
EAPI Evas_Object *
ephysics_body_cloth_face_evas_object_unset(EPhysics_Body *body, EPhysics_Body_Cloth_Face face)
static Evas_Object *
_ephysics_body_cloth_face_evas_object_unset(EPhysics_Body *body, EPhysics_Body_Face face)
{
EPhysics_Body_Face_Obj *face_obj;
Eina_List *l;
void *ldata;
if (!body)
{
ERR("Can't unset evas object from body, it wasn't provided.");
return NULL;
}
if (body->type != EPHYSICS_BODY_TYPE_CLOTH)
{
ERR("Can't unset evas object from body, it's not a cloth.");
return NULL;
}
if ((face < 0) || (face >= EPHYSICS_BODY_CLOTH_FACE_LAST))
if ((face < EPHYSICS_BODY_CLOTH_FACE_FRONT) ||
(face > EPHYSICS_BODY_CLOTH_FACE_BACK))
{
ERR("Can't unset evas object from body, face is invalid.");
return NULL;
@ -4022,6 +3899,74 @@ ephysics_body_cloth_face_evas_object_unset(EPhysics_Body *body, EPhysics_Body_Cl
return NULL;
}
EAPI void
ephysics_body_face_evas_object_set(EPhysics_Body *body, EPhysics_Body_Face face, Evas_Object *evas_obj, Eina_Bool use_obj_pos)
{
if (!body)
{
ERR("Can't set evas object to body, the last wasn't provided.");
return;
}
if (!evas_obj)
{
ERR("Can't set evas object to body, the first wasn't provided.");
return;
}
if (body->type == EPHYSICS_BODY_TYPE_CLOTH)
return _ephysics_body_cloth_face_evas_object_set(body, face, evas_obj,
use_obj_pos);
if (strcmp(body->collision_shape->getName(), SHAPE_CYLINDER))
return _ephysics_body_cylinder_face_evas_object_set(body, face, evas_obj,
use_obj_pos);
if (strcmp(body->collision_shape->getName(), SHAPE_BOX))
return _ephysics_body_box_face_evas_object_set(body, face, evas_obj,
use_obj_pos);
ERR("Can't handle body %p type.", body);
}
EAPI Evas_Object *
ephysics_body_face_evas_object_get(const EPhysics_Body *body, EPhysics_Body_Face face)
{
if (!body)
{
ERR("Can't get evas object from body, it wasn't provided.");
return NULL;
}
if (body->type == EPHYSICS_BODY_TYPE_CLOTH)
return _ephysics_body_cloth_face_evas_object_get(body, face);
if (strcmp(body->collision_shape->getName(), SHAPE_CYLINDER))
return _ephysics_body_cylinder_face_evas_object_get(body, face);
if (strcmp(body->collision_shape->getName(), SHAPE_BOX))
return _ephysics_body_box_face_evas_object_get(body, face);
ERR("Can't handle body %p type.", body);
return NULL;
}
EAPI Evas_Object *
ephysics_body_face_evas_object_unset(EPhysics_Body *body, EPhysics_Body_Face face)
{
if (!body)
{
ERR("Can't unset evas object from body, it wasn't provided.");
return NULL;
}
if (body->type == EPHYSICS_BODY_TYPE_CLOTH)
return _ephysics_body_cloth_face_evas_object_unset(body, face);
if (strcmp(body->collision_shape->getName(), SHAPE_CYLINDER))
return _ephysics_body_cylinder_face_evas_object_unset(body, face);
if (strcmp(body->collision_shape->getName(), SHAPE_BOX))
return _ephysics_body_box_face_evas_object_unset(body, face);
ERR("Can't handle body %p type.", body);
return NULL;
}
#ifdef __cplusplus
}
#endif