Page 1 of 1

Incorrect triangle-triangle collision detected in GI

Posted: Wed Jan 29, 2025 10:17 am
by ajshort
Hi all! We're using gimpact for mesh-to-mesh collisions and have come across a case where two triangles are detecting a false positive collision. I've managed to isolate this pretty well to the two triangles in the STL file linked and pictured below - as you can see these aren't colliding, but are reported as a collision.

https://gist.github.com/ajshort/f032837 ... 60d66acffa

I've made some minimal code inside the btGImpactCollisionAlgorithm class below which reports a collision between these two triangles manually defined. Does anyone have any advice or idea as to the cause? Also if I define "BULLET_TRIANGLE_COLLISION" so the GJK rather than SAT implementation is used, the result is as expected.

Code: Select all

btPrimitiveTriangle ta;
ta.m_vertices[0] = btVector3(4049.92, 12169.6, 2252.3);
ta.m_vertices[1] = btVector3(4083.47, 12166.3, 2258.52);
ta.m_vertices[2] = btVector3(4050.78, 12191, 2238.16);
ta.buildTriPlane();

btPrimitiveTriangle tb;
tb.m_vertices[0] = btVector3(5189.17, 11358, 500.004);
tb.m_vertices[1] = btVector3(3162.31, 11358, 2724.61);
tb.m_vertices[2] = btVector3(3162.31, 12642, 2724.61);
tb.buildTriPlane();

GIM_TRIANGLE_CONTACT gtc;
if (ta.overlap_test_conservative(tb) && ta.find_triangle_collision_clip_method(tb, gtc)) {
	std::cout << "A collision has been detected using SAT method" << std::endl;
} else {
	std::cout << "No collision detected using SAT method" << std::endl;
}
Screenshot 2025-01-29 211040.png
Screenshot 2025-01-29 211040.png (31.4 KiB) Viewed 146724 times

Re: Incorrect triangle-triangle collision detected in GI

Posted: Tue Mar 04, 2025 9:06 am
by otis
Hey ajshort, in your minimal code isolating the false positive collision with those two triangles,Retro Bowl have you tried tweaking the margin values or plane equations in `buildTriPlane()` to see if it resolves the SAT method’s over-detection?

Re: Incorrect triangle-triangle collision detected in GI

Posted: Fri Mar 14, 2025 3:14 am
by ajshort
Hi Otis,

We found that if we modify

Code: Select all

btPrimitiveTriangle::overlap_test_conservative
- it currently only checks if all points of one triangle lie one on the positive side of the plane formed by the other (line 82). When we modify this check to also check of the points are all on the negative side of the plane, this functions as expected.

I.e. change:

Code: Select all

if (dis0 > 0.0f && dis1 > 0.0f && dis2 > 0.0f) return false;
to

Code: Select all

if (dis0 > 0.0f && dis1 > 0.0f && dis2 > 0.0f) return false;
if (dis0 < 0.0f && dis1 < 0.0f && dis2 < 0.0f) return false;
This then seems to function as expected. We haven't been able to rigorously test this yet, and also it wouldn't take margins into account. Another potential fix would be to just check if any of the 3 points are within "margin" distance of the plane formed by the other triangle?