Bugfix: update model extents when using OpenCNCPilot parser.
This commit is contained in:
+20
@@ -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);
|
add_line(buffer_data, line->start, rapid_color, line->end, rapid_color);
|
||||||
else
|
else
|
||||||
add_line(buffer_data, line->start, feed_color, line->end, feed_color);
|
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) {
|
} else if (arc != nullptr) {
|
||||||
auto pieces = arc->split(0.1);
|
auto pieces = arc->split(0.1);
|
||||||
for (auto &p: pieces) {
|
for (auto &p: pieces) {
|
||||||
// transform arc to line
|
// transform arc to line
|
||||||
add_line(buffer_data, p->start, feed_color, p->end, feed_color);
|
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);
|
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) {
|
std::string get_shader_info_log(GLuint id) {
|
||||||
GLint log_length = 0;
|
GLint log_length = 0;
|
||||||
glGetShaderiv(id, GL_INFO_LOG_LENGTH, &log_length);
|
glGetShaderiv(id, GL_INFO_LOG_LENGTH, &log_length);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ public:
|
|||||||
void update_grid(const grbl::heightmap& grid);
|
void update_grid(const grbl::heightmap& grid);
|
||||||
private:
|
private:
|
||||||
GLsizei update_model_vbo(const grbl::program& pgm);
|
GLsizei update_model_vbo(const grbl::program& pgm);
|
||||||
|
void update_model_extents(glm::vec3 point);
|
||||||
|
|
||||||
GLuint spindle_vbo_id;
|
GLuint spindle_vbo_id;
|
||||||
GLuint spindle_vao_id;
|
GLuint spindle_vao_id;
|
||||||
|
|||||||
Reference in New Issue
Block a user