ENH:Camera and colors used for rendering are passed through parameters, reducing the use of global variables in sub classes

jira: none

Change-Id: Iec47c80f1f46a4111a16d20988f63813e33e4fa5
(cherry picked from commit 9daa2018220ca811c0ec3a2c33f30d521f2646cd)
This commit is contained in:
zhou.xu 2025-03-20 16:21:33 +08:00 committed by lane.wei
parent a11dcd9fd4
commit 7b507d4a6a
8 changed files with 194 additions and 154 deletions

View File

@ -355,7 +355,7 @@ void GLIndexedVertexArray::render(
const float GLVolume::SinkingContours::HalfWidth = 0.25f; const float GLVolume::SinkingContours::HalfWidth = 0.25f;
void GLVolume::SinkingContours::render() void GLVolume::SinkingContours::render(const GUI::Camera &camera)
{ {
const auto& shader = GUI::wxGetApp().get_shader("flat"); const auto& shader = GUI::wxGetApp().get_shader("flat");
if (!shader) { if (!shader) {
@ -365,8 +365,6 @@ void GLVolume::SinkingContours::render()
GUI::wxGetApp().bind_shader(shader); GUI::wxGetApp().bind_shader(shader);
update(); update();
const GUI::Camera& camera = GUI::wxGetApp().plater()->get_camera();
shader->set_uniform("view_model_matrix", camera.get_view_matrix() * Geometry::assemble_transform(m_shift)); shader->set_uniform("view_model_matrix", camera.get_view_matrix() * Geometry::assemble_transform(m_shift));
shader->set_uniform("projection_matrix", camera.get_projection_matrix()); shader->set_uniform("projection_matrix", camera.get_projection_matrix());
m_model.render_geometry(); m_model.render_geometry();
@ -838,7 +836,7 @@ void GLVolume::set_range(double min_z, double max_z)
//BBS: add outline related logic //BBS: add outline related logic
//static unsigned char stencil_data[1284][2944]; //static unsigned char stencil_data[1284][2944];
void GLVolume::render(const Transform3d& view_matrix, bool with_outline, const std::array<float, 4>& body_color) const void GLVolume::render(const GUI::Camera &camera, const std::vector<std::array<float, 4>> &colors, bool with_outline, const std::array<float, 4> &body_color) const
{ {
if (!is_active) if (!is_active)
return; return;
@ -846,10 +844,9 @@ void GLVolume::render(const Transform3d& view_matrix, bool with_outline, const s
if (this->is_left_handed()) if (this->is_left_handed())
glFrontFace(GL_CW); glFrontFace(GL_CW);
glsafe(::glCullFace(GL_BACK)); glsafe(::glCullFace(GL_BACK));
auto camera = GUI::wxGetApp().plater()->get_camera();
auto zoom = camera.get_zoom(); auto zoom = camera.get_zoom();
Transform3d vier_mat = camera.get_view_matrix(); auto view_matrix = camera.get_view_matrix();
Matrix4d vier_proj_mat = camera.get_projection_matrix().matrix() * vier_mat.matrix(); Matrix4d vier_proj_mat = camera.get_projection_matrix().matrix() * view_matrix.matrix();
const std::array<int, 4> &viewport = camera.get_viewport(); const std::array<int, 4> &viewport = camera.get_viewport();
// BBS: add logic for mmu segmentation rendering // BBS: add logic for mmu segmentation rendering
auto render_body = [&]() { auto render_body = [&]() {
@ -867,7 +864,6 @@ void GLVolume::render(const Transform3d& view_matrix, bool with_outline, const s
if (mv->mmu_segmentation_facets.empty()) if (mv->mmu_segmentation_facets.empty())
break; break;
std::vector<std::array<float, 4>> colors = GUI::wxGetApp().plater()->get_extruders_colors();
if (colors.size() == 1) { if (colors.size() == 1) {
break; break;
} }
@ -895,12 +891,11 @@ void GLVolume::render(const Transform3d& view_matrix, bool with_outline, const s
const auto shader = GUI::wxGetApp().get_current_shader(); const auto shader = GUI::wxGetApp().get_current_shader();
if (color_volume && !picking) { if (color_volume && !picking) {
std::vector<std::array<float, 4>> colors = GUI::wxGetApp().plater()->get_extruders_colors();
//when force_transparent, we need to keep the alpha //when force_transparent, we need to keep the alpha
auto cp_colors = colors;
if (force_native_color && (render_color[3] < 1.0)) { if (force_native_color && (render_color[3] < 1.0)) {
for (int index = 0; index < colors.size(); index ++) for (int index = 0; index < colors.size(); index ++)
colors[index][3] = render_color[3]; cp_colors[index][3] = render_color[3];
} }
for (int idx = 0; idx < mmuseg_ivas.size(); idx++) { for (int idx = 0; idx < mmuseg_ivas.size(); idx++) {
GLIndexedVertexArray* iva = &mmuseg_ivas[idx]; GLIndexedVertexArray* iva = &mmuseg_ivas[idx];
@ -912,23 +907,20 @@ void GLVolume::render(const Transform3d& view_matrix, bool with_outline, const s
ModelObject* mo = model_objects[object_idx()]; ModelObject* mo = model_objects[object_idx()];
ModelVolume* mv = mo->volumes[volume_idx()]; ModelVolume* mv = mo->volumes[volume_idx()];
int extruder_id = mv->extruder_id(); int extruder_id = mv->extruder_id();
//shader->set_uniform("uniform_color", colors[extruder_id - 1]);
//to make black not too hard too see //to make black not too hard too see
if (extruder_id <= 0) { extruder_id = 1; } if (extruder_id <= 0) { extruder_id = 1; }
std::array<float, 4> new_color = adjust_color_for_rendering(colors[extruder_id - 1]); std::array<float, 4> new_color = adjust_color_for_rendering(cp_colors[extruder_id - 1]);
shader->set_uniform("uniform_color", new_color); shader->set_uniform("uniform_color", new_color);
} }
else { else {
if (idx <= colors.size()) { if (idx <= colors.size()) {
//shader->set_uniform("uniform_color", colors[idx - 1]);
//to make black not too hard too see //to make black not too hard too see
std::array<float, 4> new_color = adjust_color_for_rendering(colors[idx - 1]); std::array<float, 4> new_color = adjust_color_for_rendering(cp_colors[idx - 1]);
shader->set_uniform("uniform_color", new_color); shader->set_uniform("uniform_color", new_color);
} }
else { else {
//shader->set_uniform("uniform_color", colors[0]);
//to make black not too hard too see //to make black not too hard too see
std::array<float, 4> new_color = adjust_color_for_rendering(colors[0]); std::array<float, 4> new_color = adjust_color_for_rendering(cp_colors[0]);
shader->set_uniform("uniform_color", new_color); shader->set_uniform("uniform_color", new_color);
} }
} }
@ -1222,9 +1214,8 @@ bool GLVolume::is_below_printbed() const
return transformed_convex_hull_bounding_box().max.z() < 0.0; return transformed_convex_hull_bounding_box().max.z() < 0.0;
} }
void GLVolume::render_sinking_contours() void GLVolume::render_sinking_contours(const GUI::Camera &camera) {
{ m_sinking_contours.render(camera);
m_sinking_contours.render();
} }
GLWipeTowerVolume::GLWipeTowerVolume(const std::vector<std::array<float, 4>>& colors) GLWipeTowerVolume::GLWipeTowerVolume(const std::vector<std::array<float, 4>>& colors)
@ -1233,7 +1224,10 @@ GLWipeTowerVolume::GLWipeTowerVolume(const std::vector<std::array<float, 4>>& co
m_colors = colors; m_colors = colors;
} }
void GLWipeTowerVolume::render(const Transform3d& view_matrix, bool with_outline,const std::array<float, 4> &body_color) const void GLWipeTowerVolume::render(const GUI::Camera &camera,
const std::vector<std::array<float, 4>> &extruder_colors,
bool with_outline,
const std::array<float, 4> &body_color) const
{ {
if (!is_active) if (!is_active)
return; return;
@ -1623,14 +1617,16 @@ int GLVolumeCollection::get_selection_support_threshold_angle(bool &enable_suppo
void GLVolumeCollection::render(GUI::ERenderPipelineStage render_pipeline_stage, void GLVolumeCollection::render(GUI::ERenderPipelineStage render_pipeline_stage,
GLVolumeCollection::ERenderType type, GLVolumeCollection::ERenderType type,
bool disable_cullface, bool disable_cullface,
const Transform3d & view_matrix, const GUI::Camera & camera,
const Transform3d& projection_matrix, const std::vector<std::array<float, 4>>& colors,
std::function<bool(const GLVolume &)> filter_func, std::function<bool(const GLVolume &)> filter_func,
bool with_outline, bool with_outline,
const std::array<float, 4> & body_color, const std::array<float, 4> & body_color,
bool partly_inside_enable, bool partly_inside_enable,
std::vector<double> * printable_heights) const std::vector<double> * printable_heights)
{ {
auto view_matrix = camera.get_view_matrix();
auto projection_matrix = camera.get_projection_matrix();
GLVolumeWithIdAndZList to_render = volumes_to_render(volumes, type, view_matrix, filter_func); GLVolumeWithIdAndZList to_render = volumes_to_render(volumes, type, view_matrix, filter_func);
if (to_render.empty()) if (to_render.empty())
return; return;
@ -1652,7 +1648,6 @@ void GLVolumeCollection::render(GUI::ERenderPipelineStage render_pip
glsafe(::glEnable(GL_CULL_FACE)); glsafe(::glEnable(GL_CULL_FACE));
} }
auto camera = GUI::wxGetApp().plater()->get_camera();
for (GLVolumeWithIdAndZ& volume : to_render) { for (GLVolumeWithIdAndZ& volume : to_render) {
auto world_box = volume.first->transformed_bounding_box(); auto world_box = volume.first->transformed_bounding_box();
if (!camera.getFrustum().intersects(world_box)) { if (!camera.getFrustum().intersects(world_box)) {
@ -1678,7 +1673,7 @@ void GLVolumeCollection::render(GUI::ERenderPipelineStage render_pip
if (volume.first->is_sinking() && !volume.first->is_below_printbed() && if (volume.first->is_sinking() && !volume.first->is_below_printbed() &&
volume.first->hover == GLVolume::HS_None && !volume.first->force_sinking_contours) { volume.first->hover == GLVolume::HS_None && !volume.first->force_sinking_contours) {
GUI::wxGetApp().unbind_shader(); GUI::wxGetApp().unbind_shader();
volume.first->render_sinking_contours(); volume.first->render_sinking_contours(camera);
GUI::wxGetApp().bind_shader(shader); GUI::wxGetApp().bind_shader(shader);
} }
} }
@ -1749,12 +1744,12 @@ void GLVolumeCollection::render(GUI::ERenderPipelineStage render_pip
//BBS: add outline related logic //BBS: add outline related logic
auto red_color = std::array<float, 4>({ 1.0f, 0.0f, 0.0f, 1.0f });//slice_error auto red_color = std::array<float, 4>({ 1.0f, 0.0f, 0.0f, 1.0f });//slice_error
volume.first->render(view_matrix, with_outline&& volume.first->selected, volume.first->slice_error ? red_color : body_color); volume.first->render(camera, colors,with_outline && volume.first->selected, volume.first->slice_error ? red_color : body_color);
} }
else { else {
if (volume.first->selected) { if (volume.first->selected) {
shader->set_uniform("u_model_matrix", volume.first->world_matrix()); shader->set_uniform("u_model_matrix", volume.first->world_matrix());
volume.first->render(view_matrix, false, body_color); volume.first->render(camera, colors, false, body_color);
} }
} }
@ -1775,7 +1770,7 @@ void GLVolumeCollection::render(GUI::ERenderPipelineStage render_pip
(volume.first->hover != GLVolume::HS_None || volume.first->force_sinking_contours)) { (volume.first->hover != GLVolume::HS_None || volume.first->force_sinking_contours)) {
GUI::wxGetApp().unbind_shader(); GUI::wxGetApp().unbind_shader();
glsafe(::glDepthFunc(GL_ALWAYS)); glsafe(::glDepthFunc(GL_ALWAYS));
volume.first->render_sinking_contours(); volume.first->render_sinking_contours(camera);
glsafe(::glDepthFunc(GL_LESS)); glsafe(::glDepthFunc(GL_LESS));
GUI::wxGetApp().bind_shader(shader); GUI::wxGetApp().bind_shader(shader);
} }

View File

@ -52,7 +52,9 @@ class ModelObject;
class ModelVolume; class ModelVolume;
class GLShaderProgram; class GLShaderProgram;
enum ModelInstanceEPrintVolumeState : unsigned char; enum ModelInstanceEPrintVolumeState : unsigned char;
namespace GUI {
struct Camera;
}
using ModelObjectPtrs = std::vector<ModelObject*>; using ModelObjectPtrs = std::vector<ModelObject*>;
struct ObjectFilamentInfo { struct ObjectFilamentInfo {
@ -352,7 +354,7 @@ protected:
public: public:
SinkingContours(GLVolume& volume) : m_parent(volume) {} SinkingContours(GLVolume& volume) : m_parent(volume) {}
void render(); void render(const GUI::Camera &camera);
private: private:
void update(); void update();
@ -585,7 +587,8 @@ public:
void set_range(double low, double high); void set_range(double low, double high);
//BBS: add outline related logic and add virtual specifier //BBS: add outline related logic and add virtual specifier
virtual void render(const Transform3d& view_matrix, virtual void render(const GUI::Camera & camera,
const std::vector<std::array<float, 4>>& colors,
bool with_outline = false, bool with_outline = false,
const std::array<float, 4> &body_color = {1.0f, 1.0f, 1.0f, 1.0f} ) const; const std::array<float, 4> &body_color = {1.0f, 1.0f, 1.0f, 1.0f} ) const;
@ -602,7 +605,7 @@ public:
bool is_sinking() const; bool is_sinking() const;
bool is_below_printbed() const; bool is_below_printbed() const;
void render_sinking_contours(); void render_sinking_contours(const GUI::Camera &camera);
// Return an estimate of the memory consumed by this class. // Return an estimate of the memory consumed by this class.
size_t cpu_memory_used() const { size_t cpu_memory_used() const {
@ -618,7 +621,10 @@ public:
class GLWipeTowerVolume : public GLVolume { class GLWipeTowerVolume : public GLVolume {
public: public:
GLWipeTowerVolume(const std::vector<std::array<float, 4>>& colors); GLWipeTowerVolume(const std::vector<std::array<float, 4>>& colors);
void render(const Transform3d& view_matrix, bool with_outline = false, const std::array<float, 4> &body_color = {1.0f, 1.0f, 1.0f, 1.0f}) const override; void render(const GUI::Camera & camera,
const std::vector<std::array<float, 4>> & colors,
bool with_outline = false,
const std::array<float, 4> & body_color = {1.0f, 1.0f, 1.0f, 1.0f}) const override;
std::vector<GLIndexedVertexArray> iva_per_colors; std::vector<GLIndexedVertexArray> iva_per_colors;
bool IsTransparent(); bool IsTransparent();
@ -731,13 +737,13 @@ public:
void render(GUI::ERenderPipelineStage render_pipeline_stage, void render(GUI::ERenderPipelineStage render_pipeline_stage,
ERenderType type, ERenderType type,
bool disable_cullface, bool disable_cullface,
const Transform3d & view_matrix, const GUI::Camera & camera,
const Transform3d& projection_matrix, const std::vector<std::array<float, 4>>& colors,
std::function<bool(const GLVolume &)> filter_func = std::function<bool(const GLVolume &)>(), std::function<bool(const GLVolume &)> filter_func = std::function<bool(const GLVolume &)>(),
bool with_outline = true, bool with_outline = true,
const std::array<float, 4> & body_color = {1.0f, 1.0f, 1.0f, 1.0f}, const std::array<float, 4> & body_color = {1.0f, 1.0f, 1.0f, 1.0f},
bool partly_inside_enable = true, bool partly_inside_enable = true,
std::vector<double> * printable_heights = nullptr) const; std::vector<double> * printable_heights = nullptr);
// Finalize the initialization of the geometry & indices, // Finalize the initialization of the geometry & indices,
// upload the geometry and indices to OpenGL VBO objects // upload the geometry and indices to OpenGL VBO objects

View File

@ -4261,10 +4261,9 @@ void GCodeViewer::render_shells()
wxGetApp().bind_shader(shader); wxGetApp().bind_shader(shader);
//BBS: reopen cul faces //BBS: reopen cul faces
const auto& camera = wxGetApp().plater()->get_camera(); auto& camera = wxGetApp().plater()->get_camera();
const auto& view_matrix = camera.get_view_matrix(); std::vector<std::array<float, 4>> colors = wxGetApp().plater()->get_extruders_colors();
const auto& projection_matrix = camera.get_projection_matrix(); m_shells.volumes.render(GUI::ERenderPipelineStage::Normal, GLVolumeCollection::ERenderType::Transparent, false, camera, colors);
m_shells.volumes.render(GUI::ERenderPipelineStage::Normal, GLVolumeCollection::ERenderType::Transparent, false, view_matrix, projection_matrix);
wxGetApp().unbind_shader(); wxGetApp().unbind_shader();
glsafe(::glDepthMask(GL_TRUE)); glsafe(::glDepthMask(GL_TRUE));

View File

@ -276,7 +276,7 @@ void GLCanvas3D::LayersEditing::render_variable_layer_height_dialog(const GLCanv
ImGuiWrapper& imgui = *wxGetApp().imgui(); ImGuiWrapper& imgui = *wxGetApp().imgui();
const Size& cnv_size = canvas.get_canvas_size(); const Size& cnv_size = canvas.get_canvas_size();
float zoom = (float)wxGetApp().plater()->get_camera().get_zoom(); float zoom = (float) canvas.get_active_camera().get_zoom();
float left_pos = canvas.m_main_toolbar.get_item("layersediting")->render_left_pos; float left_pos = canvas.m_main_toolbar.get_item("layersediting")->render_left_pos;
float x = 0.5 * cnv_size.get_width() + left_pos * zoom; float x = 0.5 * cnv_size.get_width() + left_pos * zoom;
@ -434,7 +434,7 @@ Rect GLCanvas3D::LayersEditing::get_bar_rect_viewport(const GLCanvas3D& canvas)
const Size& cnv_size = canvas.get_canvas_size(); const Size& cnv_size = canvas.get_canvas_size();
float half_w = 0.5f * (float)cnv_size.get_width(); float half_w = 0.5f * (float)cnv_size.get_width();
float half_h = 0.5f * (float)cnv_size.get_height(); float half_h = 0.5f * (float)cnv_size.get_height();
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom(); float inv_zoom = (float) canvas.get_active_camera().get_inv_zoom();
return { (half_w - thickness_bar_width(canvas)) * inv_zoom, half_h * inv_zoom, half_w * inv_zoom, -half_h * inv_zoom }; return { (half_w - thickness_bar_width(canvas)) * inv_zoom, half_h * inv_zoom, half_w * inv_zoom, -half_h * inv_zoom };
} }
@ -577,7 +577,7 @@ void GLCanvas3D::LayersEditing::render_curve(const Rect & bar_rect)
const float scale_y = bar_rect.get_height() / m_object_max_z; const float scale_y = bar_rect.get_height() / m_object_max_z;
const float x = bar_rect.get_left() + float(m_slicing_parameters->layer_height) * scale_x; const float x = bar_rect.get_left() + float(m_slicing_parameters->layer_height) * scale_x;
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera &camera = m_canvas.get_active_camera();
Transform3d view_matrix = camera.get_view_matrix_for_billboard(); Transform3d view_matrix = camera.get_view_matrix_for_billboard();
Transform3d model_matrix{ Transform3d::Identity() }; Transform3d model_matrix{ Transform3d::Identity() };
@ -664,7 +664,7 @@ void GLCanvas3D::LayersEditing::render_volumes(const GLCanvas3D & canvas, const
shader->set_uniform("z_cursor", float(m_object_max_z) * float(this->get_cursor_z_relative(canvas))); shader->set_uniform("z_cursor", float(m_object_max_z) * float(this->get_cursor_z_relative(canvas)));
shader->set_uniform("z_cursor_band_width", float(this->band_width)); shader->set_uniform("z_cursor_band_width", float(this->band_width));
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera &camera = m_canvas.get_active_camera();
const auto& view_matrix = camera.get_view_matrix(); const auto& view_matrix = camera.get_view_matrix();
const auto& projection_matrix = camera.get_projection_matrix(); const auto& projection_matrix = camera.get_projection_matrix();
shader->set_uniform("projection_matrix", projection_matrix); shader->set_uniform("projection_matrix", projection_matrix);
@ -680,6 +680,7 @@ void GLCanvas3D::LayersEditing::render_volumes(const GLCanvas3D & canvas, const
glsafe(::glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, half_w, half_h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0)); glsafe(::glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, half_w, half_h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0));
glsafe(::glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, m_layers_texture.data.data())); glsafe(::glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, m_layers_texture.data.data()));
glsafe(::glTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, half_w, half_h, GL_RGBA, GL_UNSIGNED_BYTE, m_layers_texture.data.data() + m_layers_texture.width * m_layers_texture.height * 4)); glsafe(::glTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, half_w, half_h, GL_RGBA, GL_UNSIGNED_BYTE, m_layers_texture.data.data() + m_layers_texture.width * m_layers_texture.height * 4));
std::vector<std::array<float, 4>> colors = m_canvas.get_active_colors();
for (GLVolume* glvolume : volumes.volumes) { for (GLVolume* glvolume : volumes.volumes) {
// Render the object using the layer editing shader and texture. // Render the object using the layer editing shader and texture.
if (!glvolume->is_active || glvolume->composite_id.object_id != this->last_object_id || glvolume->is_modifier) if (!glvolume->is_active || glvolume->composite_id.object_id != this->last_object_id || glvolume->is_modifier)
@ -692,7 +693,7 @@ void GLCanvas3D::LayersEditing::render_volumes(const GLCanvas3D & canvas, const
shader->set_uniform("view_model_matrix", view_model_matrix); shader->set_uniform("view_model_matrix", view_model_matrix);
shader->set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose()); shader->set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
glvolume->render(view_matrix); glvolume->render(camera, colors);
} }
// Revert back to the previous shader. // Revert back to the previous shader.
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
@ -867,7 +868,7 @@ void GLCanvas3D::Labels::render(const std::vector<const ModelInstance*>& sorted_
if (!m_enabled || !is_shown() || m_canvas.get_gizmos_manager().is_running()) if (!m_enabled || !is_shown() || m_canvas.get_gizmos_manager().is_running())
return; return;
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera &camera = m_canvas.get_active_camera();
const Model* model = m_canvas.get_model(); const Model* model = m_canvas.get_model();
if (model == nullptr) if (model == nullptr)
return; return;
@ -1134,7 +1135,7 @@ void GLCanvas3D::SequentialPrintClearance::render()
wxGetApp().bind_shader(shader); wxGetApp().bind_shader(shader);
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera &camera = m_canvas.get_active_camera();
shader->set_uniform("view_model_matrix", camera.get_view_matrix()); shader->set_uniform("view_model_matrix", camera.get_view_matrix());
shader->set_uniform("projection_matrix", camera.get_projection_matrix()); shader->set_uniform("projection_matrix", camera.get_projection_matrix());
@ -1327,8 +1328,10 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D &bed)
, m_show_picking_texture(false) , m_show_picking_texture(false)
#endif // ENABLE_RENDER_PICKING_PASS #endif // ENABLE_RENDER_PICKING_PASS
, m_render_sla_auxiliaries(true) , m_render_sla_auxiliaries(true)
, m_layers_editing(*this)
, m_labels(*this) , m_labels(*this)
, m_slope(m_volumes) , m_slope(m_volumes)
, m_sequential_print_clearance(*this)
{ {
if (m_canvas != nullptr) { if (m_canvas != nullptr) {
m_timer.SetOwner(m_canvas); m_timer.SetOwner(m_canvas);
@ -1817,7 +1820,7 @@ void GLCanvas3D::set_model(Model* model)
void GLCanvas3D::bed_shape_changed() void GLCanvas3D::bed_shape_changed()
{ {
refresh_camera_scene_box(); refresh_camera_scene_box();
wxGetApp().plater()->get_camera().requires_zoom_to_bed = true; get_active_camera().requires_zoom_to_bed = true;
m_dirty = true; m_dirty = true;
} }
@ -1848,7 +1851,7 @@ void GLCanvas3D::set_color_by(const std::string &value) {
void GLCanvas3D::refresh_camera_scene_box() void GLCanvas3D::refresh_camera_scene_box()
{ {
wxGetApp().plater()->get_camera().set_scene_box(scene_bounding_box()); get_active_camera().set_scene_box(scene_bounding_box());
} }
BoundingBoxf3 GLCanvas3D::assembly_view_cur_bounding_box() const { BoundingBoxf3 GLCanvas3D::assembly_view_cur_bounding_box() const {
@ -2083,7 +2086,7 @@ void GLCanvas3D::zoom_to_plate(int plate_idx)
void GLCanvas3D::select_view(const std::string& direction) void GLCanvas3D::select_view(const std::string& direction)
{ {
wxGetApp().plater()->get_camera().select_view(direction); get_active_camera().select_view(direction);
if (m_canvas != nullptr) if (m_canvas != nullptr)
m_canvas->Refresh(); m_canvas->Refresh();
} }
@ -2188,7 +2191,7 @@ void GLCanvas3D::render(bool only_init)
// to preview, this was called before canvas had its final size. It reported zero width // to preview, this was called before canvas had its final size. It reported zero width
// and the viewport was set incorrectly, leading to tripping glAsserts further down // and the viewport was set incorrectly, leading to tripping glAsserts further down
// the road (in apply_projection). That's why the minimum size is forced to 10. // the road (in apply_projection). That's why the minimum size is forced to 10.
Camera& camera = wxGetApp().plater()->get_camera(); Camera& camera = get_active_camera();
camera.apply_viewport(0, 0, std::max(10u, (unsigned int)cnv_size.get_width()), std::max(10u, (unsigned int)cnv_size.get_height())); camera.apply_viewport(0, 0, std::max(10u, (unsigned int)cnv_size.get_width()), std::max(10u, (unsigned int)cnv_size.get_height()));
if (camera.requires_zoom_to_bed) { if (camera.requires_zoom_to_bed) {
@ -3178,15 +3181,18 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
} }
update_volumes_colors_by_extruder(); update_volumes_colors_by_extruder();
if (m_selection.is_enabled()) {
// Update selection indices based on the old/new GLVolumeCollection. // Update selection indices based on the old/new GLVolumeCollection.
if (m_selection.get_mode() == Selection::Instance) if (m_selection.get_mode() == Selection::Instance)
m_selection.instances_changed(instance_ids_selected); m_selection.instances_changed(instance_ids_selected);
else else
m_selection.volumes_changed(map_glvolume_old_to_new); m_selection.volumes_changed(map_glvolume_old_to_new);
}
if (m_gizmos.is_enabled()) {
m_gizmos.update_data(); m_gizmos.update_data();
m_gizmos.update_assemble_view_data(); m_gizmos.update_assemble_view_data();
m_gizmos.refresh_on_off_state(); m_gizmos.refresh_on_off_state();
}
// Update the toolbar // Update the toolbar
//BBS: notify the PartPlateList to reload all objects //BBS: notify the PartPlateList to reload all objects
@ -3254,7 +3260,7 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
refresh_camera_scene_box(); refresh_camera_scene_box();
if (m_selection.is_empty()) { if (m_gizmos.is_enabled() && m_selection.is_empty()) {
// If no object is selected, deactivate the active gizmo, if any // If no object is selected, deactivate the active gizmo, if any
// Otherwise it may be shown after cleaning the scene (if it was active while the objects were deleted) // Otherwise it may be shown after cleaning the scene (if it was active while the objects were deleted)
m_gizmos.reset_all_states(); m_gizmos.reset_all_states();
@ -3395,11 +3401,7 @@ void GLCanvas3D::bind_event_handlers()
m_canvas->Bind(wxEVT_RIGHT_DCLICK, &GLCanvas3D::on_mouse, this); m_canvas->Bind(wxEVT_RIGHT_DCLICK, &GLCanvas3D::on_mouse, this);
m_canvas->Bind(wxEVT_PAINT, &GLCanvas3D::on_paint, this); m_canvas->Bind(wxEVT_PAINT, &GLCanvas3D::on_paint, this);
m_canvas->Bind(wxEVT_SET_FOCUS, &GLCanvas3D::on_set_focus, this); m_canvas->Bind(wxEVT_SET_FOCUS, &GLCanvas3D::on_set_focus, this);
m_canvas->Bind(wxEVT_KILL_FOCUS, [this](wxFocusEvent& evt) { m_canvas->Bind(wxEVT_KILL_FOCUS, &GLCanvas3D::on_kill_focus, this);
ImGui::SetWindowFocus(nullptr);
render();
evt.Skip();
});
m_event_handlers_bound = true; m_event_handlers_bound = true;
m_canvas->Bind(wxEVT_GESTURE_PAN, &GLCanvas3D::on_gesture, this); m_canvas->Bind(wxEVT_GESTURE_PAN, &GLCanvas3D::on_gesture, this);
@ -3466,7 +3468,7 @@ void GLCanvas3D::on_idle(wxIdleEvent& evt)
} }
m_dirty |= wxGetApp().plater()->get_collapse_toolbar().update_items_state(); m_dirty |= wxGetApp().plater()->get_collapse_toolbar().update_items_state();
_update_imgui_select_plate_toolbar(); _update_imgui_select_plate_toolbar();
bool mouse3d_controller_applied = wxGetApp().plater()->get_mouse3d_controller().apply(wxGetApp().plater()->get_camera()); bool mouse3d_controller_applied = wxGetApp().plater()->get_mouse3d_controller().apply(get_active_camera());
m_dirty |= mouse3d_controller_applied; m_dirty |= mouse3d_controller_applied;
m_dirty |= wxGetApp().plater()->get_notification_manager()->update_notifications(*this); m_dirty |= wxGetApp().plater()->get_notification_manager()->update_notifications(*this);
auto gizmo = wxGetApp().plater()->get_view3D_canvas3D()->get_gizmos_manager().get_current(); auto gizmo = wxGetApp().plater()->get_view3D_canvas3D()->get_gizmos_manager().get_current();
@ -3762,8 +3764,7 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
//} //}
//case 'I': //case 'I':
//case 'i': { _update_camera_zoom(1.0); break; } //case 'i': { _update_camera_zoom(1.0); break; }
//case 'K':
//case 'k': { wxGetApp().plater()->get_camera().select_next_type(); m_dirty = true; break; }
//case 'L': //case 'L':
//case 'l': { //case 'l': {
//if (!m_main_toolbar.is_enabled()) { //if (!m_main_toolbar.is_enabled()) {
@ -3916,7 +3917,7 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
Vec3d displacement; Vec3d displacement;
if (camera_space) { if (camera_space) {
Eigen::Matrix<double, 3, 3, Eigen::DontAlign> inv_view_3x3 = wxGetApp().plater()->get_camera().get_view_matrix().inverse().matrix().block(0, 0, 3, 3); Eigen::Matrix<double, 3, 3, Eigen::DontAlign> inv_view_3x3 = get_active_camera().get_view_matrix().inverse().matrix().block(0, 0, 3, 3);
displacement = multiplier * (inv_view_3x3 * direction); displacement = multiplier * (inv_view_3x3 * direction);
displacement.z() = 0.0; displacement.z() = 0.0;
} }
@ -4268,15 +4269,15 @@ void GLCanvas3D::on_mouse_wheel(wxMouseEvent& evt)
} }
else { else {
auto cnv_size = get_canvas_size(); auto cnv_size = get_canvas_size();
const Camera& camera = wxGetApp().plater()->get_camera(); Camera& camera = get_active_camera();
auto screen_center_3d_pos = _mouse_to_3d(camera, { cnv_size.get_width() * 0.5, cnv_size.get_height() * 0.5 }); auto screen_center_3d_pos = _mouse_to_3d(camera, { cnv_size.get_width() * 0.5, cnv_size.get_height() * 0.5 });
auto mouse_3d_pos = _mouse_to_3d(camera, {evt.GetX(), evt.GetY()}); auto mouse_3d_pos = _mouse_to_3d(camera, {evt.GetX(), evt.GetY()});
Vec3d displacement = mouse_3d_pos - screen_center_3d_pos; Vec3d displacement = mouse_3d_pos - screen_center_3d_pos;
wxGetApp().plater()->get_camera().translate(displacement); camera.translate(displacement);
auto origin_zoom = wxGetApp().plater()->get_camera().get_zoom(); auto origin_zoom = camera.get_zoom();
_update_camera_zoom(delta); _update_camera_zoom(delta);
auto new_zoom = wxGetApp().plater()->get_camera().get_zoom(); auto new_zoom = camera.get_zoom();
wxGetApp().plater()->get_camera().translate((-displacement) / (new_zoom / origin_zoom)); camera.translate((-displacement) / (new_zoom / origin_zoom));
} }
} }
@ -4383,7 +4384,7 @@ void GLCanvas3D::on_gesture(wxGestureEvent &evt)
if (!m_initialized || !_set_current(true)) if (!m_initialized || !_set_current(true))
return; return;
auto & camera = wxGetApp().plater()->get_camera(); auto & camera = get_active_camera();
if (evt.GetEventType() == wxEVT_GESTURE_PAN) { if (evt.GetEventType() == wxEVT_GESTURE_PAN) {
auto p = evt.GetPosition(); auto p = evt.GetPosition();
auto d = static_cast<wxPanGestureEvent&>(evt).GetDelta(); auto d = static_cast<wxPanGestureEvent&>(evt).GetDelta();
@ -4725,7 +4726,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
Vec3d cur_pos = m_mouse.drag.start_position_3D; Vec3d cur_pos = m_mouse.drag.start_position_3D;
// we do not want to translate objects if the user just clicked on an object while pressing shift to remove it from the selection and then drag // we do not want to translate objects if the user just clicked on an object while pressing shift to remove it from the selection and then drag
if (m_selection.contains_volume(get_first_hover_volume_idx())) { if (m_selection.contains_volume(get_first_hover_volume_idx())) {
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = get_active_camera();
auto camera_up_down_rad_limit = abs(asin(camera.get_dir_forward()(2) / 1.0f)); auto camera_up_down_rad_limit = abs(asin(camera.get_dir_forward()(2) / 1.0f));
if (camera_up_down_rad_limit < PI/20.0f) { if (camera_up_down_rad_limit < PI/20.0f) {
// side view -> move selected volumes orthogonally to camera view direction // side view -> move selected volumes orthogonally to camera view direction
@ -4793,7 +4794,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
if (this->m_canvas_type == ECanvasType::CanvasAssembleView || m_gizmos.get_current_type() == GLGizmosManager::FdmSupports || if (this->m_canvas_type == ECanvasType::CanvasAssembleView || m_gizmos.get_current_type() == GLGizmosManager::FdmSupports ||
m_gizmos.get_current_type() == GLGizmosManager::Seam || m_gizmos.get_current_type() == GLGizmosManager::MmuSegmentation) { m_gizmos.get_current_type() == GLGizmosManager::Seam || m_gizmos.get_current_type() == GLGizmosManager::MmuSegmentation) {
//BBS rotate around target //BBS rotate around target
Camera& camera = wxGetApp().plater()->get_camera(); Camera& camera = get_active_camera();
Vec3d rotate_target = Vec3d::Zero(); Vec3d rotate_target = Vec3d::Zero();
if (!m_selection.is_empty()) if (!m_selection.is_empty())
rotate_target = m_selection.get_bounding_box().center(); rotate_target = m_selection.get_bounding_box().center();
@ -4807,14 +4808,14 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
#ifdef SUPPORT_FEEE_CAMERA #ifdef SUPPORT_FEEE_CAMERA
if (wxGetApp().app_config->get("use_free_camera") == "1") if (wxGetApp().app_config->get("use_free_camera") == "1")
// Virtual track ball (similar to the 3DConnexion mouse). // Virtual track ball (similar to the 3DConnexion mouse).
wxGetApp().plater()->get_camera().rotate_local_around_target(Vec3d(rot.y(), rot.x(), 0.)); get_active_camera().rotate_local_around_target(Vec3d(rot.y(), rot.x(), 0.));
else { else {
#endif #endif
// Forces camera right vector to be parallel to XY plane in case it has been misaligned using the 3D mouse free rotation. // Forces camera right vector to be parallel to XY plane in case it has been misaligned using the 3D mouse free rotation.
// It is cheaper to call this function right away instead of testing wxGetApp().plater()->get_mouse3d_controller().connected(), // It is cheaper to call this function right away instead of testing wxGetApp().plater()->get_mouse3d_controller().connected(),
// which checks an atomics (flushes CPU caches). // which checks an atomics (flushes CPU caches).
// See GH issue #3816. // See GH issue #3816.
Camera& camera = wxGetApp().plater()->get_camera(); Camera& camera = get_active_camera();
bool rotate_limit = current_printer_technology() != ptSLA; bool rotate_limit = current_printer_technology() != ptSLA;
Vec3d rotate_target = m_selection.get_bounding_box().center(); Vec3d rotate_target = m_selection.get_bounding_box().center();
@ -4864,7 +4865,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
if (m_mouse.is_start_position_2D_defined()) { if (m_mouse.is_start_position_2D_defined()) {
// get point in model space at Z = 0 // get point in model space at Z = 0
float z = 0.0f; float z = 0.0f;
Camera& camera = wxGetApp().plater()->get_camera(); Camera& camera = get_active_camera();
const Vec3d& cur_pos = _mouse_to_3d(camera, pos, &z); const Vec3d& cur_pos = _mouse_to_3d(camera, pos, &z);
Vec3d orig = _mouse_to_3d(camera, m_mouse.drag.start_position_2D, &z); Vec3d orig = _mouse_to_3d(camera, m_mouse.drag.start_position_2D, &z);
#ifdef SUPPORT_FREE_CAMERA #ifdef SUPPORT_FREE_CAMERA
@ -5066,6 +5067,13 @@ void GLCanvas3D::on_paint(wxPaintEvent& evt)
this->render(); this->render();
} }
void GLCanvas3D::on_kill_focus(wxFocusEvent &evt)
{
ImGui::SetWindowFocus(nullptr);
render();
evt.Skip();
}
void GLCanvas3D::force_set_focus() { void GLCanvas3D::force_set_focus() {
m_canvas->SetFocus(); m_canvas->SetFocus();
}; };
@ -5547,7 +5555,7 @@ void GLCanvas3D::update_ui_from_settings()
if (new_scaling != orig_scaling) { if (new_scaling != orig_scaling) {
BOOST_LOG_TRIVIAL(debug) << "GLCanvas3D: Scaling factor: " << new_scaling; BOOST_LOG_TRIVIAL(debug) << "GLCanvas3D: Scaling factor: " << new_scaling;
Camera& camera = wxGetApp().plater()->get_camera(); Camera& camera = get_active_camera();
camera.set_zoom(camera.get_zoom() * new_scaling / orig_scaling); camera.set_zoom(camera.get_zoom() * new_scaling / orig_scaling);
_refresh_if_shown_on_screen(); _refresh_if_shown_on_screen();
} }
@ -5603,7 +5611,7 @@ Linef3 GLCanvas3D::mouse_ray(const Point& mouse_pos)
{ {
float z0 = 0.0f; float z0 = 0.0f;
float z1 = 1.0f; float z1 = 1.0f;
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = get_active_camera();
return Linef3(_mouse_to_3d(camera, mouse_pos, &z0), _mouse_to_3d(camera, mouse_pos, &z1)); return Linef3(_mouse_to_3d(camera, mouse_pos, &z0), _mouse_to_3d(camera, mouse_pos, &z1));
} }
@ -5981,12 +5989,12 @@ bool GLCanvas3D::_render_orient_menu(float left, float right, float bottom, floa
//original use center as {0.0}, and top is (canvas_h/2), bottom is (-canvas_h/2), also plus inv_camera //original use center as {0.0}, and top is (canvas_h/2), bottom is (-canvas_h/2), also plus inv_camera
//now change to left_up as {0,0}, and top is 0, bottom is canvas_h //now change to left_up as {0,0}, and top is 0, bottom is canvas_h
#if BBS_TOOLBAR_ON_TOP #if BBS_TOOLBAR_ON_TOP
const float x = left * float(wxGetApp().plater()->get_camera().get_zoom()) + 0.5f * canvas_w; const float x = left * float(get_active_camera().get_zoom()) + 0.5f * canvas_w;
ImGuiWrapper::push_toolbar_style(get_scale()); ImGuiWrapper::push_toolbar_style(get_scale());
imgui->set_next_window_pos(x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f); imgui->set_next_window_pos(x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
#else #else
const float x = canvas_w - m_main_toolbar.get_width(); const float x = canvas_w - m_main_toolbar.get_width();
const float y = 0.5f * canvas_h - top * float(wxGetApp().plater()->get_camera().get_zoom()); const float y = 0.5f * canvas_h - top * float(get_active_camera().get_zoom());
imgui->set_next_window_pos(x, y, ImGuiCond_Always, 1.0f, 0.0f); imgui->set_next_window_pos(x, y, ImGuiCond_Always, 1.0f, 0.0f);
#endif #endif
@ -6066,14 +6074,14 @@ bool GLCanvas3D::_render_arrange_menu(float left, float right, float bottom, flo
//original use center as {0.0}, and top is (canvas_h/2), bottom is (-canvas_h/2), also plus inv_camera //original use center as {0.0}, and top is (canvas_h/2), bottom is (-canvas_h/2), also plus inv_camera
//now change to left_up as {0,0}, and top is 0, bottom is canvas_h //now change to left_up as {0,0}, and top is 0, bottom is canvas_h
#if BBS_TOOLBAR_ON_TOP #if BBS_TOOLBAR_ON_TOP
float zoom = (float)wxGetApp().plater()->get_camera().get_zoom(); float zoom = (float)get_active_camera().get_zoom();
float left_pos = m_main_toolbar.get_item("arrange")->render_left_pos; float left_pos = m_main_toolbar.get_item("arrange")->render_left_pos;
const float x = 0.5 * canvas_w + left_pos * zoom; const float x = 0.5 * canvas_w + left_pos * zoom;
imgui->set_next_window_pos(x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.0f, 0.0f); imgui->set_next_window_pos(x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.0f, 0.0f);
#else #else
const float x = canvas_w - m_main_toolbar.get_width(); const float x = canvas_w - m_main_toolbar.get_width();
const float y = 0.5f * canvas_h - top * float(wxGetApp().plater()->get_camera().get_zoom()); const float y = 0.5f * canvas_h - top * float(get_active_camera().get_zoom());
imgui->set_next_window_pos(x, y, ImGuiCond_Always, 1.0f, 0.0f); imgui->set_next_window_pos(x, y, ImGuiCond_Always, 1.0f, 0.0f);
#endif #endif
@ -6249,7 +6257,7 @@ void GLCanvas3D::_render_3d_navigator()
const float camDistance = 8.f; const float camDistance = 8.f;
ImGuizmo::SetID(0); ImGuizmo::SetID(0);
Camera & camera = wxGetApp().plater()->get_camera(); Camera & camera = get_active_camera();
Transform3d m = Transform3d::Identity(); Transform3d m = Transform3d::Identity();
m.matrix().block(0, 0, 3, 3) = camera.get_view_rotation().toRotationMatrix(); m.matrix().block(0, 0, 3, 3) = camera.get_view_rotation().toRotationMatrix();
// Rotate along X and Z axis for 90 degrees to have Y-up // Rotate along X and Z axis for 90 degrees to have Y-up
@ -6925,16 +6933,38 @@ BoundingBoxf3 GLCanvas3D::_max_bounding_box(bool include_gizmos, bool include_be
void GLCanvas3D::_zoom_to_box(const BoundingBoxf3& box, double margin_factor) void GLCanvas3D::_zoom_to_box(const BoundingBoxf3& box, double margin_factor)
{ {
wxGetApp().plater()->get_camera().zoom_to_box(box, margin_factor); get_active_camera().zoom_to_box(box, margin_factor);
m_dirty = true; m_dirty = true;
} }
void GLCanvas3D::_update_camera_zoom(double zoom) void GLCanvas3D::_update_camera_zoom(double zoom)
{ {
wxGetApp().plater()->get_camera().update_zoom(zoom); get_active_camera().update_zoom(zoom);
m_dirty = true; m_dirty = true;
} }
Camera &GLCanvas3D::get_active_camera()
{
/*if (m_canvas_type == CanvasThumbnailView) {
return wxGetApp().plater()->get_thumbnail_camera();
} else {*/
return wxGetApp().plater()->get_camera(); // global camera
//}
}
const Camera &GLCanvas3D::get_active_camera() const
{
/*if (m_canvas_type == CanvasThumbnailView) {
return wxGetApp().plater()->get_thumbnail_camera();
} else {*/
return wxGetApp().plater()->get_camera(); // global camera
//}
}
std::vector<std::array<float, 4>> GLCanvas3D::get_active_colors() {
return GUI::wxGetApp().plater()->get_extruders_colors();
}
void GLCanvas3D::_refresh_if_shown_on_screen() void GLCanvas3D::_refresh_if_shown_on_screen()
{ {
if (_is_shown_on_screen()) { if (_is_shown_on_screen()) {
@ -6962,7 +6992,7 @@ void GLCanvas3D::_picking_pass()
picking_camera.apply_viewport(0, 0, 1, 1); picking_camera.apply_viewport(0, 0, 1, 1);
float pick_eye_z = 0.0f; float pick_eye_z = 0.0f;
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = get_active_camera();
Vec3d pick_eye = _mouse_to_3d(camera, { m_mouse.position(0), m_mouse.position(1) }, &pick_eye_z); Vec3d pick_eye = _mouse_to_3d(camera, { m_mouse.position(0), m_mouse.position(1) }, &pick_eye_z);
float pick_target_z = 1.0f; float pick_target_z = 1.0f;
@ -6989,7 +7019,7 @@ void GLCanvas3D::_picking_pass()
_render_volumes_for_picking(); _render_volumes_for_picking();
//BBS: remove the bed picking logic //BBS: remove the bed picking logic
//_render_bed_for_picking(!wxGetApp().plater()->get_camera().is_looking_downward()); //_render_bed_for_picking(!get_active_camera().is_looking_downward());
m_gizmos.render_current_gizmo_for_picking_pass(); m_gizmos.render_current_gizmo_for_picking_pass();
@ -7078,7 +7108,7 @@ void GLCanvas3D::_rectangular_selection_picking_pass()
OpenGLManager::FrameBufferModifier picking_frame(*p_ogl_manager, "rectangular_selection_pickingframe", EMSAAType::Disabled); OpenGLManager::FrameBufferModifier picking_frame(*p_ogl_manager, "rectangular_selection_pickingframe", EMSAAType::Disabled);
} }
const auto camera = wxGetApp().plater()->get_camera(); const auto& camera = get_active_camera();
const auto main_camera_type = camera.get_type(); const auto main_camera_type = camera.get_type();
auto& picking_camera = wxGetApp().plater()->get_picking_camera(); auto& picking_camera = wxGetApp().plater()->get_picking_camera();
@ -7087,7 +7117,6 @@ void GLCanvas3D::_rectangular_selection_picking_pass()
picking_camera.set_zoom(camera.get_zoom()); picking_camera.set_zoom(camera.get_zoom());
float pick_eye_z = 0.0f; float pick_eye_z = 0.0f;
const Camera& camera = wxGetApp().plater()->get_camera();
Vec3d pick_eye = _mouse_to_3d(camera, { center.x(), center.y() }, &pick_eye_z); Vec3d pick_eye = _mouse_to_3d(camera, { center.x(), center.y() }, &pick_eye_z);
float pick_target_z = 1.0f; float pick_target_z = 1.0f;
Vec3d pick_target = _mouse_to_3d(camera, { center.x(), center.y() }, &pick_target_z); Vec3d pick_target = _mouse_to_3d(camera, { center.x(), center.y() }, &pick_target_z);
@ -7114,7 +7143,7 @@ void GLCanvas3D::_rectangular_selection_picking_pass()
_render_volumes_for_picking(); _render_volumes_for_picking();
//BBS: remove the bed picking logic //BBS: remove the bed picking logic
//_render_bed_for_picking(!wxGetApp().plater()->get_camera().is_looking_downward()); //_render_bed_for_picking(!get_active_camera().is_looking_downward());
glsafe(::glDisable(GL_SCISSOR_TEST)); glsafe(::glDisable(GL_SCISSOR_TEST));
} }
@ -7351,9 +7380,8 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type, bool with
auto printable_height_option = GUI::wxGetApp().preset_bundle->printers.get_edited_preset().config.option<ConfigOptionFloatsNullable>("extruder_printable_height"); auto printable_height_option = GUI::wxGetApp().preset_bundle->printers.get_edited_preset().config.option<ConfigOptionFloatsNullable>("extruder_printable_height");
const GUI::ERenderPipelineStage render_pipeline_stage = _get_current_render_stage(); const GUI::ERenderPipelineStage render_pipeline_stage = _get_current_render_stage();
const auto& camera = wxGetApp().plater()->get_camera(); const auto& camera = get_active_camera();
const auto& view_matrix = camera.get_view_matrix(); std::vector<std::array<float, 4>> colors = get_active_colors();
const auto& projection_matrix = camera.get_projection_matrix();
if ((GUI::ERenderPipelineStage::Silhouette == render_pipeline_stage) || shader != nullptr) { if ((GUI::ERenderPipelineStage::Silhouette == render_pipeline_stage) || shader != nullptr) {
if (GUI::ERenderPipelineStage::Silhouette != render_pipeline_stage) if (GUI::ERenderPipelineStage::Silhouette != render_pipeline_stage)
{ {
@ -7369,7 +7397,7 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type, bool with
{ {
if (m_picking_enabled && m_layers_editing.is_enabled() && (m_layers_editing.last_object_id != -1) && (m_layers_editing.object_max_z() > 0.0f) && GUI::ERenderPipelineStage::Silhouette != render_pipeline_stage) { if (m_picking_enabled && m_layers_editing.is_enabled() && (m_layers_editing.last_object_id != -1) && (m_layers_editing.object_max_z() > 0.0f) && GUI::ERenderPipelineStage::Silhouette != render_pipeline_stage) {
int object_id = m_layers_editing.last_object_id; int object_id = m_layers_editing.last_object_id;
m_volumes.render(render_pipeline_stage, type, false, view_matrix, projection_matrix, [object_id](const GLVolume& volume) { m_volumes.render(render_pipeline_stage, type, false, camera, colors, [object_id](const GLVolume &volume) {
// Which volume to paint without the layer height profile shader? // Which volume to paint without the layer height profile shader?
return volume.is_active && (volume.is_modifier || volume.composite_id.object_id != object_id); return volume.is_active && (volume.is_modifier || volume.composite_id.object_id != object_id);
}); });
@ -7384,7 +7412,9 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type, bool with
}*/ }*/
//BBS:add assemble view related logic //BBS:add assemble view related logic
// do not cull backfaces to show broken geometry, if any // do not cull backfaces to show broken geometry, if any
m_volumes.render(render_pipeline_stage, type, m_picking_enabled, view_matrix, projection_matrix, [this, canvas_type](const GLVolume& volume) { m_volumes.render(
render_pipeline_stage, type, m_picking_enabled, camera,
colors,[this, canvas_type](const GLVolume &volume) {
if (canvas_type == ECanvasType::CanvasAssembleView) { if (canvas_type == ECanvasType::CanvasAssembleView) {
return !volume.is_modifier && !volume.is_wipe_tower; return !volume.is_modifier && !volume.is_wipe_tower;
} }
@ -7418,7 +7448,9 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type, bool with
shader->set_uniform("show_wireframe", false); shader->set_uniform("show_wireframe", false);
}*/ }*/
//BBS:add assemble view related logic //BBS:add assemble view related logic
m_volumes.render(render_pipeline_stage, type, false, view_matrix, projection_matrix, [this, canvas_type](const GLVolume& volume) { m_volumes.render(
render_pipeline_stage, type, false, camera, colors,
[this, canvas_type](const GLVolume &volume) {
if (canvas_type == ECanvasType::CanvasAssembleView) { if (canvas_type == ECanvasType::CanvasAssembleView) {
return !volume.is_modifier; return !volume.is_modifier;
} }
@ -7787,10 +7819,11 @@ void GLCanvas3D::_render_volumes_for_picking() const
// do not cull backfaces to show broken geometry, if any // do not cull backfaces to show broken geometry, if any
glsafe(::glDisable(GL_CULL_FACE)); glsafe(::glDisable(GL_CULL_FACE));
const Camera& camera = wxGetApp().plater()->get_picking_camera(); Camera& camera = wxGetApp().plater()->get_picking_camera();
const auto& view_matrix = camera.get_view_matrix(); const auto& view_matrix = camera.get_view_matrix();
const auto& proj_matrix = camera.get_projection_matrix(); const auto& proj_matrix = camera.get_projection_matrix();
shader->set_uniform("projection_matrix", proj_matrix); shader->set_uniform("projection_matrix", proj_matrix);
std::vector<std::array<float, 4>> colors;
for (size_t type = 0; type < 2; ++ type) { for (size_t type = 0; type < 2; ++ type) {
GLVolumeWithIdAndZList to_render = volumes_to_render(m_volumes.volumes, (type == 0) ? GLVolumeCollection::ERenderType::Opaque : GLVolumeCollection::ERenderType::Transparent, view_matrix); GLVolumeWithIdAndZList to_render = volumes_to_render(m_volumes.volumes, (type == 0) ? GLVolumeCollection::ERenderType::Opaque : GLVolumeCollection::ERenderType::Transparent, view_matrix);
for (const GLVolumeWithIdAndZ& volume : to_render) for (const GLVolumeWithIdAndZ& volume : to_render)
@ -7813,7 +7846,7 @@ void GLCanvas3D::_render_volumes_for_picking() const
std::array<float, 4> t_color{ (GLfloat)r * INV_255, (GLfloat)g * INV_255, (GLfloat)b * INV_255, (GLfloat)a * INV_255 }; std::array<float, 4> t_color{ (GLfloat)r * INV_255, (GLfloat)g * INV_255, (GLfloat)b * INV_255, (GLfloat)a * INV_255 };
shader->set_uniform("uniform_color", t_color); shader->set_uniform("uniform_color", t_color);
volume.first->picking = true; volume.first->picking = true;
volume.first->render(view_matrix); volume.first->render(camera, colors); // colors is no use here
volume.first->picking = false; volume.first->picking = false;
} }
} }
@ -7826,7 +7859,7 @@ void GLCanvas3D::_render_volumes_for_picking() const
void GLCanvas3D::_render_current_gizmo() const void GLCanvas3D::_render_current_gizmo() const
{ {
//BBS update inv_zoom //BBS update inv_zoom
GLGizmoBase::INV_ZOOM = (float)wxGetApp().plater()->get_camera().get_inv_zoom(); GLGizmoBase::INV_ZOOM = (float)get_active_camera().get_inv_zoom();
m_gizmos.render_current_gizmo(); m_gizmos.render_current_gizmo();
} }
@ -7860,7 +7893,7 @@ void GLCanvas3D::_render_main_toolbar()
return; return;
Size cnv_size = get_canvas_size(); Size cnv_size = get_canvas_size();
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom(); float inv_zoom = (float)get_active_camera().get_inv_zoom();
#if BBS_TOOLBAR_ON_TOP #if BBS_TOOLBAR_ON_TOP
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar(); GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
@ -8243,7 +8276,7 @@ void GLCanvas3D::_render_assemble_view_toolbar() const
return; return;
Size cnv_size = get_canvas_size(); Size cnv_size = get_canvas_size();
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom(); float inv_zoom = (float)get_active_camera().get_inv_zoom();
#if BBS_TOOLBAR_ON_TOP #if BBS_TOOLBAR_ON_TOP
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar(); GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
@ -8287,7 +8320,7 @@ void GLCanvas3D::_render_return_toolbar()
float window_pos_y = 14.0f; float window_pos_y = 14.0f;
{//solve ui overlap issue {//solve ui overlap issue
if (m_canvas_type == ECanvasType::CanvasView3D) { if (m_canvas_type == ECanvasType::CanvasView3D) {
float zoom = (float) wxGetApp().plater()->get_camera().get_zoom(); float zoom = (float) get_active_camera().get_zoom();
float left_pos = m_main_toolbar.get_item("add")->render_left_pos; float left_pos = m_main_toolbar.get_item("add")->render_left_pos;
const float toolbar_x = 0.5 * canvas_w + left_pos * zoom; const float toolbar_x = 0.5 * canvas_w + left_pos * zoom;
const float margin = 5; const float margin = 5;
@ -8418,7 +8451,7 @@ void GLCanvas3D::_render_separator_toolbar_right() const
return; return;
Size cnv_size = get_canvas_size(); Size cnv_size = get_canvas_size();
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom(); float inv_zoom = (float)get_active_camera().get_inv_zoom();
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar(); GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0.0f; float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0.0f;
@ -8439,7 +8472,7 @@ void GLCanvas3D::_render_separator_toolbar_left() const
return; return;
Size cnv_size = get_canvas_size(); Size cnv_size = get_canvas_size();
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom(); float inv_zoom = (float)get_active_camera().get_inv_zoom();
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar(); GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0.0f; float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0.0f;
@ -8459,7 +8492,7 @@ void GLCanvas3D::_render_collapse_toolbar() const
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar(); GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
Size cnv_size = get_canvas_size(); Size cnv_size = get_canvas_size();
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom(); float inv_zoom = (float)get_active_camera().get_inv_zoom();
float top = 0.5f * (float)cnv_size.get_height() * inv_zoom; float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
//float left = (0.5f * (float)cnv_size.get_width() - (float)collapse_toolbar.get_width() - band) * inv_zoom; //float left = (0.5f * (float)cnv_size.get_width() - (float)collapse_toolbar.get_width() - band) * inv_zoom;
@ -8857,7 +8890,7 @@ void GLCanvas3D::_render_camera_target() const
wxGetApp().bind_shader(p_flat_shader); wxGetApp().bind_shader(p_flat_shader);
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = get_active_camera();
const auto& view_matrix = camera.get_view_matrix(); const auto& view_matrix = camera.get_view_matrix();
const auto& proj_matrix = camera.get_projection_matrix(); const auto& proj_matrix = camera.get_projection_matrix();
@ -8866,7 +8899,7 @@ void GLCanvas3D::_render_camera_target() const
const auto& p_ogl_manager = wxGetApp().get_opengl_manager(); const auto& p_ogl_manager = wxGetApp().get_opengl_manager();
p_ogl_manager.set_line_width(2.0f); p_ogl_manager.set_line_width(2.0f);
const Vec3d& target = wxGetApp().plater()->get_camera().get_target(); const Vec3d& target = get_active_camera().get_target();
const float scale = 2.0f * half_length; const float scale = 2.0f * half_length;
Transform3d model_matrix{ Transform3d::Identity() }; Transform3d model_matrix{ Transform3d::Identity() };
@ -9015,7 +9048,7 @@ void GLCanvas3D::_render_sla_slices()
} }
for (const SLAPrintObject::Instance& inst : obj->instances()) { for (const SLAPrintObject::Instance& inst : obj->instances()) {
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = get_active_camera();
const Transform3d view_model_matrix = camera.get_view_matrix() * const Transform3d view_model_matrix = camera.get_view_matrix() *
Geometry::assemble_transform(Vec3d(unscale<double>(inst.shift.x()), unscale<double>(inst.shift.y()), 0.0), Geometry::assemble_transform(Vec3d(unscale<double>(inst.shift.x()), unscale<double>(inst.shift.y()), 0.0),
inst.rotation * Vec3d::UnitZ(), Vec3d::Ones(), inst.rotation * Vec3d::UnitZ(), Vec3d::Ones(),
@ -9867,7 +9900,7 @@ void GLCanvas3D::_render_silhouette_effect()
const auto& picking_color = wxGetApp().get_picking_color(); const auto& picking_color = wxGetApp().get_picking_color();
p_silhouette_shader->set_uniform("u_base_color", picking_color); p_silhouette_shader->set_uniform("u_base_color", picking_color);
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = get_active_camera();
const Transform3d& view_matrix = camera.get_view_matrix(); const Transform3d& view_matrix = camera.get_view_matrix();
const Transform3d& projection_matrix = camera.get_projection_matrix(); const Transform3d& projection_matrix = camera.get_projection_matrix();
const Matrix4d view_proj = projection_matrix.matrix() * view_matrix.matrix(); const Matrix4d view_proj = projection_matrix.matrix() * view_matrix.matrix();
@ -10019,6 +10052,22 @@ void GLCanvas3D::_composite_silhouette_effect()
// BBS: end composite silhouette // BBS: end composite silhouette
} }
bool GLCanvas3D::is_volume_in_plate_boundingbox(const GLVolume &v, int plate_idx, const BoundingBoxf3 &plate_build_volume)
{
bool ret = v.printable;
if (plate_idx >= 0) {
bool contained = false;
BoundingBoxf3 plate_bbox = plate_build_volume;
plate_bbox.min(2) = -1e10;
const BoundingBoxf3 &volume_bbox = v.transformed_convex_hull_bounding_box();
if (plate_bbox.contains(volume_bbox) && (volume_bbox.max(2) > 0)) { contained = true; }
ret &= contained;
} else {
ret &= (!v.shader_outside_printer_detection_enabled || !v.is_outside);
}
return ret;
}
void GLCanvas3D::_init_fullscreen_mesh() void GLCanvas3D::_init_fullscreen_mesh()
{ {
if (s_full_screen_mesh.is_initialized()) { if (s_full_screen_mesh.is_initialized()) {
@ -10169,7 +10218,7 @@ void GLCanvas3D::_debug_draw_camera(const Camera& t_camera)
wxGetApp().bind_shader(p_flat_shader); wxGetApp().bind_shader(p_flat_shader);
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = get_active_camera();
const auto& view_matrix = camera.get_view_matrix(); const auto& view_matrix = camera.get_view_matrix();
const auto& proj_matrix = camera.get_projection_matrix(); const auto& proj_matrix = camera.get_projection_matrix();
auto mv = view_matrix.matrix() * final_model_matrix.matrix(); auto mv = view_matrix.matrix() * final_model_matrix.matrix();
@ -10211,7 +10260,7 @@ void GLCanvas3D::_debug_draw_aabb()
glsafe(::glLineWidth(2.0f)); glsafe(::glLineWidth(2.0f));
wxGetApp().bind_shader(p_flat_shader); wxGetApp().bind_shader(p_flat_shader);
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = get_active_camera();
const auto& view_matrix = camera.get_view_matrix(); const auto& view_matrix = camera.get_view_matrix();
const auto& proj_matrix = camera.get_projection_matrix(); const auto& proj_matrix = camera.get_projection_matrix();
p_flat_shader->set_uniform("projection_matrix", proj_matrix); p_flat_shader->set_uniform("projection_matrix", proj_matrix);
@ -10304,37 +10353,12 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
int plate_idx = thumbnail_params.plate_id; int plate_idx = thumbnail_params.plate_id;
PartPlate* plate = partplate_list.get_plate(plate_idx); PartPlate* plate = partplate_list.get_plate(plate_idx);
plate_build_volume = plate->get_build_volume(); plate_build_volume = plate->get_build_volume();
plate_build_volume.min(0) -= Slic3r::BuildVolume::SceneEpsilon;
plate_build_volume.min(1) -= Slic3r::BuildVolume::SceneEpsilon;
plate_build_volume.min(2) -= Slic3r::BuildVolume::SceneEpsilon;
plate_build_volume.max(0) += Slic3r::BuildVolume::SceneEpsilon;
plate_build_volume.max(1) += Slic3r::BuildVolume::SceneEpsilon;
plate_build_volume.max(2) += Slic3r::BuildVolume::SceneEpsilon;
/*if (m_config != nullptr) {
double h = m_config->opt_float("printable_height");
plate_build_volume.min(2) = std::min(plate_build_volume.min(2), -h);
plate_build_volume.max(2) = std::max(plate_build_volume.max(2), h);
}*/
auto is_visible = [plate_idx, plate_build_volume](const GLVolume& v) {
bool ret = v.printable;
if (plate_idx >= 0) {
bool contained = false;
BoundingBoxf3 plate_bbox = plate_build_volume;
plate_bbox.min(2) = -1e10;
const BoundingBoxf3& volume_bbox = v.transformed_convex_hull_bounding_box();
if (plate_bbox.contains(volume_bbox) && (volume_bbox.max(2) > 0)) { contained = true; }
ret &= contained;
}
else {
ret &= (!v.shader_outside_printer_detection_enabled || !v.is_outside);
}
return ret;
};
for (GLVolume* vol : volumes.volumes) { for (GLVolume* vol : volumes.volumes) {
if (!vol->is_modifier && !vol->is_wipe_tower && (!thumbnail_params.parts_only || vol->composite_id.volume_id >= 0)) { if (!vol->is_modifier && !vol->is_wipe_tower && (!thumbnail_params.parts_only || vol->composite_id.volume_id >= 0)) {
if (is_visible(*vol)) { visible_volumes.emplace_back(vol); } if (is_volume_in_plate_boundingbox(*vol, plate_idx, plate_build_volume)) {
visible_volumes.emplace_back(vol);
}
} }
} }
BOOST_LOG_TRIVIAL(info) << boost::format("render_thumbnail: plate_idx %1% volumes size %2%, shader %3%, use_top_view=%4%, for_picking=%5%") % plate_idx % BOOST_LOG_TRIVIAL(info) << boost::format("render_thumbnail: plate_idx %1% volumes size %2%, shader %3%, use_top_view=%4%, for_picking=%5%") % plate_idx %

View File

@ -282,7 +282,7 @@ class GLCanvas3D
float last_z{ 0.0f }; float last_z{ 0.0f };
LayerHeightEditActionType last_action{ LAYER_HEIGHT_EDIT_ACTION_INCREASE }; LayerHeightEditActionType last_action{ LAYER_HEIGHT_EDIT_ACTION_INCREASE };
LayersEditing() = default; LayersEditing(GLCanvas3D &canvas) : m_canvas(canvas) {}
~LayersEditing(); ~LayersEditing();
void init(); void init();
@ -326,6 +326,9 @@ class GLCanvas3D
void update_slicing_parameters(); void update_slicing_parameters();
static float thickness_bar_width(const GLCanvas3D& canvas); static float thickness_bar_width(const GLCanvas3D& canvas);
private:
GLCanvas3D &m_canvas;
}; };
struct Mouse struct Mouse
@ -724,6 +727,7 @@ public:
public: public:
//BBS: add the height logic //BBS: add the height logic
SequentialPrintClearance(GLCanvas3D &m_canvas) : m_canvas(m_canvas) {}
~SequentialPrintClearance(); ~SequentialPrintClearance();
void set_polygons(const Polygons& polygons, const std::vector<std::pair<Polygon, float>>& height_polygons); void set_polygons(const Polygons& polygons, const std::vector<std::pair<Polygon, float>>& height_polygons);
void set_render_fill(bool render_fill) { m_render_fill = render_fill; } void set_render_fill(bool render_fill) { m_render_fill = render_fill; }
@ -732,6 +736,9 @@ public:
void reset(); void reset();
friend class GLCanvas3D; friend class GLCanvas3D;
private:
GLCanvas3D &m_canvas;
}; };
SequentialPrintClearance m_sequential_print_clearance; SequentialPrintClearance m_sequential_print_clearance;
@ -1010,6 +1017,7 @@ public:
void on_mouse(wxMouseEvent& evt); void on_mouse(wxMouseEvent& evt);
void on_gesture(wxGestureEvent& evt); void on_gesture(wxGestureEvent& evt);
void on_paint(wxPaintEvent& evt); void on_paint(wxPaintEvent& evt);
void on_kill_focus(wxFocusEvent &evt);
void on_set_focus(wxFocusEvent& evt); void on_set_focus(wxFocusEvent& evt);
void force_set_focus(); void force_set_focus();
@ -1164,6 +1172,10 @@ public:
void mark_context_dirty(); void mark_context_dirty();
Camera & get_active_camera();
const Camera & get_active_camera() const;
std::vector<std::array<float, 4>> get_active_colors();
private: private:
bool _is_shown_on_screen() const; bool _is_shown_on_screen() const;
@ -1187,7 +1199,6 @@ private:
void _zoom_to_box(const BoundingBoxf3& box, double margin_factor = DefaultCameraZoomToBoxMarginFactor); void _zoom_to_box(const BoundingBoxf3& box, double margin_factor = DefaultCameraZoomToBoxMarginFactor);
void _update_camera_zoom(double zoom); void _update_camera_zoom(double zoom);
void _refresh_if_shown_on_screen(); void _refresh_if_shown_on_screen();
void _picking_pass(); void _picking_pass();
@ -1300,7 +1311,7 @@ private:
void _init_unit_cube(); void _init_unit_cube();
void _append_to_frame_callback(const FrameCallback& cb); void _append_to_frame_callback(const FrameCallback& cb);
static bool is_volume_in_plate_boundingbox(const GLVolume &v, int plate_idx, const BoundingBoxf3 &plate_build_volume);
static void _init_fullscreen_mesh(); static void _init_fullscreen_mesh();
static void _rebuild_postprocessing_pipeline(const std::shared_ptr<OpenGLManager>& p_ogl_manager, const std::string& input_framebuffer_name, std::string& output_framebuffer_name, uint32_t width, uint32_t height); static void _rebuild_postprocessing_pipeline(const std::shared_ptr<OpenGLManager>& p_ogl_manager, const std::string& input_framebuffer_name, std::string& output_framebuffer_name, uint32_t width, uint32_t height);

View File

@ -124,9 +124,9 @@ void GLGizmoFdmSupports::render_painter_gizmo() const
{ {
m_support_volume->set_render_color({ 0.f, 0.7f, 0.f, 0.7f }); m_support_volume->set_render_color({ 0.f, 0.7f, 0.f, 0.7f });
const auto& camera = GUI::wxGetApp().plater()->get_camera(); const auto & camera = m_parent.get_active_camera();
const auto& view_matrix = camera.get_view_matrix(); std::vector<std::array<float, 4>> colors = m_parent.get_active_colors();
m_support_volume->render(view_matrix); m_support_volume->render(camera, colors);
} }
m_c->object_clipper()->render_cut(); m_c->object_clipper()->render_cut();

View File

@ -10889,6 +10889,8 @@ void Plater::render_project_state_debug_window() const { p->render_project_state
Sidebar& Plater::sidebar() { return *p->sidebar; } Sidebar& Plater::sidebar() { return *p->sidebar; }
const Model& Plater::model() const { return p->model; } const Model& Plater::model() const { return p->model; }
Model& Plater::model() { return p->model; } Model& Plater::model() { return p->model; }
Bed3D & Plater::bed() { return p->bed; }
BackgroundSlicingProcess &Plater::background_process() { return p->background_process; }
const Print& Plater::fff_print() const { return p->fff_print; } const Print& Plater::fff_print() const { return p->fff_print; }
Print& Plater::fff_print() { return p->fff_print; } Print& Plater::fff_print() { return p->fff_print; }
const SLAPrint& Plater::sla_print() const { return p->sla_print; } const SLAPrint& Plater::sla_print() const { return p->sla_print; }

View File

@ -37,7 +37,7 @@ class ComboBox;
class Button; class Button;
namespace Slic3r { namespace Slic3r {
class BackgroundSlicingProcess;
class BuildVolume; class BuildVolume;
class Model; class Model;
class ModelObject; class ModelObject;
@ -81,6 +81,7 @@ class PlaterPresetComboBox;
class PartPlateList; class PartPlateList;
class SyncNozzleAndAmsDialog; class SyncNozzleAndAmsDialog;
class FinishSyncAmsDialog; class FinishSyncAmsDialog;
class Bed3D;
using t_optgroups = std::vector <std::shared_ptr<ConfigOptionsGroup>>; using t_optgroups = std::vector <std::shared_ptr<ConfigOptionsGroup>>;
class Plater; class Plater;
@ -291,10 +292,12 @@ public:
Sidebar& sidebar(); Sidebar& sidebar();
const Model& model() const; const Model& model() const;
Model& model(); Model& model();
Bed3D& bed();
const Print& fff_print() const; const Print& fff_print() const;
Print& fff_print(); Print& fff_print();
const SLAPrint& sla_print() const; const SLAPrint& sla_print() const;
SLAPrint& sla_print(); SLAPrint& sla_print();
BackgroundSlicingProcess &background_process();
void reset_flags_when_new_or_close_project(); void reset_flags_when_new_or_close_project();
int new_project(bool skip_confirm = false, bool silent = false, const wxString &project_name = wxString()); int new_project(bool skip_confirm = false, bool silent = false, const wxString &project_name = wxString());