FIX: [STUDIO-2492] Model Centering Problem

Click on Add in the top menu bar, the model is not centered

Change-Id: I950ce13262090ada316d5c350af8c7edc9826222
This commit is contained in:
maosheng.wei 2023-05-09 14:02:52 +08:00 committed by Lane.Wei
parent 92d764e9ee
commit f40851ff31

View file

@ -3799,8 +3799,14 @@ std::vector<size_t> Plater::priv::load_model_objects(const ModelObjectPtrs& mode
for (auto& instance : new_instances) {
auto offset = instance->get_offset();
auto start_point = this->bed.build_volume().bounding_volume2d().center();
bool plate_empty = partplate_list.get_curr_plate()->empty();
Vec3d displacement;
if (plate_empty)
displacement = {start_point(0), start_point(1), offset(2)};
else {
auto empty_cell = wxGetApp().plater()->canvas3D()->get_nearest_empty_cell({start_point(0), start_point(1)});
Vec3d displacement = { empty_cell.x(),empty_cell.y(),offset(2)};
displacement = {empty_cell.x(), empty_cell.y(), offset(2)};
}
instance->set_offset(displacement);
}
#endif