Skip to content

Commit

Permalink
Fixed crash related to ClippingPlane and incorrect handling of sla z …
Browse files Browse the repository at this point in the history
…shift in hollowing gizmo
  • Loading branch information
lukasmatena committed Apr 7, 2020
1 parent c704849 commit 535a27d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking) cons
const Transform3d& instance_matrix = vol->get_instance_transformation().get_matrix();

glsafe(::glPushMatrix());
glsafe(::glTranslated(0.0, 0.0, m_z_shift));
glsafe(::glTranslated(0.0, 0.0, m_c->selection_info()->get_sla_shift()));
glsafe(::glMultMatrixd(instance_matrix.data()));

float render_color[4];
Expand Down Expand Up @@ -444,7 +444,7 @@ bool GLGizmoHollow::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_pos

// First collect positions of all the points in world coordinates.
Geometry::Transformation trafo = mo->instances[active_inst]->get_transformation();
trafo.set_offset(trafo.get_offset() + Vec3d(0., 0., m_z_shift));
trafo.set_offset(trafo.get_offset() + Vec3d(0., 0., m_c->selection_info()->get_sla_shift()));
std::vector<Vec3d> points;
for (unsigned int i=0; i<mo->sla_drain_holes.size(); ++i)
points.push_back(trafo.get_matrix() * mo->sla_drain_holes[i].pos.cast<double>());
Expand Down Expand Up @@ -607,7 +607,7 @@ GLGizmoHollow::get_config_options(const std::vector<std::string>& keys) const
return out;
}


/*
ClippingPlane GLGizmoHollow::get_sla_clipping_plane() const
{
if (! m_c->selection_info()->model_object()
Expand All @@ -619,7 +619,7 @@ ClippingPlane GLGizmoHollow::get_sla_clipping_plane() const
return ClippingPlane(-clp.get_normal(), clp.get_data()[3]);
}
}

*/

void GLGizmoHollow::on_render_input_window(float x, float y, float bottom_limit)
{
Expand Down
4 changes: 2 additions & 2 deletions src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ enum class SLAGizmoEventType : unsigned char;
class GLGizmoHollow : public GLGizmoBase
{
private:
mutable double m_z_shift = 0.;
//mutable double m_z_shift = 0.;
bool unproject_on_mesh(const Vec2d& mouse_pos, std::pair<Vec3f, Vec3f>& pos_and_normal);

GLUquadricObj* m_quadric;
Expand All @@ -34,7 +34,7 @@ class GLGizmoHollow : public GLGizmoBase
void set_sla_support_data(ModelObject* model_object, const Selection& selection);
bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down);
void delete_selected_points();
ClippingPlane get_sla_clipping_plane() const;
//ClippingPlane get_sla_clipping_plane() const;

bool is_selection_rectangle_dragging() const { return m_selection_rectangle.is_dragging(); }
//void set_common_data_ptr(CommonGizmosData* ptr) { m_c = ptr; }
Expand Down
4 changes: 2 additions & 2 deletions src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ std::vector<const ConfigOption*> GLGizmoSlaSupports::get_config_options(const st
return out;
}


/*
ClippingPlane GLGizmoSlaSupports::get_sla_clipping_plane() const
{
//if (!m_c->m_model_object || m_state == Off || m_c->m_clipping_plane_distance == 0.f)
Expand All @@ -707,7 +707,7 @@ ClippingPlane GLGizmoSlaSupports::get_sla_clipping_plane() const
return ClippingPlane(-clp.get_normal(), clp.get_data()[3]);
}
}

*/

/*
void GLGizmoSlaSupports::find_intersecting_facets(const igl::AABB<Eigen::MatrixXf, 3>* aabb, const Vec3f& normal, double offset, std::vector<unsigned int>& idxs) const
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class GLGizmoSlaSupports : public GLGizmoBase
void set_sla_support_data(ModelObject* model_object, const Selection& selection);
bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down);
void delete_selected_points(bool force = false);
ClippingPlane get_sla_clipping_plane() const;
//ClippingPlane get_sla_clipping_plane() const;

bool is_in_editing_mode() const { return m_editing_mode; }
bool is_selection_rectangle_dragging() const { return m_selection_rectangle.is_dragging(); }
Expand Down
13 changes: 11 additions & 2 deletions src/slic3r/GUI/Gizmos/GLGizmosManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,22 @@ bool GLGizmosManager::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_p

ClippingPlane GLGizmosManager::get_sla_clipping_plane() const
{
if (!m_enabled || (m_current != SlaSupports && m_current != Hollow) || m_gizmos.empty())
if (! m_common_gizmos_data->object_clipper()
|| m_common_gizmos_data->object_clipper()->get_position() == 0.)
return ClippingPlane::ClipsNothing();
else {
const ClippingPlane& clp = *m_common_gizmos_data->object_clipper()->get_clipping_plane();
return ClippingPlane(-clp.get_normal(), clp.get_data()[3]);
}


/*if (!m_enabled || (m_current != SlaSupports && m_current != Hollow) || m_gizmos.empty())
return ClippingPlane::ClipsNothing();
if (m_current == SlaSupports)
return dynamic_cast<GLGizmoSlaSupports*>(m_gizmos[SlaSupports].get())->get_sla_clipping_plane();
else
return dynamic_cast<GLGizmoHollow*>(m_gizmos[Hollow].get())->get_sla_clipping_plane();
return dynamic_cast<GLGizmoHollow*>(m_gizmos[Hollow].get())->get_sla_clipping_plane();*/
}

bool GLGizmosManager::wants_reslice_supports_on_undo() const
Expand Down

0 comments on commit 535a27d

Please sign in to comment.