FIX: location is incorrect when loading modifier

Change-Id: Ib750c96ad61ca9e804040a75aed0dda58b76f3af
(cherry picked from commit 8c797905e5ed81971cd72ae3a2d001b9d1bee312)
This commit is contained in:
zhimin.zeng 2022-11-21 15:32:45 +08:00 committed by Lane.Wei
parent 0ce31da96e
commit 11fa28a87a

View file

@ -1846,6 +1846,13 @@ void ObjectList::load_modifier(const wxArrayString& input_files, ModelObject& mo
// Mesh will be centered when loading. // Mesh will be centered when loading.
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();
// adjust the position according to the bounding box
const BoundingBoxf3 mesh_bb = new_volume->mesh().bounding_box();
new_volume->set_transformation(Geometry::Transformation::volume_to_bed_transformation(v->get_instance_transformation(), mesh_bb));
auto offset = Vec3d(instance_bb.max.x(), instance_bb.min.y(), instance_bb.min.z()) + 0.5 * mesh_bb.size() - v->get_instance_offset();
new_volume->set_offset(v->get_instance_transformation().get_matrix(true).inverse() * offset);
// 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
int extruder_id = 0; int extruder_id = 0;