mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 07:27:41 -06:00
Removed obsolete code from GCodeViewer
(cherry picked from commit prusa3d/PrusaSlicer@033bee6431)
This commit is contained in:
parent
63272a9df8
commit
96c8c11030
2 changed files with 8 additions and 86 deletions
|
@ -2030,18 +2030,6 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result, const
|
||||||
log_memory_used(label, vertices_size + indices_size);
|
log_memory_used(label, vertices_size + indices_size);
|
||||||
};
|
};
|
||||||
|
|
||||||
// format data into the buffers to be rendered as points
|
|
||||||
auto add_vertices_as_point = [](const GCodeProcessorResult::MoveVertex& curr, VertexBuffer& vertices) {
|
|
||||||
vertices.push_back(curr.position.x());
|
|
||||||
vertices.push_back(curr.position.y());
|
|
||||||
vertices.push_back(curr.position.z());
|
|
||||||
};
|
|
||||||
auto add_indices_as_point = [](const GCodeProcessorResult::MoveVertex& curr, TBuffer& buffer,
|
|
||||||
unsigned int ibuffer_id, IndexBuffer& indices, size_t move_id) {
|
|
||||||
buffer.add_path(curr, ibuffer_id, indices.size(), move_id);
|
|
||||||
indices.push_back(static_cast<IBufferType>(indices.size()));
|
|
||||||
};
|
|
||||||
|
|
||||||
// format data into the buffers to be rendered as lines
|
// format data into the buffers to be rendered as lines
|
||||||
auto add_vertices_as_line = [](const GCodeProcessorResult::MoveVertex& prev, const GCodeProcessorResult::MoveVertex& curr, VertexBuffer& vertices) {
|
auto add_vertices_as_line = [](const GCodeProcessorResult::MoveVertex& prev, const GCodeProcessorResult::MoveVertex& curr, VertexBuffer& vertices) {
|
||||||
auto add_vertex = [&vertices](const Vec3f& position) {
|
auto add_vertex = [&vertices](const Vec3f& position) {
|
||||||
|
@ -2505,7 +2493,6 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result, const
|
||||||
|
|
||||||
switch (t_buffer.render_primitive_type)
|
switch (t_buffer.render_primitive_type)
|
||||||
{
|
{
|
||||||
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; }
|
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, move_id); break; }
|
case TBuffer::ERenderPrimitiveType::Triangle: { add_vertices_as_solid(prev, curr, t_buffer, static_cast<unsigned int>(v_multibuffer.size()) - 1, v_buffer, move_id); break; }
|
||||||
case TBuffer::ERenderPrimitiveType::InstancedModel:
|
case TBuffer::ERenderPrimitiveType::InstancedModel:
|
||||||
|
@ -2893,8 +2880,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result, const
|
||||||
if (i_multibuffer.back().size() * sizeof(IBufferType) >= IBUFFER_THRESHOLD_BYTES - indiced_size_to_add) {
|
if (i_multibuffer.back().size() * sizeof(IBufferType) >= IBUFFER_THRESHOLD_BYTES - indiced_size_to_add) {
|
||||||
i_multibuffer.push_back(IndexBuffer());
|
i_multibuffer.push_back(IndexBuffer());
|
||||||
vbo_index_list.push_back(t_buffer.vertices.vbos[curr_vertex_buffer.first]);
|
vbo_index_list.push_back(t_buffer.vertices.vbos[curr_vertex_buffer.first]);
|
||||||
if (t_buffer.render_primitive_type != TBuffer::ERenderPrimitiveType::Point &&
|
if (t_buffer.render_primitive_type != TBuffer::ERenderPrimitiveType::BatchedModel) {
|
||||||
t_buffer.render_primitive_type != TBuffer::ERenderPrimitiveType::BatchedModel) {
|
|
||||||
Path& last_path = t_buffer.paths.back();
|
Path& last_path = t_buffer.paths.back();
|
||||||
last_path.add_sub_path(prev, static_cast<unsigned int>(i_multibuffer.size()) - 1, 0, move_id - 1);
|
last_path.add_sub_path(prev, static_cast<unsigned int>(i_multibuffer.size()) - 1, 0, move_id - 1);
|
||||||
}
|
}
|
||||||
|
@ -2911,8 +2897,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result, const
|
||||||
curr_vertex_buffer.second = 0;
|
curr_vertex_buffer.second = 0;
|
||||||
vbo_index_list.push_back(t_buffer.vertices.vbos[curr_vertex_buffer.first]);
|
vbo_index_list.push_back(t_buffer.vertices.vbos[curr_vertex_buffer.first]);
|
||||||
|
|
||||||
if (t_buffer.render_primitive_type != TBuffer::ERenderPrimitiveType::Point &&
|
if (t_buffer.render_primitive_type != TBuffer::ERenderPrimitiveType::BatchedModel) {
|
||||||
t_buffer.render_primitive_type != TBuffer::ERenderPrimitiveType::BatchedModel) {
|
|
||||||
Path& last_path = t_buffer.paths.back();
|
Path& last_path = t_buffer.paths.back();
|
||||||
last_path.add_sub_path(prev, static_cast<unsigned int>(i_multibuffer.size()) - 1, 0, move_id - 1);
|
last_path.add_sub_path(prev, static_cast<unsigned int>(i_multibuffer.size()) - 1, 0, move_id - 1);
|
||||||
}
|
}
|
||||||
|
@ -2922,11 +2907,6 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result, const
|
||||||
|
|
||||||
switch (t_buffer.render_primitive_type)
|
switch (t_buffer.render_primitive_type)
|
||||||
{
|
{
|
||||||
case TBuffer::ERenderPrimitiveType::Point: {
|
|
||||||
add_indices_as_point(curr, t_buffer, static_cast<unsigned int>(i_multibuffer.size()) - 1, i_buffer, move_id);
|
|
||||||
curr_vertex_buffer.second += t_buffer.max_vertices_per_segment();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TBuffer::ERenderPrimitiveType::Line: {
|
case TBuffer::ERenderPrimitiveType::Line: {
|
||||||
add_indices_as_line(prev, curr, t_buffer, curr_vertex_buffer.second, static_cast<unsigned int>(i_multibuffer.size()) - 1, i_buffer, move_id);
|
add_indices_as_line(prev, curr, t_buffer, curr_vertex_buffer.second, static_cast<unsigned int>(i_multibuffer.size()) - 1, i_buffer, move_id);
|
||||||
break;
|
break;
|
||||||
|
@ -3522,10 +3502,6 @@ m_no_render_path = false;
|
||||||
unsigned int size_in_indices = 0;
|
unsigned int size_in_indices = 0;
|
||||||
switch (buffer.render_primitive_type)
|
switch (buffer.render_primitive_type)
|
||||||
{
|
{
|
||||||
case TBuffer::ERenderPrimitiveType::Point: {
|
|
||||||
size_in_indices = buffer.indices_per_segment();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TBuffer::ERenderPrimitiveType::Line:
|
case TBuffer::ERenderPrimitiveType::Line:
|
||||||
case TBuffer::ERenderPrimitiveType::Triangle: {
|
case TBuffer::ERenderPrimitiveType::Triangle: {
|
||||||
// BBS: modify to support moves which has internal point
|
// BBS: modify to support moves which has internal point
|
||||||
|
@ -3780,43 +3756,6 @@ void GCodeViewer::render_toolpaths()
|
||||||
const float near_plane_height = camera.get_type() == Camera::EType::Perspective ? static_cast<float>(viewport[3]) / (2.0f * static_cast<float>(2.0 * std::tan(0.5 * Geometry::deg2rad(camera.get_fov())))) :
|
const float near_plane_height = camera.get_type() == Camera::EType::Perspective ? static_cast<float>(viewport[3]) / (2.0f * static_cast<float>(2.0 * std::tan(0.5 * Geometry::deg2rad(camera.get_fov())))) :
|
||||||
static_cast<float>(viewport[3]) * 0.0005;
|
static_cast<float>(viewport[3]) * 0.0005;
|
||||||
|
|
||||||
auto shader_init_as_points = [zoom, point_size, near_plane_height](GLShaderProgram& shader) {
|
|
||||||
#if ENABLE_FIXED_SCREEN_SIZE_POINT_MARKERS
|
|
||||||
shader.set_uniform("use_fixed_screen_size", 1);
|
|
||||||
#else
|
|
||||||
shader.set_uniform("use_fixed_screen_size", 0);
|
|
||||||
#endif // ENABLE_FIXED_SCREEN_SIZE_POINT_MARKERS
|
|
||||||
shader.set_uniform("zoom", zoom);
|
|
||||||
shader.set_uniform("percent_outline_radius", 0.0f);
|
|
||||||
shader.set_uniform("percent_center_radius", 0.33f);
|
|
||||||
shader.set_uniform("point_size", point_size);
|
|
||||||
shader.set_uniform("near_plane_height", near_plane_height);
|
|
||||||
};
|
|
||||||
|
|
||||||
auto render_as_points = [
|
|
||||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
|
||||||
this
|
|
||||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
|
||||||
](std::vector<RenderPath>::iterator it_path, std::vector<RenderPath>::iterator it_end, GLShaderProgram& shader, int uniform_color) {
|
|
||||||
glsafe(::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE));
|
|
||||||
glsafe(::glEnable(GL_POINT_SPRITE));
|
|
||||||
|
|
||||||
for (auto it = it_path; it != it_end && it_path->ibuffer_id == it->ibuffer_id; ++it) {
|
|
||||||
const RenderPath& path = *it;
|
|
||||||
// Some OpenGL drivers crash on empty glMultiDrawElements, see GH #7415.
|
|
||||||
assert(! path.sizes.empty());
|
|
||||||
assert(! path.offsets.empty());
|
|
||||||
shader.set_uniform(uniform_color, path.color);
|
|
||||||
glsafe(::glMultiDrawElements(GL_POINTS, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_SHORT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size()));
|
|
||||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
|
||||||
++m_statistics.gl_multi_points_calls_count;
|
|
||||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
|
||||||
}
|
|
||||||
|
|
||||||
glsafe(::glDisable(GL_POINT_SPRITE));
|
|
||||||
glsafe(::glDisable(GL_VERTEX_PROGRAM_POINT_SIZE));
|
|
||||||
};
|
|
||||||
|
|
||||||
auto render_as_lines = [
|
auto render_as_lines = [
|
||||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
this
|
this
|
||||||
|
@ -3957,16 +3896,11 @@ void GCodeViewer::render_toolpaths()
|
||||||
|
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
|
||||||
int position_id = -1;
|
|
||||||
int normal_id = -1;
|
|
||||||
const Transform3d& view_matrix = camera.get_view_matrix();
|
const Transform3d& view_matrix = camera.get_view_matrix();
|
||||||
shader->set_uniform("view_model_matrix", view_matrix);
|
shader->set_uniform("view_model_matrix", view_matrix);
|
||||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||||
shader->set_uniform("normal_matrix", (Matrix3d)view_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
shader->set_uniform("normal_matrix", (Matrix3d)view_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
||||||
|
|
||||||
position_id = shader->get_attrib_location("v_position");
|
|
||||||
normal_id = shader->get_attrib_location("v_normal");
|
|
||||||
|
|
||||||
if (buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::InstancedModel) {
|
if (buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::InstancedModel) {
|
||||||
shader->set_uniform("emission_factor", 0.25f);
|
shader->set_uniform("emission_factor", 0.25f);
|
||||||
render_as_instanced_model(buffer, *shader);
|
render_as_instanced_model(buffer, *shader);
|
||||||
|
@ -3974,12 +3908,14 @@ void GCodeViewer::render_toolpaths()
|
||||||
}
|
}
|
||||||
else if (buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::BatchedModel) {
|
else if (buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::BatchedModel) {
|
||||||
shader->set_uniform("emission_factor", 0.25f);
|
shader->set_uniform("emission_factor", 0.25f);
|
||||||
|
const int position_id = shader->get_attrib_location("v_position");
|
||||||
|
const int normal_id = shader->get_attrib_location("v_normal");
|
||||||
render_as_batched_model(buffer, *shader, position_id, normal_id);
|
render_as_batched_model(buffer, *shader, position_id, normal_id);
|
||||||
shader->set_uniform("emission_factor", 0.0f);
|
shader->set_uniform("emission_factor", 0.0f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::Point)
|
const int position_id = shader->get_attrib_location("v_position");
|
||||||
shader_init_as_points(*shader);
|
const int normal_id = shader->get_attrib_location("v_normal");
|
||||||
const int uniform_color = shader->get_uniform_location("uniform_color");
|
const int uniform_color = shader->get_uniform_location("uniform_color");
|
||||||
|
|
||||||
auto it_path = buffer.render_paths.begin();
|
auto it_path = buffer.render_paths.begin();
|
||||||
|
@ -4009,10 +3945,6 @@ void GCodeViewer::render_toolpaths()
|
||||||
// Render all elements with it_path->ibuffer_id == ibuffer_id, possible with varying colors.
|
// Render all elements with it_path->ibuffer_id == ibuffer_id, possible with varying colors.
|
||||||
switch (buffer.render_primitive_type)
|
switch (buffer.render_primitive_type)
|
||||||
{
|
{
|
||||||
case TBuffer::ERenderPrimitiveType::Point: {
|
|
||||||
render_as_points(it_path, buffer.render_paths.end(), *shader, uniform_color);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TBuffer::ERenderPrimitiveType::Line: {
|
case TBuffer::ERenderPrimitiveType::Line: {
|
||||||
glsafe(::glLineWidth(static_cast<GLfloat>(line_width(zoom))));
|
glsafe(::glLineWidth(static_cast<GLfloat>(line_width(zoom))));
|
||||||
render_as_lines(it_path, buffer.render_paths.end(), *shader, uniform_color);
|
render_as_lines(it_path, buffer.render_paths.end(), *shader, uniform_color);
|
||||||
|
@ -4051,16 +3983,14 @@ void GCodeViewer::render_toolpaths()
|
||||||
|
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
|
||||||
int position_id = -1;
|
|
||||||
int normal_id = -1;
|
|
||||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
const Transform3d& view_matrix = camera.get_view_matrix();
|
const Transform3d& view_matrix = camera.get_view_matrix();
|
||||||
shader->set_uniform("view_model_matrix", view_matrix);
|
shader->set_uniform("view_model_matrix", view_matrix);
|
||||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||||
shader->set_uniform("normal_matrix", (Matrix3d)view_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
shader->set_uniform("normal_matrix", (Matrix3d)view_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
||||||
|
|
||||||
position_id = shader->get_attrib_location("v_position");
|
const int position_id = shader->get_attrib_location("v_position");
|
||||||
normal_id = shader->get_attrib_location("v_normal");
|
const int normal_id = shader->get_attrib_location("v_normal");
|
||||||
|
|
||||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, cap.vbo));
|
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, cap.vbo));
|
||||||
if (position_id != -1) {
|
if (position_id != -1) {
|
||||||
|
@ -5637,7 +5567,6 @@ void GCodeViewer::render_statistics()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::CollapsingHeader("OpenGL calls")) {
|
if (ImGui::CollapsingHeader("OpenGL calls")) {
|
||||||
add_counter(std::string("Multi GL_POINTS:"), m_statistics.gl_multi_points_calls_count);
|
|
||||||
add_counter(std::string("Multi GL_LINES:"), m_statistics.gl_multi_lines_calls_count);
|
add_counter(std::string("Multi GL_LINES:"), m_statistics.gl_multi_lines_calls_count);
|
||||||
add_counter(std::string("Multi GL_TRIANGLES:"), m_statistics.gl_multi_triangles_calls_count);
|
add_counter(std::string("Multi GL_TRIANGLES:"), m_statistics.gl_multi_triangles_calls_count);
|
||||||
add_counter(std::string("GL_TRIANGLES:"), m_statistics.gl_triangles_calls_count);
|
add_counter(std::string("GL_TRIANGLES:"), m_statistics.gl_triangles_calls_count);
|
||||||
|
|
|
@ -293,7 +293,6 @@ class GCodeViewer
|
||||||
{
|
{
|
||||||
enum class ERenderPrimitiveType : unsigned char
|
enum class ERenderPrimitiveType : unsigned char
|
||||||
{
|
{
|
||||||
Point,
|
|
||||||
Line,
|
Line,
|
||||||
Triangle,
|
Triangle,
|
||||||
InstancedModel,
|
InstancedModel,
|
||||||
|
@ -334,7 +333,6 @@ class GCodeViewer
|
||||||
unsigned int max_vertices_per_segment() const {
|
unsigned int max_vertices_per_segment() const {
|
||||||
switch (render_primitive_type)
|
switch (render_primitive_type)
|
||||||
{
|
{
|
||||||
case ERenderPrimitiveType::Point: { return 1; }
|
|
||||||
case ERenderPrimitiveType::Line: { return 2; }
|
case ERenderPrimitiveType::Line: { return 2; }
|
||||||
case ERenderPrimitiveType::Triangle: { return 8; }
|
case ERenderPrimitiveType::Triangle: { return 8; }
|
||||||
default: { return 0; }
|
default: { return 0; }
|
||||||
|
@ -346,7 +344,6 @@ class GCodeViewer
|
||||||
unsigned int indices_per_segment() const {
|
unsigned int indices_per_segment() const {
|
||||||
switch (render_primitive_type)
|
switch (render_primitive_type)
|
||||||
{
|
{
|
||||||
case ERenderPrimitiveType::Point: { return 1; }
|
|
||||||
case ERenderPrimitiveType::Line: { return 2; }
|
case ERenderPrimitiveType::Line: { return 2; }
|
||||||
case ERenderPrimitiveType::Triangle: { return 30; } // 3 indices x 10 triangles
|
case ERenderPrimitiveType::Triangle: { return 30; } // 3 indices x 10 triangles
|
||||||
default: { return 0; }
|
default: { return 0; }
|
||||||
|
@ -356,7 +353,6 @@ class GCodeViewer
|
||||||
unsigned int max_indices_per_segment() const {
|
unsigned int max_indices_per_segment() const {
|
||||||
switch (render_primitive_type)
|
switch (render_primitive_type)
|
||||||
{
|
{
|
||||||
case ERenderPrimitiveType::Point: { return 1; }
|
|
||||||
case ERenderPrimitiveType::Line: { return 2; }
|
case ERenderPrimitiveType::Line: { return 2; }
|
||||||
case ERenderPrimitiveType::Triangle: { return 36; } // 3 indices x 12 triangles
|
case ERenderPrimitiveType::Triangle: { return 36; } // 3 indices x 12 triangles
|
||||||
default: { return 0; }
|
default: { return 0; }
|
||||||
|
@ -367,7 +363,6 @@ class GCodeViewer
|
||||||
bool has_data() const {
|
bool has_data() const {
|
||||||
switch (render_primitive_type)
|
switch (render_primitive_type)
|
||||||
{
|
{
|
||||||
case ERenderPrimitiveType::Point:
|
|
||||||
case ERenderPrimitiveType::Line:
|
case ERenderPrimitiveType::Line:
|
||||||
case ERenderPrimitiveType::Triangle: {
|
case ERenderPrimitiveType::Triangle: {
|
||||||
return !vertices.vbos.empty() && vertices.vbos.front() != 0 && !indices.empty() && indices.front().ibo != 0;
|
return !vertices.vbos.empty() && vertices.vbos.front() != 0 && !indices.empty() && indices.front().ibo != 0;
|
||||||
|
@ -536,7 +531,6 @@ Range layer_duration_log;
|
||||||
int64_t refresh_time{ 0 };
|
int64_t refresh_time{ 0 };
|
||||||
int64_t refresh_paths_time{ 0 };
|
int64_t refresh_paths_time{ 0 };
|
||||||
// opengl calls
|
// opengl calls
|
||||||
int64_t gl_multi_points_calls_count{ 0 };
|
|
||||||
int64_t gl_multi_lines_calls_count{ 0 };
|
int64_t gl_multi_lines_calls_count{ 0 };
|
||||||
int64_t gl_multi_triangles_calls_count{ 0 };
|
int64_t gl_multi_triangles_calls_count{ 0 };
|
||||||
int64_t gl_triangles_calls_count{ 0 };
|
int64_t gl_triangles_calls_count{ 0 };
|
||||||
|
@ -579,7 +573,6 @@ Range layer_duration_log;
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset_opengl() {
|
void reset_opengl() {
|
||||||
gl_multi_points_calls_count = 0;
|
|
||||||
gl_multi_lines_calls_count = 0;
|
gl_multi_lines_calls_count = 0;
|
||||||
gl_multi_triangles_calls_count = 0;
|
gl_multi_triangles_calls_count = 0;
|
||||||
gl_triangles_calls_count = 0;
|
gl_triangles_calls_count = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue