Raycast vehicle problems

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Raycast vehicle problems

Postby pHySiQuE » Wed Nov 26, 2014 3:12 am

I have a lot of problems with raycast vehicles hitting my character controllers and "popping" up with a lot of force. This is due to the nature of the character controllers, which are not as exact as regular physics. Is there any way to make the tires ignore certain objects in the raycast? Could it just use the body's OnAABBOverlap function?

pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Raycast vehicle problems

Postby Julio Jerez » Wed Nov 26, 2014 4:38 am

ha yes, the collision filer was had coded. I added that now.

If you sync to github the vehicle has a functionality now

there is a new function
SetContactFilter(CustomControllerConvexCastPreFilter* const filter);

what you do is that after you crate the vehicle to create an objet of type
file \packages\dCustomJoints\CustomControllerManager.h CustomControllerConvexCastPreFilter

and you overload function
CUSTOM_JOINTS_API virtual unsigned Prefilter(const NewtonBody* const body, const NewtonCollision* const myCollision)

there you can check if body or collision shape is one tat you want to collide or skip.
if you want to collide you return 1 other wise you return 0.

you get the information you need from the userdata on the collision or on the body as usual.

if you do no set a collision filter, the engine set the normal one as it was doing before, so it should works.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Raycast vehicle problems

Postby Julio Jerez » Wed Nov 26, 2014 4:43 am

the other thing is that, even without a filter that should no happens. when I play the video I see that the tire rise way above the chassis. as if there did not have a upper limit but the do.

did you set the tire pivot too high or the suspension very long? The tire should no move pass the tire hardpoint on eh chassis. BTW I live that old rusty Lincoln continental.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Raycast vehicle problems

Postby Julio Jerez » Wed Nov 26, 2014 5:24 am

Ha and I also added the callback for tire friction, which was also had coded to 1.5 in eh demos.

if you set to some low value you can see cool sliding effect like ice surfaces, plus you can also do power slides and drifts.

the function is
dFloat GetTireFrictionCoeficient(const NewtonBody* const body, const NewtonCollision* const myCollision, dLong contacID) const

right now it does not report the collision because I have to add that to the convex cast, or get it from the body. but you get the idea.

is set to 0.5 to show some extreme sliding.

Note: vehicle tire can have fruition coefficient that are larger that 1.0
typical values can be between 1.1 an 1.5 depend on tire pressure. a deflated tire can have a very strong coefficient of friction while a over inflated tire can be veryy slippery
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Raycast vehicle problems

Postby Julio Jerez » Wed Nov 26, 2014 11:16 am

al right one final change, I made the contact call back filter his own class, this way it can pass more information like what tire is colliding and have the vehicle available, etc

you subclass from
Code: Select all
class CustomVehicleControllerTireCollisionFilter: public CustomControllerConvexCastPreFilter

and you overload functions
virtual unsigned Prefilter(const NewtonBody* const body, const NewtonCollision* const myCollision)

dFloat GetTireFrictionCoefficient (const CustomVehicleControllerBodyStateTire& tire, const NewtonBody* const body, const NewtonCollision* const myCollision, dLong contacID) const


in function Prefilter, you queries the body user data, or myCollision
for use information, and if it matches some object you do not want collision then you return 0
else return 1

function tire GetTireFrictionCoefficient, gives you the which tire is colliding, from that you can get all the information you need to return a coefficient of friction for that tire.

In general you can modulate the friction by the surface the tire is in, and the slip ratio of the tire.
I am simply return 1.0 as default.

a trick to do cool drifting is to make the front tire have more friction than the rear tire.
example you can make front tire 1.2 and rear 1.0
and you get emerging drift form the physics, not fake like almost all game simulation do. it is really amusing.
you need to sync to github.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Raycast vehicle problems

Postby pHySiQuE » Thu Nov 27, 2014 5:58 pm

I am getting this error whenever I try to use my subclassed object:
IntelliSense: no default constructor exists for class "CustomVehicleControllerTireCollisionFilter"
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Raycast vehicle problems

Postby Julio Jerez » Thu Nov 27, 2014 8:06 pm

I added it now.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Raycast vehicle problems

Postby pHySiQuE » Thu Nov 27, 2014 9:28 pm

Thanks, here's the result:
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Raycast vehicle problems

Postby Julio Jerez » Thu Nov 27, 2014 10:05 pm

Nice!!
did you play with tire friction?

There are lot of cool tricks you can try. for example for an old Lincoln like the model, they tend to los traction on the rear wheel very eassilly, toy achiv that you just giv eth rear tire a lower frition that the front tires.

The call back for that is in the same filter,
dFloat GetTireFrictionCoefficient (const CustomVehicleControllerBodyStateTire& tire, const NewtonBody* const body, const NewtonCollision* const myCollision, dLong contacID) const

by default returns 1.0

but you can annotate the tires with some value and the you can check what tire it sis that you are getting and the apply the proper friction value.
usually a for tire is aboutt 20% more sticky tha the rear tires.
I will try values like 1.1 for front and 0.9 for rear and play around that vicinity,
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Raycast vehicle problems

Postby pHySiQuE » Fri Nov 28, 2014 2:19 pm

I have been. I think I need to distribute the weight towards the front and lower. My friend had a car like this and it was very very front-heavy. And all cars have their weight in the engine block, to some degree.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron