Skip to content

Commit

Permalink
Change reinterpret casts to static casts
Browse files Browse the repository at this point in the history
The underlying data structure changed so we don't
need the reinterpret casts anymore.
Leaving the static_casts to make explicit what we
expect at that point and force action if the model
changes again on some update
  • Loading branch information
Martin-Idel committed Aug 5, 2019
1 parent 6c59f7e commit b61bdea
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions rviz_common/src/rviz_common/interaction/selection_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ SelectionManager::~SelectionManager()
delete highlight_rectangle_;

for (auto & pixel_box : pixel_boxes_) {
delete[] reinterpret_cast<uint8_t *>(pixel_box.data);
delete[] static_cast<uint8_t *>(pixel_box.data);
}

delete property_model_;
Expand Down Expand Up @@ -269,7 +269,7 @@ void SelectionManager::unpackColors(const Ogre::PixelBox & box)
for (uint32_t x = 0; x < w; ++x) {
uint32_t pos = (x + y * w) * 4;

uint32_t pix_val = *reinterpret_cast<uint32_t *>(reinterpret_cast<uint8_t *>(box.data) + pos);
uint32_t pix_val = *reinterpret_cast<uint32_t *>(static_cast<uint8_t *>(box.data) + pos);
uint32_t handle = colorToHandle(box.format, pix_val);

pixel_buffer_.push_back(handle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ void SelectionRenderer::blitToMemory(
auto size = Ogre::PixelUtil::getMemorySize(viewport_w, viewport_h, 1, format);
auto data = new uint8_t[size];

delete[] reinterpret_cast<uint8_t *>(dst_box.data);
delete[] static_cast<uint8_t *>(dst_box.data);
dst_box = Ogre::PixelBox(viewport_w, viewport_h, 1, format, data);

pixel_buffer->blitToMemory(dst_box, dst_box);
Expand Down
4 changes: 2 additions & 2 deletions rviz_common/src/rviz_common/interaction/view_picker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ ViewPicker::ViewPicker(DisplayContext * context)

ViewPicker::~ViewPicker()
{
delete[] reinterpret_cast<uint8_t *>(depth_pixel_box_.data);
delete[] static_cast<uint8_t *>(depth_pixel_box_.data);
}

void ViewPicker::initialize()
Expand Down Expand Up @@ -168,7 +168,7 @@ void ViewPicker::getPatchDepthImage(
depth_render_texture_, Dimensions(depth_texture_width_, depth_texture_height_), "Depth"),
depth_pixel_box_);

auto data_ptr = reinterpret_cast<uint8_t *>(depth_pixel_box_.data);
auto data_ptr = static_cast<uint8_t *>(depth_pixel_box_.data);

for (uint32_t pixel = 0; pixel < num_pixels; ++pixel) {
uint8_t a = data_ptr[4 * pixel];
Expand Down

0 comments on commit b61bdea

Please sign in to comment.