public void Subdivide(ITriangulator triangulator, float largestAreaFactor, float areaThreshold) { Debug.Assert(spriteMeshData != null); Debug.Assert(triangulator != null); m_VerticesTemp.Clear(); m_EdgesTemp.Clear(); m_EdgesTemp.AddRange(spriteMeshData.edges); for (int i = 0; i < spriteMeshData.vertexCount; ++i) { m_VerticesTemp.Add(spriteMeshData.GetPosition(i)); } try { var indices = new List <int>(); triangulator.Tessellate(0f, 0f, 0f, largestAreaFactor, areaThreshold, 100, m_VerticesTemp, m_EdgesTemp, indices); spriteMeshData.Clear(); for (int i = 0; i < m_VerticesTemp.Count; ++i) { spriteMeshData.AddVertex(m_VerticesTemp[i], default(BoneWeight)); } spriteMeshData.edges.AddRange(m_EdgesTemp); spriteMeshData.indices.AddRange(indices); } catch (Exception) { } }
public static void Subdivide(this SpriteMeshData spriteMeshData, ITriangulator triangulator, float largestAreaFactor) { Debug.Assert(triangulator != null); m_VerticesTemp.Clear(); for (int i = 0; i < spriteMeshData.vertices.Count; ++i) { m_VerticesTemp.Add(spriteMeshData.vertices[i].position); } triangulator.Tessellate(0f, 0f, 0f, largestAreaFactor, 100, m_VerticesTemp, spriteMeshData.edges, spriteMeshData.indices); spriteMeshData.vertices.Clear(); for (int i = 0; i < m_VerticesTemp.Count; ++i) { spriteMeshData.vertices.Add(new Vertex2D(m_VerticesTemp[i])); } }