Use std::optional to replace dirty flags for bounding boxes in Selection

This commit is contained in:
enricoturri1966 2021-09-17 13:24:37 +02:00
parent 82b4a4fe11
commit 9d7549e661
2 changed files with 47 additions and 67 deletions

View file

@ -1,10 +1,12 @@
#ifndef slic3r_GUI_Selection_hpp_
#define slic3r_GUI_Selection_hpp_
#include <set>
#include "libslic3r/Geometry.hpp"
#include "GLModel.hpp"
#include <set>
#include <optional>
namespace Slic3r {
class Shader;
@ -203,14 +205,11 @@ private:
IndicesList m_list;
Cache m_cache;
Clipboard m_clipboard;
BoundingBoxf3 m_bounding_box;
bool m_bounding_box_dirty;
std::optional<BoundingBoxf3> m_bounding_box;
// Bounding box of a selection, with no instance scaling applied. This bounding box
// is useful for absolute scaling of tilted objects in world coordinate space.
BoundingBoxf3 m_unscaled_instance_bounding_box;
bool m_unscaled_instance_bounding_box_dirty;
BoundingBoxf3 m_scaled_instance_bounding_box;
bool m_scaled_instance_bounding_box_dirty;
std::optional<BoundingBoxf3> m_unscaled_instance_bounding_box;
std::optional<BoundingBoxf3> m_scaled_instance_bounding_box;
#if ENABLE_RENDER_SELECTION_CENTER
GLModel m_vbo_sphere;
@ -359,10 +358,7 @@ private:
void do_remove_volume(unsigned int volume_idx);
void do_remove_instance(unsigned int object_idx, unsigned int instance_idx);
void do_remove_object(unsigned int object_idx);
void calc_bounding_box() const;
void calc_unscaled_instance_bounding_box() const;
void calc_scaled_instance_bounding_box() const;
void set_bounding_boxes_dirty() { m_bounding_box_dirty = true; m_unscaled_instance_bounding_box_dirty = true; m_scaled_instance_bounding_box_dirty = true; }
void set_bounding_boxes_dirty() { m_bounding_box.reset(); m_unscaled_instance_bounding_box.reset(); m_scaled_instance_bounding_box.reset(); }
void render_selected_volumes() const;
void render_synchronized_volumes() const;
void render_bounding_box(const BoundingBoxf3& box, float* color) const;