Commits

Alex Szpakowski  committed ffc8cdf

Optimized Geometry:setVertex

  • Participants
  • Parent commits ba1af20

Comments (0)

Files changed (1)

File src/modules/graphics/Geometry.cpp

 	if (i >= polygon.size())
 		throw Exception("Invalid vertex index");
 
+	float oldx = polygon[i].x;
+	float oldy = polygon[i].y;
+
 	polygon[i] = v;
-	x_min = v.x < x_min ? v.x : x_min;
-	x_max = v.x > x_max ? v.x : x_max;
-	y_min = v.y < y_min ? v.y : y_min;
-	y_max = v.y > y_max ? v.y : y_max;
 
-	triangulate();
+	if (oldx != v.x || oldy != v.y)
+	{
+		x_min = v.x < x_min ? v.x : x_min;
+		x_max = v.x > x_max ? v.x : x_max;
+		y_min = v.y < y_min ? v.y : y_min;
+		y_max = v.y > y_max ? v.y : y_max;
+
+		triangulate();
+	}
 }
 
 void Geometry::flip(bool x, bool y)