summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2012-10-25 21:55:23 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-10-25 21:55:23 +0000
commit829065f97ad506fc5daf12f301a964a68290f6ac (patch)
treead6ea04fd8bb7d9f8b80540c14a9c5accbd15ca2 /legacy
parent651b562ebd94d1d738dc1aed9534f4f6184cccaa (diff)
ephysics: support disabling stacking based on Z axis
Since now we support movement on Z axis the evas objects associated to bodies need to be re-stacked to be below / above each other. But if Z axis movement is disabled, no cloth is used, ..., it can be safely disabled, since evas objects won't overlap. And it will save performance. SVN revision: 78491
Diffstat (limited to '')
-rw-r--r--legacy/ephysics/src/lib/EPhysics.h44
-rw-r--r--legacy/ephysics/src/lib/ephysics_world.cpp30
2 files changed, 72 insertions, 2 deletions
diff --git a/legacy/ephysics/src/lib/EPhysics.h b/legacy/ephysics/src/lib/EPhysics.h
index 4c2f64fe9c..b6d739bdd2 100644
--- a/legacy/ephysics/src/lib/EPhysics.h
+++ b/legacy/ephysics/src/lib/EPhysics.h
@@ -1524,6 +1524,50 @@ EAPI void ephysics_world_light_all_bodies_set(EPhysics_World *world, Eina_Bool e
1524EAPI Eina_Bool ephysics_world_light_all_bodies_get(const EPhysics_World *world); 1524EAPI Eina_Bool ephysics_world_light_all_bodies_get(const EPhysics_World *world);
1525 1525
1526/** 1526/**
1527 * @brief
1528 * Enable / disable stacking based on bodies z coordinates.
1529 *
1530 * Evas objects associated to bodies will be restacked when it's enabled.
1531 * So if a body A has coordinates x = 10, y = 10, z = 8 and a body B
1532 * has coordinates x = 10, y = 10, z = 10, the evas object associated to B
1533 * will be displayed below the evas object associated to A.
1534 *
1535 * Evas objects will be restacked at each simulation tick. It's enabled by
1536 * default, and disabling it can lead to wrong scenarios when movement
1537 * on Z axis is enabled or when cloths are used.
1538 *
1539 * But disabling it can save performance, so if you won't face these
1540 * scenarios, it safe to disable it, since no evas object will be moved to
1541 * be below or above others.
1542 *
1543 * @param world The physics world.
1544 * @param enabled If @c EINA_TRUE, stacking based on Z coordinates will be
1545 * enabled, otherwise it will be disabled.
1546 *
1547 * @see ephysics_world_stack_enable_get()
1548 * @see ephysics_body_evas_object_set()
1549 *
1550 * @ingroup EPhysics_World
1551 */
1552EAPI void ephysics_world_stack_enable_set(EPhysics_World *world, Eina_Bool enabled);
1553
1554/**
1555 * @brief
1556 * Get stacking status of world.
1557 *
1558 * Stacking based on bodies z coordinates can be enabled or disabled.
1559 *
1560 * @param world The physics world.
1561 * @return @c EINA_TRUE if it's running, or @c EINA_FALSE if it's paused or on
1562 * error.
1563 *
1564 * @see ephysics_world_stack_enable_set() for more details.
1565 *
1566 * @ingroup EPhysics_World
1567 */
1568EAPI Eina_Bool ephysics_world_stack_enable_get(const EPhysics_World *world);
1569
1570/**
1527 * @} 1571 * @}
1528 */ 1572 */
1529 1573
diff --git a/legacy/ephysics/src/lib/ephysics_world.cpp b/legacy/ephysics/src/lib/ephysics_world.cpp
index 8900f69cb3..41d089eea7 100644
--- a/legacy/ephysics/src/lib/ephysics_world.cpp
+++ b/legacy/ephysics/src/lib/ephysics_world.cpp
@@ -101,6 +101,7 @@ struct _EPhysics_World {
101 Eina_Bool outside_front:1; 101 Eina_Bool outside_front:1;
102 Eina_Bool outside_back:1; 102 Eina_Bool outside_back:1;
103 Eina_Bool pending_simulation:1; 103 Eina_Bool pending_simulation:1;
104 Eina_Bool stacking:1;
104}; 105};
105 106
106static int _ephysics_world_init_count = 0; 107static int _ephysics_world_init_count = 0;
@@ -242,7 +243,8 @@ _ephysics_world_tick(btDynamicsWorld *dynamics_world)
242 } 243 }
243 } 244 }
244 245
245 ephysics_body_evas_objects_restack(world); 246 if (world->stacking)
247 ephysics_body_evas_objects_restack(world);
246 248
247 if (camera_moved) 249 if (camera_moved)
248 { 250 {
@@ -752,8 +754,9 @@ ephysics_world_new(void)
752 INF("Couldn't initialize the collision filter."); 754 INF("Couldn't initialize the collision filter.");
753 else 755 else
754 world->dynamics_world->getPairCache()->setOverlapFilterCallback( 756 world->dynamics_world->getPairCache()->setOverlapFilterCallback(
755 world->filter_cb); 757 world->filter_cb);
756 758
759 world->stacking = EINA_TRUE;
757 world->rate = 30; 760 world->rate = 30;
758 world->max_sub_steps = 3; 761 world->max_sub_steps = 3;
759 world->fixed_time_step = 1/60.f; 762 world->fixed_time_step = 1/60.f;
@@ -1627,6 +1630,29 @@ ephysics_world_light_all_bodies_get(const EPhysics_World *world)
1627 return world->light->all_bodies; 1630 return world->light->all_bodies;
1628} 1631}
1629 1632
1633EAPI void
1634ephysics_world_stack_enable_set(EPhysics_World *world, Eina_Bool enabled)
1635{
1636 if (!world)
1637 {
1638 ERR("Can't enable / disable stacking, world wasn't provided.");
1639 return;
1640 }
1641 world->stacking = !!enabled;
1642}
1643
1644EAPI Eina_Bool
1645ephysics_world_stack_enable_get(const EPhysics_World *world)
1646{
1647 if (!world)
1648 {
1649 ERR("No world, no stacking status for you.");
1650 return EINA_FALSE;
1651 }
1652
1653 return world->stacking;
1654}
1655
1630#ifdef __cplusplus 1656#ifdef __cplusplus
1631} 1657}
1632#endif 1658#endif