I am using the BEPU vehicle with raycast wheels. Occasionally some or all of the wheels will fall through the terrain...
I'm not sure if it's to do with the scale of the vehicle/wheels or the mass (increasing the mass seems to make it happen more often) or something else??
Can anyone help me get to the root of the problem please?
My first guess would be that the origin of the wheel ray cast is either exposed (outside of the vehicle body) or very close to it. Once the origin goes underground, it has nothing to hit. The ground is 'above' the wheel. The fact that it correlates somewhat with increased mass is supporting evidence; a heavier car would tend to squish the suspension more, resulting in more chances for the ray to get stuck underground.
Starting the wheel cast within the vehicle body will prevent the ray from being stuck underground. The ray will be protected by the collision handling of the vehicle body.
If you're curious as to why being super tiny had the effect it did, the engine is tuned for a certain size range by default. An extremely small object will fall victim to contact invalidation (the engine doesn't like to create contacts right on top of each other; it is a waste of cycles), penetration resolution thresholds (the solver won't bother correcting very tiny penetration; it helps avoid jitter) and a variety of other cumulative small effects.
These tuning factors can be changed if necessary. The ConfigurationHelper.ApplyScale method and associated ScaleDemo in the BEPUphysicsDemos shows the most important collection of tuning factors which need to be changed if the scale interpretation is substantially different than the default. It's always recommended to stay within the default if possible though, so scaling up the car was probably a good idea
Thanks Norbo. I was aware from reading other posts previously that tiny scales (and very large scales) can cause issues... I just didn't realise my car was quite so small! LOL!
Anyway, it's almost all good now, but I think my maths is a bit off when calculating the wheel offset for the suspension settings. It's most likely something obvious I'm missing as I only get the problem now with high mass settings or small suspension rest length. I'll figure it out soon.