Update `triangulate_delaunay()` to avoid needless reallocations
This commit is contained in:
parent
5fb9ff9986
commit
c33e291474
|
@ -306,10 +306,12 @@ public:
|
||||||
Vector<Delaunay2D::Triangle> tr = Delaunay2D::triangulate(p_points);
|
Vector<Delaunay2D::Triangle> tr = Delaunay2D::triangulate(p_points);
|
||||||
Vector<int> triangles;
|
Vector<int> triangles;
|
||||||
|
|
||||||
|
triangles.resize(3 * tr.size());
|
||||||
|
int *ptr = triangles.ptrw();
|
||||||
for (int i = 0; i < tr.size(); i++) {
|
for (int i = 0; i < tr.size(); i++) {
|
||||||
triangles.push_back(tr[i].points[0]);
|
*ptr++ = tr[i].points[0];
|
||||||
triangles.push_back(tr[i].points[1]);
|
*ptr++ = tr[i].points[1];
|
||||||
triangles.push_back(tr[i].points[2]);
|
*ptr++ = tr[i].points[2];
|
||||||
}
|
}
|
||||||
return triangles;
|
return triangles;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue