Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide heightmaps in segmentation camera #443

Merged
merged 5 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ogre2/include/ignition/rendering/ogre2/Ogre2Scene.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::weak_ptr<Ogre2Heightmap>> &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();
Expand Down
1 change: 1 addition & 0 deletions ogre2/src/Ogre2Heightmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Ogre::Terra> terra{nullptr};
};

Expand Down
6 changes: 6 additions & 0 deletions ogre2/src/Ogre2Scene.cc
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,12 @@ MaterialMapPtr Ogre2Scene::Materials() const
return this->materials;
}

//////////////////////////////////////////////////
const std::vector<std::weak_ptr<Ogre2Heightmap>> &Ogre2Scene::Heightmaps() const
{
return this->heightmaps;
}

//////////////////////////////////////////////////
DirectionalLightPtr Ogre2Scene::CreateDirectionalLightImpl(unsigned int _id,
const std::string &_name)
Expand Down
22 changes: 22 additions & 0 deletions ogre2/src/Ogre2SegmentationMaterialSwitcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <ignition/common/Console.hh>

#include "ignition/rendering/ogre2/Ogre2Heightmap.hh"
#include "ignition/rendering/ogre2/Ogre2Scene.hh"
#include "ignition/rendering/ogre2/Ogre2Visual.hh"
#include "ignition/rendering/RenderTypes.hh"
Expand Down Expand Up @@ -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);
}
}

////////////////////////////////////////////////
Expand All @@ -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);
}
}

////////////////////////////////////////////////
Expand Down