detecting 2 moving nodes colliding?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Browndog
Posts: 74
Joined: Thu Aug 18, 2005 2:53 am

detecting 2 moving nodes colliding?

Post 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?
CZestmyr
Posts: 72
Joined: Sat Feb 12, 2005 7:11 pm
Location: Czech Republic
Contact:

Post by CZestmyr »

How did you do the collision checking between two nodes, when you say you implemented it yourself?
Browndog
Posts: 74
Joined: Thu Aug 18, 2005 2:53 am

Post 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
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post 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.
Image
Browndog
Posts: 74
Joined: Thu Aug 18, 2005 2:53 am

Post 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?
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post 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
Image
Browndog
Posts: 74
Joined: Thu Aug 18, 2005 2:53 am

Post 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.
Browndog
Posts: 74
Joined: Thu Aug 18, 2005 2:53 am

Post 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.
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

making your own linked list may be faster if it comes to that.
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

So the cylinder sped it up a lot?
Image
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post 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
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post 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!
Image
Browndog
Posts: 74
Joined: Thu Aug 18, 2005 2:53 am

Post 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.
Post Reply