forked from enlightenment/efl
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
This commit is contained in:
parent
651b562ebd
commit
829065f97a
|
@ -1523,6 +1523,50 @@ EAPI void ephysics_world_light_all_bodies_set(EPhysics_World *world, Eina_Bool e
|
||||||
*/
|
*/
|
||||||
EAPI Eina_Bool ephysics_world_light_all_bodies_get(const EPhysics_World *world);
|
EAPI Eina_Bool ephysics_world_light_all_bodies_get(const EPhysics_World *world);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* Enable / disable stacking based on bodies z coordinates.
|
||||||
|
*
|
||||||
|
* Evas objects associated to bodies will be restacked when it's enabled.
|
||||||
|
* So if a body A has coordinates x = 10, y = 10, z = 8 and a body B
|
||||||
|
* has coordinates x = 10, y = 10, z = 10, the evas object associated to B
|
||||||
|
* will be displayed below the evas object associated to A.
|
||||||
|
*
|
||||||
|
* Evas objects will be restacked at each simulation tick. It's enabled by
|
||||||
|
* default, and disabling it can lead to wrong scenarios when movement
|
||||||
|
* on Z axis is enabled or when cloths are used.
|
||||||
|
*
|
||||||
|
* But disabling it can save performance, so if you won't face these
|
||||||
|
* scenarios, it safe to disable it, since no evas object will be moved to
|
||||||
|
* be below or above others.
|
||||||
|
*
|
||||||
|
* @param world The physics world.
|
||||||
|
* @param enabled If @c EINA_TRUE, stacking based on Z coordinates will be
|
||||||
|
* enabled, otherwise it will be disabled.
|
||||||
|
*
|
||||||
|
* @see ephysics_world_stack_enable_get()
|
||||||
|
* @see ephysics_body_evas_object_set()
|
||||||
|
*
|
||||||
|
* @ingroup EPhysics_World
|
||||||
|
*/
|
||||||
|
EAPI void ephysics_world_stack_enable_set(EPhysics_World *world, Eina_Bool enabled);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* Get stacking status of world.
|
||||||
|
*
|
||||||
|
* Stacking based on bodies z coordinates can be enabled or disabled.
|
||||||
|
*
|
||||||
|
* @param world The physics world.
|
||||||
|
* @return @c EINA_TRUE if it's running, or @c EINA_FALSE if it's paused or on
|
||||||
|
* error.
|
||||||
|
*
|
||||||
|
* @see ephysics_world_stack_enable_set() for more details.
|
||||||
|
*
|
||||||
|
* @ingroup EPhysics_World
|
||||||
|
*/
|
||||||
|
EAPI Eina_Bool ephysics_world_stack_enable_get(const EPhysics_World *world);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -101,6 +101,7 @@ struct _EPhysics_World {
|
||||||
Eina_Bool outside_front:1;
|
Eina_Bool outside_front:1;
|
||||||
Eina_Bool outside_back:1;
|
Eina_Bool outside_back:1;
|
||||||
Eina_Bool pending_simulation:1;
|
Eina_Bool pending_simulation:1;
|
||||||
|
Eina_Bool stacking:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int _ephysics_world_init_count = 0;
|
static int _ephysics_world_init_count = 0;
|
||||||
|
@ -242,7 +243,8 @@ _ephysics_world_tick(btDynamicsWorld *dynamics_world)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ephysics_body_evas_objects_restack(world);
|
if (world->stacking)
|
||||||
|
ephysics_body_evas_objects_restack(world);
|
||||||
|
|
||||||
if (camera_moved)
|
if (camera_moved)
|
||||||
{
|
{
|
||||||
|
@ -752,8 +754,9 @@ ephysics_world_new(void)
|
||||||
INF("Couldn't initialize the collision filter.");
|
INF("Couldn't initialize the collision filter.");
|
||||||
else
|
else
|
||||||
world->dynamics_world->getPairCache()->setOverlapFilterCallback(
|
world->dynamics_world->getPairCache()->setOverlapFilterCallback(
|
||||||
world->filter_cb);
|
world->filter_cb);
|
||||||
|
|
||||||
|
world->stacking = EINA_TRUE;
|
||||||
world->rate = 30;
|
world->rate = 30;
|
||||||
world->max_sub_steps = 3;
|
world->max_sub_steps = 3;
|
||||||
world->fixed_time_step = 1/60.f;
|
world->fixed_time_step = 1/60.f;
|
||||||
|
@ -1627,6 +1630,29 @@ ephysics_world_light_all_bodies_get(const EPhysics_World *world)
|
||||||
return world->light->all_bodies;
|
return world->light->all_bodies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
ephysics_world_stack_enable_set(EPhysics_World *world, Eina_Bool enabled)
|
||||||
|
{
|
||||||
|
if (!world)
|
||||||
|
{
|
||||||
|
ERR("Can't enable / disable stacking, world wasn't provided.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
world->stacking = !!enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI Eina_Bool
|
||||||
|
ephysics_world_stack_enable_get(const EPhysics_World *world)
|
||||||
|
{
|
||||||
|
if (!world)
|
||||||
|
{
|
||||||
|
ERR("No world, no stacking status for you.");
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return world->stacking;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue