DanielChappuis / reactphysics3d

Open source C++ physics engine library in 3D
http://www.reactphysics3d.com
zlib License
1.51k stars 217 forks source link

Possible EPA Algorithm Issues #2 #3

Closed kovertopz closed 9 years ago

kovertopz commented 9 years ago

There is one more issue with the EPA I've discovered and that is when case 4 falls through to case 3. When it attempts to fix the bad vertex (line 249) it will set it to a point that never exists (point #5). It never exists because we jumped to case 4 because we knew we got 4 points from the simplex. I'm not sure how C++ handles this if you would get a null pointer of if the array was initialized to contain all dummy objects. This case of it falling through from 4 into 3 only seems to happen for cylinders for me and is very rare so it is difficult to reproduce.

Got 3 from the simplex. Case 3 is starting. Case 3 is falling through breaking out of the switch. Normal: (x= -6.16584E-5, y= -1.0, z= -8.335716E-6) Depth: 0.63282037 Got 4 from the simplex. Case 4 is starting. Case 4 had bad vertex 0. Got 4 from the simplex. Case 4 is starting. Case 4 had bad vertex 0. Got 4 from the simplex. Case 4 is starting. Case 4 had bad vertex 0. Got 4 from the simplex. Case 4 is starting. Case 4 had bad vertex 0. Got 4 from the simplex. Case 4 is starting. Case 4 had bad vertex 0. Got 4 from the simplex. Case 4 is starting. Case 4 had bad vertex 0. Got 4 from the simplex. Case 4 is starting. Case 4 had bad vertex 0. Got 4 from the simplex. Case 4 is starting. Case 4 had bad vertex 0. Got 4 from the simplex. Case 4 is starting. Case 4 had bad vertex 0. Got 4 from the simplex. Case 4 is starting. Case 4 had bad vertex less 4: 1 Case 4 is falling through to case 3. Case 3 is starting. Oct 06, 2014 11:40:19 PM net.smert.jreactphysics3d.framework.Application$1 run java.lang.NullPointerException at net.smert.jreactphysics3d.mathematics.Vector3.subtract(Vector3.java:238) at net.smert.jreactphysics3d.collision.narrowphase.EPA.EPAAlgorithm.computePenetrationDepthAndContactPoints(EPAAlgorithm.java:323) at net.smert.jreactphysics3d.collision.narrowphase.GJK.GJKAlgorithm.computePenetrationDepthForEnlargedObjects(GJKAlgorithm.java:197) at net.smert.jreactphysics3d.collision.narrowphase.GJK.GJKAlgorithm.testCollision(GJKAlgorithm.java:309)

DanielChappuis commented 9 years ago

I think I have fixed this issue in the following commit : 54d8b8518e9610d29df8285cc03130cd8ee17eca

This correction will be part of the next release of the library.

DanielChappuis commented 9 years ago

This fix is now part of the last release of the library (version 0.5.0).

I will therefore close this issue.