mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-14 03:01:47 +08:00
Cut WIP: Improved can_perform_cut()
This commit is contained in:
parent
94f3aaacd4
commit
c903414005
@ -752,7 +752,7 @@ BoundingBoxf3 GLGizmoCut3D::bounding_box() const
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
BoundingBoxf3 GLGizmoCut3D::transformed_bounding_box() const
|
BoundingBoxf3 GLGizmoCut3D::transformed_bounding_box(bool revert_move /*= false*/) const
|
||||||
{
|
{
|
||||||
// #ysFIXME !!!
|
// #ysFIXME !!!
|
||||||
BoundingBoxf3 ret;
|
BoundingBoxf3 ret;
|
||||||
@ -774,8 +774,9 @@ BoundingBoxf3 GLGizmoCut3D::transformed_bounding_box() const
|
|||||||
const auto rot_z = Geometry::assemble_transform(Vec3d::Zero(), Vec3d(0, 0, -rotation.z()), Vec3d::Ones(), Vec3d::Ones());
|
const auto rot_z = Geometry::assemble_transform(Vec3d::Zero(), Vec3d(0, 0, -rotation.z()), Vec3d::Ones(), Vec3d::Ones());
|
||||||
const auto rot_y = Geometry::assemble_transform(Vec3d::Zero(), Vec3d(0, -rotation.y(), 0), Vec3d::Ones(), Vec3d::Ones());
|
const auto rot_y = Geometry::assemble_transform(Vec3d::Zero(), Vec3d(0, -rotation.y(), 0), Vec3d::Ones(), Vec3d::Ones());
|
||||||
const auto rot_x = Geometry::assemble_transform(Vec3d::Zero(), Vec3d(-rotation.x(), 0, 0), Vec3d::Ones(), Vec3d::Ones());
|
const auto rot_x = Geometry::assemble_transform(Vec3d::Zero(), Vec3d(-rotation.x(), 0, 0), Vec3d::Ones(), Vec3d::Ones());
|
||||||
|
const auto move2 = Geometry::assemble_transform(m_plane_center, Vec3d::Zero(), Vec3d::Ones(), Vec3d::Ones() );
|
||||||
|
|
||||||
const auto cut_matrix = rot_x * rot_y * rot_z * move;
|
const auto cut_matrix = (revert_move ? move2 : Transform3d::Identity()) * rot_x * rot_y * rot_z * move;
|
||||||
|
|
||||||
for (unsigned int i : idxs) {
|
for (unsigned int i : idxs) {
|
||||||
const GLVolume* volume = selection.get_volume(i);
|
const GLVolume* volume = selection.get_volume(i);
|
||||||
@ -1202,12 +1203,8 @@ bool GLGizmoCut3D::can_perform_cut() const
|
|||||||
if (m_has_invalid_connector || (!m_keep_upper && !m_keep_lower))
|
if (m_has_invalid_connector || (!m_keep_upper && !m_keep_lower))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
BoundingBoxf3 box = bounding_box();
|
const BoundingBoxf3 tbb = transformed_bounding_box(true);
|
||||||
double dist = (m_plane_center - box.center()).norm();
|
return tbb.contains(m_plane_center);
|
||||||
if (dist > box.radius())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoCut3D::perform_cut(const Selection& selection)
|
void GLGizmoCut3D::perform_cut(const Selection& selection)
|
||||||
|
@ -123,7 +123,7 @@ public:
|
|||||||
void update_clipper_on_render();
|
void update_clipper_on_render();
|
||||||
|
|
||||||
BoundingBoxf3 bounding_box() const;
|
BoundingBoxf3 bounding_box() const;
|
||||||
BoundingBoxf3 transformed_bounding_box() const;
|
BoundingBoxf3 transformed_bounding_box(bool revert_move = false) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool on_init() override;
|
bool on_init() override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user