src/invert.cpp

changeset 21
0133e565e072
parent 19
ed9685f44ab3
child 24
1a0faaaceb84
--- a/src/invert.cpp	Sat Dec 14 23:00:01 2019 +0200
+++ b/src/invert.cpp	Wed Jan 01 17:45:56 2020 +0200
@@ -20,6 +20,7 @@
 #include "model.h"
 #include "matrix.h"
 #include "gl/common.h"
+#include "invert.h"
 
 #if 0
 /*
@@ -72,21 +73,10 @@
 /*
  * Returns a matrix that causes a flip on the given dimension.
  */
-Matrix4x4 flipmatrix(Axis dimension)
+Matrix4x4 math::flipmatrix(const Axis dimension)
 {
 	Matrix4x4 result = identity4x4;
-	switch (dimension)
-	{
-	case X:
-		result(0, 0) = -1;
-		break;
-	case Y:
-		result(1, 1) = -1;
-		break;
-	case Z:
-		result(2, 2) = -1;
-		break;
-	}
+	result(static_cast<int>(dimension), static_cast<int>(dimension)) = -1;
 	return result;
 }
 
@@ -143,16 +133,18 @@
 /*
  * Inverts the winding of a polygon.
  */
-void invertPolygon(gl::Polygon& polygon)
+void gl::invert(gl::Polygon& polygon)
 {
 	switch (polygon.numPolygonVertices())
 	{
 	case 2:
 	case 3:
+		// 0 1 => 1 0
+		// 0 1 2 => 1 0 2
 		std::swap(polygon.vertices[0], polygon.vertices[1]);
 		break;
-
 	case 4:
+		// 0 1 2 3 => 0 3 2 1
 		std::swap(polygon.vertices[1], polygon.vertices[3]);
 		break;
 	}

mercurial