diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index 73661723a..95d2c8f81 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -1567,11 +1567,7 @@ unsigned int ModelObject::check_instances_print_volume_state(const Polygon& prin for (const ModelVolume* vol : this->volumes) if (vol->is_model_part()) { const Transform3d matrix = model_instance->get_matrix() * vol->get_matrix(); -#if ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION const BoundingBoxf3 bb = vol->mesh().transformed_bounding_box(matrix, 0.0); -#else - const BoundingBoxf3 bb = vol->get_convex_hull().transformed_bounding_box(matrix); -#endif // ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION const Polygon volume_hull_2d = its_convex_hull_2d_above(vol->mesh().its, matrix.cast(), 0.0f); ModelInstanceEPrintVolumeState state = printbed_collision_state(printbed_shape, print_volume_height, volume_hull_2d, bb.min.z(), bb.max.z()); if (state == ModelInstancePVS_Inside) @@ -1601,11 +1597,7 @@ unsigned int ModelObject::check_instances_print_volume_state(const BoundingBoxf3 unsigned int inside_outside = 0; for (const ModelVolume *vol : this->volumes) if (vol->is_model_part()) { -#if ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION - BoundingBoxf3 bb = vol->mesh().transformed_bounding_box(model_instance->get_matrix() * vol->get_matrix(), 0.0); -#else BoundingBoxf3 bb = vol->get_convex_hull().transformed_bounding_box(model_instance->get_matrix() * vol->get_matrix()); -#endif // ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION if (print_volume.contains(bb)) inside_outside |= INSIDE; else if (print_volume.intersects(bb)) diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 365493a66..7f24b6ede 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -79,9 +79,8 @@ #define ENABLE_2_4_0_ALPHA4 1 // Enable the fix for the detection of the out of bed state for sinking objects -#define ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION (1 && ENABLE_2_4_0_ALPHA4) -// Enable detection of out of bed using the bed perimeter and other improvements -#define ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS (1 && ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION) +// and detection of out of bed using the bed perimeter +#define ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS (1 && ENABLE_2_4_0_ALPHA4) #endif // _prusaslicer_technologies_h_ diff --git a/src/libslic3r/TriangleMesh.cpp b/src/libslic3r/TriangleMesh.cpp index 6386591ae..290cb95e1 100644 --- a/src/libslic3r/TriangleMesh.cpp +++ b/src/libslic3r/TriangleMesh.cpp @@ -429,7 +429,7 @@ BoundingBoxf3 TriangleMesh::transformed_bounding_box(const Transform3d &trafo) c return bbox; } -#if ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION +#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS BoundingBoxf3 TriangleMesh::transformed_bounding_box(const Transform3d& trafo, double world_min_z) const { BoundingBoxf3 bbox; @@ -452,7 +452,7 @@ BoundingBoxf3 TriangleMesh::transformed_bounding_box(const Transform3d& trafo, d } return bbox; } -#endif // ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION +#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS TriangleMesh TriangleMesh::convex_hull_3d() const { diff --git a/src/libslic3r/TriangleMesh.hpp b/src/libslic3r/TriangleMesh.hpp index b6a3c7249..b730a7608 100644 --- a/src/libslic3r/TriangleMesh.hpp +++ b/src/libslic3r/TriangleMesh.hpp @@ -113,10 +113,10 @@ public: BoundingBoxf3 bounding_box() const; // Returns the bbox of this TriangleMesh transformed by the given transformation BoundingBoxf3 transformed_bounding_box(const Transform3d &trafo) const; -#if ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION +#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS // Variant returning the bbox of the part of this TriangleMesh above the given world_min_z BoundingBoxf3 transformed_bounding_box(const Transform3d& trafo, double world_min_z) const; -#endif // ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION +#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS // Return the size of the mesh in coordinates. Vec3d size() const { return m_stats.size.cast(); } /// Return the center of the related bounding box. diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index 4eb1837c7..f3e4cfad1 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -529,7 +529,7 @@ BoundingBoxf3 GLVolume::transformed_convex_hull_bounding_box(const Transform3d & bounding_box().transformed(trafo); } -#if ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION +#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS BoundingBoxf3 GLVolume::transformed_non_sinking_bounding_box(const Transform3d& trafo) const { return GUI::wxGetApp().plater()->model().objects[object_idx()]->volumes[volume_idx()]->mesh().transformed_bounding_box(trafo, 0.0); @@ -544,7 +544,7 @@ const BoundingBoxf3& GLVolume::transformed_non_sinking_bounding_box() const } return *m_transformed_non_sinking_bounding_box; } -#endif // ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION +#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS void GLVolume::set_range(double min_z, double max_z) { @@ -1070,12 +1070,11 @@ bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config, M if (volume->is_modifier || (!volume->shader_outside_printer_detection_enabled && (volume->is_wipe_tower || volume->composite_id.volume_id < 0))) continue; -#if ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION +#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS bool contained = false; bool intersects = false; bool is_aux_volume = volume->is_sla_support() || volume->is_sla_pad() || volume->is_wipe_tower; const BoundingBoxf3 bb = is_aux_volume ? volume->transformed_convex_hull_bounding_box() : volume->transformed_non_sinking_bounding_box(); -#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS ModelInstanceEPrintVolumeState volume_state; if (is_aux_volume) { if (volume->is_sla_support() || volume->is_wipe_tower) { @@ -1090,14 +1089,10 @@ bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config, M } contained = (volume_state == ModelInstancePVS_Inside); intersects = (volume_state == ModelInstancePVS_Partly_Outside); -#else - contained = print_volume.contains(bb); - intersects = print_volume.intersects(bb); -#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS #else const BoundingBoxf3& bb = volume->transformed_convex_hull_bounding_box(); bool contained = print_volume.contains(bb); -#endif // ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION +#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS volume->is_outside = !contained; if (!volume->printable) @@ -1108,13 +1103,13 @@ bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config, M if (overall_state == ModelInstancePVS_Inside && volume->is_outside) overall_state = ModelInstancePVS_Fully_Outside; -#if ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION +#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS if (overall_state == ModelInstancePVS_Fully_Outside && volume->is_outside && intersects) overall_state = ModelInstancePVS_Partly_Outside; #else if (overall_state == ModelInstancePVS_Fully_Outside && volume->is_outside && print_volume.intersects(bb)) overall_state = ModelInstancePVS_Partly_Outside; -#endif // ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION +#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS } if (out_state != nullptr) diff --git a/src/slic3r/GUI/3DScene.hpp b/src/slic3r/GUI/3DScene.hpp index 8aaf48549..0b1293f56 100644 --- a/src/slic3r/GUI/3DScene.hpp +++ b/src/slic3r/GUI/3DScene.hpp @@ -278,10 +278,10 @@ private: std::shared_ptr m_convex_hull; // Bounding box of this volume, in unscaled coordinates. std::optional m_transformed_convex_hull_bounding_box; -#if ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION +#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS // Bounding box of the non sinking part of this volume, in unscaled coordinates. std::optional m_transformed_non_sinking_bounding_box; -#endif // ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION +#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS class SinkingContours { @@ -472,12 +472,12 @@ public: BoundingBoxf3 transformed_convex_hull_bounding_box(const Transform3d &trafo) const; // caching variant const BoundingBoxf3& transformed_convex_hull_bounding_box() const; -#if ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION +#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS // non-caching variant BoundingBoxf3 transformed_non_sinking_bounding_box(const Transform3d& trafo) const; // caching variant const BoundingBoxf3& transformed_non_sinking_bounding_box() const; -#endif // ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION +#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS // convex hull const TriangleMesh* convex_hull() const { return m_convex_hull.get(); } @@ -490,7 +490,7 @@ public: void finalize_geometry(bool opengl_initialized) { this->indexed_vertex_array.finalize_geometry(opengl_initialized); } void release_geometry() { this->indexed_vertex_array.release_geometry(); } -#if ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION +#if ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS void set_bounding_boxes_as_dirty() { m_transformed_bounding_box.reset(); m_transformed_convex_hull_bounding_box.reset(); @@ -498,7 +498,7 @@ public: } #else void set_bounding_boxes_as_dirty() { m_transformed_bounding_box.reset(); m_transformed_convex_hull_bounding_box.reset(); } -#endif // ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION +#endif // ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS bool is_sla_support() const; bool is_sla_pad() const;