userdata in NewtonWorldForEachBodyInAABBDo

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

userdata in NewtonWorldForEachBodyInAABBDo

Postby JernejL » Wed Dec 09, 2009 7:18 pm

NewtonWorldForEachBodyInAABBDo needs a userdata parameter which is sent back in NewtonBodyIterator.

Let me give an example:

My game has joints, which automaticly attach, such as a semi trailer joint, all you do is get the truck close enough to trailer and game sees that and connects it.

I take trailer and use the NewtonWorldForEachBodyInAABBDo to look for truck cab bodies that come close to the attachment point, if they are close enough they are automaticly attached.

So, i call NewtonWorldForEachBodyInAABBDo which looks for correct bodies and discards the rest, but there in callback i have no idea for which trailer the callback is called, so i need a global variable to workaround this so the iterator callback knows which trailer it's looking for. Such code can not run properly multi-threadable.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: userdata in NewtonWorldForEachBodyInAABBDo

Postby Julio Jerez » Wed Dec 09, 2009 7:26 pm

yes you are right, I can see how a userdata will make it simpler, I will add it.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: userdata in NewtonWorldForEachBodyInAABBDo

Postby JernejL » Wed Dec 09, 2009 7:43 pm

Thanks, i hope this change won't cause much trouble for people.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron