ph_setautodisable (var maxlinear, var maxangular, var minframes, var mintime)
Checks whether objects have been mostly at rest in the past few frames,
and if so, disables them until they are moved or part of a collision.
Without auto disabling, physics entities are never completely at rest and require
frequent processing which consumes CPU time. Even if a physics entity appears
to be resting on the ground, what's really happening is that it sinks into the
ground due to gravity, then gets pushed out a bit (maybe 0.001 quants), then sinks
in again, etc. Often this produces a collision every 3 frames, which could be
avoided by suspending the entity a fraction of a quant above the ground.
At engine startup, auto-disabling is automatically activated with the default
values (0.01, 0.008, 10, 0.1). This means that entities get suspended when
within the past 10 physics frames or 0.1 seconds (whichever is longer) they a)
have not moved faster than 0.01 quants per sec and b) have not rotated faster
than 0.008 rad per sec
In some cases these values are too optimistic since spheres can easily pick
up angular velocity on slightly sloped terrain. On the other hand a box straddling
the edge of another box might move very slowly before it eventually falls down.
For this reason it's a good idea to change the values in game and see how objects
react to them. If they get stuck in weird positions, the maximum values were
too big or the timeframe too short. For the other extreme, no autodisabling
at all, you should monitor ph_num_contacts
and make sure that it equals 0 whenever there is no apparent movement and no
phent_ instructions are being executed.
maxlinear - maximum linear speed (quants per second) that qualifies
as resting; default 0.01.
maxangular - maximum angular speed that qualifies as resting,
minframes - minimum number of physics frames that an object must
be resting before it gets disabled; default 10.
mintime - minimum time (in seconds) that an object must be resting
before it gets disabled; default 0.1.
- minframes depends on the value of ph_fps_max_lock.
By default, one physics frame lasts 1/70th of a second ( 70 Hz) thus you can
set minframes 70*mintime.
- If maxlinear or maxangular is set to values
- When a disabled object comes into contact with a moving body, it will automatically
When objects tend to start vibrating or rotating at rest, increase the disabling speed limits, e.g. with ph_setautodisable(1.0,1.0,10,0.1);
// Activats/Deactivates Autodisabling
ph_setautodisable(100,100,100,100); // turn off
ph_setautodisable(0.01, 0.008, 10, 0.1); // turn on and set default values