Trying to engage support creation when the gizmo gets disabled.
This commit is contained in:
parent
a49b506121
commit
22c9c5ae95
11 changed files with 76 additions and 33 deletions
|
@ -11,6 +11,8 @@
|
|||
#include <igl/unproject_onto_mesh.h>
|
||||
#include <GL/glew.h>
|
||||
|
||||
#include <SLA/SLASupportTree.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <numeric>
|
||||
|
||||
|
@ -1599,6 +1601,29 @@ void GLGizmoSlaSupports::update_mesh()
|
|||
}
|
||||
}
|
||||
|
||||
void GLGizmoSlaSupports::on_deactivate() {
|
||||
if(!m_model_object) return;
|
||||
|
||||
sla::Controller supportctl;
|
||||
std::cout << "Generating supports:" << std::endl;
|
||||
|
||||
// TODO: somehow get the global status indicator
|
||||
supportctl.statuscb = [] (unsigned st, const std::string& msg) {
|
||||
std::cout << st << "% " << msg << std::endl;
|
||||
};
|
||||
|
||||
const Model& model = *m_model_object->get_model();
|
||||
auto emesh = sla::to_eigenmesh(model);
|
||||
sla::PointSet input = sla::support_points(model);
|
||||
sla::SupportConfig cfg;
|
||||
|
||||
sla::SLASupportTree stree(input, emesh, cfg, supportctl);
|
||||
|
||||
TriangleMesh output;
|
||||
stree.merged_mesh(output);
|
||||
m_model_object->add_volume(output);
|
||||
}
|
||||
|
||||
Vec3f GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse_pos)
|
||||
{
|
||||
// if the gizmo doesn't have the V, F structures for igl, calculate them first:
|
||||
|
|
|
@ -78,7 +78,17 @@ public:
|
|||
void set_group_id(int id) { m_group_id = id; }
|
||||
|
||||
EState get_state() const { return m_state; }
|
||||
void set_state(EState state) { m_state = state; on_set_state(); }
|
||||
void set_state(EState state) {
|
||||
// FIXME: this is my workaround to react on the disabling event (Tamas)
|
||||
bool call_deactivate = ((m_state == On || m_state == Hover) &&
|
||||
state == Off);
|
||||
|
||||
m_state = state; on_set_state();
|
||||
|
||||
if(call_deactivate) {
|
||||
on_deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
bool is_activable(const GLCanvas3D::Selection& selection) const { return on_is_activable(selection); }
|
||||
|
||||
|
@ -110,6 +120,7 @@ protected:
|
|||
virtual bool on_init() = 0;
|
||||
virtual std::string on_get_name() const = 0;
|
||||
virtual void on_set_state() {}
|
||||
virtual void on_deactivate() {} // FIXME: how to react to disabling the Gizmo? (Tamas)
|
||||
virtual void on_set_hover_id() {}
|
||||
virtual bool on_is_activable(const GLCanvas3D::Selection& selection) const { return true; }
|
||||
virtual void on_enable_grabber(unsigned int id) {}
|
||||
|
@ -415,9 +426,13 @@ private:
|
|||
|
||||
protected:
|
||||
void on_set_state() override {
|
||||
if (m_state == On && is_mesh_update_necessary())
|
||||
if (m_state == On && is_mesh_update_necessary()) {
|
||||
update_mesh();
|
||||
}
|
||||
}
|
||||
|
||||
void on_deactivate() override;
|
||||
|
||||
std::string on_get_name() const override;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue