diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 64eec96300..f3356d9e79 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -36,15 +36,6 @@ #define ENABLE_FIXED_SCREEN_SIZE_POINT_MARKERS 1 -//==================== -// 2.4.0.alpha2 techs -//==================== -#define ENABLE_2_4_0_ALPHA2 1 - -// Enable fixing the synchronization of seams with the horizontal slider in preview -#define ENABLE_FIX_SEAMS_SYNCH (1 && ENABLE_2_4_0_ALPHA2) - - //==================== // 2.4.0.alpha3 techs //==================== diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 9ca84bb9a9..671fdbe6ef 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -264,12 +264,8 @@ void GCodeViewer::SequentialView::Marker::render() const imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, _u8L("Tool position") + ":"); ImGui::SameLine(); char buf[1024]; -#if ENABLE_FIX_SEAMS_SYNCH const Vec3f position = m_world_position + m_world_offset; sprintf(buf, "X: %.3f, Y: %.3f, Z: %.3f", position.x(), position.y(), position.z()); -#else - sprintf(buf, "X: %.3f, Y: %.3f, Z: %.3f", m_world_position.x(), m_world_position.y(), m_world_position.z()); -#endif // ENABLE_FIX_SEAMS_SYNCH imgui.text(std::string(buf)); // force extra frame to automatically update window size @@ -835,9 +831,7 @@ void GCodeViewer::render() render_legend(legend_height); if (m_sequential_view.current.last != m_sequential_view.endpoints.last) { m_sequential_view.marker.set_world_position(m_sequential_view.current_position); -#if ENABLE_FIX_SEAMS_SYNCH m_sequential_view.marker.set_world_offset(m_sequential_view.current_offset); -#endif // ENABLE_FIX_SEAMS_SYNCH m_sequential_view.render(legend_height); } #if ENABLE_GCODE_VIEWER_STATISTICS @@ -1475,44 +1469,32 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) if (wxGetApp().is_editor()) m_contained_in_bed = wxGetApp().plater()->build_volume().all_paths_inside(gcode_result, m_paths_bounding_box); -#if ENABLE_FIX_SEAMS_SYNCH m_sequential_view.gcode_ids.clear(); for (size_t i = 0; i < gcode_result.moves.size(); ++i) { const GCodeProcessorResult::MoveVertex& move = gcode_result.moves[i]; if (move.type != EMoveType::Seam) m_sequential_view.gcode_ids.push_back(move.gcode_id); } -#else - for (const GCodeProcessorResult::MoveVertex& move : gcode_result.moves) { - m_sequential_view.gcode_ids.push_back(move.gcode_id); - } -#endif // ENABLE_FIX_SEAMS_SYNCH std::vector vertices(m_buffers.size()); std::vector indices(m_buffers.size()); std::vector instances(m_buffers.size()); std::vector instances_ids(m_buffers.size()); -#if ENABLE_FIX_SEAMS_SYNCH std::vector instances_offsets(m_buffers.size()); -#endif // ENABLE_FIX_SEAMS_SYNCH std::vector options_zs; -#if ENABLE_FIX_SEAMS_SYNCH size_t seams_count = 0; std::vector seams_ids; -#endif // ENABLE_FIX_SEAMS_SYNCH // toolpaths data -> extract vertices from result for (size_t i = 0; i < m_moves_count; ++i) { const GCodeProcessorResult::MoveVertex& curr = gcode_result.moves[i]; -#if ENABLE_FIX_SEAMS_SYNCH if (curr.type == EMoveType::Seam) { ++seams_count; seams_ids.push_back(i); } size_t move_id = i - seams_count; -#endif // ENABLE_FIX_SEAMS_SYNCH // skip first vertex if (i == 0) @@ -1534,9 +1516,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) MultiVertexBuffer& v_multibuffer = vertices[id]; InstanceBuffer& inst_buffer = instances[id]; InstanceIdBuffer& inst_id_buffer = instances_ids[id]; -#if ENABLE_FIX_SEAMS_SYNCH InstancesOffsets& inst_offsets = instances_offsets[id]; -#endif // ENABLE_FIX_SEAMS_SYNCH // ensure there is at least one vertex buffer if (v_multibuffer.empty()) @@ -1550,11 +1530,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) if (t_buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::Triangle) { Path& last_path = t_buffer.paths.back(); if (prev.type == curr.type && last_path.matches(curr)) -#if ENABLE_FIX_SEAMS_SYNCH last_path.add_sub_path(prev, static_cast(v_multibuffer.size()) - 1, 0, move_id - 1); -#else - last_path.add_sub_path(prev, static_cast(v_multibuffer.size()) - 1, 0, i - 1); -#endif // ENABLE_FIX_SEAMS_SYNCH } } @@ -1564,19 +1540,11 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) { case TBuffer::ERenderPrimitiveType::Point: { add_vertices_as_point(curr, v_buffer); break; } case TBuffer::ERenderPrimitiveType::Line: { add_vertices_as_line(prev, curr, v_buffer); break; } -#if ENABLE_FIX_SEAMS_SYNCH case TBuffer::ERenderPrimitiveType::Triangle: { add_vertices_as_solid(prev, curr, t_buffer, static_cast(v_multibuffer.size()) - 1, v_buffer, move_id); break; } -#else - case TBuffer::ERenderPrimitiveType::Triangle: { add_vertices_as_solid(prev, curr, t_buffer, static_cast(v_multibuffer.size()) - 1, v_buffer, i); break; } -#endif // ENABLE_FIX_SEAMS_SYNCH case TBuffer::ERenderPrimitiveType::InstancedModel: { -#if ENABLE_FIX_SEAMS_SYNCH add_model_instance(curr, inst_buffer, inst_id_buffer, move_id); inst_offsets.push_back(prev.position - curr.position); -#else - add_model_instance(curr, inst_buffer, inst_id_buffer, i); -#endif // ENABLE_FIX_SEAMS_SYNCH #if ENABLE_GCODE_VIEWER_STATISTICS ++m_statistics.instances_count; #endif // ENABLE_GCODE_VIEWER_STATISTICS @@ -1584,12 +1552,8 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) } case TBuffer::ERenderPrimitiveType::BatchedModel: { -#if ENABLE_FIX_SEAMS_SYNCH add_vertices_as_model_batch(curr, t_buffer.model.data, v_buffer, inst_buffer, inst_id_buffer, move_id); inst_offsets.push_back(prev.position - curr.position); -#else - add_vertices_as_model_batch(curr, t_buffer.model.data, v_buffer, inst_buffer, inst_id_buffer, i); -#endif // ENABLE_FIX_SEAMS_SYNCH #if ENABLE_GCODE_VIEWER_STATISTICS ++m_statistics.batched_count; #endif // ENABLE_GCODE_VIEWER_STATISTICS @@ -1606,11 +1570,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) } // smooth toolpaths corners for the given TBuffer using triangles -#if ENABLE_FIX_SEAMS_SYNCH auto smooth_triangle_toolpaths_corners = [&gcode_result, &seams_ids](const TBuffer& t_buffer, MultiVertexBuffer& v_multibuffer) { -#else - auto smooth_triangle_toolpaths_corners = [&gcode_result](const TBuffer& t_buffer, MultiVertexBuffer& v_multibuffer) { -#endif // ENABLE_FIX_SEAMS_SYNCH auto extract_position_at = [](const VertexBuffer& vertices, size_t offset) { return Vec3f(vertices[offset + 0], vertices[offset + 1], vertices[offset + 2]); }; @@ -1684,7 +1644,6 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) } }; -#if ENABLE_FIX_SEAMS_SYNCH auto extract_move_id = [&seams_ids](size_t id) { for (int i = seams_ids.size() - 1; i >= 0; --i) { if (seams_ids[i] < id + i + 1) @@ -1692,7 +1651,6 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) } return id; }; -#endif // ENABLE_FIX_SEAMS_SYNCH size_t vertex_size_floats = t_buffer.vertices.vertex_size_floats(); for (const Path& path : t_buffer.paths) { @@ -1704,16 +1662,10 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) const float half_width = 0.5f * path.width; for (size_t j = 1; j < path_vertices_count - 1; ++j) { size_t curr_s_id = path.sub_paths.front().first.s_id + j; -#if ENABLE_FIX_SEAMS_SYNCH size_t move_id = extract_move_id(curr_s_id); const Vec3f& prev = gcode_result.moves[move_id - 1].position; const Vec3f& curr = gcode_result.moves[move_id].position; const Vec3f& next = gcode_result.moves[move_id + 1].position; -#else - const Vec3f& prev = gcode_result.moves[curr_s_id - 1].position; - const Vec3f& curr = gcode_result.moves[curr_s_id].position; - const Vec3f& next = gcode_result.moves[curr_s_id + 1].position; -#endif // ENABLE_FIX_SEAMS_SYNCH // select the subpaths which contains the previous/next segments if (!path.sub_paths[prev_sub_path_id].contains(curr_s_id)) @@ -1780,10 +1732,8 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) } } -#if ENABLE_FIX_SEAMS_SYNCH // dismiss, no more needed std::vector().swap(seams_ids); -#endif // ENABLE_FIX_SEAMS_SYNCH for (MultiVertexBuffer& v_multibuffer : vertices) { for (VertexBuffer& v_buffer : v_multibuffer) { @@ -1807,9 +1757,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) if (!inst_buffer.empty()) { t_buffer.model.instances.buffer = inst_buffer; t_buffer.model.instances.s_ids = instances_ids[i]; -#if ENABLE_FIX_SEAMS_SYNCH t_buffer.model.instances.offsets = instances_offsets[i]; -#endif // ENABLE_FIX_SEAMS_SYNCH } } else { @@ -1818,9 +1766,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) if (!inst_buffer.empty()) { t_buffer.model.instances.buffer = inst_buffer; t_buffer.model.instances.s_ids = instances_ids[i]; -#if ENABLE_FIX_SEAMS_SYNCH t_buffer.model.instances.offsets = instances_offsets[i]; -#endif // ENABLE_FIX_SEAMS_SYNCH } } const MultiVertexBuffer& v_multibuffer = vertices[i]; @@ -1874,18 +1820,14 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) using VboIndexList = std::vector; std::vector vbo_indices(m_buffers.size()); -#if ENABLE_FIX_SEAMS_SYNCH seams_count = 0; -#endif // ENABLE_FIX_SEAMS_SYNCH for (size_t i = 0; i < m_moves_count; ++i) { const GCodeProcessorResult::MoveVertex& curr = gcode_result.moves[i]; -#if ENABLE_FIX_SEAMS_SYNCH if (curr.type == EMoveType::Seam) ++seams_count; size_t move_id = i - seams_count; -#endif // ENABLE_FIX_SEAMS_SYNCH // skip first vertex if (i == 0) @@ -1926,11 +1868,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) if (t_buffer.render_primitive_type != TBuffer::ERenderPrimitiveType::Point && t_buffer.render_primitive_type != TBuffer::ERenderPrimitiveType::BatchedModel) { Path& last_path = t_buffer.paths.back(); -#if ENABLE_FIX_SEAMS_SYNCH last_path.add_sub_path(prev, static_cast(i_multibuffer.size()) - 1, 0, move_id - 1); -#else - last_path.add_sub_path(prev, static_cast(i_multibuffer.size()) - 1, 0, i - 1); -#endif // ENABLE_FIX_SEAMS_SYNCH } } @@ -1947,11 +1885,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) if (t_buffer.render_primitive_type != TBuffer::ERenderPrimitiveType::Point && t_buffer.render_primitive_type != TBuffer::ERenderPrimitiveType::BatchedModel) { Path& last_path = t_buffer.paths.back(); -#if ENABLE_FIX_SEAMS_SYNCH last_path.add_sub_path(prev, static_cast(i_multibuffer.size()) - 1, 0, move_id - 1); -#else - last_path.add_sub_path(prev, static_cast(i_multibuffer.size()) - 1, 0, i - 1); -#endif // ENABLE_FIX_SEAMS_SYNCH } } @@ -1960,29 +1894,17 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) switch (t_buffer.render_primitive_type) { case TBuffer::ERenderPrimitiveType::Point: { -#if ENABLE_FIX_SEAMS_SYNCH add_indices_as_point(curr, t_buffer, static_cast(i_multibuffer.size()) - 1, i_buffer, move_id); -#else - add_indices_as_point(curr, t_buffer, static_cast(i_multibuffer.size()) - 1, i_buffer, i); -#endif // ENABLE_FIX_SEAMS_SYNCH curr_vertex_buffer.second += t_buffer.max_vertices_per_segment(); break; } case TBuffer::ERenderPrimitiveType::Line: { -#if ENABLE_FIX_SEAMS_SYNCH add_indices_as_line(prev, curr, t_buffer, static_cast(i_multibuffer.size()) - 1, i_buffer, move_id); -#else - add_indices_as_line(prev, curr, t_buffer, static_cast(i_multibuffer.size()) - 1, i_buffer, i); -#endif // ENABLE_FIX_SEAMS_SYNCH curr_vertex_buffer.second += t_buffer.max_vertices_per_segment(); break; } case TBuffer::ERenderPrimitiveType::Triangle: { -#if ENABLE_FIX_SEAMS_SYNCH add_indices_as_solid(prev, curr, next, t_buffer, curr_vertex_buffer.second, static_cast(i_multibuffer.size()) - 1, i_buffer, move_id); -#else - add_indices_as_solid(prev, curr, next, t_buffer, curr_vertex_buffer.second, static_cast(i_multibuffer.size()) - 1, i_buffer, i); -#endif // ENABLE_FIX_SEAMS_SYNCH break; } case TBuffer::ERenderPrimitiveType::BatchedModel: { @@ -2067,34 +1989,22 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) // layers zs / roles / extruder ids -> extract from result size_t last_travel_s_id = 0; -#if ENABLE_FIX_SEAMS_SYNCH seams_count = 0; -#endif // ENABLE_FIX_SEAMS_SYNCH for (size_t i = 0; i < m_moves_count; ++i) { const GCodeProcessorResult::MoveVertex& move = gcode_result.moves[i]; -#if ENABLE_FIX_SEAMS_SYNCH if (move.type == EMoveType::Seam) ++seams_count; size_t move_id = i - seams_count; -#endif // ENABLE_FIX_SEAMS_SYNCH if (move.type == EMoveType::Extrude) { // layers zs const double* const last_z = m_layers.empty() ? nullptr : &m_layers.get_zs().back(); const double z = static_cast(move.position.z()); if (last_z == nullptr || z < *last_z - EPSILON || *last_z + EPSILON < z) -#if ENABLE_FIX_SEAMS_SYNCH m_layers.append(z, { last_travel_s_id, move_id }); -#else - m_layers.append(z, { last_travel_s_id, i }); -#endif // ENABLE_FIX_SEAMS_SYNCH else -#if ENABLE_FIX_SEAMS_SYNCH m_layers.get_endpoints().back().last = move_id; -#else - m_layers.get_endpoints().back().last = i; -#endif // ENABLE_FIX_SEAMS_SYNCH // extruder ids m_extruder_ids.emplace_back(move.extruder_id); // roles @@ -2102,17 +2012,10 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) m_roles.emplace_back(move.extrusion_role); } else if (move.type == EMoveType::Travel) { -#if ENABLE_FIX_SEAMS_SYNCH if (move_id - last_travel_s_id > 1 && !m_layers.empty()) m_layers.get_endpoints().back().last = move_id; last_travel_s_id = move_id; -#else - if (i - last_travel_s_id > 1 && !m_layers.empty()) - m_layers.get_endpoints().back().last = i; - - last_travel_s_id = i; -#endif // ENABLE_FIX_SEAMS_SYNCH } } @@ -2368,10 +2271,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool sequential_view->current_position.x() = buffer.model.instances.buffer[offset + 0]; sequential_view->current_position.y() = buffer.model.instances.buffer[offset + 1]; sequential_view->current_position.z() = buffer.model.instances.buffer[offset + 2]; -#if ENABLE_FIX_SEAMS_SYNCH sequential_view->current_offset = buffer.model.instances.offsets[i]; -#endif // ENABLE_FIX_SEAMS_SYNCH - found = true; break; } @@ -2409,10 +2309,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool glsafe(::glGetBufferSubData(GL_ARRAY_BUFFER, static_cast(index * buffer.vertices.vertex_size_bytes()), static_cast(3 * sizeof(float)), static_cast(sequential_view->current_position.data()))); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0)); -#if ENABLE_FIX_SEAMS_SYNCH sequential_view->current_offset = Vec3f::Zero(); -#endif // ENABLE_FIX_SEAMS_SYNCH - found = true; break; } diff --git a/src/slic3r/GUI/GCodeViewer.hpp b/src/slic3r/GUI/GCodeViewer.hpp index bf276e88fd..9147eec84d 100644 --- a/src/slic3r/GUI/GCodeViewer.hpp +++ b/src/slic3r/GUI/GCodeViewer.hpp @@ -29,9 +29,7 @@ class GCodeViewer using MultiIndexBuffer = std::vector; using InstanceBuffer = std::vector; using InstanceIdBuffer = std::vector; -#if ENABLE_FIX_SEAMS_SYNCH using InstancesOffsets = std::vector; -#endif // ENABLE_FIX_SEAMS_SYNCH static const std::vector Extrusion_Role_Colors; static const std::vector Options_Colors; @@ -143,10 +141,8 @@ class GCodeViewer InstanceBuffer buffer; // indices of the moves for all instances std::vector s_ids; -#if ENABLE_FIX_SEAMS_SYNCH // position offsets, used to show the correct value of the tool position InstancesOffsets offsets; -#endif // ENABLE_FIX_SEAMS_SYNCH Ranges render_ranges; size_t data_size_bytes() const { return s_ids.size() * instance_size_bytes(); } @@ -610,12 +606,10 @@ public: GLModel m_model; Vec3f m_world_position; Transform3f m_world_transform; -#if ENABLE_FIX_SEAMS_SYNCH // for seams, the position of the marker is on the last endpoint of the toolpath containing it // the offset is used to show the correct value of tool position in the "ToolPosition" window // see implementation of render() method Vec3f m_world_offset; -#endif // ENABLE_FIX_SEAMS_SYNCH float m_z_offset{ 0.5f }; bool m_visible{ true }; @@ -625,9 +619,7 @@ public: const BoundingBoxf3& get_bounding_box() const { return m_model.get_bounding_box(); } void set_world_position(const Vec3f& position); -#if ENABLE_FIX_SEAMS_SYNCH void set_world_offset(const Vec3f& offset) { m_world_offset = offset; } -#endif // ENABLE_FIX_SEAMS_SYNCH bool is_visible() const { return m_visible; } void set_visible(bool visible) { m_visible = visible; } @@ -683,9 +675,7 @@ public: Endpoints last_current; Endpoints global; Vec3f current_position{ Vec3f::Zero() }; -#if ENABLE_FIX_SEAMS_SYNCH Vec3f current_offset{ Vec3f::Zero() }; -#endif // ENABLE_FIX_SEAMS_SYNCH Marker marker; GCodeWindow gcode_window; std::vector gcode_ids;