Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/simulation2/helpers/Geometry.cpp
Show First 20 Lines • Show All 336 Lines • ▼ Show 20 Lines | |||||
* is not entirely on the clockwise side of a line in direction 'axis' passing through 'a' | * is not entirely on the clockwise side of a line in direction 'axis' passing through 'a' | ||||
*/ | */ | ||||
static bool SquareSAT(const CFixedVector2D& a, const CFixedVector2D& axis, const CFixedVector2D& u, const CFixedVector2D& v, const CFixedVector2D& halfSize) | static bool SquareSAT(const CFixedVector2D& a, const CFixedVector2D& axis, const CFixedVector2D& u, const CFixedVector2D& v, const CFixedVector2D& halfSize) | ||||
{ | { | ||||
fixed hw = halfSize.X; | fixed hw = halfSize.X; | ||||
fixed hh = halfSize.Y; | fixed hh = halfSize.Y; | ||||
CFixedVector2D p = axis.Perpendicular(); | CFixedVector2D p = axis.Perpendicular(); | ||||
if (p.Dot((u.Multiply(hw) + v.Multiply(hh)) - a) <= fixed::Zero()) | if (p.RelativeOrientation(u.Multiply(hw) + v.Multiply(hh) - a) <= 0) | ||||
return true; | return true; | ||||
if (p.Dot((u.Multiply(hw) - v.Multiply(hh)) - a) <= fixed::Zero()) | if (p.RelativeOrientation(u.Multiply(hw) - v.Multiply(hh) - a) <= 0) | ||||
return true; | return true; | ||||
if (p.Dot((-u.Multiply(hw) - v.Multiply(hh)) - a) <= fixed::Zero()) | if (p.RelativeOrientation(-u.Multiply(hw) - v.Multiply(hh) - a) <= 0) | ||||
return true; | return true; | ||||
if (p.Dot((-u.Multiply(hw) + v.Multiply(hh)) - a) <= fixed::Zero()) | if (p.RelativeOrientation(-u.Multiply(hw) + v.Multiply(hh) - a) <= 0) | ||||
return true; | return true; | ||||
return false; | return false; | ||||
} | } | ||||
bool TestSquareSquare( | bool TestSquareSquare( | ||||
const CFixedVector2D& c0, const CFixedVector2D& u0, const CFixedVector2D& v0, const CFixedVector2D& halfSize0, | const CFixedVector2D& c0, const CFixedVector2D& u0, const CFixedVector2D& v0, const CFixedVector2D& halfSize0, | ||||
const CFixedVector2D& c1, const CFixedVector2D& u1, const CFixedVector2D& v1, const CFixedVector2D& halfSize1) | const CFixedVector2D& c1, const CFixedVector2D& u1, const CFixedVector2D& v1, const CFixedVector2D& halfSize1) | ||||
▲ Show 20 Lines • Show All 100 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator