Skip to content

Commit 2fa1219

Browse files
authored
Merge pull request #1156 from gazebosim/merge_9_main_20250812
Merge 9 -> main
2 parents 7d98779 + 15ad792 commit 2fa1219

File tree

11 files changed

+341
-28
lines changed

11 files changed

+341
-28
lines changed

Changelog.md

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1-
## Gazebo Rendering
1+
# Gazebo Rendering
22

33
### Gazebo Rendering 10.X
44

55
### Gazebo Rendering 10.0.0 (20XX-XX-XX)
66

77
### Gazebo Rendering 9.X
88

9+
### Gazebo Rendering 9.3.0 (2025-07-25)
10+
11+
1. Guard against bad memory access in RenderPassSystem
12+
* [Pull request #1153](https://github.com/gazebosim/gz-rendering/pull/1153)
13+
14+
1. Enable loading a render engine plugin from the static plugin registry
15+
* [Pull request #1152](https://github.com/gazebosim/gz-rendering/pull/1152)
16+
17+
1. Fix user settings of thermal camera being ignored
18+
* [Pull request #1138](https://github.com/gazebosim/gz-rendering/pull/1138)
19+
20+
1. CppCheck fixes
21+
* [Pull request #1148](https://github.com/gazebosim/gz-rendering/pull/1148)
22+
923
### Gazebo Rendering 9.2.0 (2025-06-06)
1024

1125
1. Disable a couple of tests on windows
@@ -195,9 +209,55 @@
195209
1. Add projection matrix set/get functions to Ogre Depth camera
196210
* [Pull request #928](https://github.com/gazebosim/gz-rendering/pull/928)
197211

198-
### Gazebo Rendering 8.X
212+
## Gazebo Rendering 8.X
213+
214+
### Gazebo Rendering 8.2.2 (2025-01-30)
215+
216+
1. Fix RenderingIface_TEST for ogre2 when there is no display
217+
* [Pull request #1098](https://github.com/gazebosim/gz-rendering/pull/1098)
218+
219+
1. Better approach to use std::variant
220+
* [Pull request #1093](https://github.com/gazebosim/gz-rendering/pull/1093)
221+
222+
### Gazebo Rendering 8.2.1 (2024-11-08)
223+
224+
1. Update code for loading normal and albedo maps from image data
225+
* [Pull request #1068](https://github.com/gazebosim/gz-rendering/pull/1068)
226+
227+
1. Check for zero quaternion value in MoveToHelper
228+
* [Pull request #1076](https://github.com/gazebosim/gz-rendering/pull/1076)
229+
230+
1. Fix waves 'double' to 'float' truncation warning
231+
* [Pull request #1065](https://github.com/gazebosim/gz-rendering/pull/1065)
232+
233+
1. Install Roboto fonts to ogre plugin
234+
* [Pull request #1035](https://github.com/gazebosim/gz-rendering/pull/1035)
235+
236+
1. Fixed integer underflow in OgreDistortionPass
237+
* [Pull request #994](https://github.com/gazebosim/gz-rendering/pull/994)
238+
239+
1. Add gamma correction to simple_demo_qml example
240+
* [Pull request #1019](https://github.com/gazebosim/gz-rendering/pull/1019)
241+
242+
1. Optimization: remove extra copy of data buffer in Ogre2GpuRays and Ogre2DepthCamera
243+
* [Pull request #1022](https://github.com/gazebosim/gz-rendering/pull/1022)
244+
245+
1. Fix crash when wide angle camera FOV is > 180
246+
* [Pull request #1016](https://github.com/gazebosim/gz-rendering/pull/1016)
247+
248+
1. Fix debug builds of gz-rendering-ogre2 plugin
249+
* [Pull request #1014](https://github.com/gazebosim/gz-rendering/pull/1014)
250+
251+
1. Fix lidar 1st pass texture resolution calculation for FOV < 90 degrees
252+
* [Pull request #1012](https://github.com/gazebosim/gz-rendering/pull/1012)
253+
254+
1. Use single cubemap camera in lidar
255+
* [Pull request #1013](https://github.com/gazebosim/gz-rendering/pull/1013)
256+
257+
1. Parse correctly OGRE2_RESOURCE_PATH on Windows
258+
* [Pull request #996](https://github.com/gazebosim/gz-rendering/pull/996)
199259

200-
### Gazebo Rendering 8.2.0
260+
### Gazebo Rendering 8.2.0 (2024-06-19)
201261

202262
1. Backport: Adding cone primitives.
203263
* [Pull request #1003](https://github.com/gazebosim/gz-rendering/pull/1003)

include/gz/rendering/RenderPassSystem.hh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ namespace gz
8181

8282
/// \brief A map of render pass type id name to its factory class
8383
GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
84-
private: static std::map<std::string, RenderPassFactory *> renderPassMap;
84+
private: typedef std::map<std::string, RenderPassFactory *>
85+
RenderPassMap;
86+
private: static RenderPassMap &GetRenderPassMap();
8587

8688
/// \internal
8789
/// \brief Pointer to private data class

ogre/src/OgreRenderEngine.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,3 +878,5 @@ OgreRenderEngine *OgreRenderEngine::Instance()
878878
// Register this plugin
879879
GZ_ADD_PLUGIN(rendering::OgreRenderEnginePlugin,
880880
rendering::RenderEnginePlugin)
881+
GZ_ADD_PLUGIN_ALIAS(rendering::OgreRenderEnginePlugin,
882+
"gz::rendering::ogre::Plugin")

ogre2/src/Ogre2RenderEngine.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,3 +1453,5 @@ Ogre2RenderEngine *Ogre2RenderEngine::Instance()
14531453
// Register this plugin
14541454
GZ_ADD_PLUGIN(rendering::Ogre2RenderEnginePlugin,
14551455
rendering::RenderEnginePlugin)
1456+
GZ_ADD_PLUGIN_ALIAS(rendering::Ogre2RenderEnginePlugin,
1457+
"gz::rendering::ogre2::Plugin")

optix/src/OptixRenderEngine.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,5 @@ OptixRenderEngine *OptixRenderEngine::Instance()
143143
// Register this plugin
144144
GZ_ADD_PLUGIN(OptixRenderEnginePlugin,
145145
rendering::RenderEnginePlugin)
146+
GZ_ADD_PLUGIN_ALIAS(OptixRenderEnginePlugin,
147+
"gz::rendering::optix::Plugin")

src/MoveToHelper.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void MoveToHelper::MoveTo(const CameraPtr &_camera,
7474
else
7575
key->Translation(start.Pos());
7676

77-
if (_target.Rot().IsFinite())
77+
if (_target.Rot().IsFinite() && _target.Rot() != math::Quaterniond::Zero)
7878
key->Rotation(_target.Rot());
7979
else
8080
key->Rotation(start.Rot());

src/RenderEngineManager.cc

Lines changed: 113 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
*
1616
*/
1717

18+
#include <cstddef>
1819
#include <map>
1920
#include <mutex>
21+
#include <string>
2022

2123
#include <gz/common/Console.hh>
2224
#include <gz/common/SystemPaths.hh>
@@ -48,6 +50,11 @@ class gz::rendering::RenderEngineManagerPrivate
4850
/// \brief EngineMap iterator.
4951
typedef EngineMap::iterator EngineIter;
5052

53+
/// \brief Expected filename prefix for plugin to be loaded from the static
54+
/// registry.
55+
public: static constexpr std::string_view kStaticPluginFilenamePrefix =
56+
"static://";
57+
5158
/// \brief Get a pointer to the render engine from an EngineMap iterator.
5259
/// \param[in] _iter EngineMap iterator
5360
/// \param[in] _path Another search path for rendering engine plugin.
@@ -78,6 +85,11 @@ class gz::rendering::RenderEngineManagerPrivate
7885
public: bool LoadEnginePlugin(const std::string &_filename,
7986
const std::string &_path);
8087

88+
/// \brief Load a render engine plugin from the static plugin registry.
89+
/// \param[in] _filename Filename of plugin
90+
/// \return True if the plugin is loaded successfully
91+
public: bool LoadStaticEnginePlugin(const std::string &_filename);
92+
8193
/// \brief Unload a render engine plugin.
8294
/// \param[in] _engineName Name of engine associated with this plugin
8395
/// \return True if the plugin is unloaded successfully
@@ -431,32 +443,67 @@ bool RenderEngineManagerPrivate::UnloadEngine(EngineIter _iter)
431443
//////////////////////////////////////////////////
432444
void RenderEngineManagerPrivate::RegisterDefaultEngines()
433445
{
434-
// TODO(anyone): Find a cleaner way to get the default engine library name
435446

436-
// cppcheck-suppress unreadVariable
437-
std::string libName = "gz-rendering-";
447+
auto registerStaticOrSolibPlugin = [this](const std::string& _engineName,
448+
const std::string& _staticFilename, const std::string& _solibFilename)
449+
{
450+
std::lock_guard<std::recursive_mutex> lock(this->enginesMutex);
451+
// Check static plugin registry if the plugin was statically linked in.
452+
constexpr size_t prefixLen = kStaticPluginFilenamePrefix.size();
453+
const std::string staticPluginAlias = _staticFilename.substr(prefixLen);
454+
if (!this->pluginLoader.PluginsWithAlias(staticPluginAlias).empty())
455+
{
456+
this->defaultEngines[_engineName] = _staticFilename;
457+
if (this->engines.find(_staticFilename) == this->engines.end())
458+
this->engines[_staticFilename] = nullptr;
459+
return;
460+
}
461+
// Else if a .so lib plugin file is expected, register that as the default.
462+
if (!_solibFilename.empty())
463+
{
464+
this->defaultEngines[_engineName] = _solibFilename;
465+
if (this->engines.find(_solibFilename) == this->engines.end())
466+
this->engines[_solibFilename] = nullptr;
467+
}
468+
};
438469

439-
// cppcheck-suppress unusedVariable
440-
std::string engineName;
470+
// TODO(anyone): Find a cleaner way to get the default engine .so library name
471+
// cppcheck-suppress unreadVariable
472+
const std::string libNamePrefix = "gz-rendering-";
441473

442-
std::lock_guard<std::recursive_mutex> lock(this->enginesMutex);
474+
// Register Ogre
475+
const std::string ogreEngineName = "ogre";
476+
const std::string ogreStaticFilename = "static://gz::rendering::ogre::Plugin";
443477
#if GZ_RENDERING_HAVE_OGRE
444-
engineName = "ogre";
445-
this->defaultEngines[engineName] = libName + engineName;
446-
if (this->engines.find(libName + engineName) == this->engines.end())
447-
this->engines[libName + engineName] = nullptr;
478+
registerStaticOrSolibPlugin(ogreEngineName, ogreStaticFilename,
479+
libNamePrefix + ogreEngineName);
480+
#else
481+
registerStaticOrSolibPlugin(ogreEngineName, ogreStaticFilename,
482+
/*_solibFilename=*/"");
448483
#endif
484+
485+
// Register Ogre2
486+
const std::string ogre2EngineName = "ogre2";
487+
const std::string ogre2StaticFilename =
488+
"static://gz::rendering::ogre2::Plugin";
449489
#if GZ_RENDERING_HAVE_OGRE2
450-
engineName = "ogre2";
451-
this->defaultEngines[engineName] = libName + engineName;
452-
if (this->engines.find(libName + engineName) == this->engines.end())
453-
this->engines[libName + engineName] = nullptr;
490+
registerStaticOrSolibPlugin(ogre2EngineName, ogre2StaticFilename,
491+
libNamePrefix + ogre2EngineName);
492+
#else
493+
registerStaticOrSolibPlugin(ogre2EngineName, ogre2StaticFilename,
494+
/*_solibFilename=*/"");
454495
#endif
496+
497+
// Register Optix
498+
const std::string optixEngineName = "optix";
499+
const std::string optixStaticFilename =
500+
"static://gz::rendering::optix::Plugin";
455501
#if GZ_RENDERING_HAVE_OPTIX
456-
engineName = "optix";
457-
this->defaultEngines[engineName] = libName + engineName;
458-
if (this->engines.find(libName + engineName) == this->engines.end())
459-
this->engines[libName + engineName] = nullptr;
502+
registerStaticOrSolibPlugin(optixEngineName, optixStaticFilename,
503+
libNamePrefix + optixEngineName);
504+
#else
505+
registerStaticOrSolibPlugin(optixEngineName, optixStaticFilename,
506+
/*_solibFilename=*/"");
460507
#endif
461508
}
462509

@@ -466,6 +513,12 @@ bool RenderEngineManagerPrivate::LoadEnginePlugin(
466513
{
467514
gzmsg << "Loading plugin [" << _filename << "]" << std::endl;
468515

516+
constexpr size_t prefixLen = kStaticPluginFilenamePrefix.size();
517+
if (_filename.substr(0, prefixLen) == kStaticPluginFilenamePrefix)
518+
{
519+
return this->LoadStaticEnginePlugin(_filename);
520+
}
521+
469522
gz::common::SystemPaths systemPaths;
470523
systemPaths.SetPluginPathEnv(this->pluginPathEnv);
471524

@@ -560,10 +613,52 @@ bool RenderEngineManagerPrivate::LoadEnginePlugin(
560613
return true;
561614
}
562615

616+
//////////////////////////////////////////////////
617+
bool RenderEngineManagerPrivate::LoadStaticEnginePlugin(
618+
const std::string &_filename)
619+
{
620+
constexpr size_t prefixLen = kStaticPluginFilenamePrefix.size();
621+
const std::string filenameWoPrefix = _filename.substr(prefixLen);
622+
623+
gzmsg << "Loading plugin [" << filenameWoPrefix << "] from static registry"
624+
<< std::endl;
625+
626+
auto plugin = this->pluginLoader.Instantiate(filenameWoPrefix);
627+
if (!plugin)
628+
{
629+
gzerr << "Failed to load static render engine plugin [" << filenameWoPrefix
630+
<< "]. Static plugin registry does not contain this plugin."
631+
<< std::endl;
632+
return false;
633+
}
634+
635+
auto renderPlugin = plugin->QueryInterface<rendering::RenderEnginePlugin>();
636+
if (!renderPlugin)
637+
{
638+
gzerr << "Failed to find RenderEnginePlugin interface in static render "
639+
<< "engine plugin [" << _filename << "]" << std::endl;
640+
return false;
641+
}
642+
643+
// Instantiate the engine
644+
{
645+
std::lock_guard<std::recursive_mutex> lock(this->enginesMutex);
646+
this->engines[_filename] = renderPlugin->Engine();
647+
}
648+
649+
return true;
650+
}
651+
563652
//////////////////////////////////////////////////
564653
bool RenderEngineManagerPrivate::UnloadEnginePlugin(
565654
const std::string &_engineName)
566655
{
656+
const size_t prefix_len = kStaticPluginFilenamePrefix.length();
657+
if (_engineName.substr(0, prefix_len) == kStaticPluginFilenamePrefix)
658+
{
659+
return true;
660+
}
661+
567662
auto it = this->enginePlugins.find(_engineName);
568663
if (it == this->enginePlugins.end())
569664
{

src/RenderPassSystem.cc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ class gz::rendering::RenderPassSystemPrivate
2727
{
2828
};
2929

30-
std::map<std::string, RenderPassFactory *> RenderPassSystem::renderPassMap;
31-
3230
//////////////////////////////////////////////////
3331
// RenderPassSystem
3432
//////////////////////////////////////////////////
@@ -44,8 +42,8 @@ RenderPassSystem::~RenderPassSystem() = default;
4442
RenderPassPtr RenderPassSystem::CreateImpl(const std::string &_type)
4543
{
4644
RenderPassPtr pass;
47-
auto it = renderPassMap.find(_type);
48-
if (it != renderPassMap.end())
45+
auto it = GetRenderPassMap().find(_type);
46+
if (it != GetRenderPassMap().end())
4947
{
5048
pass.reset(it->second->New());
5149
}
@@ -61,5 +59,12 @@ RenderPassPtr RenderPassSystem::CreateImpl(const std::string &_type)
6159
void RenderPassSystem::Register(const std::string &_name,
6260
RenderPassFactory *_factory)
6361
{
64-
renderPassMap[_name] = _factory;
62+
GetRenderPassMap()[_name] = _factory;
63+
}
64+
65+
//////////////////////////////////////////////////
66+
RenderPassSystem::RenderPassMap &RenderPassSystem::GetRenderPassMap()
67+
{
68+
static RenderPassMap renderPassMap;
69+
return renderPassMap;
6570
}

test/BUILD.bazel

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package(
2+
default_applicable_licenses = ["//:license"],
3+
features = [
4+
"layering_check",
5+
"parse_headers",
6+
],
7+
)
8+
9+
cc_test(
10+
name = "INTEGRATION_load_static_render_engine_plugin",
11+
srcs = ["integration/load_static_render_engine_plugin.cc"],
12+
env = {"GZ_BAZEL": "1"},
13+
deps = [
14+
"//:gz-rendering",
15+
"@googletest//:gtest",
16+
"@googletest//:gtest_main",
17+
"@gz-common",
18+
"@gz-plugin//:loader",
19+
"@gz-plugin//:register",
20+
],
21+
)

0 commit comments

Comments
 (0)