public void RenderParts(ExposedList <SubmeshInstruction> instructions, int startSubmesh, int endSubmesh) { LazyIntialize(); // STEP 1: Create instruction var smartMesh = buffers.GetNextMesh(); currentInstructions.SetWithSubset(instructions, startSubmesh, endSubmesh); bool updateTriangles = SkeletonRendererInstruction.GeometryNotEqual(currentInstructions, smartMesh.instructionUsed); // STEP 2: Generate mesh buffers. var currentInstructionsSubmeshesItems = currentInstructions.submeshInstructions.Items; meshGenerator.Begin(); if (currentInstructions.hasActiveClipping) { for (int i = 0; i < currentInstructions.submeshInstructions.Count; i++) { meshGenerator.AddSubmesh(currentInstructionsSubmeshesItems[i], updateTriangles); } } else { meshGenerator.BuildMeshWithArrays(currentInstructions, updateTriangles); } buffers.UpdateSharedMaterials(currentInstructions.submeshInstructions); // STEP 3: modify mesh. var mesh = smartMesh.mesh; if (meshGenerator.VertexCount <= 0) // Clear an empty mesh { updateTriangles = false; mesh.Clear(); } else { meshGenerator.FillVertexData(mesh); if (updateTriangles) { meshGenerator.FillTriangles(mesh); meshRenderer.sharedMaterials = buffers.GetUpdatedShaderdMaterialsArray(); } else if (buffers.MaterialsChangedInLastUpdate()) { meshRenderer.sharedMaterials = buffers.GetUpdatedShaderdMaterialsArray(); } } meshFilter.sharedMesh = mesh; smartMesh.instructionUsed.Set(currentInstructions); }
public void RenderParts(ExposedList<SubmeshInstruction> instructions, int startSubmesh, int endSubmesh) { LazyIntialize(); MeshRendererBuffers.SmartMesh nextMesh = buffers.GetNextMesh(); currentInstructions.SetWithSubset(instructions, startSubmesh, endSubmesh); bool flag = SkeletonRendererInstruction.GeometryNotEqual(currentInstructions, nextMesh.instructionUsed); SubmeshInstruction[] items = currentInstructions.submeshInstructions.Items; meshGenerator.Begin(); if (currentInstructions.hasActiveClipping) { for (int i = 0; i < currentInstructions.submeshInstructions.Count; i++) { meshGenerator.AddSubmesh(items[i], flag); } } else { meshGenerator.BuildMeshWithArrays(currentInstructions, flag); } buffers.UpdateSharedMaterials(currentInstructions.submeshInstructions); Mesh mesh = nextMesh.mesh; if (meshGenerator.VertexCount <= 0) { flag = false; mesh.Clear(); } else { meshGenerator.FillVertexData(mesh); if (flag) { meshGenerator.FillTriangles(mesh); meshRenderer.sharedMaterials = buffers.GetUpdatedShaderdMaterialsArray(); } else if (buffers.MaterialsChangedInLastUpdate()) { meshRenderer.sharedMaterials = buffers.GetUpdatedShaderdMaterialsArray(); } } meshFilter.sharedMesh = mesh; nextMesh.instructionUsed.Set(currentInstructions); }