Fix of detection of the out of bed state for sinking objects
This commit is contained in:
parent
e8418b509e
commit
5a84b46ec9
5 changed files with 71 additions and 0 deletions
|
@ -524,6 +524,23 @@ BoundingBoxf3 GLVolume::transformed_convex_hull_bounding_box(const Transform3d &
|
|||
bounding_box().transformed(trafo);
|
||||
}
|
||||
|
||||
#if ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION
|
||||
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);
|
||||
}
|
||||
|
||||
const BoundingBoxf3& GLVolume::transformed_non_sinking_bounding_box() const
|
||||
{
|
||||
if (!m_transformed_non_sinking_bounding_box.has_value()) {
|
||||
std::optional<BoundingBoxf3>* trans_box = const_cast<std::optional<BoundingBoxf3>*>(&m_transformed_non_sinking_bounding_box);
|
||||
const Transform3d& trafo = world_matrix();
|
||||
*trans_box = transformed_non_sinking_bounding_box(trafo);
|
||||
}
|
||||
return *m_transformed_non_sinking_bounding_box;
|
||||
}
|
||||
#endif // ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION
|
||||
|
||||
void GLVolume::set_range(double min_z, double max_z)
|
||||
{
|
||||
this->qverts_range.first = 0;
|
||||
|
@ -936,7 +953,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
|
||||
const BoundingBoxf3& bb = volume->transformed_non_sinking_bounding_box();
|
||||
#else
|
||||
const BoundingBoxf3& bb = volume->transformed_convex_hull_bounding_box();
|
||||
#endif // ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION
|
||||
bool contained = print_volume.contains(bb);
|
||||
|
||||
volume->is_outside = !contained;
|
||||
|
|
|
@ -279,6 +279,10 @@ private:
|
|||
std::shared_ptr<const TriangleMesh> m_convex_hull;
|
||||
// Bounding box of this volume, in unscaled coordinates.
|
||||
std::optional<BoundingBoxf3> m_transformed_convex_hull_bounding_box;
|
||||
#if ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION
|
||||
// Bounding box of the non sinking part of this volume, in unscaled coordinates.
|
||||
std::optional<BoundingBoxf3> m_transformed_non_sinking_bounding_box;
|
||||
#endif // ENABLE_FIX_SINKING_OBJECT_OUT_OF_BED_DETECTION
|
||||
|
||||
class SinkingContours
|
||||
{
|
||||
|
@ -469,6 +473,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
|
||||
// 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
|
||||
// convex hull
|
||||
const TriangleMesh* convex_hull() const { return m_convex_hull.get(); }
|
||||
|
||||
|
@ -481,7 +491,15 @@ 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
|
||||
void set_bounding_boxes_as_dirty() {
|
||||
m_transformed_bounding_box.reset();
|
||||
m_transformed_convex_hull_bounding_box.reset();
|
||||
m_transformed_non_sinking_bounding_box.reset();
|
||||
}
|
||||
#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
|
||||
|
||||
bool is_sla_support() const;
|
||||
bool is_sla_pad() const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue