shithub: etoys

Download patch

ref: 88a2aed0c2c5450437bd7935eb5847dfdfa50d59
parent: 367b5a4c7a7ca100e55bf214471cdaabae0a2014
author: rodri <[email protected]>
date: Wed Feb 1 07:48:36 EST 2023

made it work with the current libgeometry provided by the system.

--- a/ptinpoly.c
+++ b/ptinpoly.c
@@ -69,17 +69,18 @@
 	return poly;
 }
 
-int
-ptinpoly(Point2 p, Polygon poly)
-{
-	int i, j, c;
+//int
+//ptinpoly(Point2 p, Polygon poly)
+//{
+//	int i, j, c;
+//
+//	for(i = c = 0, j = poly.npts-1; i < poly.npts; j = i++)
+//		if(p.y < poly.pts[i].y != p.y < poly.pts[j].y &&
+//			p.x < (poly.pts[j].x - poly.pts[i].x) * (p.y - poly.pts[i].y)/(poly.pts[j].y - poly.pts[i].y) + poly.pts[i].x)
+//		c ^= 1;
+//	return c;
+//}
 
-	for(i = c = 0, j = poly.npts-1; i < poly.npts; j = i++)
-		if(p.y < poly.pts[i].y != p.y < poly.pts[j].y &&
-			p.x < (poly.pts[j].x - poly.pts[i].x) * (p.y - poly.pts[i].y)/(poly.pts[j].y - poly.pts[i].y) + poly.pts[i].x)
-		c ^= 1;
-	return c;
-}
 
 Point
 toscreen(Point2 p)
@@ -137,7 +138,7 @@
 rmb(Mousectl *mc)
 {
 	thepoint = fromscreen(mc->xy);
-	isinside = ptinpoly(thepoint, *thepoly);
+	isinside = ptinpoly(thepoint, thepoly->pts, thepoly->npts);
 }
 
 void
--- a/ptintriangle.c
+++ b/ptintriangle.c
@@ -50,20 +50,20 @@
  * p to the left: -
  * p on the edge: 0
  */
-static int
-edgeptcmp(Point2 e0, Point2 e1, Point2 p)
-{
-	Point3 e0p, e01, r;
-
-	p = subpt2(p, e0);
-	e1 = subpt2(e1, e0);
-	e0p = Vec3(p.x,p.y,0);
-	e01 = Vec3(e1.x,e1.y,0);
-	r = crossvec3(e0p, e01);
-
-	/* clamp to avoid overflow */
-	return fclamp(r.z, -1, 1); /* e0.x*e1.y - e0.y*e1.x */
-}
+//static int
+//edgeptcmp(Point2 e0, Point2 e1, Point2 p)
+//{
+//	Point3 e0p, e01, r;
+//
+//	p = subpt2(p, e0);
+//	e1 = subpt2(e1, e0);
+//	e0p = Vec3(p.x,p.y,0);
+//	e01 = Vec3(e1.x,e1.y,0);
+//	r = crossvec3(e0p, e01);
+//
+//	/* clamp to avoid overflow */
+//	return fclamp(r.z, -1, 1); /* e0.x*e1.y - e0.y*e1.x */
+//}
 
 int
 ptintriangle(Point2 p, Triangle t)