Page 1 of 1

detecting 2 moving nodes colliding?

Posted: Thu Sep 08, 2005 12:11 pm
by Browndog
Is there a way to detect if 2 nodes collide, I have been trying to code this but my methods have been very bad for performance is there an easy way to do this?

Posted: Thu Sep 08, 2005 5:05 pm
by CZestmyr
How did you do the collision checking between two nodes, when you say you implemented it yourself?

Posted: Fri Sep 09, 2005 9:19 am
by Browndog
I was checking if the bounded boxes overlaped, which when I get a lot of nodes moving around constanly checking this is a really performance hit.

edit I'm not sure how to use getTransformedBoundingBox() so I'm just checking for a square around my nodes. I somone could explain how getTransformedBoundingBox() would also be good

Posted: Fri Sep 09, 2005 1:11 pm
by Spintz
A faster way would be to use cylinders around the nodes. Then instead of checking if each box is intersected, by checking all the edges, you simply get the distance between the center of the 2 cylinders, and check if the radius of both cylinders combined is greater than the distance between the centers.

Posted: Fri Sep 09, 2005 2:25 pm
by Browndog
how do I create the cylinder? is it just virtual and I create it mathmaticaly each time I want to check for collision, or can I make a cylinder in the engine?

Posted: Fri Sep 09, 2005 2:31 pm
by Spintz
Center for cylinder is the center of the bounding box.

Radius of cylinder is the greater of -
( bbox.MaxEdge.X - bbox.MinEdge.X ) / 2
or
( bbox.MaxEdge.Z - bbox.MinEdge.X ) / 2

Height of the cylinder is -
bbox.MaxEdge.Y - bbox.MinEdge.Y

Posted: Fri Sep 09, 2005 11:09 pm
by Browndog
ok, the problem I see with this is my nodes may have any orientation is space ie they may be facing straight up. So I will need to create the cylinder depending on the ships orientation.


Some of my nodes are running in a straight line and I have that line3df, can I use the CollisionManager to detect if the line is intersecting any of my nodes and then if it does I will just check how close it is to the node to see if they hit.

Posted: Wed Sep 14, 2005 10:38 am
by Browndog
ok I've made it run a lot faster now I'm putting all my nodes into linkedLists and stepping through the list to see if thier aabbox intersects which is working well but it is still a bit slow, if anyone can think of anyways to optimize this method let me know.

Posted: Wed Sep 14, 2005 12:25 pm
by Midnight
making your own linked list may be faster if it comes to that.

Posted: Wed Sep 14, 2005 2:18 pm
by Spintz
So the cylinder sped it up a lot?

Posted: Wed Sep 14, 2005 4:49 pm
by bitplane
im just using spheres. i know the radius of each node and i just check the distance like so-
if (distance < radiusa+radiusb)

if the nodes are close enough, you can do a proper collision check

Posted: Wed Sep 14, 2005 8:23 pm
by Spintz
that's a good idea bitplane. use the sphere, then if the spheres collide, then check bbox's. sphere are faster and easier than cylinder's to test! Never thought of that myself!

Posted: Thu Sep 15, 2005 8:05 am
by Browndog
I'm just using the built in irrlicht method that gets a aabbox from a mesh (getTransformedBoundingBox()), I dont know what shape it is but I just use the aabbox method to see if the 2 boxes intersect (intersectsWithBox()) and it seems to work fast then what I had before.