Tech ENABLE_COLOR_CLASSES set as default

This commit is contained in:
enricoturri1966 2022-01-14 08:19:00 +01:00
parent fab35e8aa4
commit 6201dad245
50 changed files with 18 additions and 1500 deletions

View file

@ -25,21 +25,9 @@ GLGizmoBase::Grabber::Grabber()
void GLGizmoBase::Grabber::render(bool hover, float size) const
{
#if ENABLE_COLOR_CLASSES
ColorRGBA render_color = color;
if (hover)
render_color = complementary(render_color);
#else
std::array<float, 4> render_color;
if (hover) {
render_color[0] = (1.0f - color[0]);
render_color[1] = (1.0f - color[1]);
render_color[2] = (1.0f - color[2]);
render_color[3] = color[3];
}
else
render_color = color;
#endif // ENABLE_COLOR_CLASSES
render(size, render_color, false);
}
@ -54,11 +42,7 @@ float GLGizmoBase::Grabber::get_dragging_half_size(float size) const
return get_half_size(size) * DraggingScaleFactor;
}
#if ENABLE_COLOR_CLASSES
void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, bool picking) const
#else
void GLGizmoBase::Grabber::render(float size, const std::array<float, 4>& render_color, bool picking) const
#endif // ENABLE_COLOR_CLASSES
{
if (!cube.is_initialized()) {
// This cannot be done in constructor, OpenGL is not yet
@ -109,13 +93,6 @@ void GLGizmoBase::set_hover_id(int id)
}
}
#if !ENABLE_COLOR_CLASSES
void GLGizmoBase::set_highlight_color(const std::array<float, 4>& color)
{
m_highlight_color = color;
}
#endif // !ENABLE_COLOR_CLASSES
void GLGizmoBase::enable_grabber(unsigned int id)
{
if (id < m_grabbers.size())
@ -169,29 +146,13 @@ bool GLGizmoBase::update_items_state()
return res;
};
#if ENABLE_COLOR_CLASSES
ColorRGBA GLGizmoBase::picking_color_component(unsigned int id) const
{
#else
std::array<float, 4> GLGizmoBase::picking_color_component(unsigned int id) const
{
static const float INV_255 = 1.0f / 255.0f;
#endif // ENABLE_COLOR_CLASSES
id = BASE_ID - id;
if (m_group_id > -1)
id -= m_group_id;
#if ENABLE_COLOR_CLASSES
return picking_decode(id);
#else
// color components are encoded to match the calculation of volume_id made into GLCanvas3D::_picking_pass()
return std::array<float, 4> {
float((id >> 0) & 0xff) * INV_255, // red
float((id >> 8) & 0xff) * INV_255, // green
float((id >> 16) & 0xff) * INV_255, // blue
float(picking_checksum_alpha_channel(id & 0xff, (id >> 8) & 0xff, (id >> 16) & 0xff))* INV_255 // checksum for validating against unwanted alpha blending and multi sampling
};
#endif // ENABLE_COLOR_CLASSES
}
void GLGizmoBase::render_grabbers(const BoundingBoxf3& box) const
@ -219,12 +180,7 @@ void GLGizmoBase::render_grabbers_for_picking(const BoundingBoxf3& box) const
for (unsigned int i = 0; i < (unsigned int)m_grabbers.size(); ++i) {
if (m_grabbers[i].enabled) {
#if ENABLE_COLOR_CLASSES
m_grabbers[i].color = picking_color_component(i);
#else
std::array<float, 4> color = picking_color_component(i);
m_grabbers[i].color = color;
#endif // ENABLE_COLOR_CLASSES
m_grabbers[i].render_for_picking(mean_size);
}
}
@ -261,22 +217,6 @@ std::string GLGizmoBase::get_name(bool include_shortcut) const
return out;
}
#if !ENABLE_COLOR_CLASSES
// Produce an alpha channel checksum for the red green blue components. The alpha channel may then be used to verify, whether the rgb components
// were not interpolated by alpha blending or multi sampling.
unsigned char picking_checksum_alpha_channel(unsigned char red, unsigned char green, unsigned char blue)
{
// 8 bit hash for the color
unsigned char b = ((((37 * red) + green) & 0x0ff) * 37 + blue) & 0x0ff;
// Increase enthropy by a bit reversal
b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
// Flip every second bit to increase the enthropy even more.
b ^= 0x55;
return b;
}
#endif // !ENABLE_COLOR_CLASSES
} // namespace GUI
} // namespace Slic3r