Tech ENABLE_SINKING_CONTOURS set as default

This commit is contained in:
enricoturri1966 2021-09-14 15:45:21 +02:00
parent bf21abfbfa
commit f132ca9c3c
8 changed files with 1 additions and 99 deletions

View file

@ -41,8 +41,6 @@
//====================
#define ENABLE_2_4_0_ALPHA1 1
// Enable drawing contours, at cut level, for sinking volumes
#define ENABLE_SINKING_CONTOURS (1 && ENABLE_2_4_0_ALPHA1)
// Enable implementation of retract acceleration in gcode processor
#define ENABLE_RETRACT_ACCELERATION (1 && ENABLE_2_4_0_ALPHA1)
// Enable the fix for exporting and importing to/from 3mf file of mirrored volumes

View file

@ -9,9 +9,7 @@
#include "3DScene.hpp"
#include "GLShader.hpp"
#include "GUI_App.hpp"
#if ENABLE_ENVIRONMENT_MAP || ENABLE_SINKING_CONTOURS
#include "Plater.hpp"
#endif // ENABLE_ENVIRONMENT_MAP || ENABLE_SINKING_CONTOURS
#include "libslic3r/ExtrusionEntity.hpp"
#include "libslic3r/ExtrusionEntityCollection.hpp"
@ -25,9 +23,7 @@
#include "libslic3r/AppConfig.hpp"
#include "libslic3r/PresetBundle.hpp"
#include "libslic3r/ClipperUtils.hpp"
#if ENABLE_SINKING_CONTOURS
#include "libslic3r/Tesselate.hpp"
#endif // ENABLE_SINKING_CONTOURS
#include <stdio.h>
#include <stdlib.h>
@ -293,7 +289,6 @@ void GLIndexedVertexArray::render(
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
}
#if ENABLE_SINKING_CONTOURS
const float GLVolume::SinkingContours::HalfWidth = 0.25f;
void GLVolume::SinkingContours::render()
@ -362,7 +357,6 @@ void GLVolume::SinkingContours::update()
else
m_model.reset();
}
#endif // ENABLE_SINKING_CONTOURS
const std::array<float, 4> GLVolume::SELECTED_COLOR = { 0.0f, 1.0f, 0.0f, 1.0f };
const std::array<float, 4> GLVolume::HOVER_SELECT_COLOR = { 0.4f, 0.9f, 0.1f, 1.0f };
@ -384,9 +378,7 @@ GLVolume::GLVolume(float r, float g, float b, float a)
: m_transformed_bounding_box_dirty(true)
, m_sla_shift_z(0.0)
, m_transformed_convex_hull_bounding_box_dirty(true)
#if ENABLE_SINKING_CONTOURS
, m_sinking_contours(*this)
#endif // ENABLE_SINKING_CONTOURS
// geometry_id == 0 -> invalid
, geometry_id(std::pair<size_t, size_t>(0, 0))
, extruder_id(0)
@ -404,9 +396,7 @@ GLVolume::GLVolume(float r, float g, float b, float a)
, force_transparent(false)
, force_native_color(false)
, force_neutral_color(false)
#if ENABLE_SINKING_CONTOURS
, force_sinking_contours(false)
#endif // ENABLE_SINKING_CONTOURS
, tverts_range(0, size_t(-1))
, qverts_range(0, size_t(-1))
{
@ -610,12 +600,10 @@ bool GLVolume::is_below_printbed() const
return transformed_convex_hull_bounding_box().max.z() < 0.0;
}
#if ENABLE_SINKING_CONTOURS
void GLVolume::render_sinking_contours()
{
m_sinking_contours.render();
}
#endif // ENABLE_SINKING_CONTOURS
std::vector<int> GLVolumeCollection::load_object(
const ModelObject *model_object,
@ -839,11 +827,9 @@ GLVolumeWithIdAndZList volumes_to_render(const GLVolumePtrs& volumes, GLVolumeCo
void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disable_cullface, const Transform3d& view_matrix, std::function<bool(const GLVolume&)> filter_func) const
{
#if ENABLE_SINKING_CONTOURS
GLVolumeWithIdAndZList to_render = volumes_to_render(volumes, type, view_matrix, filter_func);
if (to_render.empty())
return;
#endif // ENABLE_SINKING_CONTOURS
GLShaderProgram* shader = GUI::wxGetApp().get_current_shader();
if (shader == nullptr)
@ -858,7 +844,6 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
if (disable_cullface)
glsafe(::glDisable(GL_CULL_FACE));
#if ENABLE_SINKING_CONTOURS
for (GLVolumeWithIdAndZ& volume : to_render) {
volume.first->set_render_color();
@ -908,7 +893,7 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
glsafe(::glDisableClientState(GL_NORMAL_ARRAY));
}
if (m_show_sinking_contours)
if (m_show_sinking_contours) {
for (GLVolumeWithIdAndZ& volume : to_render) {
// render sinking contours of hovered/displaced volumes
if (volume.first->is_sinking() && !volume.first->is_below_printbed() &&
@ -920,48 +905,8 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
shader->start_using();
}
}
#else
glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
shader->set_uniform("print_box.min", m_print_box_min, 3);
shader->set_uniform("print_box.max", m_print_box_max, 3);
shader->set_uniform("z_range", m_z_range, 2);
shader->set_uniform("clipping_plane", m_clipping_plane, 4);
shader->set_uniform("slope.normal_z", m_slope.normal_z);
#if ENABLE_ENVIRONMENT_MAP
unsigned int environment_texture_id = GUI::wxGetApp().plater()->get_environment_texture_id();
bool use_environment_texture = environment_texture_id > 0 && GUI::wxGetApp().app_config->get("use_environment_map") == "1";
shader->set_uniform("use_environment_tex", use_environment_texture);
if (use_environment_texture)
glsafe(::glBindTexture(GL_TEXTURE_2D, environment_texture_id));
#endif // ENABLE_ENVIRONMENT_MAP
glcheck();
GLVolumeWithIdAndZList to_render = volumes_to_render(this->volumes, type, view_matrix, filter_func);
for (GLVolumeWithIdAndZ& volume : to_render) {
volume.first->set_render_color();
shader->set_uniform("uniform_color", volume.first->render_color);
shader->set_uniform("print_box.actived", volume.first->shader_outside_printer_detection_enabled);
shader->set_uniform("print_box.volume_world_matrix", volume.first->world_matrix());
shader->set_uniform("slope.actived", m_slope.active && !volume.first->is_modifier && !volume.first->is_wipe_tower);
shader->set_uniform("slope.volume_world_normal_matrix", static_cast<Matrix3f>(volume.first->world_matrix().matrix().block(0, 0, 3, 3).inverse().transpose().cast<float>()));
volume.first->render();
}
#if ENABLE_ENVIRONMENT_MAP
if (use_environment_texture)
glsafe(::glBindTexture(GL_TEXTURE_2D, 0));
#endif // ENABLE_ENVIRONMENT_MAP
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
glsafe(::glDisableClientState(GL_NORMAL_ARRAY));
#endif // ENABLE_SINKING_CONTOURS
if (disable_cullface)
glsafe(::glEnable(GL_CULL_FACE));

View file

@ -8,9 +8,7 @@
#include "libslic3r/Utils.hpp"
#include "libslic3r/Geometry.hpp"
#if ENABLE_SINKING_CONTOURS
#include "GLModel.hpp"
#endif // ENABLE_SINKING_CONTOURS
#include <functional>
@ -260,9 +258,7 @@ public:
enum EHoverState : unsigned char
{
HS_None,
#if ENABLE_SINKING_CONTOURS
HS_Hover,
#endif // ENABLE_SINKING_CONTOURS
HS_Select,
HS_Deselect
};
@ -287,7 +283,6 @@ private:
// Whether or not is needed to recalculate the transformed convex hull bounding box.
bool m_transformed_convex_hull_bounding_box_dirty;
#if ENABLE_SINKING_CONTOURS
class SinkingContours
{
static const float HalfWidth;
@ -305,7 +300,6 @@ private:
};
SinkingContours m_sinking_contours;
#endif // ENABLE_SINKING_CONTOURS
public:
// Color of the triangles / quads held by this volume.
@ -367,10 +361,8 @@ public:
bool force_native_color : 1;
// Whether or not render this volume in neutral
bool force_neutral_color : 1;
#if ENABLE_SINKING_CONTOURS
// Whether or not to force rendering of sinking contours
bool force_sinking_contours : 1;
#endif // ENABLE_SINKING_CONTOURS
};
// Is mouse or rectangle selection over this object to select/deselect it ?
@ -499,9 +491,7 @@ public:
bool is_sinking() const;
bool is_below_printbed() const;
#if ENABLE_SINKING_CONTOURS
void render_sinking_contours();
#endif // ENABLE_SINKING_CONTOURS
// Return an estimate of the memory consumed by this class.
size_t cpu_memory_used() const {

View file

@ -2926,7 +2926,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
return;
}
#if ENABLE_SINKING_CONTOURS
for (GLVolume* volume : m_volumes.volumes) {
volume->force_sinking_contours = false;
}
@ -2938,7 +2937,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
}
m_dirty = true;
};
#endif // ENABLE_SINKING_CONTOURS
if (m_gizmos.on_mouse(evt)) {
if (wxWindow::FindFocus() != m_canvas)
@ -2964,7 +2962,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
default: { break; }
}
}
#if ENABLE_SINKING_CONTOURS
else if (evt.Dragging()) {
switch (m_gizmos.get_current_type())
{
@ -2978,7 +2975,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
default: { break; }
}
}
#endif // ENABLE_SINKING_CONTOURS
return;
}
@ -3288,10 +3284,8 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
else
evt.Skip();
#if ENABLE_SINKING_CONTOURS
if (m_moving)
show_sinking_contours();
#endif // ENABLE_SINKING_CONTOURS
#ifdef __WXMSW__
if (on_enter_workaround)
@ -5648,11 +5642,8 @@ void GLCanvas3D::_update_volumes_hover_state()
}
}
}
#if ENABLE_SINKING_CONTOURS
else if (volume.selected)
volume.hover = GLVolume::HS_Hover;
#endif // ENABLE_SINKING_CONTOURS
}
}

