* @li @ref ephysics_body_cylinder_add()
* @li @ref ephysics_body_box_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()
*
* and it can be deleted with @ref ephysics_body_del().
* Also they can be soft bodies, that won't act as rigid bodies. They will
* deform its shape under certain circunstances, like under collisions.
* 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();
*
* They can collide and have customizable properties, like:
* 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_unset()
+ * @see ephysics_body_face_evas_object_get()
*
* @ingroup EPhysics_Body
*/
EPHYSICS_BODY_BOX_FACE_TOP,
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_BACK,
EPHYSICS_BODY_CYLINDER_FACE_FRONT,
EPHYSICS_BODY_CYLINDER_FACE_BACK,
EPHYSICS_BODY_CYLINDER_FACE_CURVED,
- EPHYSICS_BODY_CLOTH_FACE_FRONT,
- EPHYSICS_BODY_CLOTH_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_SPHERE_FACE_FRONT,
+ EPHYSICS_BODY_SPHERE_FACE_BACK,
EPHYSICS_BODY_FACE_LAST,
} EPhysics_Body_Face;
/**
* @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.
*
* @note if no @p granularity is informed(i.e @p granularity = 0) the soft body
* 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.
* @return a new body or @c NULL on errors.
*
*
* @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
* ephysics_body_evas_object_set(), and it will collid as a sphere(even if
* 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.
* @return a new body or @c NULL, on errors.
* 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
- * @ref ephysics_body_soft_circle_add().
+ * @ref ephysics_body_soft_cylinder_add().
*
* @param world The world this body will belongs to.
* @return a new body or @c NULL, on errors.
/**
* @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.
*
* Any evas object can be associated to it with
* @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).
*
* Just like rotation, deformation will be applied on associated
*
* @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
* @see ephysics_body_box_add().
* @see ephysics_body_soft_box_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_world_rate_set().
*
}
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::Node *node;
for (int n = 0; n < 3; 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) ||
- (face == EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_BACK &&
+ (face == EPHYSICS_BODY_SPHERE_FACE_BACK &&
node->m_x.z() < depth_limit))
out++;
}
}
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_Face_Slice *front_face, *back_face;
if (!world)
{
- ERR("Can't add circle, world is null.");
+ ERR("Can't add soft sphere, world is null.");
return NULL;
}
body->soft_body->setPose(false, true);
- front_face = _ephysics_body_soft_ellipsoid_face_slices_add(body,
- EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_FRONT, center);
+ front_face = _ephysics_body_soft_sphere_face_slices_add(body,
+ EPHYSICS_BODY_SPHERE_FACE_FRONT, center);
if (!front_face)
{
ERR("Could not create points of deformation mapping for front face.");
}
body->default_face = front_face;
- back_face = _ephysics_body_soft_ellipsoid_face_slices_add(body,
- EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_BACK, center);
+ back_face = _ephysics_body_soft_sphere_face_slices_add(body,
+ EPHYSICS_BODY_SPHERE_FACE_BACK, center);
if (!back_face)
{
ERR("Could not create points of deformation mapping for back face.");
goto no_back_face;
}
- body->shape = EPHYSICS_BODY_SHAPE_ELLIPSOID;
+ body->shape = EPHYSICS_BODY_SHAPE_SPHERE;
ephysics_world_lock_release(world);
return 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_Face_Slice *face_slice;
body->shape = EPHYSICS_BODY_SHAPE_CYLINDER;
face_slice = _ephysics_body_face_slice_add(body,
- EPHYSICS_BODY_SOFT_CIRCLE_FACE_FRONT);
+ EPHYSICS_BODY_CYLINDER_FACE_FRONT);
if (!face_slice)
{
ERR("Could not allocate face slice data structure.");
body->shape = EPHYSICS_BODY_SHAPE_BOX;
face_slice = _ephysics_body_face_slice_add(body,
- EPHYSICS_BODY_SOFT_BOX_FACE_FRONT);
+ EPHYSICS_BODY_BOX_FACE_FRONT);
if (!face_slice)
{
ERR("Could not allocate face slice data structure.");
}
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;
Evas_Coord bd, w, h;
}
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;
void *ldata;
}
_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);
- DBG("Ellipsoid's face cleaned up.");
+
+ DBG("Soft sphere's face cleaned up.");
}
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_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,
_ephysics_body_soft_body_evas_restack_cb);
_ephysics_body_soft_body_slices_clean(slices);
_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
-_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;
double rate;
EPhysics_Body_Face_Slice *face_slice = NULL;
EPhysics_Body_Face_Obj *face_obj;
- if ((face < EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_FRONT) ||
- (face > EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_BACK))
+ if ((face < EPHYSICS_BODY_SPHERE_FACE_FRONT) ||
+ (face > EPHYSICS_BODY_SPHERE_FACE_BACK))
{
ERR("Can't set evas object to body, face is invalid.");
return;
face_obj = _ephysics_body_face_evas_object_get(body, face);
if (face_obj)
- _ephysics_body_ellipsoid_face_evas_object_clean(body, face_obj,
- face_slice->slices);
+ _ephysics_body_soft_sphere_face_evas_object_clean(body, face_obj,
+ face_slice->slices);
evas_object_geometry_get(evas_obj, NULL, NULL, &obj_w, &obj_h);
if (!obj_w && !obj_h) evas_object_resize(evas_obj, 1, 1);
_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,
- _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,
_ephysics_body_soft_body_evas_restack_cb,
ephysics_world_lock_release(body->world);
evas_object_event_callback_add(evas_obj, EVAS_CALLBACK_RESIZE,
_ephysics_body_evas_obj_resize_cb, body);
- DBG("Ellipsoid face evas object set.");
+
+ DBG("Soft sphere's face evas object set.");
}
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;
- if ((face < EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_FRONT) ||
- (face > EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_BACK))
+ if ((face < EPHYSICS_BODY_SPHERE_FACE_FRONT) ||
+ (face > EPHYSICS_BODY_SPHERE_FACE_BACK))
{
ERR("Can't get evas object from body, face is invalid.");
return NULL;
}
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_Obj *face_obj = NULL;
Evas_Object *obj;
- if ((face < EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_FRONT) ||
- (face > EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_BACK))
+ if ((face < EPHYSICS_BODY_SPHERE_FACE_FRONT) ||
+ (face > EPHYSICS_BODY_SPHERE_FACE_BACK))
{
ERR("Can't unset evas object from body, face is invalid.");
return NULL;
obj = face_obj->obj;
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);
DBG("EPhysics Body face unset.");
if (body->type == EPHYSICS_BODY_TYPE_CLOTH)
return _ephysics_body_cloth_face_evas_object_set(body, face, evas_obj,
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,
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,
use_obj_pos);
- if (body->shape == EPHYSICS_BODY_SHAPE_ELLIPSOID)
- return _ephysics_body_ellipsoid_face_evas_object_set(body, face, evas_obj,
- use_obj_pos);
+ if (body->type == EPHYSICS_BODY_TYPE_SOFT &&
+ body->shape == EPHYSICS_BODY_SHAPE_SPHERE)
+ return _ephysics_body_soft_sphere_face_evas_object_set(body, face, evas_obj,
+ use_obj_pos);
ERR("Can't handle body %p type.", body);
}
if (body->type == EPHYSICS_BODY_TYPE_CLOTH)
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);
- 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);
- if (body->shape == EPHYSICS_BODY_SHAPE_ELLIPSOID)
- return _ephysics_body_ellipsoid_face_evas_object_get(body, face);
+ if (body->type == EPHYSICS_BODY_TYPE_SOFT &&
+ 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);
return NULL;
if (body->type == EPHYSICS_BODY_TYPE_CLOTH)
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);
- 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);
- if (body->shape == EPHYSICS_BODY_SHAPE_ELLIPSOID)
- return _ephysics_body_ellipsoid_face_evas_object_unset(body, face);
+ if (body->type == EPHYSICS_BODY_TYPE_SOFT &&
+ 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);
return NULL;