These FAQs and background info will be updated periodically...

--------------------------------------------------------------------------

Q: My object is hanging in mid-air ?
A: Make sure you call ph_setgravity(), that there is no other entity nearby blocking the physics entity and that your level is surrounded by a skybox (hollow cube).


Q: What does "1 physics object" in A6 Commercial mean ?

A: You can have multiple objects with physcis, but only one can be active at any time. So you could have a door that uses physics, and a barrel that also uses them. When the player is close to the door, the door's physics are enabled. When the player is further away from the door, its physics are turned off. When the player gets close to the barrel, the barrel's physics are turned on and then when the player is out of sight, the physics are turned off.

--------------------------------------------------------------------------

time_physics is the amount of time spent calculating the new positions (CPU utilization if you want). It is _not_ related to game time or anything else.

FPS_MAX sets the frequency of display updates, PH_FPS_MAX sets the frequency of physics updates. This is easier if you think of it in terms of the inverse though: frame duration. Let's say display frame duration was 0.1 seconds (=10 fps) and physics frame duration was set to 0.01 seconds (=100 fps). In that case the physics engine gets called with a time value of 0.1 seconds and splits this into 10 tiny steps each 0.01 seconds long. At the end of these 10 steps the object is displayed at its new position.
What happens when fps_max is not a multiple of ph_fps_max ? The physics engine stores the remainder and keeps adding/subtracting from this time value in ph_fps_max duration increments. If fps_max was 0.003 threeframes would pass with physics objects not moving and the internal counter being increased to 0.003, 0.006, 0.009. In the fourth frame the value reaches 0.012, one 0.01 physics step is taken and subtracted from the counter which is now left at 0.002.

--------------------------------------------------------------------------

We have just noticed a problem with physics synchronization when time_smooth is used (assuming that fps_lock is also used which is a good idea). Physics objects may appear to occasionally jump forward every N frames due to rounding errors combined with time interpolation caused by time_smooth

Solution: set time_smooth=0 at the very beginning of your main !

--------------------------------------------------------------------------

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.

Last edited by Marco_Grubert; 02/17/06 22:28.