Colors in GLVolume defined as std::array<float, 4>

This commit is contained in:
enricoturri1966 2021-07-19 11:11:49 +02:00
parent 21abf8d88e
commit 2848ae9c4d
4 changed files with 88 additions and 106 deletions

View file

@ -236,16 +236,16 @@ private:
class GLVolume {
public:
static const float SELECTED_COLOR[4];
static const float HOVER_SELECT_COLOR[4];
static const float HOVER_DESELECT_COLOR[4];
static const float OUTSIDE_COLOR[4];
static const float SELECTED_OUTSIDE_COLOR[4];
static const float DISABLED_COLOR[4];
static const float MODEL_COLOR[4][4];
static const float SLA_SUPPORT_COLOR[4];
static const float SLA_PAD_COLOR[4];
static const float NEUTRAL_COLOR[4];
static const std::array<float, 4> SELECTED_COLOR;
static const std::array<float, 4> HOVER_SELECT_COLOR;
static const std::array<float, 4> HOVER_DESELECT_COLOR;
static const std::array<float, 4> OUTSIDE_COLOR;
static const std::array<float, 4> SELECTED_OUTSIDE_COLOR;
static const std::array<float, 4> DISABLED_COLOR;
static const std::array<float, 4> SLA_SUPPORT_COLOR;
static const std::array<float, 4> SLA_PAD_COLOR;
static const std::array<float, 4> NEUTRAL_COLOR;
static const std::array<std::array<float, 4>, 4> MODEL_COLOR;
enum EHoverState : unsigned char
{
@ -255,7 +255,7 @@ public:
};
GLVolume(float r = 1.f, float g = 1.f, float b = 1.f, float a = 1.f);
GLVolume(const float *rgba) : GLVolume(rgba[0], rgba[1], rgba[2], rgba[3]) {}
GLVolume(const std::array<float, 4>& rgba) : GLVolume(rgba[0], rgba[1], rgba[2], rgba[3]) {}
private:
Geometry::Transformation m_instance_transformation;
@ -276,9 +276,10 @@ private:
public:
// Color of the triangles / quads held by this volume.
float color[4];
std::array<float, 4> color;
// Color used to render this volume.
float render_color[4];
std::array<float, 4> render_color;
struct CompositeID {
CompositeID(int object_id, int volume_id, int instance_id) : object_id(object_id), volume_id(volume_id), instance_id(instance_id) {}
CompositeID() : object_id(-1), volume_id(-1), instance_id(-1) {}
@ -362,11 +363,11 @@ public:
}
void set_render_color(float r, float g, float b, float a);
void set_render_color(const float* rgba, unsigned int size);
void set_render_color(const std::array<float, 4>& rgba);
// Sets render color in dependence of current state
void set_render_color();
// set color according to model volume
void set_color_from_model_volume(const ModelVolume *model_volume);
void set_color_from_model_volume(const ModelVolume& model_volume);
const Geometry::Transformation& get_instance_transformation() const { return m_instance_transformation; }
void set_instance_transformation(const Geometry::Transformation& transformation) { m_instance_transformation = transformation; set_bounding_boxes_as_dirty(); }
@ -542,8 +543,8 @@ public:
int load_wipe_tower_preview(
int obj_idx, float pos_x, float pos_y, float width, float depth, float height, float rotation_angle, bool size_unknown, float brim_width, bool opengl_initialized);
GLVolume* new_toolpath_volume(const float *rgba, size_t reserve_vbo_floats = 0);
GLVolume* new_nontoolpath_volume(const float *rgba, size_t reserve_vbo_floats = 0);
GLVolume* new_toolpath_volume(const std::array<float, 4>& rgba, size_t reserve_vbo_floats = 0);
GLVolume* new_nontoolpath_volume(const std::array<float, 4>& rgba, size_t reserve_vbo_floats = 0);
// Render the volumes by OpenGL.
void render(ERenderType type, bool disable_cullface, const Transform3d& view_matrix, std::function<bool(const GLVolume&)> filter_func = std::function<bool(const GLVolume&)>()) const;