Techs ENABLE_SEAMS_USING_MODELS + ENABLE_GCODE_VIEWER_STATISTICS -> Added instances counter

This commit is contained in:
enricoturri1966 2021-08-05 10:19:02 +02:00
parent 73464c76b9
commit 252935dde7
2 changed files with 26 additions and 1 deletions

View File

@ -1514,7 +1514,14 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result)
case TBuffer::ERenderPrimitiveType::Line: { add_vertices_as_line(prev, curr, v_buffer); break; }
case TBuffer::ERenderPrimitiveType::Triangle: { add_vertices_as_solid(prev, curr, t_buffer, static_cast<unsigned int>(v_multibuffer.size()) - 1, v_buffer, i); break; }
#if ENABLE_SEAMS_USING_MODELS
case TBuffer::ERenderPrimitiveType::Model: { add_model_instance(curr, t_buffer.model.instances, i); break; }
case TBuffer::ERenderPrimitiveType::Model:
{
add_model_instance(curr, t_buffer.model.instances, i);
#if ENABLE_GCODE_VIEWER_STATISTICS
++m_statistics.instances_count;
#endif // ENABLE_GCODE_VIEWER_STATISTICS
break;
}
#endif // ENABLE_SEAMS_USING_MODELS
}
@ -1686,6 +1693,15 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result)
}
}
#if ENABLE_SEAMS_USING_MODELS
for (size_t i = 0; i < m_buffers.size(); ++i) {
TBuffer& t_buffer = m_buffers[i];
if (t_buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::Model) {
t_buffer.model.instances.shrink_to_fit();
}
}
#endif // ENABLE_SEAMS_USING_MODELS
// move the wipe toolpaths half height up to render them on proper position
MultiVertexBuffer& wipe_vertices = vertices[buffer_id(EMoveType::Wipe)];
for (VertexBuffer& v_buffer : wipe_vertices) {
@ -3677,6 +3693,9 @@ void GCodeViewer::render_statistics()
add_counter(std::string("Travel segments count:"), m_statistics.travel_segments_count);
add_counter(std::string("Wipe segments count:"), m_statistics.wipe_segments_count);
add_counter(std::string("Extrude segments count:"), m_statistics.extrude_segments_count);
#if ENABLE_SEAMS_USING_MODELS
add_counter(std::string("Instances count:"), m_statistics.instances_count);
#endif // ENABLE_SEAMS_USING_MODELS
ImGui::Separator();
add_counter(std::string("VBuffers count:"), m_statistics.vbuffers_count);
add_counter(std::string("IBuffers count:"), m_statistics.ibuffers_count);

View File

@ -500,6 +500,9 @@ class GCodeViewer
int64_t travel_segments_count{ 0 };
int64_t wipe_segments_count{ 0 };
int64_t extrude_segments_count{ 0 };
#if ENABLE_SEAMS_USING_MODELS
int64_t instances_count{ 0 };
#endif // ENABLE_SEAMS_USING_MODELS
int64_t vbuffers_count{ 0 };
int64_t ibuffers_count{ 0 };
@ -547,6 +550,9 @@ class GCodeViewer
travel_segments_count = 0;
wipe_segments_count = 0;
extrude_segments_count = 0;
#if ENABLE_SEAMS_USING_MODELS
instances_count = 0;
#endif // ENABLE_SEAMS_USING_MODELS
vbuffers_count = 0;
ibuffers_count = 0;
}