//----------------------------------------------------------------------------

    private static bool ResizeParticleMeshBuffer(Mesh mesh,
                                                 SMeshDesc renderer,
                                                 uint usedVertexCount,
                                                 uint usedIndexCount,
                                                 uint reservedVertexCount,
                                                 uint reservedIndexCount,
                                                 bool useLargeIdx)
    {
        bool hasBeenResized = false;

        if (mesh.vertexCount < usedVertexCount)
        {
            // We only do the transition from uint16 to uint32 because the transition clear the index buffer...
            if (useLargeIdx == true && mesh.indexFormat == IndexFormat.UInt16)
            {
                mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
            }
            else if (useLargeIdx == false && mesh.indexFormat == IndexFormat.UInt32)
            {
                mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt16;
            }

            mesh.Clear();

            mesh.vertices = new Vector3[reservedVertexCount];                   // positions

            if (renderer.HasMaterialFlag(EMaterialFlags.Has_Color))
            {
                mesh.colors = new Color[reservedVertexCount];                       // color
            }
            if (renderer.HasMaterialFlag(EMaterialFlags.Has_Lighting))
            {
                mesh.normals = new Vector3[reservedVertexCount];                    // normal
            }
            if (renderer.HasMaterialFlag(EMaterialFlags.Has_RibbonComplex))
            {
                mesh.uv  = new Vector2[reservedVertexCount];                        // uvFactors
                mesh.uv2 = new Vector2[reservedVertexCount];                        // uvScale
                mesh.uv3 = new Vector2[reservedVertexCount];                        // uvOffset
                if (renderer.HasMaterialFlag(EMaterialFlags.Has_AlphaRemap))
                {
                    mesh.uv4 = new Vector2[reservedVertexCount];                        // alpha cursor
                }
            }
            else if (renderer.HasMaterialFlag(EMaterialFlags.Has_AnimBlend))
            {
                mesh.uv  = new Vector2[reservedVertexCount];                    // uv0
                mesh.uv2 = new Vector2[reservedVertexCount];                    // uv1
                mesh.uv3 = new Vector2[reservedVertexCount];                    // atlas id and if Has_AlphaRemap, alpha cursor
            }
            else
            {
                if (renderer.HasMaterialFlag(EMaterialFlags.Has_Diffuse))
                {
                    mesh.uv = new Vector2[reservedVertexCount];                         // uv0
                }
                if (renderer.HasMaterialFlag(EMaterialFlags.Has_AlphaRemap))
                {
                    mesh.uv2 = new Vector2[reservedVertexCount];                        // alpha cursor
                }
            }
            hasBeenResized = true;
        }

        if (mesh.GetIndexCount(0) < usedIndexCount)
        {
            int[] triangles = new int[reservedIndexCount];                       // index
            //fix to set the right vertex buffer size on PS4 : fill the index buffer with vertex ids
            if (Application.platform == RuntimePlatform.PS4)
            {
                for (int i = 0; i < mesh.vertexCount; ++i)
                {
                    triangles[i] = i;
                }
            }
            mesh.triangles = triangles;
            hasBeenResized = true;
        }

        return(hasBeenResized);
    }