Skip to content

Commit

Permalink
Merge pull request #1027 from gazebosim/merge_7_8_20240801
Browse files Browse the repository at this point in the history
Merge 7 -> 8
  • Loading branch information
iche033 authored Aug 2, 2024
2 parents 6a2217f + 1cc9d51 commit f606a32
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 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
8 changes: 7 additions & 1 deletion ogre2/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ set(engine_name "ogre2")
gz_add_component(${engine_name} SOURCES ${sources} GET_TARGET_NAME ogre2_target)

set(OGRE2_RESOURCE_PATH_STR "${OGRE2_RESOURCE_PATH}")
string(REPLACE ";" ":" OGRE2_RESOURCE_PATH_STR "${OGRE2_RESOURCE_PATH}")
# On non-Windows, we need to convert the CMake list delimited (;) to the
# list delimiter used in list of paths in code (:)
# On Windows, the list delimiter in code is already ;, not need to change it to :
if(NOT WIN32)
string(REPLACE ";" ":" OGRE2_RESOURCE_PATH_STR "${OGRE2_RESOURCE_PATH}")
endif()

set_property(
SOURCE Ogre2RenderEngine.cc
PROPERTY COMPILE_DEFINITIONS
Expand Down
7 changes: 5 additions & 2 deletions ogre2/src/Ogre2RenderEngine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#endif
#include <gz/common/Console.hh>
#include <gz/common/Filesystem.hh>
#include <gz/common/StringUtils.hh>
#include <gz/common/SystemPaths.hh>
#include <gz/common/Util.hh>

#include <gz/plugin/Register.hh>
Expand Down Expand Up @@ -153,14 +155,15 @@ Ogre2RenderEngine::Ogre2RenderEngine() :
this->dummyWindowId = 0;

std::string ogrePath = std::string(OGRE2_RESOURCE_PATH);
std::vector<std::string> paths = common::split(ogrePath, ":");
std::vector<std::string> paths = common::Split(ogrePath,
common::SystemPaths::Delimiter());
for (const auto &path : paths)
this->ogrePaths.push_back(path);

const char *env = std::getenv("OGRE2_RESOURCE_PATH");
if (env)
{
paths = common::split(std::string(env), ":");
paths = common::Split(std::string(env), common::SystemPaths::Delimiter());
for (const auto &path : paths)
this->ogrePaths.push_back(path);
}
Expand Down

0 comments on commit f606a32

Please sign in to comment.