Heightmap probing is now rendered in real time.
This commit is contained in:
+23
-21
@@ -9,32 +9,33 @@ DONE - step every: 5mm?
|
|||||||
- z final safety height: Z15
|
- z final safety height: Z15
|
||||||
|
|
||||||
DONE - from and to can be filled from current project bounding box
|
DONE - from and to can be filled from current project bounding box
|
||||||
|
DONE 2. probing
|
||||||
2. probing
|
DONE - machine moves at grid start position (x, y)
|
||||||
- machine moves at grid start position (x, y)
|
DONE G0X0Y0
|
||||||
G0X0Y0
|
DONE - gets down for initial probing
|
||||||
- gets down for initial probing
|
DONE G38.2 Z-65 F100
|
||||||
G38.2 Z-65 F100
|
DONE - step back a bit (1mm, relative)
|
||||||
- step back a bit (1mm, relative)
|
DONE G91 G0 Z1
|
||||||
G91 G0 Z1
|
DONE - seek again with lower feed rate
|
||||||
- seek again with lower feed rate
|
DONE G38.2 Z-5 F5
|
||||||
G38.2 Z-5 F5
|
DONE - after first probe ever, this Z becomes reference 0
|
||||||
- after first probe ever, this Z becomes reference 0
|
DONE G10 L20 P0 Z0
|
||||||
G10 L20 P0 Z0
|
DONE - all subsequent probes will be relative to this
|
||||||
|
DONE - for each probing location:
|
||||||
- all subsequent probes will be relative to this
|
DONE - G0 Z"clearance height"
|
||||||
- for each probing location:
|
DONE - G0 XxxYyyy (next point location)
|
||||||
- G0 Z"clearance height"
|
DONE - G0 Z"start probing at"
|
||||||
- G0 XxxYyyy (next point location)
|
DONE - G38.2 Z-5 F5
|
||||||
- G0 Z"start probing at"
|
DONE - store Z offset and place it in the heightmap
|
||||||
- G38.2 Z-5 F5
|
|
||||||
- store Z offset and place it in the heightmap
|
|
||||||
|
|
||||||
3. modify loaded program with heightmap data
|
3. modify loaded program with heightmap data
|
||||||
- foreach line in program
|
- foreach line in program
|
||||||
- if line contains a Z coordinate, update the Z according to the X and Y
|
- if line contains a Z coordinate, update the Z according to the X and Y
|
||||||
- if line does not contain a Z coordinate, add a Z coordinate according to the X and Y
|
- if line does not contain a Z coordinate, add a Z coordinate according to the X and Y
|
||||||
|
|
||||||
|
Solve bug in which the probing data does not get rendered properly as it gets probed.
|
||||||
|
Bug: query coordinate systems after first z probe.
|
||||||
|
|
||||||
Edge finding
|
Edge finding
|
||||||
- prerequisites
|
- prerequisites
|
||||||
- which edge to find? -X/+X/-Y/+Y
|
- which edge to find? -X/+X/-Y/+Y
|
||||||
@@ -50,8 +51,9 @@ Render arcs
|
|||||||
Render quadratic splines
|
Render quadratic splines
|
||||||
Render bezier splines
|
Render bezier splines
|
||||||
Synchronize executing program with render (show executed paths with different colors)
|
Synchronize executing program with render (show executed paths with different colors)
|
||||||
Show a progress bar when executing programs.
|
|
||||||
Add aggressive buffer execution policy and make it selectable.
|
Add aggressive buffer execution policy and make it selectable.
|
||||||
|
Show a progress bar when executing programs.
|
||||||
|
Show a progress bar when probing.
|
||||||
|
|
||||||
DONE - Show program extents
|
DONE - Show program extents
|
||||||
|
|
||||||
|
|||||||
@@ -513,7 +513,7 @@ public:
|
|||||||
return result;
|
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_x->set_value(std::to_string(grid.from_x));
|
||||||
txt_heightmap_from_y->set_value(std::to_string(grid.from_y));
|
txt_heightmap_from_y->set_value(std::to_string(grid.from_y));
|
||||||
txt_heightmap_to_x->set_value(std::to_string(grid.to_x));
|
txt_heightmap_to_x->set_value(std::to_string(grid.to_x));
|
||||||
@@ -562,7 +562,7 @@ public:
|
|||||||
}, true);
|
}, true);
|
||||||
if (!path.empty()) {
|
if (!path.empty()) {
|
||||||
heightmap_grid = load_heightmap(path);
|
heightmap_grid = load_heightmap(path);
|
||||||
fill_heightmap_from_grid(heightmap_grid);
|
fill_heightmap_controls_from_grid(heightmap_grid);
|
||||||
renderer.update_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 min = renderer.get_extents_min();
|
||||||
auto max = renderer.get_extents_max();
|
auto max = renderer.get_extents_max();
|
||||||
txt_heightmap_from_x->set_value(std::to_string(min.x));
|
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());
|
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 {
|
void on_heightmap_probe_acquired(grbl::heightmap *grid) override {
|
||||||
std::cout << "Updating grid" << std::endl;
|
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 {
|
void on_check_completed(bool success, size_t failed_index, size_t error) override {
|
||||||
@@ -1065,6 +1068,12 @@ public:
|
|||||||
machine_initialized = false;
|
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);
|
Widget::draw(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1075,7 +1084,6 @@ public:
|
|||||||
m_render_pass->resize(framebuffer_size());
|
m_render_pass->resize(framebuffer_size());
|
||||||
m_render_pass->begin();
|
m_render_pass->begin();
|
||||||
|
|
||||||
if (pgm.is_loaded) {
|
|
||||||
renderer.update(pgm, cnc);
|
renderer.update(pgm, cnc);
|
||||||
// compute mvp
|
// compute mvp
|
||||||
glm::mat4 projection = glm::perspective(45.0f * glm::pi<float>() / 180.0f,
|
glm::mat4 projection = glm::perspective(45.0f * glm::pi<float>() / 180.0f,
|
||||||
@@ -1091,7 +1099,6 @@ public:
|
|||||||
glm::mat3 normal_mat = glm::inverseTranspose(glm::mat3(view * model));
|
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();
|
m_render_pass->end();
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -339,6 +339,8 @@ void grbl::program_renderer::initialize_program_buffers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GLsizei grbl::program_renderer::update_model_vbo(const grbl::program& pgm) {
|
GLsizei grbl::program_renderer::update_model_vbo(const grbl::program& pgm) {
|
||||||
|
if (!pgm.is_loaded) return 0;
|
||||||
|
|
||||||
static auto movement_re = std::regex(R"(([gG]0*1?\s+|[xXyYzZ]\s*[0-9\.\-]+))");
|
static auto movement_re = std::regex(R"(([gG]0*1?\s+|[xXyYzZ]\s*[0-9\.\-]+))");
|
||||||
bool is_tool_on = false;
|
bool is_tool_on = false;
|
||||||
|
|
||||||
@@ -428,6 +430,9 @@ void grbl::program_renderer::update_grid(const grbl::heightmap& grid) {
|
|||||||
|
|
||||||
glm::vec4 color = {0.5, 0.3, 0, 1};
|
glm::vec4 color = {0.5, 0.3, 0, 1};
|
||||||
|
|
||||||
|
// this should only be called whenever the grid changes
|
||||||
|
// therefor it should be called each and every time we
|
||||||
|
// probe a new location. let's check that.
|
||||||
std::vector<float> buffer_data;
|
std::vector<float> buffer_data;
|
||||||
|
|
||||||
for (int y = 0; y < grid.y_segments; y++) {
|
for (int y = 0; y < grid.y_segments; y++) {
|
||||||
@@ -466,7 +471,7 @@ void grbl::program_renderer::update_grid(const grbl::heightmap& grid) {
|
|||||||
heightmap_vertices_count = buffer_data.size() * sizeof(float) / size_of_vertex_in_bytes;
|
heightmap_vertices_count = buffer_data.size() * sizeof(float) / size_of_vertex_in_bytes;
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, heightmap_vbo_id);
|
glBindBuffer(GL_ARRAY_BUFFER, heightmap_vbo_id);
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * buffer_data.size(), buffer_data.data(), GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * buffer_data.size(), buffer_data.data(), GL_DYNAMIC_DRAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
void grbl::program_renderer::initialize_heightmap_buffers() {
|
void grbl::program_renderer::initialize_heightmap_buffers() {
|
||||||
|
|||||||
Reference in New Issue
Block a user