Heightmap probing is now rendered in real time.
This commit is contained in:
@@ -513,7 +513,7 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
void fill_heightmap_from_grid(const grbl::heightmap& grid) {
|
||||
void fill_heightmap_controls_from_grid(const grbl::heightmap& grid) const {
|
||||
txt_heightmap_from_x->set_value(std::to_string(grid.from_x));
|
||||
txt_heightmap_from_y->set_value(std::to_string(grid.from_y));
|
||||
txt_heightmap_to_x->set_value(std::to_string(grid.to_x));
|
||||
@@ -562,7 +562,7 @@ public:
|
||||
}, true);
|
||||
if (!path.empty()) {
|
||||
heightmap_grid = load_heightmap(path);
|
||||
fill_heightmap_from_grid(heightmap_grid);
|
||||
fill_heightmap_controls_from_grid(heightmap_grid);
|
||||
renderer.update_grid(heightmap_grid);
|
||||
}
|
||||
});
|
||||
@@ -639,7 +639,7 @@ public:
|
||||
});
|
||||
}
|
||||
|
||||
void fill_heightmap_from_model() {
|
||||
void fill_heightmap_from_model() const {
|
||||
auto min = renderer.get_extents_min();
|
||||
auto max = renderer.get_extents_max();
|
||||
txt_heightmap_from_x->set_value(std::to_string(min.x));
|
||||
@@ -895,9 +895,12 @@ public:
|
||||
new MessageDialog(this, MessageDialog::Type::Warning, "Probe result", ss.str());
|
||||
}
|
||||
|
||||
volatile bool should_render_grid = false;
|
||||
void on_heightmap_probe_acquired(grbl::heightmap *grid) override {
|
||||
std::cout << "Updating grid" << std::endl;
|
||||
renderer.update_grid(*grid);
|
||||
// let's try to update this from the UI thread since the call is invoked from the
|
||||
// grbl communicator thread.
|
||||
should_render_grid = true;
|
||||
}
|
||||
|
||||
void on_check_completed(bool success, size_t failed_index, size_t error) override {
|
||||
@@ -1065,6 +1068,12 @@ public:
|
||||
machine_initialized = false;
|
||||
}
|
||||
|
||||
// TODO: change this to something prettier. make a pipe/queue for in-between threads comm
|
||||
if (should_render_grid) {
|
||||
renderer.update_grid(heightmap_grid);
|
||||
should_render_grid = false;
|
||||
}
|
||||
|
||||
Widget::draw(ctx);
|
||||
}
|
||||
|
||||
@@ -1075,23 +1084,21 @@ public:
|
||||
m_render_pass->resize(framebuffer_size());
|
||||
m_render_pass->begin();
|
||||
|
||||
if (pgm.is_loaded) {
|
||||
renderer.update(pgm, cnc);
|
||||
// compute mvp
|
||||
glm::mat4 projection = glm::perspective(45.0f * glm::pi<float>() / 180.0f,
|
||||
(float) fb_size.x() / (float) fb_size.y(),
|
||||
0.1f,
|
||||
10000.f);
|
||||
renderer.update(pgm, cnc);
|
||||
// compute mvp
|
||||
glm::mat4 projection = glm::perspective(45.0f * glm::pi<float>() / 180.0f,
|
||||
(float) fb_size.x() / (float) fb_size.y(),
|
||||
0.1f,
|
||||
10000.f);
|
||||
|
||||
glm::mat4 view = glm::translate(glm::mat4(1.0f), glm::vec3(0, 0, -cam_zoom)) *
|
||||
glm::toMat4(cam_src_rotation) *
|
||||
glm::translate(glm::mat4(1.0f), cam_pan - cam_target);
|
||||
glm::mat4 view = glm::translate(glm::mat4(1.0f), glm::vec3(0, 0, -cam_zoom)) *
|
||||
glm::toMat4(cam_src_rotation) *
|
||||
glm::translate(glm::mat4(1.0f), cam_pan - cam_target);
|
||||
|
||||
glm::mat4 model = glm::mat4(1.0f);
|
||||
glm::mat3 normal_mat = glm::inverseTranspose(glm::mat3(view * model));
|
||||
glm::mat4 model = glm::mat4(1.0f);
|
||||
glm::mat3 normal_mat = glm::inverseTranspose(glm::mat3(view * model));
|
||||
|
||||
renderer.render(model, view, projection, normal_mat, glm::vec2(fb_size.x(), fb_size.y()));
|
||||
}
|
||||
renderer.render(model, view, projection, normal_mat, glm::vec2(fb_size.x(), fb_size.y()));
|
||||
|
||||
m_render_pass->end();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user