mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-31 12:41:20 -06:00
Lay flat gizmo improvements - merge adjacent faces, compute and cache convex hull for entire ModelObject, refresh when moved, etc.
This commit is contained in:
parent
48b9793d3d
commit
f9efcc36b6
5 changed files with 256 additions and 98 deletions
|
|
@ -10,6 +10,7 @@ namespace Slic3r {
|
|||
|
||||
class BoundingBoxf3;
|
||||
class Pointf3;
|
||||
class ModelObject;
|
||||
|
||||
namespace GUI {
|
||||
|
||||
|
|
@ -160,23 +161,39 @@ private:
|
|||
struct PlaneData {
|
||||
std::vector<Pointf3> vertices;
|
||||
Pointf3 normal;
|
||||
float color[3];
|
||||
};
|
||||
struct SourceDataSummary {
|
||||
std::vector<BoundingBoxf3> bounding_boxes; // bounding boxes of convex hulls of individual volumes
|
||||
float scaling_factor;
|
||||
float rotation;
|
||||
};
|
||||
|
||||
// This holds information to decide whether recalculation is necessary:
|
||||
SourceDataSummary m_source_data;
|
||||
|
||||
std::vector<PlaneData> m_planes;
|
||||
std::vector<Pointf> m_instances_positions;
|
||||
mutable std::unique_ptr<Pointf3> m_center = nullptr;
|
||||
const ModelObject* m_model_object = nullptr;
|
||||
void update_planes();
|
||||
bool is_plane_update_necessary() const;
|
||||
|
||||
public:
|
||||
GLGizmoFlatten();
|
||||
|
||||
void set_flattening_data(std::vector<Pointf3s> vertices_list);
|
||||
void set_flattening_data(const ModelObject* model_object);
|
||||
Pointf3 get_flattening_normal() const;
|
||||
|
||||
protected:
|
||||
virtual bool on_init();
|
||||
virtual void on_start_dragging();
|
||||
virtual void on_update(const Pointf& mouse_pos);
|
||||
virtual void on_render(const BoundingBoxf3& box) const;
|
||||
virtual void on_render_for_picking(const BoundingBoxf3& box) const;
|
||||
bool on_init() override;
|
||||
void on_start_dragging() override;
|
||||
void on_update(const Pointf& mouse_pos) override {};
|
||||
void on_render(const BoundingBoxf3& box) const override;
|
||||
void on_render_for_picking(const BoundingBoxf3& box) const override;
|
||||
void on_set_state() override {
|
||||
if (m_state == On && is_plane_update_necessary())
|
||||
update_planes();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue