diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 09577410d..85b7df56d 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -9,6 +9,8 @@ #define ENABLE_SHOW_CAMERA_TARGET 0 // Log debug messages to console when changing selection #define ENABLE_SELECTION_DEBUG_OUTPUT 0 +// Renders a small sphere in the center of the bounding box of the current selection when no gizmo is active +#define ENABLE_RENDER_SELECTION_CENTER 0 //==================== // 1.42.0.alpha1 techs @@ -24,10 +26,6 @@ #define ENABLE_SLA_SUPPORT_GIZMO_MOD (1 && ENABLE_1_42_0_ALPHA1) // Use wxDataViewRender instead of wxDataViewCustomRenderer #define ENABLE_NONCUSTOM_DATA_VIEW_RENDERING (0 && ENABLE_1_42_0_ALPHA1) -// Renders a small sphere in the center of the bounding box of the current selection when no gizmo is active -#define ENABLE_RENDER_SELECTION_CENTER (0 && ENABLE_1_42_0_ALPHA1) -// Separate rendering for opaque and transparent volumes -#define ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING (1 && ENABLE_1_42_0_ALPHA1) //==================== // 1.42.0.alpha2 techs diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index f08e8fcd4..a96731e46 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -541,9 +541,7 @@ int GLVolumeCollection::load_object_volume( color[2] = 1.0f; } color[3] = model_volume->is_model_part() ? 1.f : 0.5f; */ -#if ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING color[3] = model_volume->is_model_part() ? 1.f : 0.5f; -#endif // ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING this->volumes.emplace_back(new GLVolume(color)); GLVolume &v = *this->volumes.back(); v.set_color_from_model_volume(model_volume); @@ -687,7 +685,6 @@ int GLVolumeCollection::load_wipe_tower_preview( return int(this->volumes.size() - 1); } -#if ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING typedef std::pair GLVolumeWithZ; typedef std::vector GLVolumesWithZList; static GLVolumesWithZList volumes_to_render(const GLVolumePtrs& volumes, GLVolumeCollection::ERenderType type, std::function filter_func) @@ -724,18 +721,13 @@ static GLVolumesWithZList volumes_to_render(const GLVolumePtrs& volumes, GLVolum } void GLVolumeCollection::render_VBOs(GLVolumeCollection::ERenderType type, bool disable_cullface, std::function filter_func) const -#else -void GLVolumeCollection::render_VBOs() const -#endif // ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING { ::glEnable(GL_BLEND); ::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); ::glCullFace(GL_BACK); -#if ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING if (disable_cullface) ::glDisable(GL_CULL_FACE); -#endif // ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING ::glEnableClientState(GL_VERTEX_ARRAY); ::glEnableClientState(GL_NORMAL_ARRAY); @@ -758,19 +750,11 @@ void GLVolumeCollection::render_VBOs() const if (z_range_id != -1) ::glUniform2fv(z_range_id, 1, (const GLfloat*)z_range); -#if ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING GLVolumesWithZList to_render = volumes_to_render(this->volumes, type, filter_func); for (GLVolumeWithZ& volume : to_render) { volume.first->set_render_color(); volume.first->render_VBOs(color_id, print_box_detection_id, print_box_worldmatrix_id); } -#else - for (GLVolume *volume : this->volumes) - if (! filter_func || filter_func(*volume)) { - volume->set_render_color(); - volume->render_VBOs(color_id, print_box_detection_id, print_box_worldmatrix_id); - } -#endif // ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING ::glBindBuffer(GL_ARRAY_BUFFER, 0); ::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); @@ -778,54 +762,36 @@ void GLVolumeCollection::render_VBOs() const ::glDisableClientState(GL_VERTEX_ARRAY); ::glDisableClientState(GL_NORMAL_ARRAY); -#if ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING if (disable_cullface) ::glEnable(GL_CULL_FACE); -#endif // ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING ::glDisable(GL_BLEND); } -#if ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING void GLVolumeCollection::render_legacy(ERenderType type, bool disable_cullface) const -#else -void GLVolumeCollection::render_legacy() const -#endif // ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glCullFace(GL_BACK); -#if ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING if (disable_cullface) ::glDisable(GL_CULL_FACE); -#endif // ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); -#if ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING GLVolumesWithZList to_render = volumes_to_render(this->volumes, type, std::function()); for (GLVolumeWithZ& volume : to_render) { volume.first->set_render_color(); volume.first->render_legacy(); } -#else - for (GLVolume *volume : this->volumes) - { - volume->set_render_color(); - volume->render_legacy(); - } -#endif // ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); -#if ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING if (disable_cullface) ::glEnable(GL_CULL_FACE); -#endif // ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING glDisable(GL_BLEND); } diff --git a/src/slic3r/GUI/3DScene.hpp b/src/slic3r/GUI/3DScene.hpp index dd713dd41..e9340bd6e 100644 --- a/src/slic3r/GUI/3DScene.hpp +++ b/src/slic3r/GUI/3DScene.hpp @@ -388,7 +388,6 @@ typedef std::vector GLVolumePtrs; class GLVolumeCollection { -#if ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING public: enum ERenderType : unsigned char { @@ -398,7 +397,6 @@ public: }; private: -#endif // ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING // min and max vertex of the print box volume float print_box_min[3]; float print_box_max[3]; @@ -442,13 +440,8 @@ public: int obj_idx, float pos_x, float pos_y, float width, float depth, float height, float rotation_angle, bool use_VBOs, bool size_unknown, float brim_width); // Render the volumes by OpenGL. -#if ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING void render_VBOs(ERenderType type, bool disable_cullface, std::function filter_func = std::function()) const; void render_legacy(ERenderType type, bool disable_cullface) const; -#else - void render_VBOs() const; - void render_legacy() const; -#endif // ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING // Finalize the initialization of the geometry & indices, // upload the geometry and indices to OpenGL VBO objects diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 5f8d879cb..1599b1d4a 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -4275,13 +4275,9 @@ void GLCanvas3D::render() ::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); _render_background(); -#if ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING // textured bed needs to be rendered after objects if the texture is transparent bool early_bed_render = is_custom_bed || (theta <= 90.0f); if (early_bed_render) -#else - if (is_custom_bed) // untextured bed needs to be rendered before objects -#endif // ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING _render_bed(theta); _render_objects(); @@ -4290,11 +4286,7 @@ void GLCanvas3D::render() _render_axes(); -#if ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING if (!early_bed_render) -#else - if (!is_custom_bed) // textured bed needs to be rendered after objects -#endif // ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING _render_bed(theta); #if ENABLE_RENDER_SELECTION_CENTER @@ -6224,10 +6216,6 @@ void GLCanvas3D::_render_objects() const m_volumes.set_print_box((float)bed_bb.min(0), (float)bed_bb.min(1), 0.0f, (float)bed_bb.max(0), (float)bed_bb.max(1), (float)m_config->opt_float("max_print_height")); m_volumes.check_outside_state(m_config, nullptr); } -#if !ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING - // do not cull backfaces to show broken geometry, if any - ::glDisable(GL_CULL_FACE); -#endif // !ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING } if (m_use_clipping_planes) @@ -6236,7 +6224,6 @@ void GLCanvas3D::_render_objects() const m_volumes.set_z_range(-FLT_MAX, FLT_MAX); m_shader.start_using(); -#if ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING if (m_picking_enabled && m_layers_editing.is_enabled() && m_layers_editing.last_object_id != -1) { int object_id = m_layers_editing.last_object_id; m_volumes.render_VBOs(GLVolumeCollection::Opaque, false, [object_id](const GLVolume &volume) { @@ -6250,15 +6237,7 @@ void GLCanvas3D::_render_objects() const m_volumes.render_VBOs(GLVolumeCollection::Opaque, m_picking_enabled); } m_volumes.render_VBOs(GLVolumeCollection::Transparent, false); -#else - m_volumes.render_VBOs(); -#endif // ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING m_shader.stop_using(); - -#if !ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING - if (m_picking_enabled) - ::glEnable(GL_CULL_FACE); -#endif // !ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING } else { @@ -6270,24 +6249,9 @@ void GLCanvas3D::_render_objects() const ::glEnable(GL_CLIP_PLANE1); } -#if !ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING - // do not cull backfaces to show broken geometry, if any - if (m_picking_enabled) - ::glDisable(GL_CULL_FACE); -#endif // !ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING - -#if ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING // do not cull backfaces to show broken geometry, if any m_volumes.render_legacy(GLVolumeCollection::Opaque, m_picking_enabled); m_volumes.render_legacy(GLVolumeCollection::Transparent, false); -#else - m_volumes.render_legacy(); -#endif // ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING - -#if !ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING - if (m_picking_enabled) - ::glEnable(GL_CULL_FACE); -#endif // !ENABLE_IMPROVED_TRANSPARENT_VOLUMES_RENDERING if (m_use_clipping_planes) {