Bugfix: update model extents when using OpenCNCPilot parser.

This commit is contained in:
2023-05-16 09:26:21 +03:00
parent 42aefe8ed8
commit 15ebb7bb15
2 changed files with 21 additions and 0 deletions
+20
View File
@@ -442,11 +442,20 @@ GLsizei grbl::program_renderer::update_model_vbo(const grbl::program &pgm) {
add_line(buffer_data, line->start, rapid_color, line->end, rapid_color);
else
add_line(buffer_data, line->start, feed_color, line->end, feed_color);
if (!line->rapid) {
update_model_extents(line->start);
update_model_extents(line->end);
}
} else if (arc != nullptr) {
auto pieces = arc->split(0.1);
for (auto &p: pieces) {
// transform arc to line
add_line(buffer_data, p->start, feed_color, p->end, feed_color);
update_model_extents(p->start);
update_model_extents(p->end);
}
}
}
@@ -537,6 +546,17 @@ void grbl::program_renderer::initialize_heightmap_buffers() {
glBindVertexArray(0);
}
void grbl::program_renderer::update_model_extents(glm::vec3 point) {
min_pos.x = std::min(min_pos.x, point.x);
min_pos.y = std::min(min_pos.y, point.y);
min_pos.z = std::min(min_pos.z, point.z);
max_pos.x = std::max(max_pos.x, point.x);
max_pos.y = std::max(max_pos.y, point.y);
max_pos.z = std::max(max_pos.z, point.z);
}
std::string get_shader_info_log(GLuint id) {
GLint log_length = 0;
glGetShaderiv(id, GL_INFO_LOG_LENGTH, &log_length);
+1
View File
@@ -22,6 +22,7 @@ public:
void update_grid(const grbl::heightmap& grid);
private:
GLsizei update_model_vbo(const grbl::program& pgm);
void update_model_extents(glm::vec3 point);
GLuint spindle_vbo_id;
GLuint spindle_vao_id;