Return closest point on line-circle intersection
Don't only look for the segment endpoints when asking the closest point. If we have a collision, we need to get the collision point
This commit is contained in:
parent
a5436c92d1
commit
57c0953c39
|
@ -84,7 +84,17 @@ public:
|
|||
if( dist_sq == 0 || dist_sq < SEG::Square( minDist ) )
|
||||
{
|
||||
if( aLocation )
|
||||
*aLocation = pn;
|
||||
{
|
||||
if( std::vector<VECTOR2I> pts = m_circle.Intersect( aSeg );
|
||||
!pts.empty() && dist_sq == 0 )
|
||||
{
|
||||
*aLocation = m_circle.Intersect( aSeg )[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
*aLocation = pn;
|
||||
}
|
||||
}
|
||||
|
||||
if( aActual )
|
||||
*aActual = std::max( 0, (int) sqrt( dist_sq ) - m_circle.Radius );
|
||||
|
|
Loading…
Reference in New Issue