srmainwaring / asv_wave_sim

This package contains plugins that support the simulation of waves and surface vessels in Gazebo.
GNU General Public License v3.0
114 stars 31 forks source link

Add render engine extension to control load order of render plugins #61

Closed srmainwaring closed 1 year ago

srmainwaring commented 1 year ago

This PR adds the ability to control the order in which the rendering extension code in the WavesVisual plugin is loaded. The Ogre2 dependent code in the WaveVisual plugin is moved into a rendering plugin library which removes the need to directly link the system plugin to the ogre2 render engine.

Details

We use the same approach as gz-rendering, using copies of the RenderEngineManager and associated classes to manage the loading and lifetime of render extension plugins. The WavesVisual plugin links against abstract base classes that are implemented by render engine specific extension plugins.

The render extension provides access to an abstract SceneNodeFactory class which provides methods to create the render extension objects needed by the waves rendering code (namely a custom Visual object and a class to load dynamic textures for custom shaders).

Testing

There are two ocean rendering approaches: dynamic geometry using HlmsPbs and dynamic texture using a custom shader that applies a displacement map to the vertices. Before this change, when running the dynamic geometry example on a M1 mac (arm64), it was necessary to load the client process first then the server to avoid a crash resulting from an invalid scene pointer. The custom shader example did not work at all. Both examples now work correctly (server / client start order is not important).

The examples also run on an Ubuntu VM using llvmpipe software rendering.