Prechádzať zdrojové kódy

Fixing triangle clipping for GUI Canvas, fully clipped triangles are no longer incorrectly getting rendered

BearishSun 9 rokov pred
rodič
commit
a2ed04de6f

+ 8 - 2
Source/BansheeCore/Source/BsMeshUtility.cpp

@@ -573,7 +573,10 @@ namespace BansheeEngine
 		addEdgesAndFaces();
 
 		for (int i = 0; i < 4; i++)
-			clipByPlane(clipPlanes[i]);
+		{
+			if (clipByPlane(clipPlanes[i]) == -1)
+				return;
+		}
 
 		convertToMesh(writeCallback);
 	}
@@ -671,7 +674,10 @@ namespace BansheeEngine
 		addEdgesAndFaces();
 
 		for (int i = 0; i < 4; i++)
-			clipByPlane(clipPlanes[i]);
+		{
+			if (clipByPlane(clipPlanes[i]) == -1)
+				return;
+		}
 
 		convertToMesh(writeCallback);
 	}

+ 2 - 2
Source/BansheeEngine/Source/BsSprite.cpp

@@ -330,8 +330,8 @@ namespace BansheeEngine
 		{
 			Plane(Vector3(1.0f, 0.0f, 0.0f), (float)clipRect.x),
 			Plane(Vector3(-1.0f, 0.0f, 0.0f), (float)-(clipRect.x + clipRect.width)),
-			Plane(Vector3(0, 1.0f, 0), (float)(clipRect.y + clipRect.height)),
-			Plane(Vector3(0.0f, -1.0f, 0.0f), (float)-clipRect.y)
+			Plane(Vector3(0.0f, 1.0f, 0.0f), (float)clipRect.y),
+			Plane(Vector3(0.0f, -1.0f, 0.0f), (float)-(clipRect.y + clipRect.height))
 		};
 
 		MeshUtility::clip2D(vertices, uv, numTris, vertStride, clipPlanes, writeCallback);