EPhysics: fix issues identified by edje support

Add slices as member of obj smart parent - when it's the case -
so we can restack it when the received evas object is member of a
smart object.

Resize the evas object on ephysics_body_evas_object_set to w=1,
h=1 when its initial/original size is 0, this prevents errors on
evas_object_image_source_set().

Reset the soft body transform on resize - put it back to its
prior position - the one before scaling.

On body_move do not consider the moving of anchored rigid body
enough, move the soft body vertices as well.

--This line, and those below, will be ignored--


SVN revision: 80612
This commit is contained in:
Leandro Dorileo 2012-12-10 17:15:05 +00:00
parent 6b40542d58
commit 8fed4fff45
3 changed files with 26 additions and 18 deletions

View File

@ -9,7 +9,7 @@ _mouse_down_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, v
{
EPhysics_Body *body = data;
Evas_Event_Mouse_Down *mdown = event_info;
Evas_Coord w, h, x, y, z, zz, d;
Evas_Coord w, h, x, y, z, d;
Eina_List *triangles;
int *ldata;
@ -19,10 +19,9 @@ _mouse_down_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, v
h = 80;
x = mdown->output.x - (w / 2);
y = mdown->output.y - (h / 2);
zz = z + (d / 2);
d = d / 2;
triangles = ephysics_body_soft_body_triangles_inside_get(body, x, y, zz,
triangles = ephysics_body_soft_body_triangles_inside_get(body, x, y, z,
w, h, d);
ephysics_body_soft_body_triangle_list_impulse_apply(body, triangles, 0, 0,
200);
@ -34,7 +33,7 @@ static void
_soft_ellipsoid_add(Test_Data *test_data, Evas_Object *front_face, Evas_Object *back_face)
{
EPhysics_Body *body;
Evas_Coord w, h;
Evas_Coord x, y, w, h;
body = ephysics_body_soft_ellipsoid_add(test_data->world, 500);
@ -51,8 +50,8 @@ _soft_ellipsoid_add(Test_Data *test_data, Evas_Object *front_face, Evas_Object *
EPHYSICS_BODY_SOFT_ELLIPSOID_FACE_BACK,
back_face, EINA_TRUE);
ephysics_body_geometry_get(body, NULL, NULL, NULL, &w, &h, NULL);
ephysics_body_resize(body, w, h, h);
ephysics_body_geometry_get(body, &x, &y, NULL, &w, &h, NULL);
ephysics_body_geometry_set(body, x, y, 30, w, h, h);
ephysics_body_linear_movement_enable_set(body, EINA_FALSE, EINA_FALSE,
EINA_FALSE);

View File

@ -9,7 +9,7 @@ _mouse_down_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, v
{
EPhysics_Body *body = data;
Evas_Event_Mouse_Down *mdown = event_info;
Evas_Coord w, h, x, y, z, zz, d;
Evas_Coord w, h, x, y, z, d;
Eina_List *triangles;
int *ldata;
@ -19,10 +19,9 @@ _mouse_down_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, v
h = 20;
x = mdown->output.x - (w / 2);
y = mdown->output.y - (h / 2);
zz = z + (d / 2);
d = z;
d = d / 2;
triangles = ephysics_body_soft_body_triangles_inside_get(body, x, y, zz,
triangles = ephysics_body_soft_body_triangles_inside_get(body, x, y, z,
w, h, d);
ephysics_body_soft_body_triangle_list_impulse_apply(body, triangles, 0, 0,
10);

View File

@ -271,10 +271,12 @@ _ephysics_body_soft_body_slices_init(EPhysics_Body *body, Evas_Object *obj, Eina
Evas_Coord w, h;
Eina_List *l;
Evas *evas;
Evas_Object *parent;
evas = evas_object_evas_get(obj);
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
parent = evas_object_smart_parent_get(obj);
EINA_LIST_FOREACH(slices, l, slice_data)
{
slice = (EPhysics_Body_Soft_Body_Slice *) slice_data;
@ -289,6 +291,8 @@ _ephysics_body_soft_body_slices_init(EPhysics_Body *body, Evas_Object *obj, Eina
evas_object_event_callback_add(slice->evas_obj, EVAS_CALLBACK_DEL,
_ephysics_body_soft_body_slice_del_cb,
slice);
if (parent) evas_object_smart_member_add(slice->evas_obj, parent);
}
if (slice)
@ -487,13 +491,10 @@ static void
_ephysics_body_transform_set(EPhysics_Body *body, btTransform trans)
{
btTransform origin;
btTransform dest;
if (body->type != EPHYSICS_BODY_TYPE_RIGID)
{
origin = _ephysics_body_transform_get(body);
dest.setIdentity();
dest.setOrigin(trans.getOrigin() / origin.getOrigin());
body->soft_body->translate(trans.getOrigin() - origin.getOrigin());
return;
}
@ -965,7 +966,6 @@ _ephysics_body_resize(EPhysics_Body *body, Evas_Coord w, Evas_Coord h, Evas_Coor
{
double rate, sx, sy, sz;
btVector3 body_scale, center;
btScalar radius;
btTransform trans;
rate = ephysics_world_rate_get(body->world);
@ -976,12 +976,12 @@ _ephysics_body_resize(EPhysics_Body *body, Evas_Coord w, Evas_Coord h, Evas_Coor
body_scale = btVector3(sx, sy, sz);
if (body->type == EPHYSICS_BODY_TYPE_SOFT)
{
trans = _ephysics_body_transform_get(body);
body->soft_body->scale(btVector3(1, 1, 1) / body->scale);
body->soft_body->scale(body_scale);
body->soft_body->getCollisionShape()->getBoundingSphere(center, radius);
trans.setIdentity();
trans.setOrigin(center);
_ephysics_body_transform_set(body, trans);
body->rigid_body->proceedToTransform(trans);
_ephysics_body_soft_body_constraints_rebuild(body);
@ -1032,6 +1032,12 @@ _ephysics_body_move(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord
if (body->type == EPHYSICS_BODY_TYPE_CLOTH)
_ephysics_body_transform_set(body, trans);
else if (body->type == EPHYSICS_BODY_TYPE_SOFT)
{
_ephysics_body_transform_set(body, trans);
body->rigid_body->proceedToTransform(trans);
body->rigid_body->getMotionState()->setWorldTransform(trans);
}
else
{
body->rigid_body->proceedToTransform(trans);
@ -1113,6 +1119,7 @@ _ephysics_body_evas_obj_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *o
return;
DBG("Resizing body %p to w=%i, h=%i, d=%i", body, w, h, body->size.d);
ephysics_world_lock_take(body->world);
_ephysics_body_resize(body, w, h, body->size.d);
ephysics_world_lock_release(body->world);
@ -2432,7 +2439,7 @@ ephysics_body_soft_body_triangles_inside_get(const EPhysics_Body *body, Evas_Coo
ny = node->m_x.y();
nz = node->m_x.z();
if ((nz > zz || nz < dd) || (nx < xx || nx > xx + ww) ||
if ((nz < zz || nz > zz + dd) || (nx < xx || nx > xx + ww) ||
(ny > yy || ny < yy - hh))
out++;
}
@ -3269,6 +3276,9 @@ ephysics_body_evas_object_set(EPhysics_Body *body, Evas_Object *evas_obj, Eina_B
if (body->soft_body)
{
evas_object_geometry_get(body->evas_obj, &obj_x, &obj_y, &obj_w, &obj_h);
if (!obj_w && !obj_h) evas_object_resize(body->evas_obj, 1, 1);
evas_object_event_callback_add(body->evas_obj, EVAS_CALLBACK_RESTACK,
_ephysics_body_soft_body_evas_restack_cb, body);
_ephysics_body_soft_body_slices_init(body, body->evas_obj,