Possible bug in GImpact
Posted: Mon Jul 25, 2016 6:32 pm
I found that when working with concave shapes using G-Impact I would, at times, get bogus collisions. When I traced these down, what I found was that the function btPrimitiveTriangle::overlap_test_conservative was giving me nonsense results in the case where one triangle was "below" the plane of the other triangle. What I see is that the distance check was testing for all positive (all the same sign) results and declaring a miss. However, in the concave case this isn't really good enough I think.
So, I changed the function from:
to:
However, I'm not totally certain that this is correct, though I seem to get much better results after this change. Am I missing something? Or is this a better test?
Thanks!
So, I changed the function from:
Code: Select all
bool btPrimitiveTriangle::overlap_test_conservative(const btPrimitiveTriangle& other)
{
btScalar total_margin = m_margin + other.m_margin;
// classify points on other triangle
btScalar dis0 = bt_distance_point_plane(m_plane,other.m_vertices[0]) - total_margin;
btScalar dis1 = bt_distance_point_plane(m_plane,other.m_vertices[1]) - total_margin;
btScalar dis2 = bt_distance_point_plane(m_plane,other.m_vertices[2]) - total_margin;
if (dis0>0.0f&&dis1>0.0f&&dis2>0.0f) return false;
// classify points on this triangle
dis0 = bt_distance_point_plane(other.m_plane,m_vertices[0]) - total_margin;
dis1 = bt_distance_point_plane(other.m_plane,m_vertices[1]) - total_margin;
dis2 = bt_distance_point_plane(other.m_plane,m_vertices[2]) - total_margin;
if (dis0>0.0f&&dis1>0.0f&&dis2>0.0f) return false;
return true;
}
Code: Select all
bool btPrimitiveTriangle::overlap_test_conservative(const btPrimitiveTriangle& other)
{
btScalar total_margin = m_margin + other.m_margin;
// classify points on other triangle
btScalar dis0 = bt_distance_point_plane(m_plane,other.m_vertices[0]);
btScalar dis1 = bt_distance_point_plane(m_plane,other.m_vertices[1]);
btScalar dis2 = bt_distance_point_plane(m_plane,other.m_vertices[2]);
if (dis0>total_margin&&dis1>total_margin&&dis2>total_margin) return false;
if (dis0<-total_margin&&dis1<-total_margin&&dis2<-total_margin) return false;
// classify points on this triangle
dis0 = bt_distance_point_plane(other.m_plane,m_vertices[0]);
dis1 = bt_distance_point_plane(other.m_plane,m_vertices[1]);
dis2 = bt_distance_point_plane(other.m_plane,m_vertices[2]);
if (dis0>total_margin&&dis1>total_margin&&dis2>total_margin) return false;
if (dis0<-total_margin&&dis1<-total_margin&&dis2<-total_margin) return false;
return true;
}
Thanks!