Heightmap probing is now rendered in real time.

This commit is contained in:
2023-05-10 14:08:14 +03:00
parent 8a1c7d7d89
commit 5748e3d5af
3 changed files with 55 additions and 41 deletions
+6 -1
View File
@@ -339,6 +339,8 @@ void grbl::program_renderer::initialize_program_buffers() {
}
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\.\-]+))");
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};
// 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;
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;
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() {