EPhysics: soft_circle and soft_ellipsoid renaming

For sake of consistency moving soft_circle to soft_cylinder and
soft_ellipsoid becomes soft_sphere. Their face identification were
moved as well. The faces identifications were also unified.


SVN revision: 80720
This commit is contained in:
Leandro Dorileo 2012-12-11 21:11:19 +00:00
parent 2ccf6d2a11
commit 547ade5f6c
7 changed files with 90 additions and 93 deletions

View File

@ -139,7 +139,7 @@ _type_set_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
if (elm_radio_value_get(obj)) if (elm_radio_value_get(obj))
{ {
body = ephysics_body_soft_circle_add(world); body = ephysics_body_soft_cylinder_add(world);
ephysics_body_soft_body_hardness_set( ephysics_body_soft_body_hardness_set(
body, elm_slider_value_get(bd->controls.hardness)); body, elm_slider_value_get(bd->controls.hardness));
elm_object_disabled_set(bd->controls.hardness, EINA_FALSE); elm_object_disabled_set(bd->controls.hardness, EINA_FALSE);

View File

@ -26,7 +26,7 @@ _world_populate(Test_Data *test_data)
evas_object_show(evas_obj); evas_object_show(evas_obj);
test_data->evas_objs = eina_list_append(test_data->evas_objs, evas_obj); test_data->evas_objs = eina_list_append(test_data->evas_objs, evas_obj);
fall_body = ephysics_body_soft_circle_add(test_data->world); fall_body = ephysics_body_soft_cylinder_add(test_data->world);
ephysics_body_soft_body_hardness_set(fall_body, 10); ephysics_body_soft_body_hardness_set(fall_body, 10);
ephysics_body_evas_object_set(fall_body, evas_obj, EINA_TRUE); ephysics_body_evas_object_set(fall_body, evas_obj, EINA_TRUE);
ephysics_body_restitution_set(fall_body, 0.95); ephysics_body_restitution_set(fall_body, 0.95);
@ -51,7 +51,7 @@ _world_populate(Test_Data *test_data)
evas_object_show(evas_obj); evas_object_show(evas_obj);
test_data->evas_objs = eina_list_append(test_data->evas_objs, evas_obj); test_data->evas_objs = eina_list_append(test_data->evas_objs, evas_obj);
fall_body = ephysics_body_soft_circle_add(test_data->world); fall_body = ephysics_body_soft_cylinder_add(test_data->world);
ephysics_body_soft_body_hardness_set(fall_body, 30); ephysics_body_soft_body_hardness_set(fall_body, 30);
ephysics_body_evas_object_set(fall_body, evas_obj, EINA_TRUE); ephysics_body_evas_object_set(fall_body, evas_obj, EINA_TRUE);
ephysics_body_restitution_set(fall_body, 0.95); ephysics_body_restitution_set(fall_body, 0.95);

View File

@ -30,24 +30,24 @@ _mouse_down_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, v
} }
static void static void
_soft_ellipsoid_add(Test_Data *test_data, Evas_Object *front_face, Evas_Object *back_face) _soft_sphere_add(Test_Data *test_data, Evas_Object *front_face, Evas_Object *back_face)
{ {
EPhysics_Body *body; EPhysics_Body *body;
Evas_Coord x, y, w, h; Evas_Coord x, y, w, h;
body = ephysics_body_soft_ellipsoid_add(test_data->world, 500); body = ephysics_body_soft_sphere_add(test_data->world, 500);
ephysics_body_soft_body_position_iterations_set(body, 16); ephysics_body_soft_body_position_iterations_set(body, 16);
ephysics_body_soft_body_anchor_hardness_set(body, 0); ephysics_body_soft_body_anchor_hardness_set(body, 0);
ephysics_body_soft_body_hardness_set(body, 3); ephysics_body_soft_body_hardness_set(body, 3);
ephysics_body_face_evas_object_set(body, ephysics_body_face_evas_object_set(body,
EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_FRONT, EPHYSICS_BODY_SPHERE_FACE_FRONT,
front_face, EINA_TRUE); front_face, EINA_TRUE);
ephysics_body_face_evas_object_set(body, ephysics_body_face_evas_object_set(body,
EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_BACK, EPHYSICS_BODY_SPHERE_FACE_BACK,
back_face, EINA_TRUE); back_face, EINA_TRUE);
ephysics_body_geometry_get(body, &x, &y, NULL, &w, &h, NULL); ephysics_body_geometry_get(body, &x, &y, NULL, &w, &h, NULL);
@ -90,7 +90,7 @@ _world_populate(Test_Data *test_data)
evas_object_show(back_face); evas_object_show(back_face);
test_data->evas_objs = eina_list_append(test_data->evas_objs, back_face); test_data->evas_objs = eina_list_append(test_data->evas_objs, back_face);
_soft_ellipsoid_add(test_data, front_face, back_face); _soft_sphere_add(test_data, front_face, back_face);
} }
static void static void

