FIX: Opaque display after completed slicing
Change-Id: I944f5063ba41b767d01a26052e23bd803425b081 (cherry picked from commit f4d5ef5814c50d8477ac21e58182b00dbb20d6c8)
This commit is contained in:
parent
c7ed4e7e14
commit
eca3d311d7
5 changed files with 7 additions and 38 deletions
|
@ -89,29 +89,16 @@ std::vector<std::array<float, 4>> get_extruders_colors()
|
|||
}
|
||||
float FullyTransparentMaterialThreshold = 0.1f;
|
||||
float FullTransparentModdifiedToFixAlpha = 0.3f;
|
||||
std::array<float, 4> adjust_color_for_rendering(const std::array<float, 4> &colors, int whichView)
|
||||
std::array<float, 4> adjust_color_for_rendering(const std::array<float, 4> &colors)
|
||||
{
|
||||
if (whichView == (int) Slic3r::GUI::GLCanvas3D::ECanvasType::CanvasView3D ||
|
||||
whichView == (int) Slic3r::GUI::GLCanvas3D::ECanvasType::CanvasAssembleView) {
|
||||
if (colors[3] < FullyTransparentMaterialThreshold) { // completely transparent
|
||||
if (colors[3] < FullyTransparentMaterialThreshold) { // completely transparent
|
||||
std::array<float, 4> new_color;
|
||||
new_color[0] = 1;
|
||||
new_color[1] = 1;
|
||||
new_color[2] = 1;
|
||||
new_color[3] = FullTransparentModdifiedToFixAlpha;
|
||||
return new_color;
|
||||
}
|
||||
} else {
|
||||
if (colors[3] < FullyTransparentMaterialThreshold) { // completely transparent
|
||||
std::array<float, 4> new_color;
|
||||
new_color[0] = 1;
|
||||
new_color[1] = 1;
|
||||
new_color[2] = 1;
|
||||
new_color[3] = 0.05f;
|
||||
return new_color;
|
||||
}
|
||||
}
|
||||
|
||||
return colors;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
extern std::vector<std::array<float, 4>> get_extruders_colors();
|
||||
extern float FullyTransparentMaterialThreshold;
|
||||
extern float FullTransparentModdifiedToFixAlpha;
|
||||
extern std::array<float, 4> adjust_color_for_rendering(const std::array<float, 4> &colors, int whichView=0);
|
||||
extern std::array<float, 4> adjust_color_for_rendering(const std::array<float, 4> &colors);
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
|
|
|
@ -1153,7 +1153,7 @@ void GCodeViewer::refresh(const GCodeProcessorResult& gcode_result, const std::v
|
|||
}
|
||||
|
||||
for (int i = 0; i < m_tools.m_tool_colors.size(); i++) {
|
||||
m_tools.m_tool_colors[i] = adjust_color_for_rendering(m_tools.m_tool_colors[i], GLCanvas3D::ECanvasType::CanvasPreview);
|
||||
m_tools.m_tool_colors[i] = adjust_color_for_rendering(m_tools.m_tool_colors[i]);
|
||||
}
|
||||
// ensure there are enough colors defined
|
||||
while (m_tools.m_tool_colors.size() < std::max(size_t(1), gcode_result.extruders_count)) {
|
||||
|
@ -3266,7 +3266,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
|
|||
color = { 0.5f, 0.5f, 0.5f, 1.0f };
|
||||
else {
|
||||
color = m_tools.m_tool_colors[path.cp_color_id];
|
||||
color = adjust_color_for_rendering(color, GLCanvas3D::ECanvasType::CanvasPreview);
|
||||
color = adjust_color_for_rendering(color);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -3876,10 +3876,6 @@ void GCodeViewer::render_toolpaths()
|
|||
](std::vector<RenderPath>::reverse_iterator it_path, std::vector<RenderPath>::reverse_iterator it_end, GLShaderProgram& shader, int uniform_color) {
|
||||
for (auto it = it_path; it != it_end && it_path->ibuffer_id == it->ibuffer_id; ++it) {
|
||||
const RenderPath& path = *it;
|
||||
if (path.color[3] < 1.0) {
|
||||
glsafe(::glEnable(GL_BLEND));
|
||||
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
|
||||
}
|
||||
// Some OpenGL drivers crash on empty glMultiDrawElements, see GH #7415.
|
||||
assert(! path.sizes.empty());
|
||||
assert(! path.offsets.empty());
|
||||
|
@ -3888,9 +3884,6 @@ void GCodeViewer::render_toolpaths()
|
|||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||
++m_statistics.gl_multi_triangles_calls_count;
|
||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||
if (path.color[3] < 1.0) {
|
||||
glsafe(::glDisable(GL_BLEND));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -4170,7 +4163,7 @@ void GCodeViewer::render_all_plates_stats(const std::vector<const GCodeProcessor
|
|||
std::vector<Color> filament_colors = decode_colors(wxGetApp().plater()->get_extruder_colors_from_plater_config(gcode_result_list.back()));
|
||||
|
||||
for (int i = 0; i < filament_colors.size(); i++) {
|
||||
filament_colors[i] = adjust_color_for_rendering(filament_colors[i], GLCanvas3D::ECanvasType::CanvasPreview);
|
||||
filament_colors[i] = adjust_color_for_rendering(filament_colors[i]);
|
||||
}
|
||||
|
||||
bool imperial_units = wxGetApp().app_config->get("use_inches") == "1";
|
||||
|
|
|
@ -734,13 +734,6 @@ public:
|
|||
|
||||
//BBS
|
||||
ConflictResultOpt m_conflict_result;
|
||||
bool GetGcodeGenOk()
|
||||
{
|
||||
if (m_roles.empty())
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
private:
|
||||
std::vector<int> m_plater_extruder;
|
||||
bool m_gl_data_initialized{ false };
|
||||
|
|
|
@ -1899,10 +1899,6 @@ void GLCanvas3D::render(bool only_init)
|
|||
_render_selection();
|
||||
_render_bed(!camera.is_looking_downward(), show_axes);
|
||||
_render_platelist(!camera.is_looking_downward(), only_current, true, hover_id);
|
||||
// BBS: add outline logic
|
||||
if (m_gcode_viewer.GetGcodeGenOk()==false) {
|
||||
_render_objects(GLVolumeCollection::ERenderType::Transparent, !m_gizmos.is_running());
|
||||
}
|
||||
// BBS: GUI refactor: add canvas size as parameters
|
||||
_render_gcode(cnv_size.get_width(), cnv_size.get_height());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue