summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2012-10-15 21:54:35 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-10-15 21:54:35 +0000
commitbb90530f7b4240740ae54828bcaa269e909f80de (patch)
treea4b989fc5a3b20e7f377ced374b8aa72f5e3fef8 /legacy
parentc2b0c76b74a05eadc9f0b18db02ec54d822c22e5 (diff)
ephysics: add autodel functions for front and back of
the scene SVN revision: 78016
Diffstat (limited to 'legacy')
-rw-r--r--legacy/ephysics/src/lib/EPhysics.h78
-rw-r--r--legacy/ephysics/src/lib/ephysics_body.cpp14
-rw-r--r--legacy/ephysics/src/lib/ephysics_world.cpp68
3 files changed, 151 insertions, 9 deletions
diff --git a/legacy/ephysics/src/lib/EPhysics.h b/legacy/ephysics/src/lib/EPhysics.h
index 6884b5fe85..e2c34943a8 100644
--- a/legacy/ephysics/src/lib/EPhysics.h
+++ b/legacy/ephysics/src/lib/EPhysics.h
@@ -1033,6 +1033,8 @@ EAPI double ephysics_world_linear_slop_get(const EPhysics_World *world);
1033 * @see ephysics_world_bodies_outside_bottom_autodel_set(). 1033 * @see ephysics_world_bodies_outside_bottom_autodel_set().
1034 * @see ephysics_world_bodies_outside_left_autodel_set(). 1034 * @see ephysics_world_bodies_outside_left_autodel_set().
1035 * @see ephysics_world_bodies_outside_right_autodel_set(). 1035 * @see ephysics_world_bodies_outside_right_autodel_set().
1036 * @see ephysics_world_bodies_outside_front_autodel_set().
1037 * @see ephysics_world_bodies_outside_back_autodel_set().
1036 * 1038 *
1037 * @ingroup EPhysics_World 1039 * @ingroup EPhysics_World
1038 */ 1040 */
@@ -1066,6 +1068,8 @@ EAPI Eina_Bool ephysics_world_bodies_outside_top_autodel_get(const EPhysics_Worl
1066 * @see ephysics_world_bodies_outside_bottom_autodel_get(). 1068 * @see ephysics_world_bodies_outside_bottom_autodel_get().
1067 * @see ephysics_world_bodies_outside_left_autodel_set(). 1069 * @see ephysics_world_bodies_outside_left_autodel_set().
1068 * @see ephysics_world_bodies_outside_right_autodel_set(). 1070 * @see ephysics_world_bodies_outside_right_autodel_set().
1071 * @see ephysics_world_bodies_outside_front_autodel_set().
1072 * @see ephysics_world_bodies_outside_back_autodel_set().
1069 * 1073 *
1070 * @ingroup EPhysics_World 1074 * @ingroup EPhysics_World
1071 */ 1075 */
@@ -1099,6 +1103,8 @@ EAPI Eina_Bool ephysics_world_bodies_outside_bottom_autodel_get(const EPhysics_W
1099 * @see ephysics_world_bodies_outside_right_autodel_get(). 1103 * @see ephysics_world_bodies_outside_right_autodel_get().
1100 * @see ephysics_world_bodies_outside_bottom_autodel_set(). 1104 * @see ephysics_world_bodies_outside_bottom_autodel_set().
1101 * @see ephysics_world_bodies_outside_left_autodel_set(). 1105 * @see ephysics_world_bodies_outside_left_autodel_set().
1106 * @see ephysics_world_bodies_outside_front_autodel_set().
1107 * @see ephysics_world_bodies_outside_back_autodel_set().
1102 * 1108 *
1103 * @ingroup EPhysics_World 1109 * @ingroup EPhysics_World
1104 */ 1110 */
@@ -1132,6 +1138,8 @@ EAPI Eina_Bool ephysics_world_bodies_outside_right_autodel_get(const EPhysics_Wo
1132 * @see ephysics_world_bodies_outside_left_autodel_get(). 1138 * @see ephysics_world_bodies_outside_left_autodel_get().
1133 * @see ephysics_world_bodies_outside_bottom_autodel_set(). 1139 * @see ephysics_world_bodies_outside_bottom_autodel_set().
1134 * @see ephysics_world_bodies_outside_right_autodel_set(). 1140 * @see ephysics_world_bodies_outside_right_autodel_set().
1141 * @see ephysics_world_bodies_outside_front_autodel_set().
1142 * @see ephysics_world_bodies_outside_back_autodel_set().
1135 * 1143 *
1136 * @ingroup EPhysics_World 1144 * @ingroup EPhysics_World
1137 */ 1145 */
@@ -1154,6 +1162,76 @@ EAPI Eina_Bool ephysics_world_bodies_outside_left_autodel_get(const EPhysics_Wor
1154 1162
1155/** 1163/**
1156 * @brief 1164 * @brief
1165 * Set world autodeleting bodies mode when they're outside of render area
1166 * by the front.
1167 *
1168 * @param world The physics world.
1169 * @param autodel If @c EINA_TRUE delete bodies when they are outside render
1170 * area, otherwise, don't delete.
1171 *
1172 * @see ephysics_world_bodies_outside_top_autodel_set() for more details.
1173 * @see ephysics_world_bodies_outside_left_autodel_get().
1174 * @see ephysics_world_bodies_outside_bottom_autodel_set().
1175 * @see ephysics_world_bodies_outside_right_autodel_set().
1176 * @see ephysics_world_bodies_outside_front_autodel_set().
1177 * @see ephysics_world_bodies_outside_back_autodel_set().
1178 *
1179 * @ingroup EPhysics_World
1180 */
1181EAPI void ephysics_world_bodies_outside_front_autodel_set(EPhysics_World *world, Eina_Bool autodel);
1182
1183/**
1184 * @brief
1185 * Get world autodeleting bodies mode when they're outside of render area by
1186 * the front.
1187 *
1188 * @param world The physics world.
1189 * @return @c EINA_TRUE if bodies will be deleted or @c EINA_FALSE if they
1190 * won't, or on error.
1191 *
1192 * @see ephysics_world_bodies_outside_front_autodel_set() for details.
1193 *
1194 * @ingroup EPhysics_World
1195 */
1196EAPI Eina_Bool ephysics_world_bodies_outside_front_autodel_get(const EPhysics_World *world);
1197
1198/**
1199 * @brief
1200 * Set world autodeleting bodies mode when they're outside of render area
1201 * by the back.
1202 *
1203 * @param world The physics world.
1204 * @param autodel If @c EINA_TRUE delete bodies when they are outside render
1205 * area, otherwise, don't delete.
1206 *
1207 * @see ephysics_world_bodies_outside_top_autodel_set() for more details.
1208 * @see ephysics_world_bodies_outside_left_autodel_get().
1209 * @see ephysics_world_bodies_outside_bottom_autodel_set().
1210 * @see ephysics_world_bodies_outside_right_autodel_set().
1211 * @see ephysics_world_bodies_outside_front_autodel_set().
1212 * @see ephysics_world_bodies_outside_back_autodel_set().
1213 *
1214 * @ingroup EPhysics_World
1215 */
1216EAPI void ephysics_world_bodies_outside_back_autodel_set(EPhysics_World *world, Eina_Bool autodel);
1217
1218/**
1219 * @brief
1220 * Get world autodeleting bodies mode when they're outside of render area by
1221 * the back.
1222 *
1223 * @param world The physics world.
1224 * @return @c EINA_TRUE if bodies will be deleted or @c EINA_FALSE if they
1225 * won't, or on error.
1226 *
1227 * @see ephysics_world_bodies_outside_back_autodel_set() for details.
1228 *
1229 * @ingroup EPhysics_World
1230 */
1231EAPI Eina_Bool ephysics_world_bodies_outside_back_autodel_get(const EPhysics_World *world);
1232
1233/**
1234 * @brief
1157 * Set world simulation's fixed time step and max number of sub steps 1235 * Set world simulation's fixed time step and max number of sub steps
1158 * configuration. 1236 * configuration.
1159 * 1237 *
diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp
index 983704f506..e95d965610 100644
--- a/legacy/ephysics/src/lib/ephysics_body.cpp
+++ b/legacy/ephysics/src/lib/ephysics_body.cpp
@@ -1071,11 +1071,11 @@ _ephysics_body_evas_object_default_update(EPhysics_Body *body)
1071static void 1071static void
1072_ephysics_body_outside_render_area_check(EPhysics_Body *body) 1072_ephysics_body_outside_render_area_check(EPhysics_Body *body)
1073{ 1073{
1074 int wx, wy, ww, wh, bx, by, bw, bh; 1074 int wx, wy, wz, ww, wh, wd, bx, by, bz, bw, bh, bd;
1075 1075
1076 ephysics_world_render_geometry_get(body->world, &wx, &wy, NULL, 1076 ephysics_world_render_geometry_get(body->world, &wx, &wy, &wz,
1077 &ww, &wh, NULL); 1077 &ww, &wh, &wd);
1078 ephysics_body_geometry_get(body, &bx, &by, NULL, &bw, &bh, NULL); 1078 ephysics_body_geometry_get(body, &bx, &by, &bz, &bw, &bh, &bd);
1079 1079
1080 // FIXME: check what should be done regarding rotated bodies 1080 // FIXME: check what should be done regarding rotated bodies
1081 if (((ephysics_world_bodies_outside_top_autodel_get(body->world)) && 1081 if (((ephysics_world_bodies_outside_top_autodel_get(body->world)) &&
@@ -1085,7 +1085,11 @@ _ephysics_body_outside_render_area_check(EPhysics_Body *body)
1085 ((ephysics_world_bodies_outside_left_autodel_get(body->world)) && 1085 ((ephysics_world_bodies_outside_left_autodel_get(body->world)) &&
1086 (bx + bh < wx)) || 1086 (bx + bh < wx)) ||
1087 ((ephysics_world_bodies_outside_right_autodel_get(body->world)) && 1087 ((ephysics_world_bodies_outside_right_autodel_get(body->world)) &&
1088 (bx > wx + ww))) 1088 (bx > wx + ww)) ||
1089 ((ephysics_world_bodies_outside_front_autodel_get(body->world)) &&
1090 (bz + bd < wz)) ||
1091 ((ephysics_world_bodies_outside_back_autodel_get(body->world)) &&
1092 (bz > wz + wd)))
1089 { 1093 {
1090 DBG("Body %p out of render area", body); 1094 DBG("Body %p out of render area", body);
1091 ephysics_body_del(body); 1095 ephysics_body_del(body);
diff --git a/legacy/ephysics/src/lib/ephysics_world.cpp b/legacy/ephysics/src/lib/ephysics_world.cpp
index d4981458b2..0a70ccde38 100644
--- a/legacy/ephysics/src/lib/ephysics_world.cpp
+++ b/legacy/ephysics/src/lib/ephysics_world.cpp
@@ -97,6 +97,8 @@ struct _EPhysics_World {
97 Eina_Bool outside_bottom:1; 97 Eina_Bool outside_bottom:1;
98 Eina_Bool outside_left:1; 98 Eina_Bool outside_left:1;
99 Eina_Bool outside_right:1; 99 Eina_Bool outside_right:1;
100 Eina_Bool outside_front:1;
101 Eina_Bool outside_back:1;
100 Eina_Bool pending_simulation:1; 102 Eina_Bool pending_simulation:1;
101}; 103};
102 104
@@ -1284,7 +1286,8 @@ ephysics_world_bodies_outside_top_autodel_set(EPhysics_World *world, Eina_Bool a
1284 1286
1285 world->outside_top = !!autodel; 1287 world->outside_top = !!autodel;
1286 world->outside_autodel = world->outside_top || world->outside_bottom || 1288 world->outside_autodel = world->outside_top || world->outside_bottom ||
1287 world->outside_left || world->outside_right; 1289 world->outside_left || world->outside_right ||
1290 world->outside_front || world->outside_back;
1288} 1291}
1289 1292
1290EAPI Eina_Bool 1293EAPI Eina_Bool
@@ -1310,7 +1313,8 @@ ephysics_world_bodies_outside_bottom_autodel_set(EPhysics_World *world, Eina_Boo
1310 1313
1311 world->outside_bottom = !!autodel; 1314 world->outside_bottom = !!autodel;
1312 world->outside_autodel = world->outside_top || world->outside_bottom || 1315 world->outside_autodel = world->outside_top || world->outside_bottom ||
1313 world->outside_left || world->outside_right; 1316 world->outside_left || world->outside_right ||
1317 world->outside_front || world->outside_back;
1314} 1318}
1315 1319
1316EAPI Eina_Bool 1320EAPI Eina_Bool
@@ -1336,7 +1340,8 @@ ephysics_world_bodies_outside_left_autodel_set(EPhysics_World *world, Eina_Bool
1336 1340
1337 world->outside_left = !!autodel; 1341 world->outside_left = !!autodel;
1338 world->outside_autodel = world->outside_top || world->outside_bottom || 1342 world->outside_autodel = world->outside_top || world->outside_bottom ||
1339 world->outside_left || world->outside_right; 1343 world->outside_left || world->outside_right ||
1344 world->outside_front || world->outside_back;
1340} 1345}
1341 1346
1342EAPI Eina_Bool 1347EAPI Eina_Bool
@@ -1362,7 +1367,8 @@ ephysics_world_bodies_outside_right_autodel_set(EPhysics_World *world, Eina_Bool
1362 1367
1363 world->outside_right = !!autodel; 1368 world->outside_right = !!autodel;
1364 world->outside_autodel = world->outside_top || world->outside_bottom || 1369 world->outside_autodel = world->outside_top || world->outside_bottom ||
1365 world->outside_left || world->outside_right; 1370 world->outside_left || world->outside_right ||
1371 world->outside_front || world->outside_back;
1366} 1372}
1367 1373
1368EAPI Eina_Bool 1374EAPI Eina_Bool
@@ -1377,6 +1383,60 @@ ephysics_world_bodies_outside_right_autodel_get(const EPhysics_World *world)
1377 return world->outside_right; 1383 return world->outside_right;
1378} 1384}
1379 1385
1386EAPI void
1387ephysics_world_bodies_outside_front_autodel_set(EPhysics_World *world, Eina_Bool autodel)
1388{
1389 if (!world)
1390 {
1391 ERR("Can't set autodelete mode, world is null.");
1392 return;
1393 }
1394
1395 world->outside_front = !!autodel;
1396 world->outside_autodel = world->outside_top || world->outside_bottom ||
1397 world->outside_left || world->outside_right ||
1398 world->outside_front || world->outside_back;
1399}
1400
1401EAPI Eina_Bool
1402ephysics_world_bodies_outside_front_autodel_get(const EPhysics_World *world)
1403{
1404 if (!world)
1405 {
1406 ERR("Can't get autodelete mode, world is null.");
1407 return EINA_FALSE;
1408 }
1409
1410 return world->outside_front;
1411}
1412
1413EAPI void
1414ephysics_world_bodies_outside_back_autodel_set(EPhysics_World *world, Eina_Bool autodel)
1415{
1416 if (!world)
1417 {
1418 ERR("Can't set autodelete mode, world is null.");
1419 return;
1420 }
1421
1422 world->outside_back = !!autodel;
1423 world->outside_autodel = world->outside_top || world->outside_bottom ||
1424 world->outside_left || world->outside_right ||
1425 world->outside_front || world->outside_back;
1426}
1427
1428EAPI Eina_Bool
1429ephysics_world_bodies_outside_back_autodel_get(const EPhysics_World *world)
1430{
1431 if (!world)
1432 {
1433 ERR("Can't get autodelete mode, world is null.");
1434 return EINA_FALSE;
1435 }
1436
1437 return world->outside_back;
1438}
1439
1380EAPI Eina_Bool 1440EAPI Eina_Bool
1381ephysics_world_bodies_outside_autodel_get(const EPhysics_World *world) 1441ephysics_world_bodies_outside_autodel_get(const EPhysics_World *world)
1382{ 1442{