From fa8a4ebd71120d6069a90fc8cec14769ae7e885d Mon Sep 17 00:00:00 2001 From: Victor Reijgwart Date: Thu, 12 Dec 2024 18:30:47 +0100 Subject: [PATCH] Make sure cell sizes are updated when map min cell width changes --- .../ros1/wavemap_rviz_plugin/src/visuals/slice_visual.cc | 6 +++--- .../ros1/wavemap_rviz_plugin/src/visuals/voxel_visual.cc | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/interfaces/ros1/wavemap_rviz_plugin/src/visuals/slice_visual.cc b/interfaces/ros1/wavemap_rviz_plugin/src/visuals/slice_visual.cc index b21154f13..fdb2fb4db 100644 --- a/interfaces/ros1/wavemap_rviz_plugin/src/visuals/slice_visual.cc +++ b/interfaces/ros1/wavemap_rviz_plugin/src/visuals/slice_visual.cc @@ -144,17 +144,17 @@ void SliceVisual::update() { // Allocate the pointcloud representing this grid level if needed if (static_cast(grid_levels_.size()) <= height) { const Ogre::String name = "multi_res_slice_" + std::to_string(height); - const FloatingPoint cell_width = - convert::heightToCellWidth(min_cell_width, height); auto& grid_level = grid_levels_.emplace_back( std::make_unique(slice_cell_material_)); grid_level->setName(name); - grid_level->setCellDimensions(cell_width, cell_width, 0.0); grid_level->setAlpha(alpha); frame_node_->attachObject(grid_level.get()); } // Update the points auto& grid_level = grid_levels_[height]; + const FloatingPoint cell_width = + convert::heightToCellWidth(min_cell_width, height); + grid_level->setCellDimensions(cell_width, cell_width, 0.0); grid_level->clear(); const auto& cells_at_level = cells_per_level[height]; grid_level->setCells(cells_at_level); diff --git a/interfaces/ros1/wavemap_rviz_plugin/src/visuals/voxel_visual.cc b/interfaces/ros1/wavemap_rviz_plugin/src/visuals/voxel_visual.cc index 1b7fe412c..d093f0d7d 100644 --- a/interfaces/ros1/wavemap_rviz_plugin/src/visuals/voxel_visual.cc +++ b/interfaces/ros1/wavemap_rviz_plugin/src/visuals/voxel_visual.cc @@ -383,18 +383,18 @@ void VoxelVisual::drawMultiResolutionVoxels(IndexElement tree_height, // Allocate the pointcloud representing this voxel grid level if needed if (voxel_layer_visuals.size() <= depth) { const Ogre::String name = prefix + std::to_string(depth); - const IndexElement height = tree_height - static_cast(depth); - const FloatingPoint cell_width = - convert::heightToCellWidth(min_cell_width, height); auto& voxel_layer = voxel_layer_visuals.emplace_back( std::make_unique(voxel_material_)); voxel_layer->setName(name); - voxel_layer->setCellDimensions(cell_width, cell_width, cell_width); voxel_layer->setAlpha(alpha); frame_node_->attachObject(voxel_layer.get()); } // Update the cells auto& voxel_layer = voxel_layer_visuals[depth]; + const IndexElement height = tree_height - static_cast(depth); + const FloatingPoint cell_width = + convert::heightToCellWidth(min_cell_width, height); + voxel_layer->setCellDimensions(cell_width, cell_width, cell_width); const auto& cells_at_level = voxels_per_level[depth]; voxel_layer->setCells(cells_at_level); }