Fixed crash related to ClippingPlane and incorrect handling of sla z shift in hollowing gizmo

This commit is contained in:
Lukas Matena 2020-04-07 15:55:54 +02:00
parent c704849a7a
commit 535a27de65
5 changed files with 20 additions and 11 deletions

View File

@ -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];
@ -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>());
@ -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()
@ -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)
{

View File

@ -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;
@ -34,7 +34,7 @@ public:
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; }

View File

@ -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)
@ -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

View File

@ -75,7 +75,7 @@ public:
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(); }

View File

@ -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