I use convex casting with my player controller to detect the ground, but Newton "optimizes" the results too aggressively; If I hit a slope that is not walkable, Newton returns this result and stops looking for results below that surface. This is causing some major problems because if my player runs into a steep slope, they fall into the ground.
I am aware of how Newton ray casts reduce the ray length each time a hit occurs. Normally this is good, but in this case I need to be able to detect all hits, as some of them are considered "invalid" and are to be ignored.
I'm poking around in the source, but am having trouble finding the place where a cylinder performs a convex cast against a collision tree shape. Can you point me in the right direction?
int NewtonWorldCollide (const NewtonWorld* const newtonWorld, const dFloat* const matrix, const NewtonCollision* const shape, void* const userData, NewtonWorldRayPrefilterCallback prefilter, NewtonWorldConvexCastReturnInfo* const info, int maxContactsCount, int threadIndex); int NewtonWorldConvexCast (const NewtonWorld* const newtonWorld, const dFloat* const matrix, const dFloat* const target, const NewtonCollision* const shape, dFloat* const hitParam, void* const userData, NewtonWorldRayPrefilterCallback prefilter, NewtonWorldConvexCastReturnInfo* const info, int maxContactsCount, int threadIndex);
The ray cast take filter and prefilter that workl ar the featre granularity of the collsion, the contact calculation work at the object collision granularity they only take prefilter; My guess is that you are using a NewtonWorldConvexCast function to do that job of a NewtonWorldConvexRayCast.
NewtonWorldConvexRayCast is a convex cast that works like using NewtonWorldConvexCast, but is does not calculate contacts, I use for the player controller.
The results of this command are really nice. I've finally got control of my player and I have resolved a lot of little problems.
The only issue I have now is that it seems like the convex raycast misses heightfields, until I am almost falling through it. It seems like the AABB overlap code might have a problem? I am using a rather older copy of the source code: http://www.leadwerks.com/post/convexcast.avi
Actually, I found that the convex casting on terrain is still experiencing the same problem:
I move the cylinder up by the step height and cast downwards, the distance of the step height. It seems like no raycast is detected until the starting position intersects the height field, making the character controller bounce up and down. It looks like the AABB overlap test is not working right.
It works perfectly on everything but height fields.