Modified MMU painting gizmo behavior so that all triangles aren't painted by default by the first extruder, which was causing several problems.

This commit also fixed the following issues:
1) After loading a 3MF with painted triangles using the MMU painting gizmo, the painted triangles might not be displayed correctly in the MMU painting gizmo.
2) The MMU segmentation was unnecessarily executed for all layers and not just for the painted layers.
3) Object's base color wasn't changed when the assigned extruder for that object was changed while the MMU paint gizmo was opened.
4) Changing the base color of an object was only possible by removing all painted triangles.
This commit is contained in:
Lukáš Hejl 2021-06-09 08:07:15 +02:00
parent b2677f513c
commit 8a77fa38f0
4 changed files with 51 additions and 30 deletions

View file

@ -7,9 +7,10 @@ namespace Slic3r::GUI {
class TriangleSelectorMmuGui : public TriangleSelectorGUI {
public:
explicit TriangleSelectorMmuGui(const TriangleMesh& mesh, const std::vector<std::array<uint8_t, 3>> &colors)
: TriangleSelectorGUI(mesh), m_colors(colors) {
m_iva_colors = std::vector<GLIndexedVertexArray>(colors.size());
explicit TriangleSelectorMmuGui(const TriangleMesh& mesh, const std::vector<std::array<uint8_t, 3>> &colors, const std::array<uint8_t, 3> &default_volume_color)
: TriangleSelectorGUI(mesh), m_colors(colors), m_default_volume_color(default_volume_color) {
// Plus 1 is because the first position is allocated for non-painted triangles.
m_iva_colors = std::vector<GLIndexedVertexArray>(colors.size() + 1);
}
~TriangleSelectorMmuGui() override = default;
@ -19,7 +20,8 @@ public:
private:
const std::vector<std::array<uint8_t, 3>> &m_colors;
std::vector<GLIndexedVertexArray> m_iva_colors;
std::vector<GLIndexedVertexArray> m_iva_colors;
const std::array<uint8_t, 3> m_default_volume_color;
};
class GLGizmoMmuSegmentation : public GLGizmoPainterBase
@ -37,8 +39,8 @@ protected:
std::array<float, 4> get_cursor_sphere_left_button_color() const override;
std::array<float, 4> get_cursor_sphere_right_button_color() const override;
EnforcerBlockerType get_left_button_state_type() const override { return EnforcerBlockerType(m_first_selected_extruder_idx); }
EnforcerBlockerType get_right_button_state_type() const override { return EnforcerBlockerType(m_second_selected_extruder_idx); }
EnforcerBlockerType get_left_button_state_type() const override { return EnforcerBlockerType(m_first_selected_extruder_idx + 1); }
EnforcerBlockerType get_right_button_state_type() const override { return EnforcerBlockerType(m_second_selected_extruder_idx + 1); }
void on_render_input_window(float x, float y, float bottom_limit) override;
std::string on_get_name() const override;
@ -52,6 +54,7 @@ protected:
std::vector<std::string> m_original_extruders_names;
std::vector<std::array<uint8_t, 3>> m_original_extruders_colors;
std::vector<std::array<uint8_t, 3>> m_modified_extruders_colors;
std::vector<int> m_original_volumes_extruder_idxs;
private:
bool on_init() override;