Advertisement

GJK Simplex Caching and Circles

Started by August 22, 2013 05:35 PM
20 comments, last by RastaRunna 11 years, 2 months ago

Correct, you get the closest point between the sphere center (or capsule segment) and the polygon/polyhedra and then move the closest point onto the sphere (or capsule) surface.

I think some sample code makes this clearer:


ClosestPointsResult result = FindClosestPoints( pSphere, pPolyhedra );

if ( result.m_flDistance > pSphere->Radius() )
{
   // Shallow penetration - correct for sphere radius and move closest point onto sphere surface
   float flSeparation = result.m_flDistance - pSphere->Radius();
   Vec3 vClosestPointOnSphere = result.m_vPoint1 + pShere->Radius() * Normalize( result.m_vPoint2 - result.m_vPoint1 );
   Vec3 vClosestPointOnPolyhedra = result.m_vPoint2;
}
else
{
    // Deep penetration -> do something else...
}

Very cool, thanks!

This topic is closed to new replies.

Advertisement