Possible Bug in Per Triangle Collision Detection

I’ve been working with the Collision detection stuff for the past couple of days and I believe there is a bug in the per triangle collision detection.

I currently have a box:

Box leftBox = new Box("Left Box",new Vector3f(0,0,0),new Vector3f(4,4,4));

I can collide into the box with my ship (the ship is just a pyramid I made)
All movement is restricted to the xz plane so there are only four faces on the box which the ship can collide with. We'll call these faces left, right, front, back. The two faces which cannot be collided with are top/bottom (i.e. the faces parallel with the xz plane).

When I steer my ship into the front face of the box everything works perfectly. When I steer my ship into the right face of the box everything works perfectly. When I steer my ship into the back face of the box everything works perfectly.

However, when I steer my ship into the left face of the box jME's collision detection is telling me that I collided with the triangle on the bottom of the box when this is obviously not the case.

Now I initially thought since my box is sitting on the xz plane where y=0 and my ship is moving around on the xz plane where y=0 it's slightly ambiguous when you hit the box as to whether or not you hit a triangle on the bottom face. This is not the problem as I looped through all "hit" triangles and it only returns triangles on the bottom face of the box and nothing else.

Furthermore if I declare my box as

Box leftBox = new Box("Left Box",new Vector3f(0,-4,0),new Vector3f(4,4,4));    // Make a box

(which should just stretch the box below y=0 in the xz plane)

The collision detection works on the right face properly except I can fly through the box if I hit the right spot on the right face and left face.

I'm really at a loss what to do now as I'm quite sure it's no longer my code. I know the devs have a lot of stuff to fix but I hope they can take a look at the collision detection code to see if there is something wrong.

I really wish I could fix it myself but I don't think I'm smart enough. If someone wants me to post the code that exhibits the problem I'd be more than happy to clean it up, add comments and put it on my website if that would help with debugging.


--I did a little more testing and when I hit 90 degree corners I get vertices which don't even exists as part of the box as collided triangle vertices so something is definitely up.

--Another odd thing I noticed is that when you collide with teh box it will give you the same triangle 5 times over. In other words, when you check the list of target triangles that have been collided with it will have 5 entries and all of them will be the same triangle.

Ok, the collision detection stuff (particularly the triangle detection) is new so you are one of the few actually using it now. We will look into soon, I promise. If you can come up with a nice test case that really shows off what you are seeing, that’d help speed up the process.

Yeah … I’m gonna put together as simple a test case as possible that exhibits the problem today. I’ll let you know when it’s done and where to get it.

Okay … I put together a demo which shows off the problems. There’s a ship you can fly around using WASD keys and 2 boxes. The box on the right exhibits the problem of being able to fly through the box. I’ve found you can fly through the left and right sides near the top.

The box on the left has the problem where if you hit the left side it tells you that you hit the bottom of the box.

Here’s where you can download the source code. I zipped up my eclipse project. Hopefully that will be adequate.


Thanks, shochu, my next task is to get the Issue Tracker up to date and running, so this will be put in there. We’ll start hammering it out as time allows (don’t let that stop you from investigating it if you want :wink: )

Your welcome Mojo,

Let me know if you can reproduce the same problems. Do you have any good articles on the collision detection algorithm jME uses? With my current knowledge it’s very unlikely that I’ll find the bug but I can definitely devote some time each day to learning up on it and hopefully figure out what’s going on then.