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.
Thanks!
--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.