There is not way to get that equal at different update rates because damping if a not linear function.
It already considering the time steps scaling but that assumes the body velocity is not affected by externals forces.
This is the nature of numerical integration, the smaller integration step the more accurate it is.
what most people do is that the run the simulation at a fix rate. But I do not know how to do numerical integration the always produce the same result independent of the integration step.
Below is the function that calculate that adjust the damping coefficient to math the time step is this.
It caches the time step because assumes fix time step and because the Pow function is quite expensive to run thousand of time per frame.
try commenting out the read and see if there is a bug with the caching, but Like I said the
compensation will only generate correct result if the body in moving under the effect for the drag force and not other forces are action on it.
- Code: Select all
DG_INLINE const dgVector& dgDynamicBody::GetDampCoeffcient (dgFloat32 timestep)
{
[color=#FF4040]// try commenting this line out to see if there is a bug.[/color]
if (dgAbs(m_cachedTimeStep - timestep) > dgFloat32(1.0e-6f))
{
m_cachedTimeStep = timestep;
const dgFloat32 tau = dgFloat32(1.0f) / (dgFloat32(60.0f) * timestep);
m_cachedDampCoef.m_x = dgPow(dgFloat32(1.0f) - m_dampCoef.m_x, tau);
m_cachedDampCoef.m_y = dgPow(dgFloat32(1.0f) - m_dampCoef.m_y, tau);
m_cachedDampCoef.m_z = dgPow(dgFloat32(1.0f) - m_dampCoef.m_z, tau);
m_cachedDampCoef.m_w = dgPow(dgFloat32(1.0f) - m_dampCoef.m_w, tau);
}
return m_cachedDampCoef;
}
Engines which are impulse based can do this better than newton because they first integrate external forces and them clip impulses to resolve constraint violation, this make those engine first order differential equations integrators.
This can make engines that run fast and stable but with the very wrong physics simulation, because the equation of motion say the motion of a body is the summation of all forces, not the summation of all impulses.
Newton apply the external forces, them calculate the reactions forces and finally integrate force and them integrate velocity. This make newton a second order integrator.
Most people do not care about these thongs, but I am telling you so that you know what you get into.
I try to minimize the maximum number of cheats in the engine, but this implied some thing will be different.
This is the secret that makes in general Newton a better physics simulator than impulse based which are basically collision systems that resolve interpenetration at the expenses of really wrong physics behavior.