WIP: Added a circle cursor and naive logic to select triangles inside

Deselection is possible when holding shift
Triangles obscured by the mesh are selected nonetheless (so far)
This commit is contained in:
Lukas Matena 2019-10-08 10:15:06 +02:00
parent 08daddb5de
commit 2e71dcefc3
4 changed files with 141 additions and 23 deletions

View file

@ -21,7 +21,7 @@ private:
ObjectID m_model_object_id = 0;
int m_active_instance = -1;
float m_active_instance_bb_radius; // to cache the bb
bool unproject_on_mesh(const Vec2d& mouse_pos, size_t& facet_idx);
bool unproject_on_mesh(const Vec2d& mouse_pos, size_t& facet_idx, Vec3f* position = nullptr);
GLUquadricObj* m_quadric;
@ -30,9 +30,9 @@ private:
const TriangleMesh* m_mesh;
const indexed_triangle_set* m_its;
mutable std::vector<Vec2f> m_triangles;
float m_cursor_radius = 2.f;
std::vector<size_t> m_selected_facets;
std::vector<bool> m_selected_facets;
public:
GLGizmoFdmSupports(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
@ -40,6 +40,7 @@ public:
void set_fdm_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);
ClippingPlane get_fdm_clipping_plane() const;
using NeighborData = std::pair<size_t, size_t>;
private:
@ -49,6 +50,7 @@ private:
void render_triangles(const Selection& selection) const;
void render_clipping_plane(const Selection& selection) const;
void render_cursor_circle() const;
bool is_mesh_update_necessary() const;
void update_mesh();
@ -64,6 +66,8 @@ private:
mutable std::unique_ptr<MeshClipper> m_object_clipper;
std::vector<NeighborData> m_neighbors; // pairs of vertex_index - facet_index
bool is_point_clipped(const Vec3d& point) const;
void update_clipping_plane(bool keep_normal = false) const;