From 77b887f1858cfb31eb5d090f6f46cb3c0f74b47f Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Sun, 19 Dec 2021 20:38:53 -0300 Subject: [PATCH 1/2] Rename Ogre2IgnHlmsCustomizations to Ogre2IgnHlmsSphericalClipMinDistance Signed-off-by: Matias N. Goldberg --- .../rendering/ogre2/Ogre2RenderEngine.hh | 8 ++- ogre2/src/Ogre2GpuRays.cc | 6 +-- ogre2/src/Ogre2IgnHlmsPbsPrivate.cc | 2 +- ogre2/src/Ogre2IgnHlmsPbsPrivate.hh | 5 +- ...> Ogre2IgnHlmsSphericalClipMinDistance.cc} | 52 +++++++++---------- ...> Ogre2IgnHlmsSphericalClipMinDistance.hh} | 14 ++--- ogre2/src/Ogre2IgnHlmsUnlitPrivate.cc | 2 +- ogre2/src/Ogre2IgnHlmsUnlitPrivate.hh | 5 +- ogre2/src/Ogre2RenderEngine.cc | 28 ++++++---- 9 files changed, 67 insertions(+), 55 deletions(-) rename ogre2/src/{Ogre2IgnHlmsCustomizations.cc => Ogre2IgnHlmsSphericalClipMinDistance.cc} (68%) rename ogre2/src/{Ogre2IgnHlmsCustomizations.hh => Ogre2IgnHlmsSphericalClipMinDistance.hh} (90%) diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh index c78d775f7..11bb1f8e3 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh @@ -53,7 +53,7 @@ namespace ignition // // forward declaration class Ogre2RenderEnginePrivate; - class Ogre2IgnHlmsCustomizations; + class Ogre2IgnHlmsSphericalClipMinDistance; /// \brief Plugin for loading ogre render engine class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2RenderEnginePlugin : @@ -175,9 +175,13 @@ namespace ignition /// \return a list of FSAA levels public: std::vector FSAALevels() const; + /// \brief Deprecated. Use SphericalClipMinDistance instead + public: Ogre2IgnHlmsSphericalClipMinDistance &IGN_DEPRECATED(7) + HlmsCustomizations(); + /// \brief Retrieves Hlms customizations for tweaking them /// \return Ogre HLMS customizations - public: Ogre2IgnHlmsCustomizations &HlmsCustomizations(); + public: Ogre2IgnHlmsSphericalClipMinDistance &SphericalClipMinDistance(); /// \internal /// \brief Get a pointer to the Ogre overlay system. diff --git a/ogre2/src/Ogre2GpuRays.cc b/ogre2/src/Ogre2GpuRays.cc index 2f6490043..7832cfde6 100644 --- a/ogre2/src/Ogre2GpuRays.cc +++ b/ogre2/src/Ogre2GpuRays.cc @@ -33,7 +33,7 @@ #include "ignition/rendering/ogre2/Ogre2Sensor.hh" #include "ignition/rendering/ogre2/Ogre2Visual.hh" -#include "Ogre2IgnHlmsCustomizations.hh" +#include "Ogre2IgnHlmsSphericalClipMinDistance.hh" #include "Ogre2ParticleNoiseListener.hh" #ifdef _MSC_VER @@ -218,7 +218,7 @@ void Ogre2LaserRetroMaterialSwitcher::cameraPreRenderScene( { { auto engine = Ogre2RenderEngine::Instance(); - Ogre2IgnHlmsCustomizations &hlmsCustomizations = + Ogre2IgnHlmsSphericalClipMinDistance &hlmsCustomizations = engine->HlmsCustomizations(); Ogre::Pass *pass = this->laserRetroSourceMaterial->getBestTechnique()->getPass(0u); @@ -1245,7 +1245,7 @@ void Ogre2GpuRays::Render() // These customization can be used to implement multi-tiered // "near plane distances" as proposed in: // https://github.com/ignitionrobotics/ign-rendering/issues/395 - Ogre2IgnHlmsCustomizations &hlmsCustomizations = + Ogre2IgnHlmsSphericalClipMinDistance &hlmsCustomizations = engine->HlmsCustomizations(); hlmsCustomizations.minDistanceClip = diff --git a/ogre2/src/Ogre2IgnHlmsPbsPrivate.cc b/ogre2/src/Ogre2IgnHlmsPbsPrivate.cc index e4f063c94..63413d9dc 100644 --- a/ogre2/src/Ogre2IgnHlmsPbsPrivate.cc +++ b/ogre2/src/Ogre2IgnHlmsPbsPrivate.cc @@ -47,7 +47,7 @@ namespace Ogre Ogre2IgnHlmsPbs::Ogre2IgnHlmsPbs( Archive *dataFolder, ArchiveVec *libraryFolders, - Ogre2IgnHlmsCustomizations *_sphericalClipMinDistance, + Ogre2IgnHlmsSphericalClipMinDistance *_sphericalClipMinDistance, Ogre::HlmsPbsTerraShadows *terraShadows) : HlmsPbs(dataFolder, libraryFolders) { diff --git a/ogre2/src/Ogre2IgnHlmsPbsPrivate.hh b/ogre2/src/Ogre2IgnHlmsPbsPrivate.hh index 9169da2cc..c97a4895c 100644 --- a/ogre2/src/Ogre2IgnHlmsPbsPrivate.hh +++ b/ogre2/src/Ogre2IgnHlmsPbsPrivate.hh @@ -20,7 +20,7 @@ #include "ignition/rendering/config.hh" #include "ignition/rendering/ogre2/Export.hh" -#include "Ogre2IgnHlmsCustomizations.hh" +#include "Ogre2IgnHlmsSphericalClipMinDistance.hh" #include "Ogre2IgnHlmsSharedPrivate.hh" #ifdef _MSC_VER @@ -66,7 +66,8 @@ namespace Ogre /// \brief Constructor. Asks for modular listeners so we can add /// them in the proper order public: Ogre2IgnHlmsPbs(Archive *dataFolder, ArchiveVec *libraryFolders, - ignition::rendering::Ogre2IgnHlmsCustomizations + ignition::rendering:: + Ogre2IgnHlmsSphericalClipMinDistance *_sphericalClipMinDistance, Ogre::HlmsPbsTerraShadows *terraShadows); diff --git a/ogre2/src/Ogre2IgnHlmsCustomizations.cc b/ogre2/src/Ogre2IgnHlmsSphericalClipMinDistance.cc similarity index 68% rename from ogre2/src/Ogre2IgnHlmsCustomizations.cc rename to ogre2/src/Ogre2IgnHlmsSphericalClipMinDistance.cc index 1cdeb5b0a..db936444e 100644 --- a/ogre2/src/Ogre2IgnHlmsCustomizations.cc +++ b/ogre2/src/Ogre2IgnHlmsSphericalClipMinDistance.cc @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ + */ -#include "Ogre2IgnHlmsCustomizations.hh" +#include "Ogre2IgnHlmsSphericalClipMinDistance.hh" #include "ignition/rendering/ogre2/Ogre2RenderEngine.hh" #ifdef _MSC_VER - #pragma warning(push, 0) +# pragma warning(push, 0) #endif #include #include @@ -28,18 +28,17 @@ #include #include #ifdef _MSC_VER - #pragma warning(pop) +# pragma warning(pop) #endif using namespace ignition; using namespace rendering; ////////////////////////////////////////////////// -void Ogre2IgnHlmsCustomizations::preparePassHash( - const Ogre::CompositorShadowNode */*_shadowNode*/, - bool _casterPass, bool /*_dualParaboloid*/, - Ogre::SceneManager */*_sceneManager*/, - Ogre::Hlms *_hlms) +void Ogre2IgnHlmsSphericalClipMinDistance::preparePassHash( + const Ogre::CompositorShadowNode * /*_shadowNode*/, bool _casterPass, + bool /*_dualParaboloid*/, Ogre::SceneManager * /*_sceneManager*/, + Ogre::Hlms *_hlms) { this->needsWorldPos = false; if (!_casterPass && this->MinDistanceClipEnabled()) @@ -62,10 +61,9 @@ void Ogre2IgnHlmsCustomizations::preparePassHash( } ////////////////////////////////////////////////// -Ogre::uint32 Ogre2IgnHlmsCustomizations::getPassBufferSize( - const Ogre::CompositorShadowNode */*_shadowNode*/, - bool _casterPass, bool /*_dualParaboloid*/, - Ogre::SceneManager */*_sceneManager*/) const +Ogre::uint32 Ogre2IgnHlmsSphericalClipMinDistance::getPassBufferSize( + const Ogre::CompositorShadowNode * /*_shadowNode*/, bool _casterPass, + bool /*_dualParaboloid*/, Ogre::SceneManager * /*_sceneManager*/) const { if (_casterPass || !this->MinDistanceClipEnabled()) return 0u; @@ -78,16 +76,15 @@ Ogre::uint32 Ogre2IgnHlmsCustomizations::getPassBufferSize( } ////////////////////////////////////////////////// -float* Ogre2IgnHlmsCustomizations::preparePassBuffer( - const Ogre::CompositorShadowNode */*_shadowNode*/, - bool _casterPass, bool /*_dualParaboloid*/, - Ogre::SceneManager *_sceneManager, - float *_passBufferPtr) +float *Ogre2IgnHlmsSphericalClipMinDistance::preparePassBuffer( + const Ogre::CompositorShadowNode * /*_shadowNode*/, bool _casterPass, + bool /*_dualParaboloid*/, Ogre::SceneManager *_sceneManager, + float *_passBufferPtr) { if (!_casterPass && this->MinDistanceClipEnabled()) { const Ogre::Camera *camera = - _sceneManager->getCamerasInProgress().renderingCamera; + _sceneManager->getCamerasInProgress().renderingCamera; const Ogre::Vector3 &camPos = camera->getDerivedPosition(); // float4 ignMinClipDistance_ignCameraPos @@ -105,19 +102,18 @@ float* Ogre2IgnHlmsCustomizations::preparePassBuffer( auto engine = Ogre2RenderEngine::Instance(); auto ogreRoot = engine->OgreRoot(); Ogre::RenderPassDescriptor *renderPassDesc = - ogreRoot->getRenderSystem()->getCurrentPassDescriptor(); - Ogre::Matrix4 projectionMatrix = - camera->getProjectionMatrixWithRSDepth(); + ogreRoot->getRenderSystem()->getCurrentPassDescriptor(); + Ogre::Matrix4 projectionMatrix = camera->getProjectionMatrixWithRSDepth(); if (renderPassDesc->requiresTextureFlipping()) { - projectionMatrix[1][0] = -projectionMatrix[1][0]; - projectionMatrix[1][1] = -projectionMatrix[1][1]; - projectionMatrix[1][2] = -projectionMatrix[1][2]; - projectionMatrix[1][3] = -projectionMatrix[1][3]; + projectionMatrix[1][0] = -projectionMatrix[1][0]; + projectionMatrix[1][1] = -projectionMatrix[1][1]; + projectionMatrix[1][2] = -projectionMatrix[1][2]; + projectionMatrix[1][3] = -projectionMatrix[1][3]; } - Ogre::Matrix4 invViewProj = (projectionMatrix * - camera->getViewMatrix(true)).inverse(); + Ogre::Matrix4 invViewProj = + (projectionMatrix * camera->getViewMatrix(true)).inverse(); for (size_t i = 0; i < 16u; ++i) { *_passBufferPtr++ = static_cast(invViewProj[0][i]); diff --git a/ogre2/src/Ogre2IgnHlmsCustomizations.hh b/ogre2/src/Ogre2IgnHlmsSphericalClipMinDistance.hh similarity index 90% rename from ogre2/src/Ogre2IgnHlmsCustomizations.hh rename to ogre2/src/Ogre2IgnHlmsSphericalClipMinDistance.hh index 81b7e5db2..c35e04f46 100644 --- a/ogre2/src/Ogre2IgnHlmsCustomizations.hh +++ b/ogre2/src/Ogre2IgnHlmsSphericalClipMinDistance.hh @@ -46,11 +46,10 @@ namespace ignition /// \internal /// \remark Public variables take effect immediately (i.e. for the /// next render) - class IGNITION_RENDERING_OGRE2_HIDDEN Ogre2IgnHlmsCustomizations final : - public Ogre::HlmsListener + class IGNITION_RENDERING_OGRE2_HIDDEN Ogre2IgnHlmsSphericalClipMinDistance + final : public Ogre::HlmsListener { - public: - virtual ~Ogre2IgnHlmsCustomizations() = default; + public: virtual ~Ogre2IgnHlmsSphericalClipMinDistance() = default; /// \brief /// \return Returns true if spherical clipping customizations should @@ -72,7 +71,8 @@ namespace ignition /// \brief Tells Ogre the buffer data sent to GPU should be a little /// bigger to fit our data we need to send /// - /// This data is sent in Ogre2IgnHlmsCustomizations::preparePassBuffer + /// This data is sent in + /// Ogre2IgnHlmsSphericalClipMinDistance::preparePassBuffer /// \param _casterPass /// \param _hlms private: virtual Ogre::uint32 getPassBufferSize( @@ -81,8 +81,8 @@ namespace ignition Ogre::SceneManager *_sceneManager) const override; /// \brief Sends our custom data to GPU buffers that our - /// pieces activated in Ogre2IgnHlmsCustomizations::preparePassHash - /// will need. + /// pieces activated in + /// Ogre2IgnHlmsSphericalClipMinDistance::preparePassHash will need. /// /// Bytes written must not exceed what we informed in getPassBufferSize /// \param _casterPass diff --git a/ogre2/src/Ogre2IgnHlmsUnlitPrivate.cc b/ogre2/src/Ogre2IgnHlmsUnlitPrivate.cc index c0b924f0b..d43880006 100644 --- a/ogre2/src/Ogre2IgnHlmsUnlitPrivate.cc +++ b/ogre2/src/Ogre2IgnHlmsUnlitPrivate.cc @@ -45,7 +45,7 @@ namespace Ogre Ogre2IgnHlmsUnlit::Ogre2IgnHlmsUnlit( Archive *dataFolder, ArchiveVec *libraryFolders, - Ogre2IgnHlmsCustomizations *_sphericalClipMinDistance) : + Ogre2IgnHlmsSphericalClipMinDistance *_sphericalClipMinDistance) : HlmsUnlit(dataFolder, libraryFolders) { this->customizations.push_back(_sphericalClipMinDistance); diff --git a/ogre2/src/Ogre2IgnHlmsUnlitPrivate.hh b/ogre2/src/Ogre2IgnHlmsUnlitPrivate.hh index 507159f02..ccc7583cd 100644 --- a/ogre2/src/Ogre2IgnHlmsUnlitPrivate.hh +++ b/ogre2/src/Ogre2IgnHlmsUnlitPrivate.hh @@ -20,7 +20,7 @@ #include "ignition/rendering/config.hh" #include "ignition/rendering/ogre2/Export.hh" -#include "Ogre2IgnHlmsCustomizations.hh" +#include "Ogre2IgnHlmsSphericalClipMinDistance.hh" #include "Ogre2IgnHlmsSharedPrivate.hh" #ifdef _MSC_VER @@ -64,7 +64,8 @@ namespace Ogre /// \brief Constructor. Asks for modular listeners so we can add /// them in the proper order public: Ogre2IgnHlmsUnlit(Archive *dataFolder, ArchiveVec *libraryFolders, - ignition::rendering::Ogre2IgnHlmsCustomizations + ignition::rendering:: + Ogre2IgnHlmsSphericalClipMinDistance *_sphericalClipMinDistance); /// \brief Destructor. Virtual to silence warnings diff --git a/ogre2/src/Ogre2RenderEngine.cc b/ogre2/src/Ogre2RenderEngine.cc index 5bbdc7d6c..6a0d0d208 100644 --- a/ogre2/src/Ogre2RenderEngine.cc +++ b/ogre2/src/Ogre2RenderEngine.cc @@ -48,7 +48,7 @@ #include "Terra/Hlms/OgreHlmsTerra.h" #include "Terra/Hlms/PbsListener/OgreHlmsPbsTerraShadows.h" #include "Terra/TerraWorkspaceListener.h" -#include "Ogre2IgnHlmsCustomizations.hh" +#include "Ogre2IgnHlmsSphericalClipMinDistance.hh" class IGNITION_RENDERING_OGRE2_HIDDEN ignition::rendering::Ogre2RenderEnginePrivate @@ -64,7 +64,8 @@ class IGNITION_RENDERING_OGRE2_HIDDEN public: std::vector fsaaLevels; /// \brief Controls Hlms customizations for both PBS and Unlit - public: ignition::rendering::Ogre2IgnHlmsCustomizations hlmsCustomizations; + public: ignition::rendering::Ogre2IgnHlmsSphericalClipMinDistance + sphericalClipMinDistance; /// \brief Pbs listener that adds terra shadows public: std::unique_ptr hlmsPbsTerraShadows; @@ -754,8 +755,9 @@ void Ogre2RenderEngine::RegisterHlms() archiveUnlitLibraryFolders.push_back(customizationsArchiveLibrary); // Create and register the unlit Hlms - hlmsUnlit = OGRE_NEW Ogre::Ogre2IgnHlmsUnlit(archiveUnlit, - &archiveUnlitLibraryFolders, &this->dataPtr->hlmsCustomizations); + hlmsUnlit = OGRE_NEW Ogre::Ogre2IgnHlmsUnlit( + archiveUnlit, &archiveUnlitLibraryFolders, + &this->dataPtr->sphericalClipMinDistance); Ogre::Root::getSingleton().getHlmsManager()->registerHlms(hlmsUnlit); // disable writting debug output to disk @@ -795,9 +797,10 @@ void Ogre2RenderEngine::RegisterHlms() } // Create and register - hlmsPbs = OGRE_NEW Ogre::Ogre2IgnHlmsPbs( - archivePbs, &archivePbsLibraryFolders, &this->dataPtr->hlmsCustomizations, - this->dataPtr->hlmsPbsTerraShadows.get()); + hlmsPbs = + OGRE_NEW Ogre::Ogre2IgnHlmsPbs(archivePbs, &archivePbsLibraryFolders, + &this->dataPtr->sphericalClipMinDistance, + this->dataPtr->hlmsPbsTerraShadows.get()); Ogre::Root::getSingleton().getHlmsManager()->registerHlms(hlmsPbs); // disable writting debug output to disk @@ -1012,9 +1015,16 @@ std::vector Ogre2RenderEngine::FSAALevels() const } ///////////////////////////////////////////////// -Ogre2IgnHlmsCustomizations& Ogre2RenderEngine::HlmsCustomizations() +Ogre2IgnHlmsSphericalClipMinDistance& Ogre2RenderEngine::HlmsCustomizations() { - return this->dataPtr->hlmsCustomizations; + return this->dataPtr->sphericalClipMinDistance; +} + +///////////////////////////////////////////////// +Ogre2IgnHlmsSphericalClipMinDistance& Ogre2RenderEngine:: +SphericalClipMinDistance() +{ + return this->dataPtr->sphericalClipMinDistance; } ///////////////////////////////////////////////// From 82bf6290c68b83445ca5d191445001a76941b7f4 Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Sun, 9 Jan 2022 20:51:28 -0300 Subject: [PATCH 2/2] Fix MSVC build Fix deprecation warnings Signed-off-by: Matias N. Goldberg --- ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh | 2 +- ogre2/src/Ogre2GpuRays.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh index 11bb1f8e3..ebb46e908 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2RenderEngine.hh @@ -176,7 +176,7 @@ namespace ignition public: std::vector FSAALevels() const; /// \brief Deprecated. Use SphericalClipMinDistance instead - public: Ogre2IgnHlmsSphericalClipMinDistance &IGN_DEPRECATED(7) + public: Ogre2IgnHlmsSphericalClipMinDistance IGN_DEPRECATED(7) & HlmsCustomizations(); /// \brief Retrieves Hlms customizations for tweaking them diff --git a/ogre2/src/Ogre2GpuRays.cc b/ogre2/src/Ogre2GpuRays.cc index 7832cfde6..2b3ca74f7 100644 --- a/ogre2/src/Ogre2GpuRays.cc +++ b/ogre2/src/Ogre2GpuRays.cc @@ -219,7 +219,7 @@ void Ogre2LaserRetroMaterialSwitcher::cameraPreRenderScene( { auto engine = Ogre2RenderEngine::Instance(); Ogre2IgnHlmsSphericalClipMinDistance &hlmsCustomizations = - engine->HlmsCustomizations(); + engine->SphericalClipMinDistance(); Ogre::Pass *pass = this->laserRetroSourceMaterial->getBestTechnique()->getPass(0u); pass->getVertexProgramParameters()->setNamedConstant( @@ -1246,7 +1246,7 @@ void Ogre2GpuRays::Render() // "near plane distances" as proposed in: // https://github.com/ignitionrobotics/ign-rendering/issues/395 Ogre2IgnHlmsSphericalClipMinDistance &hlmsCustomizations = - engine->HlmsCustomizations(); + engine->SphericalClipMinDistance(); hlmsCustomizations.minDistanceClip = static_cast(this->NearClipPlane());