Remap paint after split to objects
This commit is contained in:
@@ -2028,13 +2028,14 @@ static void invalidate_translations(ModelObject* object, const ModelInstance* sr
|
||||
}
|
||||
}
|
||||
|
||||
void ModelObject::split(ModelObjectPtrs* new_objects)
|
||||
void ModelObject::split(ModelObjectPtrs* new_objects, const bool remap_paint)
|
||||
{
|
||||
std::vector<TriangleMesh> all_meshes;
|
||||
std::vector<Transform3d> all_transfos;
|
||||
std::vector<std::pair<int, int>> volume_mesh_counts;
|
||||
all_meshes.reserve(this->volumes.size() * 5);
|
||||
bool is_multi_volume_object = (this->volumes.size() > 1);
|
||||
std::optional<TriangleSelector::SavedPainting> saved_painting;
|
||||
|
||||
for (int volume_idx = 0; volume_idx < this->volumes.size(); volume_idx++) {
|
||||
ModelVolume* volume = this->volumes[volume_idx];
|
||||
@@ -2046,6 +2047,10 @@ void ModelObject::split(ModelObjectPtrs* new_objects)
|
||||
volume->text_configuration.reset();
|
||||
|
||||
if (!is_multi_volume_object) {
|
||||
if (remap_paint) {
|
||||
// Save painting so we could restore them after the mesh split
|
||||
saved_painting = volume->save_painting();
|
||||
}
|
||||
//BBS: not multi volume object, then split mesh.
|
||||
std::vector<TriangleMesh> volume_meshes = volume->mesh().split();
|
||||
int mesh_count = 0;
|
||||
@@ -2123,6 +2128,9 @@ void ModelObject::split(ModelObjectPtrs* new_objects)
|
||||
COPY_FACETS(seam_facets);
|
||||
COPY_FACETS(mmu_segmentation_facets);
|
||||
COPY_FACETS(fuzzy_skin_facets);
|
||||
} else if (saved_painting) {
|
||||
// Geometry changed, attempt to remap them to the new mesh
|
||||
new_vol->restore_painting(saved_painting);
|
||||
}
|
||||
|
||||
// BBS: clear volume's config, as we already set them into object
|
||||
|
||||
Reference in New Issue
Block a user