rendered paste bodybool PolyObj::findSegmentAt(int x, int y, Coord *point1, Coord *point2)
{
printf("foo\n");
int i;
for (i = 0; i < nrPoints(); ++i)
{
point1 = (Coord*)(points->get(i));
if (i == (points->size() - 1))
point2 = (Coord*)(points->get(0));
else
point2 = (Coord*)(points->get(i+1));
//printf("bar %x %x\n", (int)point1, (int)point2);
if (((point1->x <= x && x <= point2->x) ||
(point2->x <= x && x <= point1->x)) &&
((point1->y <= y && y <= point2->y) ||
(point2->y <= y && y <= point1->y)))
return true;
}
return false;
}
called:
Coord *oldPoint1, *oldPoint2;
in loop:
if (findSegmentAt(photon->xOrigin, photon->yOrigin, oldPoint1, oldPoint2))
{
if ((oldPoint1 == point1 && oldPoint2 == point2) ||
(oldPoint1 == point2 && oldPoint2 == point1))
continue;
}