Refactoring

This commit is contained in:
Jon Evans 2021-04-12 20:40:05 -04:00
parent 73fb85a352
commit 2aa5e568e8
1 changed files with 10 additions and 14 deletions

View File

@ -119,28 +119,24 @@ void DP_PRIMITIVE_PAIR::CursorOrientation( const VECTOR2I& aCursorPos, VECTOR2I&
{ {
assert( m_primP && m_primN ); assert( m_primP && m_primN );
VECTOR2I aP, aN, dir, midpoint; VECTOR2I aP, aN;
if( m_primP->OfKind( ITEM::SEGMENT_T ) && m_primN->OfKind( ITEM::SEGMENT_T ) ) if( m_primP->OfKind( ITEM::SEGMENT_T ) && m_primN->OfKind( ITEM::SEGMENT_T ) )
{ {
aP = m_primP->Anchor( 1 ); aP = m_primP->Anchor( 1 );
aN = m_primN->Anchor( 1 ); aN = m_primN->Anchor( 1 );
midpoint = ( aP + aN ) / 2;
dir = ( aP - aN ).Perpendicular();
} }
else else
{ {
aP = m_primP->Anchor( 0 ); aP = m_primP->Anchor( 0 );
aN = m_primN->Anchor( 0 ); aN = m_primN->Anchor( 0 );
midpoint = ( aP + aN ) / 2;
dir = ( aP - aN ).Perpendicular();
if( dir.Dot( aCursorPos - midpoint ) < 0 )
dir = -dir;
} }
aMidpoint = midpoint; aMidpoint = ( aP + aN ) / 2;
aDirection = dir; aDirection = ( aP - aN ).Perpendicular();
if( aDirection.Dot( aCursorPos - aMidpoint ) < 0 )
aDirection = -aDirection;
} }