[ODE] ? about dAddBodyForce

Michael Molkenthin molle at michael-molkenthin.de
Tue Aug 22 02:05:47 MST 2006


On Mon, 21 Aug 2006, tomek wrote:

> You can change linear speed
>
> --== pseodo c++ ==--
>
> if ( Length (dBodyGetLinearSpeed() ) > MAX_SPEED )
> {
>   direction= Normalize (dBodyGetLinearSpeed());
>   dBodySetLinearSpeed( direction* MAX_SPEED );

instead of setting the speed directly, you could
calculate a single "clipping" force:
dBodyGetLinearSpeed - (direction * MAX_SPEED)

and multiply it by the mass of the body (dMass.mass):

clip_force = ( dBodyGetLinearSpeed - direction*MAX_SPEED ) * dMass.mass;

Then it is ready for a proper

dBodyAddForce(clip_force);

just my 0.02f
Michael

> }
>
> -- 
> Tomek Klin
>
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode
>
>


More information about the ODE mailing list