Reminder: ph_setautodisable

Posted By: Marco_Grubert

Reminder: ph_setautodisable - 04/12/05 22:36

Just a little reminder that you have the function ph_setautodisable in your physics toolbox and if you have not been using it you might want to do so in the future. What this function does is it 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 (=CPU time) ! Even if a physics entity appears to be resting on the ground what is 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 times you will get a collision every 3 frames this way 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 following values: ph_setautodisable(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 have
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.
Posted By: fastlane69

Re: Reminder: ph_setautodisable - 04/18/05 22:39

Hi Marco,

Could you make these and other similar reminders as stickys so they are at the top of the list and we don't end up forgetting?
© 2024 lite-C Forums