A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by JernejL » Sat Nov 21, 2009 9:26 pm
Newton must have a internal structure, which is efficient for AABB body searches in order to perform collision checks as fast as it does.
I wonder, could that functionality be exposed to users? i'm having a real problem lately finding bodies in proximity of points (very slow performance issue), what i need is something like..
int NewtonBodiesInAABB(startpoint, endpoint, prefiltercallback, storehere, maxstorelength)
And it would return number of bodies actually found in that AABB (minus prefilter - prefiltering would work similar to how the raycast callback's works).
Could you please add something like this to newton?
-

JernejL
-
- Posts: 1587
- Joined: Mon Dec 06, 2004 2:00 pm
- Location: Slovenia
-
by Julio Jerez » Sun Nov 22, 2009 7:18 am
but it isnt' that what Bodie is AABB does, can you elaborate better?
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by JernejL » Sun Nov 22, 2009 11:40 am
I just need a list of bodies that their central points or AABBs intresect a particular AABB, so i can later perform more precise distance checks on them - in order to know which bodies are in range of explosions, fires and radius triggers in my game.
Currently i have to compare every body at every particle, which slows down terribly when i reach a lot of particles (> 3000), this is the slowest part of my game, and i would spend another week implementing R-tree or something similar unless i could use newton's spatial body management from newton to get this information, which it probably has internally.
-

JernejL
-
- Posts: 1587
- Joined: Mon Dec 06, 2004 2:00 pm
- Location: Slovenia
-
by Julio Jerez » Sun Nov 22, 2009 11:43 am
can you give me and example? I am still confuse GetBodyInAABB returns the bodies that intesert the AABB.
but that is what you are describing you wna the funtion to do.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by JernejL » Sun Nov 22, 2009 12:51 pm
Oh wow, i didn't know there was already a NewtonWorldForEachBodyInAABBDo
Kinda explains why i shouldn't be coding at 5 AM anymore

-

JernejL
-
- Posts: 1587
- Joined: Mon Dec 06, 2004 2:00 pm
- Location: Slovenia
-
by JernejL » Tue Nov 24, 2009 6:14 pm
A question for julio - before i try and figure it out by brute force:
Does NewtonWorldForEachBodyInAABBDo use body AABB check Vs provided AABB, or does it use the provided AABB and checks against a body centre point?
-

JernejL
-
- Posts: 1587
- Joined: Mon Dec 06, 2004 2:00 pm
- Location: Slovenia
-
by Julio Jerez » Tue Nov 24, 2009 6:39 pm
it checks the aabb you provide, against the AABB of the bodies
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by JernejL » Tue Nov 24, 2009 7:04 pm
Ok cool, i wrote the wiki page for it: NewtonWorldForEachBodyInAABBDo so it is documented better.
-

JernejL
-
- Posts: 1587
- Joined: Mon Dec 06, 2004 2:00 pm
- Location: Slovenia
-
by JernejL » Thu Dec 17, 2009 5:08 am
The NewtonWorldForEachBodyInAABBDo is amazing, i started using it everywhere.
I use it now to integrate my particle system with the engine better (searching for neighbouring objects on which particles have effects such as explosions, fire, etc..), it's much faster than what i wrote previously (simple distance comparison loops for each entity vs each particle).
What algorythm does this function use internally that it is so fast? i'm guessing a kind of R-tree? well whatever it uses.. it is really fast!

-

JernejL
-
- Posts: 1587
- Joined: Mon Dec 06, 2004 2:00 pm
- Location: Slovenia
-
by Julio Jerez » Thu Dec 17, 2009 8:33 am
Newton uses a mutl resulution grid for broad phase collision.
remember is version 2.14 the prototype nwo takes the user data callback.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by JernejL » Thu Dec 17, 2009 2:22 pm
Julio Jerez wrote:Newton uses a mutl resulution grid for broad phase collision.
remember is version 2.14 the prototype nwo takes the user data callback.
Yep i'm already using 2.14 with the new userdata param in callback, and it works great

-

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 0 guests