Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / Newton question + collisions

Author
Message
RaceGT
19
Years of Service
User Offline
Joined: 15th Aug 2005
Location:
Posted: 14th May 2006 07:39
I was wondering if there was a way to detect collisions between more than 2 bodies at once? I can get the collisions between a body and a material just fine, or a body with 1 other body, fine. But I was wondering if there was another way. I thought the collision detection worked like this:

1.) Set up bodies + materials, apply materials to bodies.
2.) Call NDB_NewtonMaterialSetCollisionCallback(mat1,mat2) (!!!)
3.) On every frame (or whenever) of the simulation, check either NDB_GetCollisionBodyToBody or NDB_GetCollisionBodyToMaterial.

Now, I thought you used ~BodyToBody and ~BodyToMaterial to retrieve an index to the collision # that is the collision of the body in question (the one passed as a parameter in ~BodyToBody and ~BodyToMaterial). With that index, you can then use NDB_GetCollisionBody() or GetCollisionData to get the more detailed information pertaining to that particular collision.

So this implies that for each frame (after NetwonUpdate, I presume), whatever collisions are present are stored. This makes sense because on any particular frame, there could be many or more than 1 collision happening concurrently. And this seems to work when calling GetCollisionBody() or GetCollisionData using the index; the index references a certain collision (the one you're checking for, or 0).

So, the only way I've seen to check for collisions between objects is with NDB_GetCollisionBodyToBody, which can only check for collision between 2 bodies. Doing this, you'd have to make 1 check for every other object. With 50 objects, that's 49 checks for every 1 object, = 2950 checks, once per loop! I tried it and it obviously can't be the way to do it, my program can't even run with that kind of bog in the loop.

I thought I could trick it by using the same material as the objects were made of, but no go, it didn't work to detect its own material. I was hoping there was a way to detect the collisions between all objects much like it works when using the material method; all the collisions that are present on the current frame are indexed, and all you have to do is retrieve the index to the collision in question, if present. Is there a correct way to go about this?

http://www.geocities.com/crmnlelmnt/
tiresius
22
Years of Service
User Offline
Joined: 13th Nov 2002
Location: MA USA
Posted: 19th May 2006 06:49 Edited at: 19th May 2006 06:56
The issue is when you use function NDB_GetCollisionBodyToXXX function, it returns the first collision found in the collision list. As you've discovered there's no way to find out multiple objects hit in a material per update.

Kjelle/Walaber,
Is it possible for the wrapper to remember the last collision found for each BodyToMaterial, and then start the for loop with that value (reset to -1 for every NewtonUpdate of course)?

Something like:


That way subsequent calls to the BodyToXXX functions will return each collision, like this:


Alternately, if the NDB_GetCollisionBodyToBody command could possibly accept one argument, where each call would return the next body hit as it crawled along the index (similar to suggestion for materials above).

That way we could do:



Note: Even if this can be fixed/changed, the next version of the wrapper will probably be released later this year as the maintainers of the wrapper are very busy.

I'm not a real programmer but I play one with DBPro!
RaceGT
19
Years of Service
User Offline
Joined: 15th Aug 2005
Location:
Posted: 20th May 2006 00:16
I thought there may not be a solution within the DB wrapper, I may have to look into one of the more complete physics packages. I still think Newton works great, any updates sound promising.

http://www.geocities.com/crmnlelmnt/

Login to post a reply

Server time is: 2024-11-22 05:54:00
Your offset time is: 2024-11-22 05:54:00