Ver a proveniência

fix CheckCollisionPointPoly (#3750)

pull/3753/head
Antonio Raúl há 1 ano
committed by GitHub
ascendente
cometimento
ef92ced370
Não foi encontrada uma chave conhecida para esta assinatura, na base de dados ID da chave GPG: B5690EEEBB952194
1 ficheiros alterados com 8 adições e 8 eliminações
  1. +8
    -8
      src/rshapes.c

+ 8
- 8
src/rshapes.c Ver ficheiro

@ -2196,21 +2196,21 @@ bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2
// NOTE: Based on http://jeffreythompson.org/collision-detection/poly-point.php
bool CheckCollisionPointPoly(Vector2 point, Vector2 *points, int pointCount)
{
bool collision = false;
bool inside = false;
if (pointCount > 2)
{
for (int i = 0; i < pointCount - 1; i++)
for (int i = 0, j = pointCount - 1; i < pointCount; j = i++)
{
n">Vector2 vc = points[i];
Vector2 vn = points[i + 1];
if ((((vc.y >= point.y) && (vn.y < point.y)) || ((vc.y < point.y) && (vn.y >= point.y))) &&;
(point.x < ((vn.x - vc.x)*(point.y - vc.y)/(vn.y - vc.y) + vc.x))) collision = !collision;
k">if ((points[i].y > point.y) != (points[j].y > point.y) &&;
(point.x < (points[j].x - points[i].x) * (point.y - points[i].y) / (points[j].y - points[i].y) + points[i].x))
{
inside = !inside;
}
}
}
return collision;
return inside;
}
// Check collision between two rectangles

Carregando…
Cancelar
Guardar