REVIEWED: CheckCollisionPointLine()
Use fabsf() instead of abs()
This commit is contained in:
parent
fd3e2fda00
commit
8e51e6d1df
1 changed files with 2 additions and 3 deletions
|
@ -1555,11 +1555,10 @@ bool CheckCollisionPointLine(Vector2 point, Vector2 p1, Vector2 p2, int threshol
|
||||||
float dyl = p2.y - p1.y;
|
float dyl = p2.y - p1.y;
|
||||||
float cross = dxc*dyl - dyc*dxl;
|
float cross = dxc*dyl - dyc*dxl;
|
||||||
|
|
||||||
if (abs(cross) < threshold*fmaxf(fabsf(dxl), fabsf(dyl)))
|
if (fabsf(cross) < (threshold*fmaxf(fabsf(dxl), fabsf(dyl))))
|
||||||
{
|
{
|
||||||
if (fabsf(dxl) >= fabsf(dyl)) collision = (dxl > 0)? ((p1.x <= point.x) && (point.x <= p2.x)) : ((p2.x <= point.x) && (point.x <= p1.x));
|
if (fabsf(dxl) >= fabsf(dyl)) collision = (dxl > 0)? ((p1.x <= point.x) && (point.x <= p2.x)) : ((p2.x <= point.x) && (point.x <= p1.x));
|
||||||
else
|
else collision = (dyl > 0)? ((p1.y <= point.y) && (point.y <= p2.y)) : ((p2.y <= point.y) && (point.y <= p1.y));
|
||||||
collision = (dyl > 0)? ((p1.y <= point.y) && (point.y <= p2.y)) : ((p2.y <= point.y) && (point.y <= p1.y));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return collision;
|
return collision;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue