Modifiers should load at object offset like in Prusaslicer (#3802)

* fix precedence errors

Fix a handful of precedence errors and 1 logic/precedence error.  None of the code will compile as intended without these changes.

* Update GUI_ObjectList.cpp

Modifiers should load at same offset as object they are created against.  Based on prusaslicer ObjectList::load_from_files where it works correctly.

---------

Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
foghatredbird 2024-01-24 07:50:42 -08:00 committed by GitHub
parent 55b6f2a588
commit afb89c4309
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2030,9 +2030,10 @@ void ObjectList::load_modifier(const wxArrayString& input_files, ModelObject& mo
ModelVolume* new_volume = model_object.add_volume(std::move(mesh), type); ModelVolume* new_volume = model_object.add_volume(std::move(mesh), type);
new_volume->name = boost::filesystem::path(input_file).filename().string(); new_volume->name = boost::filesystem::path(input_file).filename().string();
// BBS: object_mesh.get_init_shift() keep the relative position // adjust offset as prusaslicer ObjectList::load_from_files does (works) instead of BBS method
TriangleMesh object_mesh = model_object.volumes[0]->mesh(); //// BBS: object_mesh.get_init_shift() keep the relative position
new_volume->set_offset(new_volume->mesh().get_init_shift() - object_mesh.get_init_shift()); //TriangleMesh object_mesh = model_object.volumes[0]->mesh();
//new_volume->set_offset(new_volume->mesh().get_init_shift() - object_mesh.get_init_shift());
// set a default extruder value, since user can't add it manually // set a default extruder value, since user can't add it manually
// BBS // BBS
@ -2056,6 +2057,8 @@ void ObjectList::load_modifier(const wxArrayString& input_files, ModelObject& mo
const Vec3d offset = Vec3d(instance_bb.max.x(), instance_bb.min.y(), instance_bb.min.z()) + 0.5 * mesh_bb.size() - instance_offset; const Vec3d offset = Vec3d(instance_bb.max.x(), instance_bb.min.y(), instance_bb.min.z()) + 0.5 * mesh_bb.size() - instance_offset;
new_volume->set_offset(inv_inst_transform * offset); new_volume->set_offset(inv_inst_transform * offset);
} }
else
new_volume->set_offset(new_volume->source.mesh_offset - model_object.volumes.front()->source.mesh_offset);
added_volumes.push_back(new_volume); added_volumes.push_back(new_volume);
} }