Hi Erwin,
Erwin Coumans wrote:The raycast vehicle uses a raycast to determine contact with the ground, so it will not use the regular collision detection (and hence no gContactAddedCallback, if you get gContactAddedCallback calls it means the chassis is touching the environment).
Ah - that would explain what I see, and means that I can remove all of this gContactAddedCallback handling
.
Please check and modify the following method in Bullet/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp:
Code: Select all
void btRaycastVehicle::updateFriction(btScalar timeStep).
I just made 'updateFriction' a virtual method, so you can customize the friction model in your derived class.
I had a quick look, it appears to be a lot of work. Without really studying all of the code, I guess I'd have to:
- write a new castRay plus result structure, since the triangle index information is lost somewhere from the AddSingleResult call in the rayTest to the castRay call of the vehicle. I don't want to have separate bodies for each material (which would be easier to handle otherwise, since this information is available in m_groundObject), since in my case I end up with many bodies for the actual track: e.g. there would be road, road_grass, grass, grass_beach, beach for a track with a road, some grass on the side before beach is coming - meaning 5 bodies to test instead of one. That would add (I guess) some unnecessary overhead for rayTesting, collision detection etc.(?)
- understand updateFriction and rewrite it
Would it be possible to add a more convenient interface for this problem to bullet? After all, I would suspect that most programs using the raycast vehicle will face this problem sooner or later. This is not an urgent issue for me at the moment, since skidding is currently being scheduled for the release after the next (I was rather surprised how easy it was to add friction when I looked at the gContactAddedCallback, which I though would solve my 'when to trigger automatic rescue' problem ... which it is not
).
As a side note, after a very quick glance at the code in updateFriction:
Code: Select all
btScalar maximp = wheelInfo.m_wheelsSuspensionForce * timeStep * wheelInfo.m_frictionSlip
...
if (impulseSquared > maximpSquared)
{
sliding = true;
btScalar factor = maximp / btSqrt(impulseSquared);
...
m_wheelInfo[wheel].m_skidInfo *= factor;
}
Wouldn't it be enough if I modified the wheelInfo.m_frictionSlip in each timestep to get the desired effect (i.e. skidding)?
Thanks for your quick answer!
Joerg