From d8896278b95596df4da1c7c604d6be022267e86b Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Tue, 23 Sep 2025 19:48:11 +0200 Subject: [PATCH 1/4] Exclude OGRE2 Overlay using a CMake argument (gz-rendering9) This is mainly a port of https://github.com/gazebosim/gz-rendering/pull/1175 to be activated under the parameter `USE_OGRE2_OVERLAY` enabled by default. Signed-off-by: Jose Luis Rivero --- CMakeLists.txt | 16 ++++++++++++++-- Changelog.md | 6 ++++++ include/gz/rendering/config.hh.in | 1 + .../include/gz/rendering/ogre2/Ogre2Includes.hh | 4 ++++ .../gz/rendering/ogre2/Ogre2RenderEngine.hh | 9 +++++++++ ogre2/src/Ogre2RenderEngine.cc | 9 +++++++++ ogre2/src/Ogre2Scene.cc | 7 +++++++ 7 files changed, 50 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 54864ef0f..283fa31ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,7 @@ gz_configure_project(VERSION_SUFFIX) # Set project-specific options #============================================================================ option(USE_UNOFFICIAL_OGRE_VERSIONS "Accept unsupported Ogre versions in the build" OFF) +option(USE_OGRE2_OVERLAY "Enable OGRE2 Overlay support" ON) #============================================================================ # Search for project-specific dependencies @@ -102,21 +103,32 @@ endif() # Find OGRE2: first try to find OGRE2 built with PlanarReflections support and # fallback to look for OGRE2 without it. Both seems to works for gz-rendering. # See https://github.com/gazebosim/gz-rendering/issues/597 + +# Build the list of OGRE2 components based on the options +set(OGRE2_COMPONENTS HlmsPbs HlmsUnlit PlanarReflections) +if(USE_OGRE2_OVERLAY) + list(APPEND OGRE2_COMPONENTS Overlay) +endif() + gz_find_package(GzOGRE2 VERSION 2.3.1 - COMPONENTS HlmsPbs HlmsUnlit Overlay PlanarReflections + COMPONENTS ${OGRE2_COMPONENTS} PRIVATE_FOR ogre2 QUIET) if ("${OGRE2-PlanarReflections}" STREQUAL "OGRE2-PlanarReflections-NOTFOUND") message(STATUS "PlanarReflections component was not found. Try looking without it:") gz_find_package(GzOGRE2 VERSION 2.3.1 - COMPONENTS HlmsPbs HlmsUnlit Overlay + COMPONENTS ${OGRE2_COMPONENTS} REQUIRED_BY ogre2 PRIVATE_FOR ogre2) endif() if (OGRE2_FOUND) set(GZ_RENDERING_HAVE_OGRE2 TRUE) + + if(NOT USE_OGRE2_OVERLAY) + message(STATUS "OGRE2 Overlay support disabled by configuration") + endif() endif() #-------------------------------------- diff --git a/Changelog.md b/Changelog.md index b5e905594..29b1cd71d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,12 @@ ### Gazebo Rendering 9.X +1. Conditional OGRE2 Overlay Support + * By default, OGRE2 overlay support is enabled, but it can be disabled using the + CMake option `USE_OGRE2_OVERLAY=OFF`. This is useful for builds using libc++ + version 19 or greater than are broken, see (). + * [Pull request]() + ### Gazebo Rendering 9.4.0 (2025-09-05) 1. Add bazel build for ogre2 engine diff --git a/include/gz/rendering/config.hh.in b/include/gz/rendering/config.hh.in index f76f96d1f..b84591469 100644 --- a/include/gz/rendering/config.hh.in +++ b/include/gz/rendering/config.hh.in @@ -38,6 +38,7 @@ #cmakedefine GZ_RENDERING_HAVE_OGRE 1 #cmakedefine GZ_RENDERING_HAVE_OGRE2 1 +#cmakedefine GZ_RENDERING_HAVE_OGRE2_OVERLAY 1 #cmakedefine GZ_RENDERING_HAVE_OPTIX 1 #cmakedefine GZ_RENDERING_HAVE_VULKAN 1 diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Includes.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Includes.hh index f5c04839b..ff5222fbc 100644 --- a/ogre2/include/gz/rendering/ogre2/Ogre2Includes.hh +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Includes.hh @@ -17,6 +17,8 @@ #ifndef GZ_RENDERING_OGRE2_OGRE2INCLUDES_HH_ #define GZ_RENDERING_OGRE2_OGRE2INCLUDES_HH_ +#include "gz/rendering/config.hh" + // This disables warning messages for OGRE #ifndef _MSC_VER #pragma GCC system_header @@ -96,12 +98,14 @@ #include #include +#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY #include #include #include #include #include #include +#endif // TODO(anyone): enable when ogre 2.1 fully supports paging // and terrain components diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2RenderEngine.hh b/ogre2/include/gz/rendering/ogre2/Ogre2RenderEngine.hh index 9223385d6..821419ab2 100644 --- a/ogre2/include/gz/rendering/ogre2/Ogre2RenderEngine.hh +++ b/ogre2/include/gz/rendering/ogre2/Ogre2RenderEngine.hh @@ -24,6 +24,7 @@ #include +#include "gz/rendering/config.hh" #include "gz/rendering/GraphicsAPI.hh" #include "gz/rendering/RenderEnginePlugin.hh" #include "gz/rendering/base/BaseRenderEngine.hh" @@ -37,10 +38,12 @@ namespace Ogre class LogManager; class Root; class Window; +#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY namespace v1 { class OverlaySystem; } +#endif class HlmsPbsTerraShadows; class CompositorWorkspaceListener; @@ -161,8 +164,10 @@ namespace gz /// \brief Create ogre root private: void CreateRoot(); +#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY /// \brief Create ogre overlay component private: void CreateOverlay(); +#endif /// \brief Create ogre plugins. private: void LoadPlugins(); @@ -187,10 +192,12 @@ namespace gz /// \return Ogre HLMS customizations public: Ogre2GzHlmsSphericalClipMinDistance &SphericalClipMinDistance(); +#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY /// \internal /// \brief Get a pointer to the Ogre overlay system. /// \return Pointer to the ogre overlay system. public: Ogre::v1::OverlaySystem *OverlaySystem() const; +#endif /// \internal /// \brief Sets the current rendering mode. See GzOgreRenderingMode @@ -221,8 +228,10 @@ namespace gz /// \return a pointer to the render engine public: static Ogre2RenderEngine *Instance(); +#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY /// \brief Pointer to the ogre's overlay system private: Ogre::v1::OverlaySystem *ogreOverlaySystem = nullptr; +#endif /// \brief List of scenes managed by the render engine private: Ogre2SceneStorePtr scenes; diff --git a/ogre2/src/Ogre2RenderEngine.cc b/ogre2/src/Ogre2RenderEngine.cc index 0290a632e..b8431e4ab 100644 --- a/ogre2/src/Ogre2RenderEngine.cc +++ b/ogre2/src/Ogre2RenderEngine.cc @@ -28,6 +28,7 @@ #include +#include "gz/rendering/config.hh" #include "gz/rendering/GraphicsAPI.hh" #include "gz/rendering/InstallationDirectories.hh" #include "gz/rendering/RenderEngineManager.hh" @@ -190,8 +191,10 @@ void Ogre2RenderEngine::Destroy() this->scenes->RemoveAll(); } +#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY delete this->ogreOverlaySystem; this->ogreOverlaySystem = nullptr; +#endif this->dataPtr->hlmsPbsTerraShadows.reset(); @@ -501,7 +504,9 @@ void Ogre2RenderEngine::LoadAttempt() } this->CreateRoot(); +#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY this->CreateOverlay(); +#endif this->LoadPlugins(); this->CreateRenderSystem(); this->ogreRoot->initialise(false); @@ -636,11 +641,13 @@ void Ogre2RenderEngine::CreateRoot() } } +#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY ////////////////////////////////////////////////// void Ogre2RenderEngine::CreateOverlay() { this->ogreOverlaySystem = new Ogre::v1::OverlaySystem(); } +#endif ////////////////////////////////////////////////// void Ogre2RenderEngine::LoadPlugins() @@ -1416,11 +1423,13 @@ SphericalClipMinDistance() return this->dataPtr->sphericalClipMinDistance; } +#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY ///////////////////////////////////////////////// Ogre::v1::OverlaySystem *Ogre2RenderEngine::OverlaySystem() const { return this->ogreOverlaySystem; } +#endif ///////////////////////////////////////////////// void Ogre2RenderEngine::SetGzOgreRenderingMode( diff --git a/ogre2/src/Ogre2Scene.cc b/ogre2/src/Ogre2Scene.cc index 6c9c07a3c..204303385 100644 --- a/ogre2/src/Ogre2Scene.cc +++ b/ogre2/src/Ogre2Scene.cc @@ -31,6 +31,7 @@ #include +#include "gz/rendering/config.hh" #include "gz/rendering/base/SceneExt.hh" #include "gz/rendering/GraphicsAPI.hh" #include "gz/rendering/RenderTypes.hh" @@ -83,8 +84,10 @@ #include #include #include +#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY #include #include +#endif #if OGRE_VERSION_MAJOR == 2 && OGRE_VERSION_MINOR == 1 #include #include @@ -501,11 +504,13 @@ void Ogre2Scene::Destroy() BaseScene::Destroy(); +#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY if (this->ogreSceneManager) { this->ogreSceneManager->removeRenderQueueListener( Ogre2RenderEngine::Instance()->OverlaySystem()); } +#endif if (this->dataPtr->activeGi) { @@ -1477,12 +1482,14 @@ void Ogre2Scene::CreateContext() this->ogreSceneManager = root->createSceneManager(Ogre::ST_GENERIC, numThreads); +#ifdef GZ_RENDERING_HAVE_OGRE2_OVERLAY this->ogreSceneManager->addRenderQueueListener( Ogre2RenderEngine::Instance()->OverlaySystem()); this->ogreSceneManager->getRenderQueue()->setSortRenderQueue( Ogre::v1::OverlayManager::getSingleton().mDefaultRenderQueueId, Ogre::RenderQueue::StableSort); +#endif // Set sane defaults for proper shadow mapping this->ogreSceneManager->setShadowDirectionalLightExtrusionDistance(500.0f); From 05d1834fe410a0ad9384cf91d1eaa6229339dd25 Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Wed, 24 Sep 2025 23:08:25 +0200 Subject: [PATCH 2/4] Use CMake argument to send a compiler flag. Do not mess with headers Signed-off-by: Jose Luis Rivero --- include/gz/rendering/config.hh.in | 1 - ogre2/include/gz/rendering/ogre2/Ogre2Includes.hh | 2 -- ogre2/src/CMakeLists.txt | 6 ++++++ ogre2/src/Ogre2RenderEngine.cc | 1 - 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/gz/rendering/config.hh.in b/include/gz/rendering/config.hh.in index b84591469..f76f96d1f 100644 --- a/include/gz/rendering/config.hh.in +++ b/include/gz/rendering/config.hh.in @@ -38,7 +38,6 @@ #cmakedefine GZ_RENDERING_HAVE_OGRE 1 #cmakedefine GZ_RENDERING_HAVE_OGRE2 1 -#cmakedefine GZ_RENDERING_HAVE_OGRE2_OVERLAY 1 #cmakedefine GZ_RENDERING_HAVE_OPTIX 1 #cmakedefine GZ_RENDERING_HAVE_VULKAN 1 diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Includes.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Includes.hh index ff5222fbc..c7a1ae173 100644 --- a/ogre2/include/gz/rendering/ogre2/Ogre2Includes.hh +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Includes.hh @@ -17,8 +17,6 @@ #ifndef GZ_RENDERING_OGRE2_OGRE2INCLUDES_HH_ #define GZ_RENDERING_OGRE2_OGRE2INCLUDES_HH_ -#include "gz/rendering/config.hh" - // This disables warning messages for OGRE #ifndef _MSC_VER #pragma GCC system_header diff --git a/ogre2/src/CMakeLists.txt b/ogre2/src/CMakeLists.txt index e939e103f..2635d7267 100644 --- a/ogre2/src/CMakeLists.txt +++ b/ogre2/src/CMakeLists.txt @@ -34,6 +34,12 @@ set_property( target_compile_definitions(${ogre2_target} PRIVATE OGRE_IGNORE_UNKNOWN_DEBUG) +# Add OGRE2 Overlay support definition if enabled +if(GZ_RENDERING_HAVE_OGRE2_OVERLAY) + target_compile_definitions(${ogre2_target} + PRIVATE GZ_RENDERING_HAVE_OGRE2_OVERLAY=1) +endif() + # Add OGRE2_LIBRARY_DIRS to INSTALL_RPATH # Append to a copy of CMAKE_INSTALL_RPATH since that is the default set(ogre2_target_install_rpath ${CMAKE_INSTALL_RPATH}) diff --git a/ogre2/src/Ogre2RenderEngine.cc b/ogre2/src/Ogre2RenderEngine.cc index b8431e4ab..a2c3d92c5 100644 --- a/ogre2/src/Ogre2RenderEngine.cc +++ b/ogre2/src/Ogre2RenderEngine.cc @@ -28,7 +28,6 @@ #include -#include "gz/rendering/config.hh" #include "gz/rendering/GraphicsAPI.hh" #include "gz/rendering/InstallationDirectories.hh" #include "gz/rendering/RenderEngineManager.hh" From 5631b93589306fd608dde498e04eedd61d79a62b Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Thu, 25 Sep 2025 11:13:31 +0200 Subject: [PATCH 3/4] Revert "Use CMake argument to send a compiler flag. Do not mess with headers" This reverts commit 05d1834fe410a0ad9384cf91d1eaa6229339dd25. --- include/gz/rendering/config.hh.in | 1 + ogre2/include/gz/rendering/ogre2/Ogre2Includes.hh | 2 ++ ogre2/src/CMakeLists.txt | 6 ------ ogre2/src/Ogre2RenderEngine.cc | 1 + 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/gz/rendering/config.hh.in b/include/gz/rendering/config.hh.in index f76f96d1f..b84591469 100644 --- a/include/gz/rendering/config.hh.in +++ b/include/gz/rendering/config.hh.in @@ -38,6 +38,7 @@ #cmakedefine GZ_RENDERING_HAVE_OGRE 1 #cmakedefine GZ_RENDERING_HAVE_OGRE2 1 +#cmakedefine GZ_RENDERING_HAVE_OGRE2_OVERLAY 1 #cmakedefine GZ_RENDERING_HAVE_OPTIX 1 #cmakedefine GZ_RENDERING_HAVE_VULKAN 1 diff --git a/ogre2/include/gz/rendering/ogre2/Ogre2Includes.hh b/ogre2/include/gz/rendering/ogre2/Ogre2Includes.hh index c7a1ae173..ff5222fbc 100644 --- a/ogre2/include/gz/rendering/ogre2/Ogre2Includes.hh +++ b/ogre2/include/gz/rendering/ogre2/Ogre2Includes.hh @@ -17,6 +17,8 @@ #ifndef GZ_RENDERING_OGRE2_OGRE2INCLUDES_HH_ #define GZ_RENDERING_OGRE2_OGRE2INCLUDES_HH_ +#include "gz/rendering/config.hh" + // This disables warning messages for OGRE #ifndef _MSC_VER #pragma GCC system_header diff --git a/ogre2/src/CMakeLists.txt b/ogre2/src/CMakeLists.txt index 2635d7267..e939e103f 100644 --- a/ogre2/src/CMakeLists.txt +++ b/ogre2/src/CMakeLists.txt @@ -34,12 +34,6 @@ set_property( target_compile_definitions(${ogre2_target} PRIVATE OGRE_IGNORE_UNKNOWN_DEBUG) -# Add OGRE2 Overlay support definition if enabled -if(GZ_RENDERING_HAVE_OGRE2_OVERLAY) - target_compile_definitions(${ogre2_target} - PRIVATE GZ_RENDERING_HAVE_OGRE2_OVERLAY=1) -endif() - # Add OGRE2_LIBRARY_DIRS to INSTALL_RPATH # Append to a copy of CMAKE_INSTALL_RPATH since that is the default set(ogre2_target_install_rpath ${CMAKE_INSTALL_RPATH}) diff --git a/ogre2/src/Ogre2RenderEngine.cc b/ogre2/src/Ogre2RenderEngine.cc index a2c3d92c5..b8431e4ab 100644 --- a/ogre2/src/Ogre2RenderEngine.cc +++ b/ogre2/src/Ogre2RenderEngine.cc @@ -28,6 +28,7 @@ #include +#include "gz/rendering/config.hh" #include "gz/rendering/GraphicsAPI.hh" #include "gz/rendering/InstallationDirectories.hh" #include "gz/rendering/RenderEngineManager.hh" From 1131d9c4d39e81a47b563303fc67dc0d1be0c186 Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Thu, 25 Sep 2025 11:27:06 +0200 Subject: [PATCH 4/4] Add compile definition for the ogre2 when building Signed-off-by: Jose Luis Rivero --- ogre2/src/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ogre2/src/CMakeLists.txt b/ogre2/src/CMakeLists.txt index e939e103f..3864de986 100644 --- a/ogre2/src/CMakeLists.txt +++ b/ogre2/src/CMakeLists.txt @@ -34,6 +34,12 @@ set_property( target_compile_definitions(${ogre2_target} PRIVATE OGRE_IGNORE_UNKNOWN_DEBUG) +# Add overlay support definition if enabled +if(USE_OGRE2_OVERLAY) + target_compile_definitions(${ogre2_target} + PRIVATE GZ_RENDERING_HAVE_OGRE2_OVERLAY=1) +endif() + # Add OGRE2_LIBRARY_DIRS to INSTALL_RPATH # Append to a copy of CMAKE_INSTALL_RPATH since that is the default set(ogre2_target_install_rpath ${CMAKE_INSTALL_RPATH})