From 65b5ed83f349707a195e16d5509ee48d6835db48 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Tue, 28 May 2024 14:41:28 +0200 Subject: [PATCH 1/2] Parse correctly OGRE2_RESOURCE_PATH on Windows (#996) Signed-off-by: Silvio Traversaro --- ogre2/src/CMakeLists.txt | 8 +++++++- ogre2/src/Ogre2RenderEngine.cc | 7 +++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ogre2/src/CMakeLists.txt b/ogre2/src/CMakeLists.txt index cfd9b220b..537b5f180 100644 --- a/ogre2/src/CMakeLists.txt +++ b/ogre2/src/CMakeLists.txt @@ -16,7 +16,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 diff --git a/ogre2/src/Ogre2RenderEngine.cc b/ogre2/src/Ogre2RenderEngine.cc index ae0184d6b..ffce08dc4 100644 --- a/ogre2/src/Ogre2RenderEngine.cc +++ b/ogre2/src/Ogre2RenderEngine.cc @@ -22,6 +22,8 @@ #endif #include #include +#include +#include #include #include @@ -118,14 +120,15 @@ Ogre2RenderEngine::Ogre2RenderEngine() : this->dummyWindowId = 0; std::string ogrePath = std::string(OGRE2_RESOURCE_PATH); - std::vector paths = common::split(ogrePath, ":"); + std::vector 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); } From 7d4b0125f5e20c445bcecbdd67a2b4400000ab4e Mon Sep 17 00:00:00 2001 From: Martin Pecka Date: Thu, 25 Apr 2024 20:00:14 +0200 Subject: [PATCH 2/2] Fixed integer underflow in OgreDistortionPass (#994) Signed-off-by: Martin Pecka --- ogre/src/OgreDistortionPass.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ogre/src/OgreDistortionPass.cc b/ogre/src/OgreDistortionPass.cc index 7c97c471d..774759e8e 100644 --- a/ogre/src/OgreDistortionPass.cc +++ b/ogre/src/OgreDistortionPass.cc @@ -196,8 +196,8 @@ void OgreDistortionPass::CreateRenderPass() distortedLocation, newDistortedCoordinates, currDistortedCoordinates; - unsigned int distortedIdx, - distortedCol, + unsigned int distortedIdx; + int distortedCol, distortedRow; double normalizedColLocation, normalizedRowLocation; @@ -223,9 +223,9 @@ void OgreDistortionPass::CreateRenderPass() focalLength); // compute the index in the distortion map - distortedCol = static_cast(round(distortedLocation.X() * + distortedCol = static_cast(round(distortedLocation.X() * this->dataPtr->distortionTexWidth)); - distortedRow = static_cast(round(distortedLocation.Y() * + distortedRow = static_cast(round(distortedLocation.Y() * this->dataPtr->distortionTexHeight)); // Note that the following makes sure that, for significant distortions, @@ -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(distortedCol) < + this->dataPtr->distortionTexWidth && + static_cast(distortedRow) < + this->dataPtr->distortionTexHeight) { distortedIdx = distortedRow * this->dataPtr->distortionTexWidth + distortedCol;