summaryrefslogtreecommitdiff
path: root/legacy/ephysics
diff options
context:
space:
mode:
authorLeandro Dorileo <dorileo@profusion.mobi>2012-11-09 18:58:43 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-11-09 18:58:43 +0000
commitbe9c5adb457842e4ea9515d92e722d58894fedca (patch)
tree58fc114981299cf10d6247f1581ecd2afb6d2e32 /legacy/ephysics
parent8fa96610bb9ffbc075e490c6a480cc3422ff7423 (diff)
EPhysics: fix soft body geometry set
Issue found on ephysics_sandbox. The scale was been applied considering the rigid body behaviour. This patch applies a reverse scale then scale again. Patch by: Leandro Dorileo <dorileo@profusion.mobi> SVN revision: 79056
Diffstat (limited to 'legacy/ephysics')
-rw-r--r--legacy/ephysics/src/lib/ephysics_body.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp
index 44a18deed2..7459f6012b 100644
--- a/legacy/ephysics/src/lib/ephysics_body.cpp
+++ b/legacy/ephysics/src/lib/ephysics_body.cpp
@@ -427,7 +427,7 @@ _ephysics_body_transform_set(EPhysics_Body *body, btTransform trans)
427 btTransform origin; 427 btTransform origin;
428 btTransform dest; 428 btTransform dest;
429 429
430 if (body->type == EPHYSICS_BODY_TYPE_CLOTH) 430 if (body->type != EPHYSICS_BODY_TYPE_RIGID)
431 { 431 {
432 origin = _ephysics_body_transform_get(body); 432 origin = _ephysics_body_transform_get(body);
433 dest.setIdentity(); 433 dest.setIdentity();
@@ -887,20 +887,29 @@ static void
887_ephysics_body_resize(EPhysics_Body *body, Evas_Coord w, Evas_Coord h, Evas_Coord d) 887_ephysics_body_resize(EPhysics_Body *body, Evas_Coord w, Evas_Coord h, Evas_Coord d)
888{ 888{
889 double rate, sx, sy, sz; 889 double rate, sx, sy, sz;
890 btVector3 body_scale;
890 891
891 rate = ephysics_world_rate_get(body->world); 892 rate = ephysics_world_rate_get(body->world);
892 sx = w / rate; 893 sx = w / rate;
893 sy = h / rate; 894 sy = h / rate;
894 sz = d / rate; 895 sz = d / rate;
895 896
896 if (body->soft_body) 897 body_scale = btVector3(sx, sy, sz);
898 if (body->type == EPHYSICS_BODY_TYPE_SOFT)
897 { 899 {
898 body->soft_body->scale(btVector3(sx, sy, sz)); 900 body->soft_body->scale(btVector3(1, 1, 1) / body->scale);
901 body->soft_body->scale(body_scale);
899 _ephysics_body_soft_body_constraints_rebuild(body); 902 _ephysics_body_soft_body_constraints_rebuild(body);
900 } 903 }
904 else if (body->type == EPHYSICS_BODY_TYPE_CLOTH)
905 {
906 body->soft_body->scale(btVector3(1, 1, 1) / body->scale);
907 body->soft_body->scale(body_scale);
908 _ephysics_body_cloth_constraints_rebuild(body);
909 }
901 else 910 else
902 { 911 {
903 body->collision_shape->setLocalScaling(btVector3(sx, sy, sz)); 912 body->collision_shape->setLocalScaling(body_scale);
904 913
905 if(!body->rigid_body->isStaticObject()) 914 if(!body->rigid_body->isStaticObject())
906 _ephysics_body_mass_set(body, ephysics_body_mass_get(body)); 915 _ephysics_body_mass_set(body, ephysics_body_mass_get(body));
@@ -909,7 +918,7 @@ _ephysics_body_resize(EPhysics_Body *body, Evas_Coord w, Evas_Coord h, Evas_Coor
909 body->size.w = w; 918 body->size.w = w;
910 body->size.h = h; 919 body->size.h = h;
911 body->size.d = d; 920 body->size.d = d;
912 body->scale = btVector3(sx, sy, sz); 921 body->scale = body_scale;
913 922
914 ephysics_body_activate(body, EINA_TRUE); 923 ephysics_body_activate(body, EINA_TRUE);
915 924
@@ -974,14 +983,15 @@ _ephysics_body_geometry_set(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Eva
974 983
975 if (body->type == EPHYSICS_BODY_TYPE_SOFT) 984 if (body->type == EPHYSICS_BODY_TYPE_SOFT)
976 { 985 {
986 body->soft_body->scale(btVector3(1, 1, 1) / body->scale);
977 body->soft_body->scale(body_scale); 987 body->soft_body->scale(body_scale);
978 body->soft_body->getCollisionShape()->setLocalScaling(body_scale);
979 body->rigid_body->proceedToTransform(trans); 988 body->rigid_body->proceedToTransform(trans);
980 body->soft_body->transform(trans); 989 _ephysics_body_transform_set(body, trans);
981 _ephysics_body_soft_body_constraints_rebuild(body); 990 _ephysics_body_soft_body_constraints_rebuild(body);
982 } 991 }
983 else if (body->type == EPHYSICS_BODY_TYPE_CLOTH) 992 else if (body->type == EPHYSICS_BODY_TYPE_CLOTH)
984 { 993 {
994 body->soft_body->scale(btVector3(1, 1, 1) / body->scale);
985 body->soft_body->scale(body_scale); 995 body->soft_body->scale(body_scale);
986 _ephysics_body_transform_set(body, trans); 996 _ephysics_body_transform_set(body, trans);
987 _ephysics_body_cloth_constraints_rebuild(body); 997 _ephysics_body_cloth_constraints_rebuild(body);