Raycast wheel falling through terrain

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
cjhazard
Posts: 35
Joined: Mon Aug 01, 2011 8:05 pm

Raycast wheel falling through terrain

Post by cjhazard »

I am using the BEPU vehicle with raycast wheels. Occasionally some or all of the wheels will fall through the terrain...

Image

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?

Thanks.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Raycast wheel falling through terrain

Post by Norbo »

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.
cjhazard
Posts: 35
Joined: Mon Aug 01, 2011 8:05 pm

Re: Raycast wheel falling through terrain

Post by cjhazard »

Wow! Quick reply or what!

Thanks Norbo, that seems the likely culprit to me. I'll try it out tomorrow and let you know... laptop battery almost dead. :D
cjhazard
Posts: 35
Joined: Mon Aug 01, 2011 8:05 pm

Re: Raycast wheel falling through terrain

Post by cjhazard »

Excellent stuff! I increased the scale of my car (it was VERY small) and it seems to have cured the problem. What you said made perfect sense.

However, I've noticed another issue which I'll post in a separate thread.

Thanks again! :D
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Raycast wheel falling through terrain

Post by Norbo »

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 :)
cjhazard
Posts: 35
Joined: Mon Aug 01, 2011 8:05 pm

Re: Raycast wheel falling through terrain

Post by cjhazard »

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.

Cheers Norbo!
Post Reply