Fix of the previous commit on color change fix.
This commit is contained in:
parent
5320ed9374
commit
d689195bda
@ -4646,23 +4646,25 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Ensure that no volume grows over the limits. If the volume is too large, allocate a new one.
|
// Ensure that no volume grows over the limits. If the volume is too large, allocate a new one.
|
||||||
for (GLVolume *&vol : vols)
|
for (size_t i = 0; i < vols.size(); ++i) {
|
||||||
if (vol->indexed_vertex_array.vertices_and_normals_interleaved.size() / 6 > ctxt.alloc_size_max()) {
|
GLVolume &vol = *vols[i];
|
||||||
|
if (vol.indexed_vertex_array.vertices_and_normals_interleaved.size() / 6 > ctxt.alloc_size_max()) {
|
||||||
// Store the vertex arrays and restart their containers,
|
// Store the vertex arrays and restart their containers,
|
||||||
vol = new_volume(vol->color);
|
vols[i] = new_volume(vol.color);
|
||||||
GLVolume &vol_new = *vol;
|
GLVolume &vol_new = *vols[i];
|
||||||
// Assign the large pre-allocated buffers to the new GLVolume.
|
// Assign the large pre-allocated buffers to the new GLVolume.
|
||||||
vol_new.indexed_vertex_array = std::move(vol->indexed_vertex_array);
|
vol_new.indexed_vertex_array = std::move(vol.indexed_vertex_array);
|
||||||
// Copy the content back to the old GLVolume.
|
// Copy the content back to the old GLVolume.
|
||||||
vol->indexed_vertex_array = vol_new.indexed_vertex_array;
|
vol.indexed_vertex_array = vol_new.indexed_vertex_array;
|
||||||
// Finalize a bounding box of the old GLVolume.
|
// Finalize a bounding box of the old GLVolume.
|
||||||
vol->bounding_box = vol->indexed_vertex_array.bounding_box();
|
vol.bounding_box = vol.indexed_vertex_array.bounding_box();
|
||||||
// Clear the buffers, but keep them pre-allocated.
|
// Clear the buffers, but keep them pre-allocated.
|
||||||
vol_new.indexed_vertex_array.clear();
|
vol_new.indexed_vertex_array.clear();
|
||||||
// Just make sure that clear did not clear the reserved memory.
|
// Just make sure that clear did not clear the reserved memory.
|
||||||
vol_new.indexed_vertex_array.reserve(ctxt.alloc_size_reserve());
|
vol_new.indexed_vertex_array.reserve(ctxt.alloc_size_reserve());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (GLVolume *vol : vols) {
|
for (GLVolume *vol : vols) {
|
||||||
vol->bounding_box = vol->indexed_vertex_array.bounding_box();
|
vol->bounding_box = vol->indexed_vertex_array.bounding_box();
|
||||||
vol->indexed_vertex_array.shrink_to_fit();
|
vol->indexed_vertex_array.shrink_to_fit();
|
||||||
|
Loading…
Reference in New Issue
Block a user