View File

@ -36,13 +36,13 @@ _soft_ellipsoid_add(Test_Data *test_data, Evas_Object *front_face, Evas_Object *
Evas_Coord w, h; Evas_Coord w, h;
body = ephysics_body_soft_ellipsoid_add(test_data->world, 100); body = ephysics_body_soft_sphere_add(test_data->world, 100);
ephysics_body_face_evas_object_set(body, ephysics_body_face_evas_object_set(body,
EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_FRONT, front_face, EINA_TRUE); EPHYSICS_BODY_SPHERE_FACE_FRONT, front_face, EINA_TRUE);
ephysics_body_face_evas_object_set(body, ephysics_body_face_evas_object_set(body,
EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_BACK, back_face, EINA_TRUE); EPHYSICS_BODY_SPHERE_FACE_BACK, back_face, EINA_TRUE);
ephysics_body_geometry_get(body, NULL, NULL, NULL, &w, &h, NULL); ephysics_body_geometry_get(body, NULL, NULL, NULL, &w, &h, NULL);
ephysics_body_resize(body, w, h, h); ephysics_body_resize(body, w, h, h);

View File

@ -621,7 +621,7 @@ EAPI Eina_Bool ephysics_shape_save(const EPhysics_Shape *shape, const char *file
* @li @ref ephysics_body_cylinder_add() * @li @ref ephysics_body_cylinder_add()
* @li @ref ephysics_body_box_add() * @li @ref ephysics_body_box_add()
* @li @ref ephysics_body_shape_add() * @li @ref ephysics_body_shape_add()
* @li @ref ephysics_body_soft_circle_add() * @li @ref ephysics_body_soft_cylinder_add()
* @li @ref ephysics_body_soft_box_add() * @li @ref ephysics_body_soft_box_add()
* *
* and it can be deleted with @ref ephysics_body_del(). * and it can be deleted with @ref ephysics_body_del().
@ -1959,7 +1959,7 @@ EAPI Eina_Bool ephysics_world_stack_enable_get(const EPhysics_World *world);
* Also they can be soft bodies, that won't act as rigid bodies. They will * Also they can be soft bodies, that won't act as rigid bodies. They will
* deform its shape under certain circunstances, like under collisions. * deform its shape under certain circunstances, like under collisions.
* Soft bodies can be created with: * Soft bodies can be created with:
* @li @ref ephysics_body_soft_circle_add(); * @li @ref ephysics_body_soft_cylinder_add();
* @li @ref ephysics_body_soft_box_add(); * @li @ref ephysics_body_soft_box_add();
* *
* They can collide and have customizable properties, like: * They can collide and have customizable properties, like:
@ -2173,6 +2173,8 @@ typedef enum _EPhysics_Body_Cloth_Anchor_Side
* Define in wich body's face the evas object should be set. * Define in wich body's face the evas object should be set.
* *
* @see ephysics_body_face_evas_object_set() * @see ephysics_body_face_evas_object_set()
* @see ephysics_body_face_evas_object_unset()
* @see ephysics_body_face_evas_object_get()
* *
* @ingroup EPhysics_Body * @ingroup EPhysics_Body
*/ */
@ -2187,32 +2189,17 @@ typedef enum _EPhysics_Body_Face
EPHYSICS_BODY_BOX_FACE_TOP, EPHYSICS_BODY_BOX_FACE_TOP,
EPHYSICS_BODY_BOX_FACE_BOTTOM, EPHYSICS_BODY_BOX_FACE_BOTTOM,
EPHYSICS_BODY_CLOTH_FACE_FRONT,
EPHYSICS_BODY_CLOTH_FACE_BACK,
EPHYSICS_BODY_CYLINDER_FACE_MIDDLE_FRONT, EPHYSICS_BODY_CYLINDER_FACE_MIDDLE_FRONT,
EPHYSICS_BODY_CYLINDER_FACE_MIDDLE_BACK, EPHYSICS_BODY_CYLINDER_FACE_MIDDLE_BACK,
EPHYSICS_BODY_CYLINDER_FACE_FRONT, EPHYSICS_BODY_CYLINDER_FACE_FRONT,
EPHYSICS_BODY_CYLINDER_FACE_BACK, EPHYSICS_BODY_CYLINDER_FACE_BACK,
EPHYSICS_BODY_CYLINDER_FACE_CURVED, EPHYSICS_BODY_CYLINDER_FACE_CURVED,
EPHYSICS_BODY_CLOTH_FACE_FRONT, EPHYSICS_BODY_SPHERE_FACE_FRONT,
EPHYSICS_BODY_CLOTH_FACE_BACK, EPHYSICS_BODY_SPHERE_FACE_BACK,
EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_FRONT,
EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_BACK,
EPHYSICS_BODY_SOFT_BOX_FACE_MIDDLE_FRONT,
EPHYSICS_BODY_SOFT_BOX_FACE_MIDDLE_BACK,
EPHYSICS_BODY_SOFT_BOX_FACE_FRONT,
EPHYSICS_BODY_SOFT_BOX_FACE_BACK,
EPHYSICS_BODY_SOFT_BOX_FACE_LEFT,
EPHYSICS_BODY_SOFT_BOX_FACE_RIGHT,
EPHYSICS_BODY_SOFT_BOX_FACE_TOP,
EPHYSICS_BODY_SOFT_BOX_FACE_BOTTOM,
EPHYSICS_BODY_SOFT_CIRCLE_FACE_MIDDLE_FRONT,
EPHYSICS_BODY_SOFT_CIRCLE_FACE_MIDDLE_BACK,
EPHYSICS_BODY_SOFT_CIRCLE_FACE_FRONT,
EPHYSICS_BODY_SOFT_CIRCLE_FACE_BACK,
EPHYSICS_BODY_SOFT_CIRCLE_FACE_CURVED,
EPHYSICS_BODY_FACE_LAST, EPHYSICS_BODY_FACE_LAST,
} EPhysics_Body_Face; } EPhysics_Body_Face;
@ -2494,15 +2481,15 @@ EAPI int ephysics_body_soft_body_slice_index_get(EPhysics_Body *body, Evas_Objec
/** /**
* @brief * @brief
* Add a soft ellipsoid. * Add a soft sphere.
* *
* Add a new soft 3d ellipsoid to the simulation. The @p granularity defines how * Add a new soft 3d sphere to the simulation. The @p granularity defines how
* many triangles are to be added. * many triangles are to be added.
* *
* @note if no @p granularity is informed(i.e @p granularity = 0) the soft body * @note if no @p granularity is informed(i.e @p granularity = 0) the soft body
* will be created with a triangle mesh of 100. * will be created with a triangle mesh of 100.
* *
* @param world The world the new soft ellipsoid is to be added. * @param world The world the new soft sphere is to be added.
* @param granularity How many triangles the soft body triangle mesh must have. * @param granularity How many triangles the soft body triangle mesh must have.
* @return a new body or @c NULL on errors. * @return a new body or @c NULL on errors.
* *
@ -2512,7 +2499,7 @@ EAPI int ephysics_body_soft_body_slice_index_get(EPhysics_Body *body, Evas_Objec
* *
* @ingroup EPhysics_Body * @ingroup EPhysics_Body
*/ */
EAPI EPhysics_Body *ephysics_body_soft_ellipsoid_add(EPhysics_World *world, int granularity); EAPI EPhysics_Body *ephysics_body_soft_sphere_add(EPhysics_World *world, int granularity);
/** /**
* @brief * @brief
@ -2679,7 +2666,7 @@ EAPI void ephysics_body_soft_body_bending_constraints_add(EPhysics_Body *body, i
* ephysics_body_evas_object_set(), and it will collid as a sphere(even if * ephysics_body_evas_object_set(), and it will collid as a sphere(even if
* you`ve associated an evas rectangle). * you`ve associated an evas rectangle).
* *
* For deformable sphere use @p ephysics_body_soft_ellipsoid_add() instead. * For deformable sphere use @p ephysics_body_soft_sphere_add() instead.
* *
* @param world The world this body will belong to. * @param world The world this body will belong to.
* @return a new body or @c NULL, on errors. * @return a new body or @c NULL, on errors.
@ -2704,7 +2691,7 @@ EAPI EPhysics_Body *ephysics_body_sphere_add(EPhysics_World *world);
* and it will collide as a cylinder (even if you have an evas rectangle). * and it will collide as a cylinder (even if you have an evas rectangle).
* *
* If a cylinder that could have its shape deformed is required, use * If a cylinder that could have its shape deformed is required, use
* @ref ephysics_body_soft_circle_add(). * @ref ephysics_body_soft_cylinder_add().
* *
* @param world The world this body will belongs to. * @param world The world this body will belongs to.
* @return a new body or @c NULL, on errors. * @return a new body or @c NULL, on errors.
@ -2719,14 +2706,14 @@ EAPI EPhysics_Body *ephysics_body_cylinder_add(EPhysics_World *world);
/** /**
* @brief * @brief
* Create a new deformable circle physics body. * Create a new deformable cylinder physics body.
* *
* Its collision shape will be a circle of diameter 1. To change it's size * Its collision shape will be a cylinder of diameter 1. To change it's size
* @ref ephysics_body_geometry_set() should be used. * @ref ephysics_body_geometry_set() should be used.
* *
* Any evas object can be associated to it with * Any evas object can be associated to it with
* @ref ephysics_body_evas_object_set(), * @ref ephysics_body_evas_object_set(),
* and it will collide and deform as a circle (even if you have an evas * and it will collide and deform as a cylinder (even if you have an evas
* rectangle). * rectangle).
* *
* Just like rotation, deformation will be applied on associated * Just like rotation, deformation will be applied on associated
@ -2747,7 +2734,7 @@ EAPI EPhysics_Body *ephysics_body_cylinder_add(EPhysics_World *world);
* *
* @ingroup EPhysics_Body * @ingroup EPhysics_Body
*/ */
EAPI EPhysics_Body *ephysics_body_soft_circle_add(EPhysics_World *world); EAPI EPhysics_Body *ephysics_body_soft_cylinder_add(EPhysics_World *world);
/** /**
* @brief * @brief
@ -3073,7 +3060,7 @@ EAPI EPhysics_World *ephysics_body_world_get(const EPhysics_Body *body);
* @see ephysics_body_box_add(). * @see ephysics_body_box_add().
* @see ephysics_body_soft_box_add(). * @see ephysics_body_soft_box_add().
* @see ephysics_body_cylinder_add(). * @see ephysics_body_cylinder_add().
* @see ephysics_body_soft_circle_add(). * @see ephysics_body_soft_cylinder_add().
* @see ephysics_body_evas_object_unset(). * @see ephysics_body_evas_object_unset().
* @see ephysics_world_rate_set(). * @see ephysics_world_rate_set().
* *

View File

@ -2603,7 +2603,7 @@ ephysics_body_soft_body_triangle_index_get(EPhysics_Body *body, Evas_Coord x, Ev
} }
static EPhysics_Body_Face_Slice * static EPhysics_Body_Face_Slice *
_ephysics_body_soft_ellipsoid_face_slices_add(EPhysics_Body *body, EPhysics_Body_Face face, btVector3 center) _ephysics_body_soft_sphere_face_slices_add(EPhysics_Body *body, EPhysics_Body_Face face, btVector3 center)
{ {
btSoftBody::Face *bt_face; btSoftBody::Face *bt_face;
btSoftBody::Node *node; btSoftBody::Node *node;
@ -2623,9 +2623,9 @@ _ephysics_body_soft_ellipsoid_face_slices_add(EPhysics_Body *body, EPhysics_Body
for (int n = 0; n < 3; n++) for (int n = 0; n < 3; n++)
{ {
node = bt_face->m_n[n]; node = bt_face->m_n[n];
if ((face == EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_FRONT && if ((face == EPHYSICS_BODY_SPHERE_FACE_FRONT &&
node->m_x.z() > depth_limit) || node->m_x.z() > depth_limit) ||
(face == EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_BACK && (face == EPHYSICS_BODY_SPHERE_FACE_BACK &&
node->m_x.z() < depth_limit)) node->m_x.z() < depth_limit))
out++; out++;
} }
@ -2677,7 +2677,7 @@ no_deform:
} }
EAPI EPhysics_Body * EAPI EPhysics_Body *
ephysics_body_soft_ellipsoid_add(EPhysics_World *world, int granularity) ephysics_body_soft_sphere_add(EPhysics_World *world, int granularity)
{ {
EPhysics_Body *body; EPhysics_Body *body;
EPhysics_Body_Face_Slice *front_face, *back_face; EPhysics_Body_Face_Slice *front_face, *back_face;
@ -2690,7 +2690,7 @@ ephysics_body_soft_ellipsoid_add(EPhysics_World *world, int granularity)
if (!world) if (!world)
{ {
ERR("Can't add circle, world is null."); ERR("Can't add soft sphere, world is null.");
return NULL; return NULL;
} }
@ -2721,8 +2721,8 @@ ephysics_body_soft_ellipsoid_add(EPhysics_World *world, int granularity)
body->soft_body->setPose(false, true); body->soft_body->setPose(false, true);
front_face = _ephysics_body_soft_ellipsoid_face_slices_add(body, front_face = _ephysics_body_soft_sphere_face_slices_add(body,
EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_FRONT, center); EPHYSICS_BODY_SPHERE_FACE_FRONT, center);
if (!front_face) if (!front_face)
{ {
ERR("Could not create points of deformation mapping for front face."); ERR("Could not create points of deformation mapping for front face.");
@ -2730,15 +2730,15 @@ ephysics_body_soft_ellipsoid_add(EPhysics_World *world, int granularity)
} }
body->default_face = front_face; body->default_face = front_face;
back_face = _ephysics_body_soft_ellipsoid_face_slices_add(body, back_face = _ephysics_body_soft_sphere_face_slices_add(body,
EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_BACK, center); EPHYSICS_BODY_SPHERE_FACE_BACK, center);
if (!back_face) if (!back_face)
{ {
ERR("Could not create points of deformation mapping for back face."); ERR("Could not create points of deformation mapping for back face.");
goto no_back_face; goto no_back_face;
} }
body->shape = EPHYSICS_BODY_SHAPE_ELLIPSOID; body->shape = EPHYSICS_BODY_SHAPE_SPHERE;
ephysics_world_lock_release(world); ephysics_world_lock_release(world);
return body; return body;
@ -2756,7 +2756,7 @@ no_collision_shape:
} }
EAPI EPhysics_Body * EAPI EPhysics_Body *
ephysics_body_soft_circle_add(EPhysics_World *world) ephysics_body_soft_cylinder_add(EPhysics_World *world)
{ {
EPhysics_Body *body; EPhysics_Body *body;
EPhysics_Body_Face_Slice *face_slice; EPhysics_Body_Face_Slice *face_slice;
@ -2798,7 +2798,7 @@ ephysics_body_soft_circle_add(EPhysics_World *world)
body->shape = EPHYSICS_BODY_SHAPE_CYLINDER; body->shape = EPHYSICS_BODY_SHAPE_CYLINDER;
face_slice = _ephysics_body_face_slice_add(body, face_slice = _ephysics_body_face_slice_add(body,
EPHYSICS_BODY_SOFT_CIRCLE_FACE_FRONT); EPHYSICS_BODY_CYLINDER_FACE_FRONT);
if (!face_slice) if (!face_slice)
{ {
ERR("Could not allocate face slice data structure."); ERR("Could not allocate face slice data structure.");
@ -2942,7 +2942,7 @@ ephysics_body_soft_box_add(EPhysics_World *world)
body->shape = EPHYSICS_BODY_SHAPE_BOX; body->shape = EPHYSICS_BODY_SHAPE_BOX;
face_slice = _ephysics_body_face_slice_add(body, face_slice = _ephysics_body_face_slice_add(body,
EPHYSICS_BODY_SOFT_BOX_FACE_FRONT); EPHYSICS_BODY_BOX_FACE_FRONT);
if (!face_slice) if (!face_slice)
{ {
ERR("Could not allocate face slice data structure."); ERR("Could not allocate face slice data structure.");
@ -4973,7 +4973,7 @@ _ephysics_body_cloth_face_evas_object_unset(EPhysics_Body *body, EPhysics_Body_F
} }
static void static void
_ephysics_body_ellipsoid_face_obj_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) _ephysics_body_soft_sphere_face_obj_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
{ {
EPhysics_Body *body = (EPhysics_Body *) data; EPhysics_Body *body = (EPhysics_Body *) data;
Evas_Coord bd, w, h; Evas_Coord bd, w, h;
@ -4986,7 +4986,7 @@ _ephysics_body_ellipsoid_face_obj_resize_cb(void *data, Evas *e __UNUSED__, Evas
} }
static void static void
_ephysics_body_ellipsoid_face_evas_object_del_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) _ephysics_body_soft_sphere_face_evas_object_del_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{ {
Eina_List *l; Eina_List *l;
void *ldata; void *ldata;
@ -5004,36 +5004,37 @@ _ephysics_body_ellipsoid_face_evas_object_del_cb(void *data, Evas *evas __UNUSED
} }
_ephysics_body_face_evas_object_del(body, face_obj, _ephysics_body_face_evas_object_del(body, face_obj,
_ephysics_body_ellipsoid_face_obj_resize_cb); _ephysics_body_soft_sphere_face_obj_resize_cb);
_ephysics_body_soft_body_slices_clean(face_slice->slices); _ephysics_body_soft_body_slices_clean(face_slice->slices);
DBG("Ellipsoid's face cleaned up.");
DBG("Soft sphere's face cleaned up.");
} }
static void static void
_ephysics_body_ellipsoid_face_evas_object_clean(EPhysics_Body *body, EPhysics_Body_Face_Obj *face_obj, Eina_List *slices) _ephysics_body_soft_sphere_face_evas_object_clean(EPhysics_Body *body, EPhysics_Body_Face_Obj *face_obj, Eina_List *slices)
{ {
evas_object_map_enable_set(face_obj->obj, EINA_FALSE); evas_object_map_enable_set(face_obj->obj, EINA_FALSE);
evas_object_event_callback_del(face_obj->obj, EVAS_CALLBACK_DEL, evas_object_event_callback_del(face_obj->obj, EVAS_CALLBACK_DEL,
_ephysics_body_ellipsoid_face_evas_object_del_cb); _ephysics_body_soft_sphere_face_evas_object_del_cb);
evas_object_event_callback_del(face_obj->obj, EVAS_CALLBACK_RESTACK, evas_object_event_callback_del(face_obj->obj, EVAS_CALLBACK_RESTACK,
_ephysics_body_soft_body_evas_restack_cb); _ephysics_body_soft_body_evas_restack_cb);
_ephysics_body_soft_body_slices_clean(slices); _ephysics_body_soft_body_slices_clean(slices);
_ephysics_body_face_evas_object_del(body, face_obj, _ephysics_body_face_evas_object_del(body, face_obj,
_ephysics_body_ellipsoid_face_obj_resize_cb); _ephysics_body_soft_sphere_face_obj_resize_cb);
} }
static void static void
_ephysics_body_ellipsoid_face_evas_object_set(EPhysics_Body *body, EPhysics_Body_Face face, Evas_Object *evas_obj, Eina_Bool use_obj_pos) _ephysics_body_soft_sphere_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; int obj_x, obj_y, obj_w, obj_h, bz, bd;
double rate; double rate;
EPhysics_Body_Face_Slice *face_slice = NULL; EPhysics_Body_Face_Slice *face_slice = NULL;
EPhysics_Body_Face_Obj *face_obj; EPhysics_Body_Face_Obj *face_obj;
if ((face < EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_FRONT) || if ((face < EPHYSICS_BODY_SPHERE_FACE_FRONT) ||
(face > EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_BACK)) (face > EPHYSICS_BODY_SPHERE_FACE_BACK))
{ {
ERR("Can't set evas object to body, face is invalid."); ERR("Can't set evas object to body, face is invalid.");
return; return;
@ -5061,17 +5062,17 @@ _ephysics_body_ellipsoid_face_evas_object_set(EPhysics_Body *body, EPhysics_Body
face_obj = _ephysics_body_face_evas_object_get(body, face); face_obj = _ephysics_body_face_evas_object_get(body, face);
if (face_obj) if (face_obj)
_ephysics_body_ellipsoid_face_evas_object_clean(body, face_obj, _ephysics_body_soft_sphere_face_evas_object_clean(body, face_obj,
face_slice->slices); face_slice->slices);
evas_object_geometry_get(evas_obj, NULL, NULL, &obj_w, &obj_h); evas_object_geometry_get(evas_obj, NULL, NULL, &obj_w, &obj_h);
if (!obj_w && !obj_h) evas_object_resize(evas_obj, 1, 1); if (!obj_w && !obj_h) evas_object_resize(evas_obj, 1, 1);
_ephysics_body_face_evas_object_add(body, face, evas_obj, _ephysics_body_face_evas_object_add(body, face, evas_obj,
_ephysics_body_ellipsoid_face_obj_resize_cb); _ephysics_body_soft_sphere_face_obj_resize_cb);
evas_object_event_callback_add(evas_obj, EVAS_CALLBACK_DEL, evas_object_event_callback_add(evas_obj, EVAS_CALLBACK_DEL,
_ephysics_body_ellipsoid_face_evas_object_del_cb, face_slice); _ephysics_body_soft_sphere_face_evas_object_del_cb, face_slice);
evas_object_event_callback_add(evas_obj, EVAS_CALLBACK_RESTACK, evas_object_event_callback_add(evas_obj, EVAS_CALLBACK_RESTACK,
_ephysics_body_soft_body_evas_restack_cb, _ephysics_body_soft_body_evas_restack_cb,
@ -5091,16 +5092,17 @@ _ephysics_body_ellipsoid_face_evas_object_set(EPhysics_Body *body, EPhysics_Body
ephysics_world_lock_release(body->world); ephysics_world_lock_release(body->world);
evas_object_event_callback_add(evas_obj, EVAS_CALLBACK_RESIZE, evas_object_event_callback_add(evas_obj, EVAS_CALLBACK_RESIZE,
_ephysics_body_evas_obj_resize_cb, body); _ephysics_body_evas_obj_resize_cb, body);
DBG("Ellipsoid face evas object set.");
DBG("Soft sphere's face evas object set.");
} }
static Evas_Object * static Evas_Object *
_ephysics_body_ellipsoid_face_evas_object_get(const EPhysics_Body *body, EPhysics_Body_Face face) _ephysics_body_soft_sphere_face_evas_object_get(const EPhysics_Body *body, EPhysics_Body_Face face)
{ {
EPhysics_Body_Face_Obj *face_obj = NULL; EPhysics_Body_Face_Obj *face_obj = NULL;
if ((face < EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_FRONT) || if ((face < EPHYSICS_BODY_SPHERE_FACE_FRONT) ||
(face > EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_BACK)) (face > EPHYSICS_BODY_SPHERE_FACE_BACK))
{ {
ERR("Can't get evas object from body, face is invalid."); ERR("Can't get evas object from body, face is invalid.");
return NULL; return NULL;
@ -5114,14 +5116,14 @@ _ephysics_body_ellipsoid_face_evas_object_get(const EPhysics_Body *body, EPhysic
} }
static Evas_Object * static Evas_Object *
_ephysics_body_ellipsoid_face_evas_object_unset(EPhysics_Body *body, EPhysics_Body_Face face) _ephysics_body_soft_sphere_face_evas_object_unset(EPhysics_Body *body, EPhysics_Body_Face face)
{ {
EPhysics_Body_Face_Slice *face_slice; EPhysics_Body_Face_Slice *face_slice;
EPhysics_Body_Face_Obj *face_obj = NULL; EPhysics_Body_Face_Obj *face_obj = NULL;
Evas_Object *obj; Evas_Object *obj;
if ((face < EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_FRONT) || if ((face < EPHYSICS_BODY_SPHERE_FACE_FRONT) ||
(face > EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_BACK)) (face > EPHYSICS_BODY_SPHERE_FACE_BACK))
{ {
ERR("Can't unset evas object from body, face is invalid."); ERR("Can't unset evas object from body, face is invalid.");
return NULL; return NULL;
@ -5133,7 +5135,7 @@ _ephysics_body_ellipsoid_face_evas_object_unset(EPhysics_Body *body, EPhysics_Bo
obj = face_obj->obj; obj = face_obj->obj;
face_slice = _ephysics_body_face_slice_get(body, face); face_slice = _ephysics_body_face_slice_get(body, face);
_ephysics_body_ellipsoid_face_evas_object_clean(body, face_obj, _ephysics_body_soft_sphere_face_evas_object_clean(body, face_obj,
face_slice->slices); face_slice->slices);
DBG("EPhysics Body face unset."); DBG("EPhysics Body face unset.");
@ -5158,15 +5160,18 @@ ephysics_body_face_evas_object_set(EPhysics_Body *body, EPhysics_Body_Face face,
if (body->type == EPHYSICS_BODY_TYPE_CLOTH) if (body->type == EPHYSICS_BODY_TYPE_CLOTH)
return _ephysics_body_cloth_face_evas_object_set(body, face, evas_obj, return _ephysics_body_cloth_face_evas_object_set(body, face, evas_obj,
use_obj_pos); use_obj_pos);
if (body->shape == EPHYSICS_BODY_SHAPE_CYLINDER) if (body->type == EPHYSICS_BODY_TYPE_RIGID &&
body->shape == EPHYSICS_BODY_SHAPE_CYLINDER)
return _ephysics_body_cylinder_face_evas_object_set(body, face, evas_obj, return _ephysics_body_cylinder_face_evas_object_set(body, face, evas_obj,
use_obj_pos); use_obj_pos);
if (body->shape == EPHYSICS_BODY_SHAPE_BOX) if (body->type == EPHYSICS_BODY_TYPE_RIGID &&
body->shape == EPHYSICS_BODY_SHAPE_BOX)
return _ephysics_body_box_face_evas_object_set(body, face, evas_obj, return _ephysics_body_box_face_evas_object_set(body, face, evas_obj,
use_obj_pos); use_obj_pos);
if (body->shape == EPHYSICS_BODY_SHAPE_ELLIPSOID) if (body->type == EPHYSICS_BODY_TYPE_SOFT &&
return _ephysics_body_ellipsoid_face_evas_object_set(body, face, evas_obj, body->shape == EPHYSICS_BODY_SHAPE_SPHERE)
use_obj_pos); return _ephysics_body_soft_sphere_face_evas_object_set(body, face, evas_obj,
use_obj_pos);
ERR("Can't handle body %p type.", body); ERR("Can't handle body %p type.", body);
} }
@ -5182,12 +5187,15 @@ ephysics_body_face_evas_object_get(const EPhysics_Body *body, EPhysics_Body_Face
if (body->type == EPHYSICS_BODY_TYPE_CLOTH) if (body->type == EPHYSICS_BODY_TYPE_CLOTH)
return _ephysics_body_cloth_face_evas_object_get(body, face); return _ephysics_body_cloth_face_evas_object_get(body, face);
if (body->shape == EPHYSICS_BODY_SHAPE_CYLINDER) if (body->type == EPHYSICS_BODY_TYPE_RIGID &&
body->shape == EPHYSICS_BODY_SHAPE_CYLINDER)
return _ephysics_body_cylinder_face_evas_object_get(body, face); return _ephysics_body_cylinder_face_evas_object_get(body, face);
if (body->shape == EPHYSICS_BODY_SHAPE_BOX) if (body->type == EPHYSICS_BODY_TYPE_RIGID &&
body->shape == EPHYSICS_BODY_SHAPE_BOX)
return _ephysics_body_box_face_evas_object_get(body, face); return _ephysics_body_box_face_evas_object_get(body, face);
if (body->shape == EPHYSICS_BODY_SHAPE_ELLIPSOID) if (body->type == EPHYSICS_BODY_TYPE_SOFT &&
return _ephysics_body_ellipsoid_face_evas_object_get(body, face); body->shape == EPHYSICS_BODY_SHAPE_SPHERE)
return _ephysics_body_soft_sphere_face_evas_object_get(body, face);
ERR("Can't handle body %p type.", body); ERR("Can't handle body %p type.", body);
return NULL; return NULL;
@ -5204,12 +5212,15 @@ ephysics_body_face_evas_object_unset(EPhysics_Body *body, EPhysics_Body_Face fac
if (body->type == EPHYSICS_BODY_TYPE_CLOTH) if (body->type == EPHYSICS_BODY_TYPE_CLOTH)
return _ephysics_body_cloth_face_evas_object_unset(body, face); return _ephysics_body_cloth_face_evas_object_unset(body, face);
if (body->shape == EPHYSICS_BODY_SHAPE_CYLINDER) if (body->type == EPHYSICS_BODY_TYPE_RIGID &&
body->shape == EPHYSICS_BODY_SHAPE_CYLINDER)
return _ephysics_body_cylinder_face_evas_object_unset(body, face); return _ephysics_body_cylinder_face_evas_object_unset(body, face);
if (body->shape == EPHYSICS_BODY_SHAPE_BOX) if (body->type == EPHYSICS_BODY_TYPE_RIGID &&
body->shape == EPHYSICS_BODY_SHAPE_BOX)
return _ephysics_body_box_face_evas_object_unset(body, face); return _ephysics_body_box_face_evas_object_unset(body, face);
if (body->shape == EPHYSICS_BODY_SHAPE_ELLIPSOID) if (body->type == EPHYSICS_BODY_TYPE_SOFT &&
return _ephysics_body_ellipsoid_face_evas_object_unset(body, face); body->shape == EPHYSICS_BODY_SHAPE_SPHERE)
return _ephysics_body_soft_sphere_face_evas_object_unset(body, face);
ERR("Can't handle body %p type.", body); ERR("Can't handle body %p type.", body);
return NULL; return NULL;

View File

@ -67,7 +67,6 @@ typedef enum _EPhysics_Body_Shape
EPHYSICS_BODY_SHAPE_CUSTOM, EPHYSICS_BODY_SHAPE_CUSTOM,
EPHYSICS_BODY_SHAPE_CYLINDER, EPHYSICS_BODY_SHAPE_CYLINDER,
EPHYSICS_BODY_SHAPE_SPHERE, EPHYSICS_BODY_SHAPE_SPHERE,
EPHYSICS_BODY_SHAPE_ELLIPSOID,
EPHYSICS_BODY_SHAPE_LAST, EPHYSICS_BODY_SHAPE_LAST,
} EPhysics_Body_Shape; } EPhysics_Body_Shape;