al right one final change, I made the contact call back filter his own class, this way it can pass more information like what tire is colliding and have the vehicle available, etc
you subclass from
- Code: Select all
class CustomVehicleControllerTireCollisionFilter: public CustomControllerConvexCastPreFilter
and you overload functions
virtual unsigned Prefilter(const NewtonBody* const body, const NewtonCollision* const myCollision)
dFloat GetTireFrictionCoefficient (const CustomVehicleControllerBodyStateTire& tire, const NewtonBody* const body, const NewtonCollision* const myCollision, dLong contacID) const
in function Prefilter, you queries the body user data, or myCollision
for use information, and if it matches some object you do not want collision then you return 0
else return 1
function tire GetTireFrictionCoefficient, gives you the which tire is colliding, from that you can get all the information you need to return a coefficient of friction for that tire.
In general you can modulate the friction by the surface the tire is in, and the slip ratio of the tire.
I am simply return 1.0 as default.
a trick to do cool drifting is to make the front tire have more friction than the rear tire.
example you can make front tire 1.2 and rear 1.0
and you get emerging drift form the physics, not fake like almost all game simulation do. it is really amusing.
you need to sync to github.