src/geometry.cpp

changeset 200
ca23936b455b
parent 187
30204975694a
child 201
5d201ee4a9c3
--- a/src/geometry.cpp	Wed May 25 20:36:34 2022 +0300
+++ b/src/geometry.cpp	Mon Jun 06 22:01:22 2022 +0300
@@ -33,7 +33,7 @@
  */
 geom::Plane geom::planeFromTriangle(const geom::Triangle& triangle)
 {
-	return geom::Plane{normalVector(triangle), triangle.points[0]};
+	return geom::Plane{normalVector(triangle), triangle.p1};
 }
 
 /**
@@ -45,8 +45,8 @@
 {
 	return glm::normalize(
 		glm::cross(
-			triangle.points[1] - triangle.points[0],
-			triangle.points[2] - triangle.points[0]));
+			triangle.p2 - triangle.p1,
+			triangle.p3 - triangle.p1));
 }
 
 /**
@@ -107,7 +107,7 @@
 {
 	std::optional<glm::vec2> result = lineLineIntersection(
 		rayToLine(ray),
-		lineFromPoints(line.points[0], line.points[1]));
+		lineFromPoints(line.p1, line.p2));
 	if (result.has_value())
 	{
 		const float d1 = glm::dot(*result - ray.anchor, ray.direction);
@@ -117,7 +117,7 @@
 		}
 		else
 		{
-			const float d2 = glm::dot(*result - line.points[0], *result - line.points[1]);
+			const float d2 = glm::dot(*result - line.p1, *result - line.p2);
 			if (d2 > 0)
 			{
 				result.reset();

mercurial