public void MapperExtractsInvalidConnectedFaces() { Assert.Throws <Exception>(delegate { FaceMapper.extractFaces(null, 0); }); Assert.Throws <Exception>(delegate { FaceMapper.extractFaces(mappedTriangles, 100); }); Assert.Throws <Exception>(delegate { FaceMapper.extractFaces(mappedTriangles, -1); }); Assert.Throws <Exception>(delegate { FaceMapper.extractFaces(mappedTriangles, 0); }); }
void MapAndExtract() { foreach (var meshFilter in objectsToExtract) { Mesh mesh = meshFilter.sharedMesh; Stopwatch sw = Stopwatch.StartNew(); var(triangles, vertices) = FaceMapper.mapTriangles(mesh.triangles, mesh.vertices); clearAllChildren(meshFilter.gameObject); int totalFaces = triangles.Count; int facesForContinents = (int)(totalFaces * (1f - percentageOfSea)); int totalAmountOfLand = 0; foreach (var size in continents.Values) { totalAmountOfLand += size; } foreach (var continent in continents) { int sizeOfThisContinent = facesForContinents * continent.Value / totalAmountOfLand; var extractedFaces = FaceMapper.extractFaces(triangles, sizeOfThisContinent); createSubMesh(meshFilter.gameObject, continent.Key, extractedFaces, landMaterial); } createSubMesh(meshFilter.gameObject, "sea", triangles, seaMaterial); sw.Stop(); UnityEngine.Debug.Log("Time taken for " + meshFilter.gameObject.name + " -> " + sw.Elapsed.TotalMilliseconds + "ms"); } }
public void MapperExtractsFaces(int numFaces) { var connectedFaces = FaceMapper.extractFaces(mappedTriangles, numFaces); Assert.AreEqual(numFaces, connectedFaces.Count); Assert.AreEqual(12 - numFaces, mappedTriangles.Count); foreach (var extractedFace in connectedFaces) { Assert.False(mappedTriangles.Contains(extractedFace)); } }