Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorenricoturri1966 <enricoturri@seznam.cz>2021-01-21 18:33:35 +0300
committerenricoturri1966 <enricoturri@seznam.cz>2021-04-12 15:09:17 +0300
commitdd2cd72099a410888aa7ec8c59a1181d4cebb8fd (patch)
tree1269e5c21c7a2fd50ccf6a6b1f9f5bc5c7059407
parent81bf9609ce3ed12849c7c461262dbb3a1822f9d9 (diff)
ENABLE_SPLITTED_VERTEX_BUFFER - Re-enable tech ENABLE_TOOLPATHS_ALTERNATE_SMOOTHING after fixing it
-rw-r--r--src/libslic3r/Technologies.hpp2
-rw-r--r--src/slic3r/GUI/GCodeViewer.cpp92
2 files changed, 61 insertions, 33 deletions
diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp
index f53bf74a2..faf4e1acc 100644
--- a/src/libslic3r/Technologies.hpp
+++ b/src/libslic3r/Technologies.hpp
@@ -114,7 +114,7 @@
#define ENABLE_2_3_1 1
#define ENABLE_SPLITTED_VERTEX_BUFFER (1 && ENABLE_2_3_1)
-#define ENABLE_TOOLPATHS_ALTERNATE_SMOOTHING (0 && ENABLE_SPLITTED_VERTEX_BUFFER)
+#define ENABLE_TOOLPATHS_ALTERNATE_SMOOTHING (1 && ENABLE_SPLITTED_VERTEX_BUFFER)
#define ENABLE_UNSIGNED_SHORT_INDEX_BUFFER (1 && ENABLE_SPLITTED_VERTEX_BUFFER)
diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp
index 150f65acf..43bf0345a 100644
--- a/src/slic3r/GUI/GCodeViewer.cpp
+++ b/src/slic3r/GUI/GCodeViewer.cpp
@@ -1794,7 +1794,6 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result)
#if ENABLE_TOOLPATHS_ALTERNATE_SMOOTHING
#if ENABLE_UNSIGNED_SHORT_INDEX_BUFFER
if (v_multibuffer.back().size() * sizeof(float) > t_buffer.vertices.max_size_bytes() - t_buffer.max_vertices_per_segment_size_bytes()) {
- std::cout << "Splitted v buffer at " << i << "\n";
#else
if (v_multibuffer.back().size() * sizeof(float) > VBUFFER_THRESHOLD_BYTES - t_buffer.max_vertices_per_segment_size_bytes()) {
#endif // ENABLE_UNSIGNED_SHORT_INDEX_BUFFER
@@ -1807,10 +1806,8 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result)
}
#else
#if ENABLE_UNSIGNED_SHORT_INDEX_BUFFER
- if (v_multibuffer.back().size() * sizeof(float) > t_buffer.vertices.max_size_bytes() - t_buffer.max_vertices_per_segment_size_bytes()) {
-// std::cout << "Splitted v buffer at " << i << "\n";
+ if (v_multibuffer.back().size() * sizeof(float) > t_buffer.vertices.max_size_bytes() - t_buffer.max_vertices_per_segment_size_bytes())
v_multibuffer.push_back(VertexBuffer());
- }
#else
if (v_multibuffer.back().size() * sizeof(float) > VBUFFER_THRESHOLD_BYTES - t_buffer.max_vertices_per_segment_size_bytes())
v_multibuffer.push_back(VertexBuffer());
@@ -1851,35 +1848,67 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result)
};
auto match_right_vertices = [&](const Path::Sub_Path& prev_sub_path, const Path::Sub_Path& next_sub_path,
size_t curr_s_id, size_t vertex_size_floats, const Vec3f& displacement_vec) {
- // offset into the vertex buffer of the next segment 1st vertex
- size_t next_offset = (prev_sub_path.last.s_id - curr_s_id) * 6 * vertex_size_floats;
- // offset into the vertex buffer of the right vertex of the previous segment
- size_t prev_right_offset = prev_sub_path.last.i_id - next_offset - 3 * vertex_size_floats;
- // new position of the right vertices
- Vec3f shared_vertex = extract_position_at(v_multibuffer[prev_sub_path.first.b_id], prev_right_offset) + displacement_vec;
- // update previous segment
- update_position_at(v_multibuffer[prev_sub_path.first.b_id], prev_right_offset, shared_vertex);
- // offset into the vertex buffer of the right vertex of the next segment
- size_t r_offset = (curr_s_id == next_sub_path.first.i_id) ? 1 : 0;
- size_t next_right_offset = next_sub_path.last.i_id - next_offset + r_offset * vertex_size_floats;
- // update next segment
- update_position_at(v_multibuffer[next_sub_path.first.b_id], next_right_offset, shared_vertex);
+ if (&prev_sub_path == &next_sub_path) { // previous and next segment are both contained into to the same vertex buffer
+ VertexBuffer& vbuffer = v_multibuffer[prev_sub_path.first.b_id];
+ // offset into the vertex buffer of the next segment 1st vertex
+ size_t next_1st_offset = (prev_sub_path.last.s_id - curr_s_id) * 6 * vertex_size_floats;
+ // offset into the vertex buffer of the right vertex of the previous segment
+ size_t prev_right_offset = prev_sub_path.last.i_id - next_1st_offset - 3 * vertex_size_floats;
+ // new position of the right vertices
+ Vec3f shared_vertex = extract_position_at(vbuffer, prev_right_offset) + displacement_vec;
+ // update previous segment
+ update_position_at(vbuffer, prev_right_offset, shared_vertex);
+ // offset into the vertex buffer of the right vertex of the next segment
+ size_t next_right_offset = next_sub_path.last.i_id - next_1st_offset;
+ // update next segment
+ update_position_at(vbuffer, next_right_offset, shared_vertex);
+ }
+ else { // previous and next segment are contained into different vertex buffers
+ VertexBuffer& prev_vbuffer = v_multibuffer[prev_sub_path.first.b_id];
+ VertexBuffer& next_vbuffer = v_multibuffer[next_sub_path.first.b_id];
+ // offset into the previous vertex buffer of the right vertex of the previous segment
+ size_t prev_right_offset = prev_sub_path.last.i_id - 3 * vertex_size_floats;
+ // new position of the right vertices
+ Vec3f shared_vertex = extract_position_at(prev_vbuffer, prev_right_offset) + displacement_vec;
+ // update previous segment
+ update_position_at(prev_vbuffer, prev_right_offset, shared_vertex);
+ // offset into the next vertex buffer of the right vertex of the next segment
+ size_t next_right_offset = next_sub_path.first.i_id + 1 * vertex_size_floats;
+ // update next segment
+ update_position_at(next_vbuffer, next_right_offset, shared_vertex);
+ }
};
auto match_left_vertices = [&](const Path::Sub_Path& prev_sub_path, const Path::Sub_Path& next_sub_path,
size_t curr_s_id, size_t vertex_size_floats, const Vec3f& displacement_vec) {
- // offset into the vertex buffer of the next segment 1st vertex
- size_t next_offset = (prev_sub_path.last.s_id - curr_s_id) * 6 * vertex_size_floats;
- // offset into the vertex buffer of the left vertex of the previous segment
- size_t prev_left_offset = prev_sub_path.last.i_id - next_offset - 1 * vertex_size_floats;
- // new position of the left vertices
- Vec3f shared_vertex = extract_position_at(v_multibuffer[prev_sub_path.first.b_id], prev_left_offset) + displacement_vec;
- // update previous segment
- update_position_at(v_multibuffer[prev_sub_path.first.b_id], prev_left_offset, shared_vertex);
- // offset into the vertex buffer of the left vertex of the next segment
- size_t l_offset = (curr_s_id == next_sub_path.first.i_id) ? 3 : 1;
- size_t next_left_offset = next_sub_path.last.i_id - next_offset + l_offset * vertex_size_floats;
- // update next segment
- update_position_at(v_multibuffer[next_sub_path.first.b_id], next_left_offset, shared_vertex);
+ if (&prev_sub_path == &next_sub_path) { // previous and next segment are both contained into to the same vertex buffer
+ VertexBuffer& vbuffer = v_multibuffer[prev_sub_path.first.b_id];
+ // offset into the vertex buffer of the next segment 1st vertex
+ size_t next_1st_offset = (prev_sub_path.last.s_id - curr_s_id) * 6 * vertex_size_floats;
+ // offset into the vertex buffer of the left vertex of the previous segment
+ size_t prev_left_offset = prev_sub_path.last.i_id - next_1st_offset - 1 * vertex_size_floats;
+ // new position of the left vertices
+ Vec3f shared_vertex = extract_position_at(vbuffer, prev_left_offset) + displacement_vec;
+ // update previous segment
+ update_position_at(vbuffer, prev_left_offset, shared_vertex);
+ // offset into the vertex buffer of the left vertex of the next segment
+ size_t next_left_offset = next_sub_path.last.i_id - next_1st_offset + 1 * vertex_size_floats;
+ // update next segment
+ update_position_at(vbuffer, next_left_offset, shared_vertex);
+ }
+ else { // previous and next segment are contained into different vertex buffers
+ VertexBuffer& prev_vbuffer = v_multibuffer[prev_sub_path.first.b_id];
+ VertexBuffer& next_vbuffer = v_multibuffer[next_sub_path.first.b_id];
+ // offset into the previous vertex buffer of the left vertex of the previous segment
+ size_t prev_left_offset = prev_sub_path.last.i_id - 1 * vertex_size_floats;
+ // new position of the left vertices
+ Vec3f shared_vertex = extract_position_at(prev_vbuffer, prev_left_offset) + displacement_vec;
+ // update previous segment
+ update_position_at(prev_vbuffer, prev_left_offset, shared_vertex);
+ // offset into the next vertex buffer of the left vertex of the next segment
+ size_t next_left_offset = next_sub_path.first.i_id + 3 * vertex_size_floats;
+ // update next segment
+ update_position_at(next_vbuffer, next_left_offset, shared_vertex);
+ }
};
size_t vertex_size_floats = t_buffer.vertices.vertex_size_floats();
@@ -1927,7 +1956,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result)
float sq_prev_length = (curr - prev).squaredNorm();
float sq_next_length = (next - curr).squaredNorm();
float sq_displacement = sqr(displacement);
- bool can_displace = displacement > 0.0f && sq_displacement < sq_prev_length&& sq_displacement < sq_next_length;
+ bool can_displace = displacement > 0.0f && sq_displacement < sq_prev_length && sq_displacement < sq_next_length;
if (can_displace) {
// displacement to apply to the vertices to match
@@ -2068,7 +2097,6 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result)
// create another index buffer
#if ENABLE_UNSIGNED_SHORT_INDEX_BUFFER
if (curr_vertex_buffer.second * t_buffer.vertices.vertex_size_bytes() > t_buffer.vertices.max_size_bytes() - t_buffer.max_vertices_per_segment_size_bytes()) {
-// std::cout << "Splitted i buffer at " << i << "\n";
#else
if (curr_vertex_buffer.second * t_buffer.vertices.vertex_size_bytes() > VBUFFER_THRESHOLD_BYTES - t_buffer.max_vertices_per_segment_size_bytes()) {
#endif // ENABLE_UNSIGNED_SHORT_INDEX_BUFFER