Fix of the previous commit on color change fix.

This commit is contained in:
bubnikv 2019-06-25 08:56:53 +02:00
parent 5320ed9374
commit d689195bda

View file

@ -4646,22 +4646,24 @@ 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];
// Store the vertex arrays and restart their containers, if (vol.indexed_vertex_array.vertices_and_normals_interleaved.size() / 6 > ctxt.alloc_size_max()) {
vol = new_volume(vol->color); // Store the vertex arrays and restart their containers,
GLVolume &vol_new = *vol; vols[i] = new_volume(vol.color);
// Assign the large pre-allocated buffers to the new GLVolume. GLVolume &vol_new = *vols[i];
vol_new.indexed_vertex_array = std::move(vol->indexed_vertex_array); // Assign the large pre-allocated buffers to the new GLVolume.
// Copy the content back to the old GLVolume. vol_new.indexed_vertex_array = std::move(vol.indexed_vertex_array);
vol->indexed_vertex_array = vol_new.indexed_vertex_array; // Copy the content back to the old GLVolume.
// Finalize a bounding box of the old GLVolume. vol.indexed_vertex_array = vol_new.indexed_vertex_array;
vol->bounding_box = vol->indexed_vertex_array.bounding_box(); // Finalize a bounding box of the old GLVolume.
// Clear the buffers, but keep them pre-allocated. vol.bounding_box = vol.indexed_vertex_array.bounding_box();
vol_new.indexed_vertex_array.clear(); // Clear the buffers, but keep them pre-allocated.
// Just make sure that clear did not clear the reserved memory. vol_new.indexed_vertex_array.clear();
vol_new.indexed_vertex_array.reserve(ctxt.alloc_size_reserve()); // Just make sure that clear did not clear the reserved memory.
} 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();