diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index 306f80394..5c291a0c6 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -918,7 +918,6 @@ BoundingBoxf3 ModelObject::instance_bounding_box(size_t instance_idx, bool dont_ // Calculate 2D convex hull of of a projection of the transformed printable volumes into the XY plane. // This method is cheap in that it does not make any unnecessary copy of the volume meshes. // This method is used by the auto arrange function. -#if ENABLE_ALLOW_NEGATIVE_Z Polygon ModelObject::convex_hull_2d(const Transform3d& trafo_instance) const { Points pts; @@ -928,33 +927,6 @@ Polygon ModelObject::convex_hull_2d(const Transform3d& trafo_instance) const } return Geometry::convex_hull(std::move(pts)); } -#else -Polygon ModelObject::convex_hull_2d(const Transform3d &trafo_instance) const -{ - Points pts; - for (const ModelVolume *v : this->volumes) - if (v->is_model_part()) { - Transform3d trafo = trafo_instance * v->get_matrix(); - const indexed_triangle_set &its = v->mesh().its; - if (its.vertices.empty()) { - // Using the STL faces. - const stl_file& stl = v->mesh().stl; - for (const stl_facet &facet : stl.facet_start) - for (size_t j = 0; j < 3; ++ j) { - Vec3d p = trafo * facet.vertex[j].cast(); - pts.emplace_back(coord_t(scale_(p.x())), coord_t(scale_(p.y()))); - } - } else { - // Using the shared vertices should be a bit quicker than using the STL faces. - for (size_t i = 0; i < its.vertices.size(); ++ i) { - Vec3d p = trafo * its.vertices[i].cast(); - pts.emplace_back(coord_t(scale_(p.x())), coord_t(scale_(p.y()))); - } - } - } - return Geometry::convex_hull(std::move(pts)); -} -#endif // ENABLE_ALLOW_NEGATIVE_Z void ModelObject::center_around_origin(bool include_modifiers) { @@ -969,19 +941,12 @@ void ModelObject::center_around_origin(bool include_modifiers) this->origin_translation += shift; } -#if ENABLE_ALLOW_NEGATIVE_Z void ModelObject::ensure_on_bed(bool allow_negative_z) { const double min_z = get_min_z(); if (!allow_negative_z || min_z > SINKING_Z_THRESHOLD) translate_instances({ 0.0, 0.0, -min_z }); } -#else -void ModelObject::ensure_on_bed() -{ - translate_instances({ 0.0, 0.0, -get_min_z() }); -} -#endif // ENABLE_ALLOW_NEGATIVE_Z void ModelObject::translate_instances(const Vec3d& vector) { @@ -1927,20 +1892,10 @@ arrangement::ArrangePolygon ModelInstance::get_arrange_polygon() const Vec3d rotation = get_rotation(); rotation.z() = 0.; Transform3d trafo_instance = -#if ENABLE_ALLOW_NEGATIVE_Z - Geometry::assemble_transform(get_offset().z() * Vec3d::UnitZ(), rotation, - get_scaling_factor(), get_mirror()); -#else - Geometry::assemble_transform(Vec3d::Zero(), rotation, - get_scaling_factor(), get_mirror()); -#endif // ENABLE_ALLOW_NEGATIVE_Z + Geometry::assemble_transform(get_offset().z() * Vec3d::UnitZ(), rotation, get_scaling_factor(), get_mirror()); Polygon p = get_object()->convex_hull_2d(trafo_instance); -#if !ENABLE_ALLOW_NEGATIVE_Z - assert(!p.points.empty()); -#endif // !ENABLE_ALLOW_NEGATIVE_Z - // if (!p.points.empty()) { // Polygons pp{p}; // pp = p.simplify(scaled(SIMPLIFY_TOLERANCE_MM)); diff --git a/src/libslic3r/Model.hpp b/src/libslic3r/Model.hpp index 5e7e4c03d..fda500810 100644 --- a/src/libslic3r/Model.hpp +++ b/src/libslic3r/Model.hpp @@ -322,12 +322,8 @@ public: Polygon convex_hull_2d(const Transform3d &trafo_instance) const; void center_around_origin(bool include_modifiers = true); - -#if ENABLE_ALLOW_NEGATIVE_Z void ensure_on_bed(bool allow_negative_z = false); -#else - void ensure_on_bed(); -#endif // ENABLE_ALLOW_NEGATIVE_Z + void translate_instances(const Vec3d& vector); void translate_instance(size_t instance_idx, const Vec3d& vector); void translate(const Vec3d &vector) { this->translate(vector(0), vector(1), vector(2)); } @@ -1176,9 +1172,7 @@ void check_model_ids_validity(const Model &model); void check_model_ids_equal(const Model &model1, const Model &model2); #endif /* NDEBUG */ -#if ENABLE_ALLOW_NEGATIVE_Z static const float SINKING_Z_THRESHOLD = -0.001f; -#endif // ENABLE_ALLOW_NEGATIVE_Z } // namespace Slic3r diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index e6603e36e..b3a1bc993 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -373,7 +373,6 @@ bool Print::sequential_print_horizontal_clearance_valid(const Print& print, Poly // FIXME: Arrangement has different parameters for offsetting (jtMiter, limit 2) // which causes that the warning will be showed after arrangement with the // appropriate object distance. Even if I set this to jtMiter the warning still shows up. -#if ENABLE_ALLOW_NEGATIVE_Z it_convex_hull = map_model_object_to_convex_hull.emplace_hint(it_convex_hull, model_object_id, offset(print_object->model_object()->convex_hull_2d( Geometry::assemble_transform({ 0.0, 0.0, model_instance0->get_offset().z() }, model_instance0->get_rotation(), model_instance0->get_scaling_factor(), model_instance0->get_mirror())), @@ -381,15 +380,6 @@ bool Print::sequential_print_horizontal_clearance_valid(const Print& print, Poly // exactly by satisfying the extruder_clearance_radius, this test will not trigger collision. float(scale_(0.5 * print.config().extruder_clearance_radius.value - EPSILON)), jtRound, scale_(0.1)).front()); -#else - it_convex_hull = map_model_object_to_convex_hull.emplace_hint(it_convex_hull, model_object_id, - offset(print_object->model_object()->convex_hull_2d( - Geometry::assemble_transform(Vec3d::Zero(), model_instance0->get_rotation(), model_instance0->get_scaling_factor(), model_instance0->get_mirror())), - // Shrink the extruder_clearance_radius a tiny bit, so that if the object arrangement algorithm placed the objects - // exactly by satisfying the extruder_clearance_radius, this test will not trigger collision. - float(scale_(0.5 * print.config().extruder_clearance_radius.value - EPSILON)), - jtRound, float(scale_(0.1))).front()); -#endif // ENABLE_ALLOW_NEGATIVE_Z } // Make a copy, so it may be rotated for instances. Polygon convex_hull0 = it_convex_hull->second; diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index e1d4096bf..7aa39c823 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -1600,15 +1600,9 @@ PrintRegionConfig region_config_from_model_volume(const PrintRegionConfig &defau void PrintObject::update_slicing_parameters() { -#if ENABLE_ALLOW_NEGATIVE_Z if (!m_slicing_params.valid) m_slicing_params = SlicingParameters::create_from_config( this->print()->config(), m_config, this->model_object()->bounding_box().max.z(), this->object_extruders()); -#else - if (! m_slicing_params.valid) - m_slicing_params = SlicingParameters::create_from_config( - this->print()->config(), m_config, unscale(this->height()), this->object_extruders()); -#endif // ENABLE_ALLOW_NEGATIVE_Z } SlicingParameters PrintObject::slicing_parameters(const DynamicPrintConfig& full_config, const ModelObject& model_object, float object_max_z) @@ -1670,7 +1664,6 @@ bool PrintObject::update_layer_height_profile(const ModelObject &model_object, c updated = true; } -#if ENABLE_ALLOW_NEGATIVE_Z // Verify the layer_height_profile. if (!layer_height_profile.empty() && // Must not be of even length. @@ -1678,15 +1671,6 @@ bool PrintObject::update_layer_height_profile(const ModelObject &model_object, c // Last entry must be at the top of the object. std::abs(layer_height_profile[layer_height_profile.size() - 2] - slicing_parameters.object_print_z_max) > 1e-3)) layer_height_profile.clear(); -#else - // Verify the layer_height_profile. - if (! layer_height_profile.empty() && - // Must not be of even length. - ((layer_height_profile.size() & 1) != 0 || - // Last entry must be at the top of the object. - std::abs(layer_height_profile[layer_height_profile.size() - 2] - slicing_parameters.object_print_z_height()) > 1e-3)) - layer_height_profile.clear(); -#endif // ENABLE_ALLOW_NEGATIVE_Z if (layer_height_profile.empty()) { //layer_height_profile = layer_height_profile_adaptive(slicing_parameters, model_object.layer_config_ranges, model_object.volumes); diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index cfeb12fa1..d55a67724 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -53,9 +53,6 @@ #define ENABLE_PROJECT_DIRTY_STATE (1 && ENABLE_2_4_0_ALPHA0) // Enable project dirty state manager debug window #define ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW (0 && ENABLE_PROJECT_DIRTY_STATE) -// Enable to push object instances under the bed -#define ENABLE_ALLOW_NEGATIVE_Z (1 && ENABLE_2_4_0_ALPHA0) -#define DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA (1 && ENABLE_ALLOW_NEGATIVE_Z) // Enable delayed rendering of transparent volumes #define ENABLE_DELAYED_TRANSPARENT_VOLUMES_RENDERING (1 && ENABLE_2_4_0_ALPHA0) diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index fb464ce02..f84d221bd 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -23,9 +23,7 @@ #include "libslic3r/Format/STL.hpp" #include "libslic3r/Utils.hpp" #include "libslic3r/AppConfig.hpp" -#if DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA #include "libslic3r/PresetBundle.hpp" -#endif // DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA #include #include @@ -342,16 +340,10 @@ void GLVolume::set_render_color(const std::array& rgba) void GLVolume::set_render_color() { -#if ENABLE_ALLOW_NEGATIVE_Z bool outside = is_outside || is_below_printbed(); -#endif // ENABLE_ALLOW_NEGATIVE_Z if (force_native_color || force_neutral_color) { -#if ENABLE_ALLOW_NEGATIVE_Z if (outside && shader_outside_printer_detection_enabled) -#else - if (is_outside && shader_outside_printer_detection_enabled) -#endif // ENABLE_ALLOW_NEGATIVE_Z set_render_color(OUTSIDE_COLOR); else { if (force_native_color) @@ -366,18 +358,10 @@ void GLVolume::set_render_color() else if (hover == HS_Deselect) set_render_color(HOVER_DESELECT_COLOR); else if (selected) -#if ENABLE_ALLOW_NEGATIVE_Z set_render_color(outside ? SELECTED_OUTSIDE_COLOR : SELECTED_COLOR); -#else - set_render_color(is_outside ? SELECTED_OUTSIDE_COLOR : SELECTED_COLOR); -#endif // ENABLE_ALLOW_NEGATIVE_Z else if (disabled) set_render_color(DISABLED_COLOR); -#if ENABLE_ALLOW_NEGATIVE_Z else if (outside && shader_outside_printer_detection_enabled) -#else - else if (is_outside && shader_outside_printer_detection_enabled) -#endif // ENABLE_ALLOW_NEGATIVE_Z set_render_color(OUTSIDE_COLOR); else set_render_color(color); @@ -520,14 +504,9 @@ void GLVolume::render() const bool GLVolume::is_sla_support() const { return this->composite_id.volume_id == -int(slaposSupportTree); } bool GLVolume::is_sla_pad() const { return this->composite_id.volume_id == -int(slaposPad); } -#if ENABLE_ALLOW_NEGATIVE_Z bool GLVolume::is_sinking() const { -#if DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA if (is_modifier || GUI::wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA) -#else - if (is_modifier) -#endif // DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA return false; const BoundingBoxf3& box = transformed_convex_hull_bounding_box(); return box.min.z() < SINKING_Z_THRESHOLD && box.max.z() >= SINKING_Z_THRESHOLD; @@ -537,7 +516,6 @@ bool GLVolume::is_below_printbed() const { return transformed_convex_hull_bounding_box().max(2) < 0.0; } -#endif // ENABLE_ALLOW_NEGATIVE_Z std::vector GLVolumeCollection::load_object( const ModelObject *model_object, diff --git a/src/slic3r/GUI/3DScene.hpp b/src/slic3r/GUI/3DScene.hpp index 217d39746..fad4427e8 100644 --- a/src/slic3r/GUI/3DScene.hpp +++ b/src/slic3r/GUI/3DScene.hpp @@ -459,10 +459,8 @@ public: bool is_sla_support() const; bool is_sla_pad() const; -#if ENABLE_ALLOW_NEGATIVE_Z bool is_sinking() const; bool is_below_printbed() const; -#endif // ENABLE_ALLOW_NEGATIVE_Z // Return an estimate of the memory consumed by this class. size_t cpu_memory_used() const { diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index b4afc05d6..e7f30bf17 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -169,17 +169,10 @@ void GLCanvas3D::LayersEditing::set_config(const DynamicPrintConfig* config) void GLCanvas3D::LayersEditing::select_object(const Model &model, int object_id) { const ModelObject *model_object_new = (object_id >= 0) ? model.objects[object_id] : nullptr; -#if ENABLE_ALLOW_NEGATIVE_Z // Maximum height of an object changes when the object gets rotated or scaled. // Changing maximum height of an object will invalidate the layer heigth editing profile. // m_model_object->bounding_box() is cached, therefore it is cheap even if this method is called frequently. const float new_max_z = (model_object_new == nullptr) ? 0.0f : static_cast(model_object_new->bounding_box().max.z()); -#else - // Maximum height of an object changes when the object gets rotated or scaled. - // Changing maximum height of an object will invalidate the layer heigth editing profile. - // m_model_object->raw_bounding_box() is cached, therefore it is cheap even if this method is called frequently. - float new_max_z = (model_object_new == nullptr) ? 0.f : model_object_new->raw_bounding_box().size().z(); -#endif // ENABLE_ALLOW_NEGATIVE_Z if (m_model_object != model_object_new || this->last_object_id != object_id || m_object_max_z != new_max_z || (model_object_new != nullptr && m_model_object->id() != model_object_new->id())) { m_layer_height_profile.clear(); @@ -3401,37 +3394,21 @@ void GLCanvas3D::do_move(const std::string& snapshot_type) wipe_tower_origin = v->get_volume_offset(); } -#if ENABLE_ALLOW_NEGATIVE_Z // Fixes flying instances -#else - // Fixes sinking/flying instances -#endif // ENABLE_ALLOW_NEGATIVE_Z for (const std::pair& i : done) { ModelObject* m = m_model->objects[i.first]; -#if ENABLE_ALLOW_NEGATIVE_Z const double shift_z = m->get_instance_min_z(i.second); -#if DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA if (current_printer_technology() == ptSLA || shift_z > SINKING_Z_THRESHOLD) { -#else - if (shift_z > 0.0) { -#endif // DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA const Vec3d shift(0.0, 0.0, -shift_z); -#else - const Vec3d shift(0.0, 0.0, -m->get_instance_min_z(i.second)); -#endif // ENABLE_ALLOW_NEGATIVE_Z - m_selection.translate(i.first, i.second, shift); - m->translate_instance(i.second, shift); -#if ENABLE_ALLOW_NEGATIVE_Z + m_selection.translate(i.first, i.second, shift); + m->translate_instance(i.second, shift); } -#endif // ENABLE_ALLOW_NEGATIVE_Z } -#if ENABLE_ALLOW_NEGATIVE_Z // if the selection is not valid to allow for layer editing after the move, we need to turn off the tool if it is running // similar to void Plater::priv::selection_changed() if (!wxGetApp().plater()->can_layers_editing() && is_layers_editing_enabled()) post_event(SimpleEvent(EVT_GLTOOLBAR_LAYERSEDITING)); -#endif // ENABLE_ALLOW_NEGATIVE_Z if (object_moved) post_event(SimpleEvent(EVT_GLCANVAS_INSTANCE_MOVED)); @@ -3452,7 +3429,6 @@ void GLCanvas3D::do_rotate(const std::string& snapshot_type) if (!snapshot_type.empty()) wxGetApp().plater()->take_snapshot(_(snapshot_type)); -#if ENABLE_ALLOW_NEGATIVE_Z // stores current min_z of instances std::map, double> min_zs; if (!snapshot_type.empty()) { @@ -3463,7 +3439,6 @@ void GLCanvas3D::do_rotate(const std::string& snapshot_type) } } } -#endif // ENABLE_ALLOW_NEGATIVE_Z std::set> done; // keeps track of modified instances @@ -3501,19 +3476,13 @@ void GLCanvas3D::do_rotate(const std::string& snapshot_type) // Fixes sinking/flying instances for (const std::pair& i : done) { ModelObject* m = m_model->objects[i.first]; -#if ENABLE_ALLOW_NEGATIVE_Z double shift_z = m->get_instance_min_z(i.second); // leave sinking instances as sinking if (min_zs.empty() || min_zs.find({ i.first, i.second })->second >= SINKING_Z_THRESHOLD || shift_z > SINKING_Z_THRESHOLD) { Vec3d shift(0.0, 0.0, -shift_z); -#else - Vec3d shift(0.0, 0.0, -m->get_instance_min_z(i.second)); -#endif // ENABLE_ALLOW_NEGATIVE_Z m_selection.translate(i.first, i.second, shift); m->translate_instance(i.second, shift); -#if ENABLE_ALLOW_NEGATIVE_Z } -#endif // ENABLE_ALLOW_NEGATIVE_Z } if (!done.empty()) @@ -3530,7 +3499,6 @@ void GLCanvas3D::do_scale(const std::string& snapshot_type) if (!snapshot_type.empty()) wxGetApp().plater()->take_snapshot(_(snapshot_type)); -#if ENABLE_ALLOW_NEGATIVE_Z // stores current min_z of instances std::map, double> min_zs; if (!snapshot_type.empty()) { @@ -3541,7 +3509,6 @@ void GLCanvas3D::do_scale(const std::string& snapshot_type) } } } -#endif // ENABLE_ALLOW_NEGATIVE_Z std::set> done; // keeps track of modified instances @@ -3576,19 +3543,13 @@ void GLCanvas3D::do_scale(const std::string& snapshot_type) // Fixes sinking/flying instances for (const std::pair& i : done) { ModelObject* m = m_model->objects[i.first]; -#if ENABLE_ALLOW_NEGATIVE_Z double shift_z = m->get_instance_min_z(i.second); // leave sinking instances as sinking if (min_zs.empty() || min_zs.find({ i.first, i.second })->second >= SINKING_Z_THRESHOLD || shift_z > SINKING_Z_THRESHOLD) { Vec3d shift(0.0, 0.0, -shift_z); -#else - Vec3d shift(0.0, 0.0, -m->get_instance_min_z(i.second)); -#endif // ENABLE_ALLOW_NEGATIVE_Z - m_selection.translate(i.first, i.second, shift); - m->translate_instance(i.second, shift); -#if ENABLE_ALLOW_NEGATIVE_Z + m_selection.translate(i.first, i.second, shift); + m->translate_instance(i.second, shift); } -#endif // ENABLE_ALLOW_NEGATIVE_Z } if (!done.empty()) diff --git a/src/slic3r/GUI/GUI_ObjectManipulation.cpp b/src/slic3r/GUI/GUI_ObjectManipulation.cpp index d55acf054..42e0c8d54 100644 --- a/src/slic3r/GUI/GUI_ObjectManipulation.cpp +++ b/src/slic3r/GUI/GUI_ObjectManipulation.cpp @@ -30,28 +30,9 @@ const double ObjectManipulation::mm_to_in = 0.0393700787; // volume in world coordinate system. static double get_volume_min_z(const GLVolume& volume) { -#if ENABLE_ALLOW_NEGATIVE_Z return volume.transformed_convex_hull_bounding_box().min.z(); -#else - const Transform3f& world_matrix = volume.world_matrix().cast(); - - // need to get the ModelVolume pointer - const ModelObject* mo = wxGetApp().model().objects[volume.composite_id.object_id]; - const ModelVolume* mv = mo->volumes[volume.composite_id.volume_id]; - const TriangleMesh& hull = mv->get_convex_hull(); - - float min_z = std::numeric_limits::max(); - for (const stl_facet& facet : hull.stl.facet_start) { - for (int i = 0; i < 3; ++i) - min_z = std::min(min_z, Vec3f::UnitZ().dot(world_matrix * facet.vertex[i])); - } - - return min_z; -#endif // ENABLE_ALLOW_NEGATIVE_Z } - - static choice_ctrl* create_word_local_combo(wxWindow *parent) { wxSize size(15 * wxGetApp().em_unit(), -1); @@ -358,7 +339,6 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) : change_position_value(1, diff.y()); change_position_value(2, diff.z()); } -#if ENABLE_ALLOW_NEGATIVE_Z else if (selection.is_single_full_instance()) { const ModelObjectPtrs& objects = wxGetApp().model().objects; const int idx = selection.get_object_idx(); @@ -371,7 +351,6 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) : } } } -#endif // ENABLE_ALLOW_NEGATIVE_Z }); editors_grid_sizer->Add(m_drop_to_bed_button); @@ -702,10 +681,7 @@ void ObjectManipulation::update_reset_buttons_visibility() if (selection.is_single_full_instance()) { rotation = volume->get_instance_rotation(); scale = volume->get_instance_scaling_factor(); -#if ENABLE_ALLOW_NEGATIVE_Z min_z = wxGetApp().model().objects[volume->composite_id.object_id]->bounding_box().min.z(); -#endif // ENABLE_ALLOW_NEGATIVE_Z - } else { rotation = volume->get_volume_rotation(); @@ -714,11 +690,7 @@ void ObjectManipulation::update_reset_buttons_visibility() } show_rotation = !rotation.isApprox(Vec3d::Zero()); show_scale = !scale.isApprox(Vec3d::Ones()); -#if ENABLE_ALLOW_NEGATIVE_Z show_drop_to_bed = std::abs(min_z) > SINKING_Z_THRESHOLD; -#else - show_drop_to_bed = (std::abs(min_z) > EPSILON); -#endif // ENABLE_ALLOW_NEGATIVE_Z } wxGetApp().CallAfter([this, show_rotation, show_scale, show_drop_to_bed] { diff --git a/src/slic3r/GUI/GalleryDialog.cpp b/src/slic3r/GUI/GalleryDialog.cpp index d64c09fb6..f306dff98 100644 --- a/src/slic3r/GUI/GalleryDialog.cpp +++ b/src/slic3r/GUI/GalleryDialog.cpp @@ -253,11 +253,7 @@ static void generate_thumbnail_from_stl(const std::string& filename) assert(model.objects[0]->instances.size() == 1); model.objects[0]->center_around_origin(false); -#if ENABLE_ALLOW_NEGATIVE_Z model.objects[0]->ensure_on_bed(false); -#else - model.objects[0]->ensure_on_bed(); -#endif // ENABLE_ALLOW_NEGATIVE_Z const Vec3d bed_center_3d = wxGetApp().plater()->get_bed().get_bounding_box(false).center(); const Vec2d bed_center_2d = { bed_center_3d.x(), bed_center_3d.y()}; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index a32e4fd7a..1998ef19b 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1650,11 +1650,8 @@ struct Plater::priv BoundingBox scaled_bed_shape_bb() const; std::vector load_files(const std::vector& input_files, bool load_model, bool load_config, bool used_inches = false); -#if ENABLE_ALLOW_NEGATIVE_Z std::vector load_model_objects(const ModelObjectPtrs& model_objects, bool allow_negative_z = false); -#else - std::vector load_model_objects(const ModelObjectPtrs &model_objects); -#endif // ENABLE_ALLOW_NEGATIVE_Z + wxString get_export_file(GUI::FileType file_type); const Selection& get_selection() const; @@ -2417,19 +2414,11 @@ std::vector Plater::priv::load_files(const std::vector& input_ return obj_idxs; } -#if ENABLE_ALLOW_NEGATIVE_Z for (ModelObject* model_object : model.objects) { if (!type_3mf && !type_zip_amf) model_object->center_around_origin(false); model_object->ensure_on_bed(is_project_file); } -#else - for (ModelObject* model_object : model.objects) { - if (!type_3mf && !type_zip_amf) - model_object->center_around_origin(false); - model_object->ensure_on_bed(); - } -#endif // ENABLE_ALLOW_NEGATIVE_Z // check multi-part object adding for the SLA-printing if (printer_technology == ptSLA) { @@ -2443,11 +2432,7 @@ std::vector Plater::priv::load_files(const std::vector& input_ } if (one_by_one) { -#if ENABLE_ALLOW_NEGATIVE_Z auto loaded_idxs = load_model_objects(model.objects, is_project_file); -#else - auto loaded_idxs = load_model_objects(model.objects); -#endif // ENABLE_ALLOW_NEGATIVE_Z obj_idxs.insert(obj_idxs.end(), loaded_idxs.begin(), loaded_idxs.end()); } else { // This must be an .stl or .obj file, which may contain a maximum of one volume. @@ -2500,11 +2485,7 @@ std::vector Plater::priv::load_files(const std::vector& input_ // #define AUTOPLACEMENT_ON_LOAD -#if ENABLE_ALLOW_NEGATIVE_Z std::vector Plater::priv::load_model_objects(const ModelObjectPtrs& model_objects, bool allow_negative_z) -#else -std::vector Plater::priv::load_model_objects(const ModelObjectPtrs &model_objects) -#endif // ENABLE_ALLOW_NEGATIVE_Z { const BoundingBoxf bed_shape = bed_shape_bb(); const Vec3d bed_size = Slic3r::to_3d(bed_shape.size().cast(), 1.0) - 2.0 * Vec3d::Ones(); @@ -2582,11 +2563,7 @@ std::vector Plater::priv::load_model_objects(const ModelObjectPtrs &mode } #endif // ENABLE_MODIFIED_DOWNSCALE_ON_LOAD_OBJECTS_TOO_BIG -#if ENABLE_ALLOW_NEGATIVE_Z object->ensure_on_bed(allow_negative_z); -#else - object->ensure_on_bed(); -#endif // ENABLE_ALLOW_NEGATIVE_Z } #ifdef AUTOPLACEMENT_ON_LOAD @@ -3247,9 +3224,7 @@ void Plater::priv::replace_with_stl() ModelObject* old_model_object = model.objects[object_idx]; ModelVolume* old_volume = old_model_object->volumes[volume_idx]; -#if ENABLE_ALLOW_NEGATIVE_Z bool sinking = old_model_object->bounding_box().min.z() < SINKING_Z_THRESHOLD; -#endif // ENABLE_ALLOW_NEGATIVE_Z ModelObject* new_model_object = new_model.objects[0]; old_model_object->add_volume(*new_model_object->volumes[0]); @@ -3269,9 +3244,7 @@ void Plater::priv::replace_with_stl() new_volume->mmu_segmentation_facets.assign(old_volume->mmu_segmentation_facets); std::swap(old_model_object->volumes[volume_idx], old_model_object->volumes.back()); old_model_object->delete_volume(old_model_object->volumes.size() - 1); -#if ENABLE_ALLOW_NEGATIVE_Z if (!sinking) -#endif // ENABLE_ALLOW_NEGATIVE_Z old_model_object->ensure_on_bed(); old_model_object->sort_volumes(wxGetApp().app_config->get("order_volumes") == "1"); @@ -3422,9 +3395,7 @@ void Plater::priv::reload_from_disk() ModelObject* old_model_object = model.objects[sel_v.object_idx]; ModelVolume* old_volume = old_model_object->volumes[sel_v.volume_idx]; -#if ENABLE_ALLOW_NEGATIVE_Z bool sinking = old_model_object->bounding_box().min.z() < SINKING_Z_THRESHOLD; -#endif // ENABLE_ALLOW_NEGATIVE_Z bool has_source = !old_volume->source.input_file.empty() && boost::algorithm::iequals(fs::path(old_volume->source.input_file).filename().string(), fs::path(path).filename().string()); bool has_name = !old_volume->name.empty() && boost::algorithm::iequals(old_volume->name, fs::path(path).filename().string()); @@ -3481,9 +3452,7 @@ void Plater::priv::reload_from_disk() new_volume->mmu_segmentation_facets.assign(old_volume->mmu_segmentation_facets); std::swap(old_model_object->volumes[sel_v.volume_idx], old_model_object->volumes.back()); old_model_object->delete_volume(old_model_object->volumes.size() - 1); -#if ENABLE_ALLOW_NEGATIVE_Z if (!sinking) -#endif // ENABLE_ALLOW_NEGATIVE_Z old_model_object->ensure_on_bed(); old_model_object->sort_volumes(wxGetApp().app_config->get("order_volumes") == "1"); @@ -4277,12 +4246,8 @@ bool Plater::priv::layers_height_allowed() const return false; int obj_idx = get_selected_object_idx(); -#if ENABLE_ALLOW_NEGATIVE_Z return 0 <= obj_idx && obj_idx < (int)model.objects.size() && model.objects[obj_idx]->bounding_box().max.z() > SINKING_Z_THRESHOLD && config->opt_bool("variable_layer_height") && view3D->is_layers_editing_allowed(); -#else - return 0 <= obj_idx && obj_idx < (int)model.objects.size() && config->opt_bool("variable_layer_height") && view3D->is_layers_editing_allowed(); -#endif // ENABLE_ALLOW_NEGATIVE_Z } bool Plater::priv::can_mirror() const @@ -6223,13 +6188,11 @@ bool Plater::set_printer_technology(PrinterTechnology printer_technology) //FIXME for SLA synchronize //p->background_process.apply(Model)! -#if DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA if (printer_technology == ptSLA) { for (ModelObject* model_object : p->model.objects) { model_object->ensure_on_bed(); } } -#endif // DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA p->label_btn_export = printer_technology == ptFFF ? L("Export G-code") : L("Export"); p->label_btn_send = printer_technology == ptFFF ? L("Send G-code") : L("Send to printer"); @@ -6250,15 +6213,7 @@ void Plater::changed_object(int obj_idx) return; // recenter and re - align to Z = 0 auto model_object = p->model.objects[obj_idx]; -#if ENABLE_ALLOW_NEGATIVE_Z -#if DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA model_object->ensure_on_bed(this->p->printer_technology != ptSLA); -#else - model_object->ensure_on_bed(true); -#endif // DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA -#else - model_object->ensure_on_bed(); -#endif // ENABLE_ALLOW_NEGATIVE_Z if (this->p->printer_technology == ptSLA) { // Update the SLAPrint from the current Model, so that the reload_scene() // pulls the correct data, update the 3D scene. @@ -6277,17 +6232,11 @@ void Plater::changed_objects(const std::vector& object_idxs) return; for (size_t obj_idx : object_idxs) { -#if ENABLE_ALLOW_NEGATIVE_Z if (obj_idx < p->model.objects.size()) { if (p->model.objects[obj_idx]->bounding_box().min.z() >= SINKING_Z_THRESHOLD) // re - align to Z = 0 p->model.objects[obj_idx]->ensure_on_bed(); } -#else - if (obj_idx < p->model.objects.size()) - // recenter and re - align to Z = 0 - p->model.objects[obj_idx]->ensure_on_bed(); -#endif // ENABLE_ALLOW_NEGATIVE_Z } if (this->p->printer_technology == ptSLA) { // Update the SLAPrint from the current Model, so that the reload_scene() diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index f2e879605..ec882a3a5 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -13,9 +13,7 @@ #include "libslic3r/LocalesUtils.hpp" #include "libslic3r/Model.hpp" -#if DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA #include "libslic3r/PresetBundle.hpp" -#endif // DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA #include @@ -838,21 +836,13 @@ void Selection::scale(const Vec3d& scale, TransformationType transformation_type if (!m_valid) return; -#if ENABLE_ALLOW_NEGATIVE_Z bool is_any_volume_sinking = false; -#if DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA bool is_sla = wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA; -#endif // DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA -#endif // ENABLE_ALLOW_NEGATIVE_Z for (unsigned int i : m_list) { GLVolume &volume = *(*m_volumes)[i]; -#if ENABLE_ALLOW_NEGATIVE_Z -#if DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA if (!is_sla) -#endif // DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA is_any_volume_sinking |= !volume.is_modifier && std::find(m_cache.sinking_volumes.begin(), m_cache.sinking_volumes.end(), i) != m_cache.sinking_volumes.end(); -#endif // ENABLE_ALLOW_NEGATIVE_Z if (is_single_full_instance()) { if (transformation_type.relative()) { Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), scale); @@ -908,10 +898,8 @@ void Selection::scale(const Vec3d& scale, TransformationType transformation_type synchronize_unselected_volumes(); #endif // !DISABLE_INSTANCES_SYNCH -#if ENABLE_ALLOW_NEGATIVE_Z if (!is_any_volume_sinking) ensure_on_bed(); -#endif // ENABLE_ALLOW_NEGATIVE_Z this->set_bounding_boxes_dirty(); } @@ -1657,16 +1645,12 @@ void Selection::update_type() void Selection::set_caches() { m_cache.volumes_data.clear(); -#if ENABLE_ALLOW_NEGATIVE_Z m_cache.sinking_volumes.clear(); -#endif // ENABLE_ALLOW_NEGATIVE_Z for (unsigned int i = 0; i < (unsigned int)m_volumes->size(); ++i) { const GLVolume& v = *(*m_volumes)[i]; m_cache.volumes_data.emplace(i, VolumeCache(v.get_volume_transformation(), v.get_instance_transformation())); -#if ENABLE_ALLOW_NEGATIVE_Z if (v.is_sinking()) m_cache.sinking_volumes.push_back(i); -#endif // ENABLE_ALLOW_NEGATIVE_Z } m_cache.dragging_center = get_bounding_box().center(); } @@ -2071,21 +2055,12 @@ void Selection::synchronize_unselected_instances(SyncRotationType sync_rotation_ assert(is_rotation_xy_synchronized(m_cache.volumes_data[i].get_instance_rotation(), m_cache.volumes_data[j].get_instance_rotation())); switch (sync_rotation_type) { case SYNC_ROTATION_NONE: { -#if ENABLE_ALLOW_NEGATIVE_Z // z only rotation -> synch instance z // The X,Y rotations should be synchronized from start to end of the rotation. assert(is_rotation_xy_synchronized(rotation, v->get_instance_rotation())); -#if DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA if (wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA) -#endif // DISABLE_ALLOW_NEGATIVE_Z_FOR_SLA v->set_instance_offset(Z, volume->get_instance_offset().z()); break; -#else - // z only rotation -> keep instance z - // The X,Y rotations should be synchronized from start to end of the rotation. - assert(is_rotation_xy_synchronized(rotation, v->get_instance_rotation())); - break; -#endif // ENABLE_ALLOW_NEGATIVE_Z } case SYNC_ROTATION_FULL: // rotation comes from place on face -> force given z diff --git a/src/slic3r/GUI/Selection.hpp b/src/slic3r/GUI/Selection.hpp index c6409f9f2..0e0e869ef 100644 --- a/src/slic3r/GUI/Selection.hpp +++ b/src/slic3r/GUI/Selection.hpp @@ -186,10 +186,8 @@ private: // to a set of indices of ModelVolume instances in ModelObject::instances // Here the index means a position inside the respective std::vector, not ObjectID. ObjectIdxsToInstanceIdxsMap content; -#if ENABLE_ALLOW_NEGATIVE_Z // List of ids of the volumes which are sinking when starting dragging std::vector sinking_volumes; -#endif // ENABLE_ALLOW_NEGATIVE_Z }; // Volumes owned by GLCanvas3D.