Vehicle raycasts seems to affect other vehicles

Hi, i’ve been noticing a strange behavior in my racing game.

I have multiple vehicles, and when one of the vehicles turns upside down, or go up to high, or get out of the scene (falls from defined ground, for example), it seems to affect other cars raycasts, by making them to sink into the ground, and their stand only in the ground supported by the body of the vehicle itself, not the wheels… it looks like, if a vehicle wheels fails to get a valid raycast (don’t find ground), somehow affects other cars wheels.

Not sure why this happens… i’m using physx 3.3.0.

I’m doing the raycasts (PxVehicleSuspensionRaycasts(…)), followed by PxVehicleUpdates(…), on every step.

I’ve taken too much time to figure this out myself, but simply can’t understand what’s happening…

Any help would be appreciated!

Thanks!

It sounds like the raycasts for each vehicle stop returning a hit with the ground when one of them falls out of the world or goes upside down. This makes me think that they are all sharing the same raycast results. Is this plausible? For example, if your track was perfectly flat it might not be immediately clear that they are all colliding sharing the same raycast result because the result would be correct for all vehicles. Is your track a flat plane?

Thanks,

Gordon

Hi Gordon, thanks for the reply. I’ve followed that lead just after noticing this… the track is not all flat.

I’ve done numerous tests (also visual ones) that show me that they are not sharing the same raycast results. I found a workaround for this - set an extremely high value for the suspension spring. This keeps affected vehicles above the road, instead of sink into the ground, and drivable, but it’s not the perfect scenario… this also shows that affected vehicle have hits with the ground, contrary to vehicle that may be upside down or out of scene.

Any other thought that may occur to you?

Thanks!
Carlos V.

I can’t think of anything obvious. It’s worth doing some quick experiements, though, to help diagonose the problem. The first would be to update each vehicle individually rather than pass an array of vehicles to PxVehicleUpdates.

Let’s say you have an array of N vehicles and you currently do the following:

PxVehicleSuspensionRaycasts(batchQuery, N, vehicleArray, etc etc);
PxVehicleUpdates(params, other params, N, vehicleArray);

You could do the following instead:

for(int i = 0; i < N; i++)
{
PxVehicleSuspensionRaycasts(batchQuery, 1, &vehicleArray[i], etc etc);
PxVehicleUpdates(params, other params, i, &vehicleArray[i]);
}

or

for(int i = 0; i < N; i++)
{
PxVehicleSuspensionRaycasts(batchQuery, 1, &vehicleArray[i], etc etc);
}
for(int i = 0; i < N; i++)
{
PxVehicleUpdates(params, other params, i, &vehicleArray[i], etc etc);
}

It would be interesting to see the results with different update orders.

Thanks,

Gordon

I’m actually raycasting and updating one at a time, like one of yours suggestions. I already tested also raycasting and updating all vehicles at once, with no luck…

I’ve tried just now your last suggestion, with no luck too :(

Just weird stuff going on here ;)

Thanks!

The next step would be to use pvd to visualise the raycasts. This will let you see the extent and direction of every suspension raycast, along wtih the hit triangle, position and normal. My guess is that the error is in the raycast rather than the vehicle update.

Gordon

Hi Gordon, i will test it like that… thanks for the suggestion!

Carlos V.

Hi Gordon,

I’ve never used PVD before, so i went looking for info about it… unfortunaly i think it will be necessary Visual Studio and Windows to use it… well, i just use Linux so i guess this is not an option for me right now.

Could you lead me to how to get the raycasts information so that i can print them out myself?

Thank You!

Carlos V.

Hi,

Pretty much everything of relevance is available for inspection in PxWheelQueryResult immediately after callling PxVehicleUpdates.

The extents of the most recent raycast are stored in these member variables:

PxVec3 suspLineStart;
PxVec3 suspLineDir;
PxReal suspLineLength;

The results of the most recent raycast are stored here:

PxVec3 tireContactPoint;
PxVec3 tireContactNormal;

Hope this helps,

Gordon

Dear Gordon, Dear Carlos,
I have exactly the same issue in my current game.
the issue occur only with a lot of vehicles and never with only one.
I think i have investigated more deeper than you. This is the result of my last investigations:
The raycast results seems to be ok, and the code in process Suspire Wheels seems to work fine. The issue seems to be located in susp limit constraint.
I strongly suspect an bug on the management of Px1 Constraint when we have a lot of constraints ( we can have a maximun of 4 constraint per vehicles, and the static const PxU32 MAX_CONSTRAINTS = 12 look a lot optimistic).
early in the thread carlos write : “I found a workaround for this - set an extremely high value for the suspension spring.”
With this workaround, the susp limit constraint is never needed, and the bug don’t occur.
Like Carlos, I need a real bugfix, i can’t keep hardest springs in my game.
Gordon, have you any idea ?

Regards,
David Alloza

Hi,
I put here the solution:

This bug is fixed on last PhysX version.

If you use an old version, to fix this issue you must remove the line:

[i]data->mSuspLimitData.mActiveFlags = false;

in file : PxVehicleSuspLimitConstraintShader.h

regards,
David Alloza.

Edit…

Edit…