diff --git a/ogre2/include/ignition/rendering/ogre2/Ogre2Scene.hh b/ogre2/include/ignition/rendering/ogre2/Ogre2Scene.hh index 4339159d2..48c0e85f9 100644 --- a/ogre2/include/ignition/rendering/ogre2/Ogre2Scene.hh +++ b/ogre2/include/ignition/rendering/ogre2/Ogre2Scene.hh @@ -350,6 +350,11 @@ namespace ignition /// \param[in] _camera Camera about to be used for rendering public: void UpdateAllHeightmaps(Ogre::Camera *_camera); + /// \internal + /// \brief Return all heightmaps in the scene + public: const std::vector> &Heightmaps() + const; + /// \brief Create a compositor shadow node with the same number of shadow /// textures as the number of shadow casting lights protected: void UpdateShadowNode(); diff --git a/ogre2/src/Ogre2Heightmap.cc b/ogre2/src/Ogre2Heightmap.cc index 0252fc2ed..04273b12b 100644 --- a/ogre2/src/Ogre2Heightmap.cc +++ b/ogre2/src/Ogre2Heightmap.cc @@ -60,6 +60,7 @@ class ignition::rendering::Ogre2HeightmapPrivate /// \brief Size of the heightmap data. public: unsigned int dataSize{0u}; + /// \brief Pointer to ogre terra object public: std::unique_ptr terra{nullptr}; }; diff --git a/ogre2/src/Ogre2Scene.cc b/ogre2/src/Ogre2Scene.cc index 7571c57e4..c0d0ab8a3 100644 --- a/ogre2/src/Ogre2Scene.cc +++ b/ogre2/src/Ogre2Scene.cc @@ -923,6 +923,12 @@ MaterialMapPtr Ogre2Scene::Materials() const return this->materials; } +////////////////////////////////////////////////// +const std::vector> &Ogre2Scene::Heightmaps() const +{ + return this->heightmaps; +} + ////////////////////////////////////////////////// DirectionalLightPtr Ogre2Scene::CreateDirectionalLightImpl(unsigned int _id, const std::string &_name) diff --git a/ogre2/src/Ogre2SegmentationMaterialSwitcher.cc b/ogre2/src/Ogre2SegmentationMaterialSwitcher.cc index ef266252a..04e2438d1 100644 --- a/ogre2/src/Ogre2SegmentationMaterialSwitcher.cc +++ b/ogre2/src/Ogre2SegmentationMaterialSwitcher.cc @@ -23,6 +23,7 @@ #include +#include "ignition/rendering/ogre2/Ogre2Heightmap.hh" #include "ignition/rendering/ogre2/Ogre2Scene.hh" #include "ignition/rendering/ogre2/Ogre2Visual.hh" #include "ignition/rendering/RenderTypes.hh" @@ -317,6 +318,18 @@ void Ogre2SegmentationMaterialSwitcher::cameraPreRenderScene( this->instancesCount.clear(); this->takenColors.clear(); this->coloredLabel.clear(); + + // disable heightmaps in segmentation camera sensor + // until we support changing its material based on input label + // TODO(anyone) add support for heightmaps with the segmentation camera + // https://github.com/ignitionrobotics/ign-rendering/issues/444 + auto heightmaps = this->scene->Heightmaps(); + for (auto h : heightmaps) + { + auto heightmap = h.lock(); + if (heightmap) + heightmap->Parent()->SetVisible(false); + } } //////////////////////////////////////////////// @@ -326,6 +339,15 @@ void Ogre2SegmentationMaterialSwitcher::cameraPostRenderScene( // restore item to use pbs hlms material for (const auto &[subItem, dataBlock] : this->datablockMap) subItem->setDatablock(dataBlock); + + // re-enable heightmaps + auto heightmaps = this->scene->Heightmaps(); + for (auto h : heightmaps) + { + auto heightmap = h.lock(); + if (heightmap) + heightmap->Parent()->SetVisible(true); + } } ////////////////////////////////////////////////