mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 19:35:57 +08:00
Propagate transformation from UI to backend on close Emboss gizmo
(from GLVolume to ModelVolume) Fix SPE-2126
This commit is contained in:
parent
a30ca5eb71
commit
c5d94d1d95
@ -1343,20 +1343,58 @@ bool GLGizmoEmboss::process(bool make_snapshot)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
// IMPROVE: Move to Point.hpp and rename to is_approx()
|
||||||
|
// NOTE: Point has its own epsilon :-(
|
||||||
|
template<typename T, int I, int J>
|
||||||
|
inline bool is_approx2(
|
||||||
|
const Eigen::Matrix<T, I, J, Eigen::DontAlign> &m1,
|
||||||
|
const Eigen::Matrix<T, I, J, Eigen::DontAlign> &m2,
|
||||||
|
T epsilon = static_cast<T>(EPSILON)
|
||||||
|
) {
|
||||||
|
for (size_t i = 0; i < I; i++)
|
||||||
|
for (size_t j = 0; j < J; j++)
|
||||||
|
if (!is_approx(m1(i, j), m2(i, j), epsilon))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GLGizmoEmboss::close()
|
void GLGizmoEmboss::close()
|
||||||
{
|
{
|
||||||
// remove volume when text is empty
|
|
||||||
if (m_volume != nullptr &&
|
if (m_volume != nullptr &&
|
||||||
m_volume->text_configuration.has_value() &&
|
m_volume->text_configuration.has_value() ){
|
||||||
is_text_empty(m_text)) {
|
|
||||||
Plater &p = *wxGetApp().plater();
|
// remove volume when text is empty
|
||||||
// is the text object?
|
if (is_text_empty(m_text)) {
|
||||||
if (m_volume->is_the_only_one_part()) {
|
Plater &p = *wxGetApp().plater();
|
||||||
// delete whole object
|
// is the text object?
|
||||||
p.remove(m_parent.get_selection().get_object_idx());
|
if (m_volume->is_the_only_one_part()) {
|
||||||
} else {
|
// delete whole object
|
||||||
// delete text volume
|
p.remove(m_parent.get_selection().get_object_idx());
|
||||||
p.remove_selected();
|
} else {
|
||||||
|
// delete text volume
|
||||||
|
p.remove_selected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fix phanthom transformation
|
||||||
|
// appear when right click into scene during edit Rotation in input (click "Edit" button)
|
||||||
|
const GLVolume *gl_volume_ptr = m_parent.get_selection().get_first_volume();
|
||||||
|
if (gl_volume_ptr != nullptr) {
|
||||||
|
const Transform3d &v_tr = m_volume->get_matrix();
|
||||||
|
const Transform3d &gl_v_tr = gl_volume_ptr->get_volume_transformation().get_matrix();
|
||||||
|
|
||||||
|
const Matrix3d &v_rot = v_tr.linear();
|
||||||
|
const Matrix3d &gl_v_rot = gl_v_tr.linear();
|
||||||
|
const Vec3d &v_move = v_tr.translation();
|
||||||
|
const Vec3d &gl_v_move = gl_v_tr.translation();
|
||||||
|
if (!is_approx2(v_rot, gl_v_rot)) {
|
||||||
|
m_parent.do_rotate(rotation_snapshot_name);
|
||||||
|
} else if (!is_approx2(v_move, gl_v_move)){
|
||||||
|
m_parent.do_move(move_snapshot_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user