Skip to content

Commit

Permalink
Merge pull request #1026 from gazebosim/merge_6_7_partial_20240731
Browse files Browse the repository at this point in the history
Merge 6 -> 7 (Partial merge forward)
  • Loading branch information
iche033 authored Aug 1, 2024
2 parents 65b5ed8 + 7d4b012 commit ad30d4e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions ogre/src/OgreDistortionPass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ void OgreDistortionPass::CreateRenderPass()
distortedLocation,
newDistortedCoordinates,
currDistortedCoordinates;
unsigned int distortedIdx,
distortedCol,
unsigned int distortedIdx;
int distortedCol,
distortedRow;
double normalizedColLocation, normalizedRowLocation;

Expand All @@ -223,9 +223,9 @@ void OgreDistortionPass::CreateRenderPass()
focalLength);

// compute the index in the distortion map
distortedCol = static_cast<unsigned int>(round(distortedLocation.X() *
distortedCol = static_cast<int>(round(distortedLocation.X() *
this->dataPtr->distortionTexWidth));
distortedRow = static_cast<unsigned int>(round(distortedLocation.Y() *
distortedRow = static_cast<int>(round(distortedLocation.Y() *
this->dataPtr->distortionTexHeight));

// Note that the following makes sure that, for significant distortions,
Expand All @@ -235,8 +235,11 @@ void OgreDistortionPass::CreateRenderPass()
// nonlegacy distortion modes.

// Make sure the distorted pixel is within the texture dimensions
if (distortedCol < this->dataPtr->distortionTexWidth &&
distortedRow < this->dataPtr->distortionTexHeight)
if (distortedCol >= 0 && distortedRow >= 0 &&
static_cast<unsigned int>(distortedCol) <
this->dataPtr->distortionTexWidth &&
static_cast<unsigned int>(distortedRow) <
this->dataPtr->distortionTexHeight)
{
distortedIdx = distortedRow * this->dataPtr->distortionTexWidth +
distortedCol;
Expand Down

0 comments on commit ad30d4e

Please sign in to comment.