Skip to content

Commit

Permalink
Make sure cell sizes are updated when map min cell width changes
Browse files Browse the repository at this point in the history
  • Loading branch information
victorreijgwart committed Dec 12, 2024
1 parent 21c91e2 commit fa8a4eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,17 @@ void SliceVisual::update() {
// Allocate the pointcloud representing this grid level if needed
if (static_cast<int>(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<CellLayer>(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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(depth);
const FloatingPoint cell_width =
convert::heightToCellWidth(min_cell_width, height);
auto& voxel_layer = voxel_layer_visuals.emplace_back(
std::make_unique<CellLayer>(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<int>(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);
}
Expand Down

0 comments on commit fa8a4eb

Please sign in to comment.