summaryrefslogtreecommitdiff
path: root/legacy/ephysics
diff options
context:
space:
mode:
authorLeandro Dorileo <dorileo@profusion.mobi>2012-12-10 17:15:11 +0000
committerLeandro Dorileo <dorileo@profusion.mobi>2012-12-10 17:15:11 +0000
commitd56bd9c189357d117fea631a5dc4e7465ea8fdfa (patch)
treec98a867a8826ffcd235105c2baf7d928f7b499e5 /legacy/ephysics
parent8fed4fff457f435f81555203948563af51ee715c (diff)
EPHysics: change the location of _ephysics_body_geometry_set
--This line, and those below, will be ignored-- SVN revision: 80613
Diffstat (limited to 'legacy/ephysics')
-rw-r--r--legacy/ephysics/src/lib/ephysics_body.cpp118
1 files changed, 59 insertions, 59 deletions
diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp
index 15c23a3561..608c259db5 100644
--- a/legacy/ephysics/src/lib/ephysics_body.cpp
+++ b/legacy/ephysics/src/lib/ephysics_body.cpp
@@ -962,6 +962,65 @@ _ephysics_body_mass_set(EPhysics_Body *body, double mass)
962} 962}
963 963
964static void 964static void
965_ephysics_body_geometry_set(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord z, Evas_Coord w, Evas_Coord h, Evas_Coord d, double rate)
966{
967 double mx, my, mz, sx, sy, sz;
968 btTransform trans;
969 int wy, height;
970 btVector3 body_scale;
971
972 ephysics_world_render_geometry_get(body->world, NULL, &wy, NULL,
973 NULL, &height, NULL);
974 height += wy;
975
976 mx = (x + w * body->cm.x) / rate;
977 my = (height - (y + h * body->cm.y)) / rate;
978 mz = (z + d * body->cm.z) / rate;
979 sx = (w <= 0) ? 1 : w / rate;
980 sy = (h <= 0) ? 1 : h / rate;
981 sz = (d <= 0) ? 1 : d / rate;
982
983 trans = _ephysics_body_transform_get(body);
984 trans.setOrigin(btVector3(mx, my, mz));
985 body_scale = btVector3(sx, sy, sz);
986
987 if (body->type == EPHYSICS_BODY_TYPE_SOFT)
988 {
989 body->soft_body->scale(btVector3(1, 1, 1) / body->scale);
990 body->soft_body->scale(body_scale);
991 body->rigid_body->proceedToTransform(trans);
992 _ephysics_body_transform_set(body, trans);
993 _ephysics_body_soft_body_constraints_rebuild(body);
994 }
995 else if (body->type == EPHYSICS_BODY_TYPE_CLOTH)
996 {
997 body->soft_body->scale(btVector3(1, 1, 1) / body->scale);
998 body->soft_body->scale(body_scale);
999 _ephysics_body_transform_set(body, trans);
1000 _ephysics_body_cloth_constraints_rebuild(body);
1001 }
1002 else
1003 {
1004 body->collision_shape->setLocalScaling(body_scale);
1005 body->rigid_body->proceedToTransform(trans);
1006
1007 if (!body->rigid_body->isStaticObject())
1008 _ephysics_body_mass_set(body, ephysics_body_mass_get(body));
1009 }
1010
1011 _ephysics_body_transform_set(body, trans);
1012 ephysics_body_activate(body, EINA_TRUE);
1013
1014 body->size.w = w;
1015 body->size.h = h;
1016 body->size.d = d;
1017 body->scale = body_scale;
1018
1019 DBG("Body %p position changed to (%lf, %lf, %lf).", body, mx, my, mz);
1020 DBG("Body %p scale changed to (%lf, %lf, %lf).", body, sx, sy, sz);
1021}
1022
1023static void
965_ephysics_body_resize(EPhysics_Body *body, Evas_Coord w, Evas_Coord h, Evas_Coord d) 1024_ephysics_body_resize(EPhysics_Body *body, Evas_Coord w, Evas_Coord h, Evas_Coord d)
966{ 1025{
967 double rate, sx, sy, sz; 1026 double rate, sx, sy, sz;
@@ -1050,65 +1109,6 @@ _ephysics_body_move(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord
1050} 1109}
1051 1110
1052static void 1111static void
1053_ephysics_body_geometry_set(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord z, Evas_Coord w, Evas_Coord h, Evas_Coord d, double rate)
1054{
1055 double mx, my, mz, sx, sy, sz;
1056 btTransform trans;
1057 int wy, height;
1058 btVector3 body_scale;
1059
1060 ephysics_world_render_geometry_get(body->world, NULL, &wy, NULL,
1061 NULL, &height, NULL);
1062 height += wy;
1063
1064 mx = (x + w * body->cm.x) / rate;
1065 my = (height - (y + h * body->cm.y)) / rate;
1066 mz = (z + d * body->cm.z) / rate;
1067 sx = (w <= 0) ? 1 : w / rate;
1068 sy = (h <= 0) ? 1 : h / rate;
1069 sz = (d <= 0) ? 1 : d / rate;
1070
1071 trans = _ephysics_body_transform_get(body);
1072 trans.setOrigin(btVector3(mx, my, mz));
1073 body_scale = btVector3(sx, sy, sz);
1074
1075 if (body->type == EPHYSICS_BODY_TYPE_SOFT)
1076 {
1077 body->soft_body->scale(btVector3(1, 1, 1) / body->scale);
1078 body->soft_body->scale(body_scale);
1079 body->rigid_body->proceedToTransform(trans);
1080 _ephysics_body_transform_set(body, trans);
1081 _ephysics_body_soft_body_constraints_rebuild(body);
1082 }
1083 else if (body->type == EPHYSICS_BODY_TYPE_CLOTH)
1084 {
1085 body->soft_body->scale(btVector3(1, 1, 1) / body->scale);
1086 body->soft_body->scale(body_scale);
1087 _ephysics_body_transform_set(body, trans);
1088 _ephysics_body_cloth_constraints_rebuild(body);
1089 }
1090 else
1091 {
1092 body->collision_shape->setLocalScaling(body_scale);
1093 body->rigid_body->proceedToTransform(trans);
1094
1095 if (!body->rigid_body->isStaticObject())
1096 _ephysics_body_mass_set(body, ephysics_body_mass_get(body));
1097 }
1098
1099 _ephysics_body_transform_set(body, trans);
1100 ephysics_body_activate(body, EINA_TRUE);
1101
1102 body->size.w = w;
1103 body->size.h = h;
1104 body->size.d = d;
1105 body->scale = body_scale;
1106
1107 DBG("Body %p position changed to (%lf, %lf, %lf).", body, mx, my, mz);
1108 DBG("Body %p scale changed to (%lf, %lf, %lf).", body, sx, sy, sz);
1109}
1110
1111static void
1112_ephysics_body_evas_obj_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) 1112_ephysics_body_evas_obj_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1113{ 1113{
1114 EPhysics_Body *body = (EPhysics_Body *) data; 1114 EPhysics_Body *body = (EPhysics_Body *) data;