public static void ExtrudeFaceMultipleTimes() { using (var shapes = new TestUtility.BuiltInPrimitives()) { foreach (ProBuilderMesh pb in shapes) { int initialVertexCount = pb.vertexCount; UnityEngine.ProBuilder.Face face = pb.facesInternal[m_Random.Next(0, pb.facesInternal.Length)]; pb.Extrude(new UnityEngine.ProBuilder.Face[] { face }, ExtrudeMethod.FaceNormal, 1f); pb.ToMesh(); pb.Refresh(); LogAssert.NoUnexpectedReceived(); TestUtility.AssertMeshAttributesValid(pb.mesh); Assert.AreEqual(initialVertexCount + face.edgesInternal.Length * 4, pb.vertexCount); initialVertexCount = pb.vertexCount; pb.Extrude(new UnityEngine.ProBuilder.Face[] { face }, ExtrudeMethod.VertexNormal, 1f); pb.ToMesh(); pb.Refresh(); LogAssert.NoUnexpectedReceived(); TestUtility.AssertMeshAttributesValid(pb.mesh); Assert.AreEqual(initialVertexCount + face.edgesInternal.Length * 4, pb.vertexCount); initialVertexCount = pb.vertexCount; pb.Extrude(new UnityEngine.ProBuilder.Face[] { face }, ExtrudeMethod.IndividualFaces, 1f); pb.ToMesh(); pb.Refresh(); LogAssert.NoUnexpectedReceived(); TestUtility.AssertMeshAttributesValid(pb.mesh); Assert.AreEqual(initialVertexCount + face.edgesInternal.Length * 4, pb.vertexCount); } } }
public static void Extrude_Face_MultipleTimes_CreatesValidGeometry([ValueSource("shapeTypes")] ShapeType shape) { var mesh = ShapeGenerator.CreateShape(shape); try { int initialVertexCount = mesh.vertexCount; UnityEngine.ProBuilder.Face face = mesh.facesInternal[m_Random.Next(0, mesh.facesInternal.Length)]; mesh.Extrude(new UnityEngine.ProBuilder.Face[] { face }, ExtrudeMethod.FaceNormal, 1f); mesh.ToMesh(); mesh.Refresh(); LogAssert.NoUnexpectedReceived(); TestUtility.AssertMeshAttributesValid(mesh.mesh); Assert.AreEqual(initialVertexCount + face.edgesInternal.Length * 4, mesh.vertexCount); initialVertexCount = mesh.vertexCount; mesh.Extrude(new UnityEngine.ProBuilder.Face[] { face }, ExtrudeMethod.VertexNormal, 1f); mesh.ToMesh(); mesh.Refresh(); LogAssert.NoUnexpectedReceived(); TestUtility.AssertMeshAttributesValid(mesh.mesh); Assert.AreEqual(initialVertexCount + face.edgesInternal.Length * 4, mesh.vertexCount); initialVertexCount = mesh.vertexCount; mesh.Extrude(new UnityEngine.ProBuilder.Face[] { face }, ExtrudeMethod.IndividualFaces, 1f); mesh.ToMesh(); mesh.Refresh(); LogAssert.NoUnexpectedReceived(); TestUtility.AssertMeshAttributesValid(mesh.mesh); Assert.AreEqual(initialVertexCount + face.edgesInternal.Length * 4, mesh.vertexCount); } catch (Exception e) { Debug.LogError(e.ToString()); } finally { if (mesh != null) { Object.DestroyImmediate(mesh.gameObject); } } }
static void ExtrudeSingleFace(ExtrudeMethod method, float distance = 1f) { using (var shapes = new TestUtility.BuiltInPrimitives()) { foreach (var pb in (IEnumerable <ProBuilderMesh>)shapes) { int initialVertexCount = pb.vertexCount; UnityEngine.ProBuilder.Face face = pb.facesInternal[m_Random.Next(0, pb.facesInternal.Length)]; pb.Extrude(new UnityEngine.ProBuilder.Face[] { face }, method, 1f); pb.ToMesh(); pb.Refresh(); LogAssert.NoUnexpectedReceived(); TestUtility.AssertMeshAttributesValid(pb.mesh); #if PB_CREATE_TEST_MESH_TEMPLATES TestUtility.SaveAssetTemplate(pb.mesh, pb.name); #endif Assert.AreEqual(initialVertexCount + face.edgesInternal.Length * 4, pb.vertexCount); } } }
public static void ExtrudeSingleEdge() { var pb = ShapeGenerator.CreateShape(ShapeType.Cube); try { int vertexCount = pb.vertexCount; UnityEngine.ProBuilder.Edge[] edges = new UnityEngine.ProBuilder.Edge[1]; UnityEngine.ProBuilder.Face face = pb.facesInternal[m_Random.Next(0, pb.faceCount)]; edges[0] = face.edgesInternal[m_Random.Next(0, face.edgesInternal.Length)]; // as group, enable manifold extrude Assert.IsFalse(pb.Extrude(edges, .5f, true, false) != null, "Do not allow manifold edge extrude"); Assert.IsTrue(pb.Extrude(edges, .5f, true, true) != null, "Do allow manifold edge extrude"); pb.ToMesh(); pb.Refresh(); TestUtility.AssertMeshAttributesValid(pb.mesh); Assert.AreEqual(vertexCount + edges.Length * 4, pb.vertexCount); } finally { UObject.DestroyImmediate(pb.gameObject); } }