EPhysics - Sleeping Threshold

The purpose of this example is to demonstrate the EPhysics Sleeping Threshold usage - The code apply sleeping threshold in two cubes.

For this example we'll have an EPhysics_World, and two basic EPhysics_Bodys.

The basic concepts like - defining an EPhysics_World, render geometry, physics limiting boundaries, add an EPhysics_Body, associate it to evas objects, change restitution, friction and impulse properties, were already covered in EPhysics - Bouncing Ball

Concept of velocity were already covered in EPhysics - Velocity

Adding Max Sleeping Time

Setting the max sleeping time determines how long(in seconds) a rigid body under the linear and angular threshold is supposed to be marked as sleeping.

Adding a Sleeping Threshold

Here we set EPhysics_Bodys linear and angular sleeping threshold. These factors are used to determine whenever a rigid body is supposed to increment the sleeping time.

After every tick the sleeping time is incremented. After reaching the max sleeping time the body is market to sleep, that means the rigid body is to be deactivated.

ephysics_body_sleeping_threshold_set(sphere_body1, 60, 360);
ephysics_body_sleeping_threshold_set(sphere_body2, 10, 360);

We can get the EPhysics_Bodys linear and angular sleeping threshold as well.

ephysics_body_sleeping_threshold_get(sphere_body1, &linear, &angular);
ephysics_body_sleeping_threshold_get(sphere_body2, &linear, &angular);

Adding a Damping

Here we set EPhysics_Bodys linear and angular damping values.The damping is a force synchronous with the velocity of the object but in opposite direction - like air resistance.

ephysics_body_damping_set(sphere_body1, 0.5, 0.5);
ephysics_body_damping_set(sphere_body2, 0.5, 0.5);

Here we finish the example. The full source code can be found at test_sleeping_threshold.c.