Ejemplo n.º 1
0
        private void HandleRender(SkeletonRendererInstruction instruction)
        {
            int count = partsRenderers.Count;

            if (count <= 0)
            {
                return;
            }
            if (copyPropertyBlock)
            {
                mainMeshRenderer.GetPropertyBlock(copiedBlock);
            }
            MeshGenerator.Settings settings = default(MeshGenerator.Settings);
            settings.addNormals         = skeletonRenderer.addNormals;
            settings.calculateTangents  = skeletonRenderer.calculateTangents;
            settings.immutableTriangles = false;
            settings.pmaVertexColors    = skeletonRenderer.pmaVertexColors;
            settings.tintBlack          = skeletonRenderer.tintBlack;
            settings.useClipping        = true;
            settings.zSpacing           = skeletonRenderer.zSpacing;
            MeshGenerator.Settings           settings2           = settings;
            ExposedList <SubmeshInstruction> submeshInstructions = instruction.submeshInstructions;

            SubmeshInstruction[] items = submeshInstructions.Items;
            int num = submeshInstructions.Count - 1;
            int i   = 0;
            SkeletonPartsRenderer skeletonPartsRenderer = partsRenderers[i];
            int j            = 0;
            int startSubmesh = 0;

            for (; j <= num; j++)
            {
                if (items[j].forceSeparate || j == num)
                {
                    MeshGenerator meshGenerator = skeletonPartsRenderer.MeshGenerator;
                    meshGenerator.settings = settings2;
                    if (copyPropertyBlock)
                    {
                        skeletonPartsRenderer.SetPropertyBlock(copiedBlock);
                    }
                    skeletonPartsRenderer.RenderParts(instruction.submeshInstructions, startSubmesh, j + 1);
                    startSubmesh = j + 1;
                    i++;
                    if (i >= count)
                    {
                        break;
                    }
                    skeletonPartsRenderer = partsRenderers[i];
                }
            }
            for (; i < count; i++)
            {
                partsRenderers[i].ClearMesh();
            }
        }
Ejemplo n.º 2
0
        private void HandleRender(SkeletonRendererInstruction instruction)
        {
            int count = this.partsRenderers.Count;

            if (count > 0)
            {
                if (this.copyPropertyBlock)
                {
                    this.mainMeshRenderer.GetPropertyBlock(this.copiedBlock);
                }
                MeshGenerator.Settings settings = new MeshGenerator.Settings {
                    addNormals         = this.skeletonRenderer.addNormals,
                    calculateTangents  = this.skeletonRenderer.calculateTangents,
                    immutableTriangles = false,
                    pmaVertexColors    = this.skeletonRenderer.pmaVertexColors,
                    tintBlack          = this.skeletonRenderer.tintBlack,
                    useClipping        = true,
                    zSpacing           = this.skeletonRenderer.zSpacing
                };
                ExposedList <SubmeshInstruction> submeshInstructions = instruction.submeshInstructions;
                SubmeshInstruction[]             items = submeshInstructions.Items;
                int num2 = submeshInstructions.Count - 1;
                int num3 = 0;
                SkeletonPartsRenderer renderer = this.partsRenderers[num3];
                int index        = 0;
                int startSubmesh = 0;
                while (index <= num2)
                {
                    if (items[index].forceSeparate || (index == num2))
                    {
                        renderer.MeshGenerator.settings = settings;
                        if (this.copyPropertyBlock)
                        {
                            renderer.SetPropertyBlock(this.copiedBlock);
                        }
                        renderer.RenderParts(instruction.submeshInstructions, startSubmesh, index + 1);
                        startSubmesh = index + 1;
                        num3++;
                        if (num3 >= count)
                        {
                            break;
                        }
                        renderer = this.partsRenderers[num3];
                    }
                    index++;
                }
                while (num3 < count)
                {
                    this.partsRenderers[num3].ClearMesh();
                    num3++;
                }
            }
        }
        void HandleRender(SkeletonRendererInstruction instruction)
        {
            int rendererCount = partsRenderers.Count;

            if (rendererCount <= 0)
            {
                return;
            }

            if (copyPropertyBlock)
            {
                mainMeshRenderer.GetPropertyBlock(copiedBlock);
            }

            var settings = new MeshGenerator.Settings {
                addNormals         = skeletonRenderer.addNormals,
                calculateTangents  = skeletonRenderer.calculateTangents,
                immutableTriangles = false,                 // parts cannot do immutable triangles.
                pmaVertexColors    = skeletonRenderer.pmaVertexColors,
                //renderMeshes = skeletonRenderer.renderMeshes,
                tintBlack   = skeletonRenderer.tintBlack,
                useClipping = true,
                zSpacing    = skeletonRenderer.zSpacing
            };

            var submeshInstructions      = instruction.submeshInstructions;
            var submeshInstructionsItems = submeshInstructions.Items;
            int lastSubmeshInstruction   = submeshInstructions.Count - 1;

            int rendererIndex   = 0;
            var currentRenderer = partsRenderers[rendererIndex];

            for (int si = 0, start = 0; si <= lastSubmeshInstruction; si++)
            {
                if (submeshInstructionsItems[si].forceSeparate || si == lastSubmeshInstruction)
                {
                    // Apply properties
                    var meshGenerator = currentRenderer.MeshGenerator;
                    meshGenerator.settings = settings;

                    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();
            }
        }