void HandleRender(SkeletonRenderer.SmartMesh.Instruction instruction) { int rendererCount = partsRenderers.Count; if (rendererCount <= 0) { return; } int rendererIndex = 0; if (copyPropertyBlock) { mainMeshRenderer.GetPropertyBlock(copiedBlock); } var submeshInstructions = instruction.submeshInstructions; var submeshInstructionsItems = submeshInstructions.Items; int lastSubmeshInstruction = submeshInstructions.Count - 1; var currentRenderer = partsRenderers[rendererIndex]; bool addNormals = skeletonRenderer.calculateNormals; bool addTangents = skeletonRenderer.calculateTangents; for (int si = 0, start = 0; si <= lastSubmeshInstruction; si++) { if (submeshInstructionsItems[si].forceSeparate || si == lastSubmeshInstruction) { // Apply properties var meshGenerator = currentRenderer.MeshGenerator; meshGenerator.AddNormals = addNormals; meshGenerator.AddTangents = addTangents; if (copyPropertyBlock) { currentRenderer.SetPropertyBlock(copiedBlock); } // Render currentRenderer.RenderParts(instruction.submeshInstructions, start, si + 1); start = si + 1; rendererIndex++; if (rendererIndex < rendererCount) { currentRenderer = partsRenderers[rendererIndex]; } else { // Not enough renderers. Skip the rest of the instructions. break; } } } // Clear extra renderers if they exist. for (; rendererIndex < rendererCount; rendererIndex++) { partsRenderers[rendererIndex].ClearMesh(); } }
private void HandleRender(SkeletonRenderer.SmartMesh.Instruction instruction) { int count = this.partsRenderers.Count; if (count <= 0) { return; } int i = 0; if (this.copyPropertyBlock) { this.mainMeshRenderer.GetPropertyBlock(this.copiedBlock); } ExposedList <SubmeshInstruction> submeshInstructions = instruction.submeshInstructions; SubmeshInstruction[] items = submeshInstructions.Items; int num = submeshInstructions.Count - 1; SkeletonPartsRenderer skeletonPartsRenderer = this.partsRenderers[i]; bool calculateNormals = this.skeletonRenderer.calculateNormals; bool calculateTangents = this.skeletonRenderer.calculateTangents; bool pmaVertexColors = this.skeletonRenderer.pmaVertexColors; int j = 0; int startSubmesh = 0; while (j <= num) { if (items[j].forceSeparate || j == num) { ISubmeshSetMeshGenerator meshGenerator = skeletonPartsRenderer.MeshGenerator; meshGenerator.AddNormals = calculateNormals; meshGenerator.AddTangents = calculateTangents; meshGenerator.PremultiplyVertexColors = pmaVertexColors; if (this.copyPropertyBlock) { skeletonPartsRenderer.SetPropertyBlock(this.copiedBlock); } skeletonPartsRenderer.RenderParts(instruction.submeshInstructions, startSubmesh, j + 1); startSubmesh = j + 1; i++; if (i >= count) { break; } skeletonPartsRenderer = this.partsRenderers[i]; } j++; } while (i < count) { this.partsRenderers[i].ClearMesh(); i++; } }
void HandleRender(SkeletonRenderer.SmartMesh.Instruction instruction) { int rendererCount = partsRenderers.Count; if (rendererCount <= 0) { return; } int rendererIndex = 0; if (copyPropertyBlock) { mainMeshRenderer.GetPropertyBlock(block); } var submeshInstructions = instruction.submeshInstructions; var submeshInstructionsItems = submeshInstructions.Items; int lastSubmeshInstruction = submeshInstructions.Count - 1; var currentRenderer = partsRenderers[rendererIndex]; bool skeletonRendererCalculateNormals = skeletonRenderer.calculateNormals; for (int i = 0, start = 0; i <= lastSubmeshInstruction; i++) { if (submeshInstructionsItems[i].forceSeparate) { currentRenderer.RenderParts(instruction.submeshInstructions, start, i + 1); currentRenderer.MeshGenerator.GenerateNormals = skeletonRendererCalculateNormals; if (copyPropertyBlock) { currentRenderer.SetPropertyBlock(block); } start = i + 1; rendererIndex++; if (rendererIndex < rendererCount) { currentRenderer = partsRenderers[rendererIndex]; } else { // Not enough renderers. Skip the rest of the instructions. break; } } else if (i == lastSubmeshInstruction) { currentRenderer.RenderParts(instruction.submeshInstructions, start, i + 1); currentRenderer.MeshGenerator.GenerateNormals = skeletonRendererCalculateNormals; if (copyPropertyBlock) { currentRenderer.SetPropertyBlock(block); } } } // If too many renderers. Clear the rest. rendererIndex++; if (rendererIndex < rendererCount - 1) { for (int i = rendererIndex; i < rendererCount; i++) { currentRenderer = partsRenderers[i]; currentRenderer.ClearMesh(); } } }