View file

@ -7,9 +7,7 @@
#include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/Model.hpp"
#if ENABLE_SINKING_CONTOURS
#include "libslic3r/Polygon.hpp"
#endif // ENABLE_SINKING_CONTOURS
#include <boost/filesystem/operations.hpp>
#include <boost/algorithm/string/predicate.hpp>
@ -116,7 +114,6 @@ void GLModel::init_from(const indexed_triangle_set& its)
this->init_from(its, bounding_box(its));
}
#if ENABLE_SINKING_CONTOURS
void GLModel::init_from(const Polygons& polygons, float z)
{
auto append_polygon = [](const Polygon& polygon, float z, GUI::GLModel::InitializationData& data) {
@ -143,7 +140,6 @@ void GLModel::init_from(const Polygons& polygons, float z)
}
init_from(init_data);
}
#endif // ENABLE_SINKING_CONTOURS
bool GLModel::init_from_file(const std::string& filename)
{

View file

@ -9,10 +9,8 @@
namespace Slic3r {
class TriangleMesh;
#if ENABLE_SINKING_CONTOURS
class Polygon;
using Polygons = std::vector<Polygon>;
#endif // ENABLE_SINKING_CONTOURS
namespace GUI {
@ -72,9 +70,7 @@ namespace GUI {
void init_from(const InitializationData& data);
void init_from(const indexed_triangle_set& its, const BoundingBoxf3& bbox);
void init_from(const indexed_triangle_set& its);
#if ENABLE_SINKING_CONTOURS
void init_from(const Polygons& polygons, float z);
#endif // ENABLE_SINKING_CONTOURS
bool init_from_file(const std::string& filename);
// if entity_id == -1 set the color of all entities

View file

@ -16,9 +16,7 @@
#include "slic3r/GUI/GUI_ObjectManipulation.hpp"
#include "libslic3r/AppConfig.hpp"
#include "libslic3r/Model.hpp"
#if ENABLE_SINKING_CONTOURS
#include "libslic3r/TriangleMeshSlicer.hpp"
#endif // ENABLE_SINKING_CONTOURS
namespace Slic3r {
namespace GUI {
@ -92,9 +90,7 @@ void GLGizmoCut::on_render()
m_max_z = box.max.z();
set_cut_z(m_cut_z);
#if ENABLE_SINKING_CONTOURS
update_contours();
#endif // ENABLE_SINKING_CONTOURS
const float min_x = box.min.x() - Margin;
const float max_x = box.max.x() + Margin;
@ -143,13 +139,11 @@ void GLGizmoCut::on_render()
shader->stop_using();
#if ENABLE_SINKING_CONTOURS
glsafe(::glPushMatrix());
glsafe(::glTranslated(m_cut_contours.shift.x(), m_cut_contours.shift.y(), m_cut_contours.shift.z()));
glsafe(::glLineWidth(2.0f));
m_cut_contours.contours.render();
glsafe(::glPopMatrix());
#endif // ENABLE_SINKING_CONTOURS
}
void GLGizmoCut::on_render_for_picking()
@ -275,7 +269,6 @@ BoundingBoxf3 GLGizmoCut::bounding_box() const
return ret;
}
#if ENABLE_SINKING_CONTOURS
void GLGizmoCut::update_contours()
{
const Selection& selection = m_parent.get_selection();
@ -315,7 +308,6 @@ void GLGizmoCut::update_contours()
else
m_cut_contours.contours.reset();
}
#endif // ENABLE_SINKING_CONTOURS
} // namespace GUI
} // namespace Slic3r

View file

@ -2,11 +2,9 @@
#define slic3r_GLGizmoCut_hpp_
#include "GLGizmoBase.hpp"
#if ENABLE_SINKING_CONTOURS
#include "slic3r/GUI/GLModel.hpp"
#include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/ObjectID.hpp"
#endif // ENABLE_SINKING_CONTOURS
namespace Slic3r {
namespace GUI {
@ -26,7 +24,6 @@ class GLGizmoCut : public GLGizmoBase
bool m_keep_lower{ true };
bool m_rotate_lower{ false };
#if ENABLE_SINKING_CONTOURS
struct CutContours
{
TriangleMesh mesh;
@ -39,7 +36,6 @@ class GLGizmoCut : public GLGizmoBase
};
CutContours m_cut_contours;
#endif // ENABLE_SINKING_CONTOURS
public:
GLGizmoCut(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
@ -66,9 +62,7 @@ private:
void perform_cut(const Selection& selection);
double calc_projection(const Linef3& mouse_ray) const;
BoundingBoxf3 bounding_box() const;
#if ENABLE_SINKING_CONTOURS
void update_contours();
#endif // ENABLE_SINKING_CONTOURS
};
} // namespace GUI