summaryrefslogtreecommitdiff
path: root/legacy/ephysics/src/lib/ephysics_body.cpp
diff options
context:
space:
mode:
authorLeandro Dorileo <dorileo@profusion.mobi>2012-12-10 17:15:05 +0000
committerLeandro Dorileo <dorileo@profusion.mobi>2012-12-10 17:15:05 +0000
commit8fed4fff457f435f81555203948563af51ee715c (patch)
treec75e42450718d8dfcebf67d10abc28bff501f603 /legacy/ephysics/src/lib/ephysics_body.cpp
parent6b40542d582428fbe984f808e388ec79cf831c36 (diff)
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
Diffstat (limited to '')
-rw-r--r--legacy/ephysics/src/lib/ephysics_body.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp
index ed35f83b98..15c23a3561 100644
--- a/legacy/ephysics/src/lib/ephysics_body.cpp
+++ b/legacy/ephysics/src/lib/ephysics_body.cpp
@@ -271,10 +271,12 @@ _ephysics_body_soft_body_slices_init(EPhysics_Body *body, Evas_Object *obj, Eina
271 Evas_Coord w, h; 271 Evas_Coord w, h;
272 Eina_List *l; 272 Eina_List *l;
273 Evas *evas; 273 Evas *evas;
274 Evas_Object *parent;
274 275
275 evas = evas_object_evas_get(obj); 276 evas = evas_object_evas_get(obj);
276 evas_object_geometry_get(obj, NULL, NULL, &w, &h); 277 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
277 278
279 parent = evas_object_smart_parent_get(obj);
278 EINA_LIST_FOREACH(slices, l, slice_data) 280 EINA_LIST_FOREACH(slices, l, slice_data)
279 { 281 {
280 slice = (EPhysics_Body_Soft_Body_Slice *) slice_data; 282 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
289 evas_object_event_callback_add(slice->evas_obj, EVAS_CALLBACK_DEL, 291 evas_object_event_callback_add(slice->evas_obj, EVAS_CALLBACK_DEL,
290 _ephysics_body_soft_body_slice_del_cb, 292 _ephysics_body_soft_body_slice_del_cb,
291 slice); 293 slice);
294
295 if (parent) evas_object_smart_member_add(slice->evas_obj, parent);
292 } 296 }
293 297
294 if (slice) 298 if (slice)
@@ -487,13 +491,10 @@ static void
487_ephysics_body_transform_set(EPhysics_Body *body, btTransform trans) 491_ephysics_body_transform_set(EPhysics_Body *body, btTransform trans)
488{ 492{
489 btTransform origin; 493 btTransform origin;
490 btTransform dest;
491 494
492 if (body->type != EPHYSICS_BODY_TYPE_RIGID) 495 if (body->type != EPHYSICS_BODY_TYPE_RIGID)
493 { 496 {
494 origin = _ephysics_body_transform_get(body); 497 origin = _ephysics_body_transform_get(body);
495 dest.setIdentity();
496 dest.setOrigin(trans.getOrigin() / origin.getOrigin());
497 body->soft_body->translate(trans.getOrigin() - origin.getOrigin()); 498 body->soft_body->translate(trans.getOrigin() - origin.getOrigin());
498 return; 499 return;
499 } 500 }
@@ -965,7 +966,6 @@ _ephysics_body_resize(EPhysics_Body *body, Evas_Coord w, Evas_Coord h, Evas_Coor
965{ 966{
966 double rate, sx, sy, sz; 967 double rate, sx, sy, sz;
967 btVector3 body_scale, center; 968 btVector3 body_scale, center;
968 btScalar radius;
969 btTransform trans; 969 btTransform trans;
970 970
971 rate = ephysics_world_rate_get(body->world); 971 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
976 body_scale = btVector3(sx, sy, sz); 976 body_scale = btVector3(sx, sy, sz);
977 if (body->type == EPHYSICS_BODY_TYPE_SOFT) 977 if (body->type == EPHYSICS_BODY_TYPE_SOFT)
978 { 978 {
979 trans = _ephysics_body_transform_get(body);
980
979 body->soft_body->scale(btVector3(1, 1, 1) / body->scale); 981 body->soft_body->scale(btVector3(1, 1, 1) / body->scale);
980 body->soft_body->scale(body_scale); 982 body->soft_body->scale(body_scale);
981 983
982 body->soft_body->getCollisionShape()->getBoundingSphere(center, radius); 984 _ephysics_body_transform_set(body, trans);
983 trans.setIdentity();
984 trans.setOrigin(center);
985 body->rigid_body->proceedToTransform(trans); 985 body->rigid_body->proceedToTransform(trans);
986 986
987 _ephysics_body_soft_body_constraints_rebuild(body); 987 _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
1032 1032
1033 if (body->type == EPHYSICS_BODY_TYPE_CLOTH) 1033 if (body->type == EPHYSICS_BODY_TYPE_CLOTH)
1034 _ephysics_body_transform_set(body, trans); 1034 _ephysics_body_transform_set(body, trans);
1035 else if (body->type == EPHYSICS_BODY_TYPE_SOFT)
1036 {
1037 _ephysics_body_transform_set(body, trans);
1038 body->rigid_body->proceedToTransform(trans);
1039 body->rigid_body->getMotionState()->setWorldTransform(trans);
1040 }
1035 else 1041 else
1036 { 1042 {
1037 body->rigid_body->proceedToTransform(trans); 1043 body->rigid_body->proceedToTransform(trans);
@@ -1113,6 +1119,7 @@ _ephysics_body_evas_obj_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *o
1113 return; 1119 return;
1114 1120
1115 DBG("Resizing body %p to w=%i, h=%i, d=%i", body, w, h, body->size.d); 1121 DBG("Resizing body %p to w=%i, h=%i, d=%i", body, w, h, body->size.d);
1122
1116 ephysics_world_lock_take(body->world); 1123 ephysics_world_lock_take(body->world);
1117 _ephysics_body_resize(body, w, h, body->size.d); 1124 _ephysics_body_resize(body, w, h, body->size.d);
1118 ephysics_world_lock_release(body->world); 1125 ephysics_world_lock_release(body->world);
@@ -2432,7 +2439,7 @@ ephysics_body_soft_body_triangles_inside_get(const EPhysics_Body *body, Evas_Coo
2432 ny = node->m_x.y(); 2439 ny = node->m_x.y();
2433 nz = node->m_x.z(); 2440 nz = node->m_x.z();
2434 2441
2435 if ((nz > zz || nz < dd) || (nx < xx || nx > xx + ww) || 2442 if ((nz < zz || nz > zz + dd) || (nx < xx || nx > xx + ww) ||
2436 (ny > yy || ny < yy - hh)) 2443 (ny > yy || ny < yy - hh))
2437 out++; 2444 out++;
2438 } 2445 }
@@ -3269,6 +3276,9 @@ ephysics_body_evas_object_set(EPhysics_Body *body, Evas_Object *evas_obj, Eina_B
3269 3276
3270 if (body->soft_body) 3277 if (body->soft_body)
3271 { 3278 {
3279 evas_object_geometry_get(body->evas_obj, &obj_x, &obj_y, &obj_w, &obj_h);
3280 if (!obj_w && !obj_h) evas_object_resize(body->evas_obj, 1, 1);
3281
3272 evas_object_event_callback_add(body->evas_obj, EVAS_CALLBACK_RESTACK, 3282 evas_object_event_callback_add(body->evas_obj, EVAS_CALLBACK_RESTACK,
3273 _ephysics_body_soft_body_evas_restack_cb, body); 3283 _ephysics_body_soft_body_evas_restack_cb, body);
3274 _ephysics_body_soft_body_slices_init(body, body->evas_obj, 3284 _ephysics_body_soft_body_slices_init(body, body->evas_obj,