public void AddTriangle(RecastVisualTriangle triangle) { // Unity has a limit of 64k vertices for a single mesh, so if we can not store this triangle we build the mesh // with all triangles until now and start a new mesh. if (currentVertexIdx > 65532) { BuildAndAddMesh(ref vertices, ref triangles, ref colors); remainingVertexCount -= currentVertexIdx; if (remainingVertexCount < 65535) { vertices = new Vector3[remainingVertexCount]; triangles = new int[remainingVertexCount]; colors = new Color32[remainingVertexCount]; } currentVertexIdx = 0; } triangle.m_triangle.Offset(0.3f); vertices[currentVertexIdx] = triangle.m_triangle.m_A; vertices[currentVertexIdx + 1] = triangle.m_triangle.m_B; vertices[currentVertexIdx + 2] = triangle.m_triangle.m_C; triangles[currentVertexIdx] = (int)currentVertexIdx; triangles[currentVertexIdx + 1] = (int)currentVertexIdx + 1; triangles[currentVertexIdx + 2] = (int)currentVertexIdx + 2; colors[currentVertexIdx] = triangle.m_color; colors[currentVertexIdx + 1] = triangle.m_color; colors[currentVertexIdx + 2] = triangle.m_color; currentVertexIdx += 3; }
public static extern bool GetDatabaseTriangle(uint triangleIndex, out RecastVisualTriangle triangle);