Fix for cut gizmo during move of object
This commit is contained in:
parent
5f51811a3c
commit
576a63cd20
3 changed files with 15 additions and 8 deletions
src/slic3r/GUI/Gizmos
|
@ -159,8 +159,9 @@ bool GLGizmoBase::use_grabbers(const wxMouseEvent &mouse_event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mouse_event.LeftDown()) {
|
if (mouse_event.LeftDown()) {
|
||||||
Selection &selection = m_parent.get_selection();
|
Selection &selection = m_parent.get_selection();
|
||||||
if (!selection.is_empty() && m_hover_id != -1) {
|
if (!selection.is_empty() && m_hover_id != -1 &&
|
||||||
|
(m_grabbers.empty() || m_hover_id < static_cast<int>(m_grabbers.size()))) {
|
||||||
// TODO: investigate if it is neccessary -> there was no stop dragging
|
// TODO: investigate if it is neccessary -> there was no stop dragging
|
||||||
selection.start_dragging();
|
selection.start_dragging();
|
||||||
|
|
||||||
|
|
|
@ -110,11 +110,15 @@ void GLGizmoCut::on_render()
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
Vec3d diff = plane_center - m_old_center;
|
||||||
|
// Z changed when move with cut plane
|
||||||
|
// X and Y changed when move with cutted object
|
||||||
|
bool is_changed = std::abs(diff.x()) > EPSILON ||
|
||||||
|
std::abs(diff.y()) > EPSILON ||
|
||||||
|
std::abs(diff.z()) > EPSILON;
|
||||||
|
m_old_center = plane_center;
|
||||||
|
|
||||||
const bool z_changed = std::abs(plane_center.z() - m_old_z) > EPSILON;
|
if (!m_plane.is_initialized() || is_changed) {
|
||||||
m_old_z = plane_center.z();
|
|
||||||
|
|
||||||
if (!m_plane.is_initialized() || z_changed) {
|
|
||||||
m_plane.reset();
|
m_plane.reset();
|
||||||
|
|
||||||
GLModel::Geometry init_data;
|
GLModel::Geometry init_data;
|
||||||
|
@ -159,7 +163,7 @@ void GLGizmoCut::on_render()
|
||||||
|
|
||||||
glsafe(::glLineWidth(m_hover_id != -1 ? 2.0f : 1.5f));
|
glsafe(::glLineWidth(m_hover_id != -1 ? 2.0f : 1.5f));
|
||||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
if (!m_grabber_connection.is_initialized() || z_changed) {
|
if (!m_grabber_connection.is_initialized() || is_changed) {
|
||||||
m_grabber_connection.reset();
|
m_grabber_connection.reset();
|
||||||
|
|
||||||
GLModel::Geometry init_data;
|
GLModel::Geometry init_data;
|
||||||
|
@ -334,6 +338,8 @@ BoundingBoxf3 GLGizmoCut::bounding_box() const
|
||||||
BoundingBoxf3 ret;
|
BoundingBoxf3 ret;
|
||||||
const Selection& selection = m_parent.get_selection();
|
const Selection& selection = m_parent.get_selection();
|
||||||
const Selection::IndicesList& idxs = selection.get_volume_idxs();
|
const Selection::IndicesList& idxs = selection.get_volume_idxs();
|
||||||
|
return selection.get_bounding_box();
|
||||||
|
|
||||||
for (unsigned int i : idxs) {
|
for (unsigned int i : idxs) {
|
||||||
const GLVolume* volume = selection.get_volume(i);
|
const GLVolume* volume = selection.get_volume(i);
|
||||||
if (!volume->is_modifier)
|
if (!volume->is_modifier)
|
||||||
|
|
|
@ -26,7 +26,7 @@ class GLGizmoCut : public GLGizmoBase
|
||||||
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
GLModel m_plane;
|
GLModel m_plane;
|
||||||
GLModel m_grabber_connection;
|
GLModel m_grabber_connection;
|
||||||
float m_old_z{ 0.0f };
|
Vec3d m_old_center;
|
||||||
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
|
||||||
struct CutContours
|
struct CutContours
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue