ObjectList: Fixed position of the added sub-object, when it is Slab

This commit is contained in:
YuSanka 2022-10-31 12:55:43 +01:00
parent e32d03318d
commit 7742ebb813

View File

@ -1698,11 +1698,16 @@ void ObjectList::load_generic_subobject(const std::string& type_name, const Mode
new_volume->set_transformation(Geometry::Transformation::volume_to_bed_transformation(v->get_instance_transformation(), mesh_bb)); new_volume->set_transformation(Geometry::Transformation::volume_to_bed_transformation(v->get_instance_transformation(), mesh_bb));
#endif // ENABLE_WORLD_COORDINATE #endif // ENABLE_WORLD_COORDINATE
// Set the modifier position. // Set the modifier position.
auto offset = (type_name == "Slab") ? Vec3d offset;
// Slab: Lift to print bed if (type_name == "Slab") {
Vec3d(0., 0., 0.5 * mesh_bb.size().z() + instance_bb.min.z() - v->get_instance_offset().z()) : Vec3d inst_center = instance_bb.center() - v->get_instance_offset();
// Slab: Lift to print bed and and push to the center of instance
offset = Vec3d(inst_center.x(), inst_center.y(), 0.5 * mesh_bb.size().z() + instance_bb.min.z() - v->get_instance_offset().z());
}
else {
// Translate the new modifier to be pickable: move to the left front corner of the instance's bounding box, lift to print bed. // Translate the new modifier to be pickable: move to the left front corner of the instance's bounding box, lift to print bed.
Vec3d(instance_bb.max.x(), instance_bb.min.y(), instance_bb.min.z()) + 0.5 * mesh_bb.size() - v->get_instance_offset(); offset = Vec3d(instance_bb.max.x(), instance_bb.min.y(), instance_bb.min.z()) + 0.5 * mesh_bb.size() - v->get_instance_offset();
}
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
new_volume->set_offset(v->get_instance_transformation().get_matrix_no_offset().inverse() * offset); new_volume->set_offset(v->get_instance_transformation().get_matrix_no_offset().inverse() * offset);
#else #else