Skip to content

Commit

Permalink
Only set shadow texture size if configured by the user in the SDForma…
Browse files Browse the repository at this point in the history
…t file

Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
  • Loading branch information
azeey committed Sep 16, 2024
1 parent ce5315c commit 9cb72f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/plugins/minimal_scene/MinimalScene.cc
Original file line number Diff line number Diff line change
Expand Up @@ -762,11 +762,12 @@ std::string GzRenderer::Initialize(RenderThreadRhi &_rhi)
scene->SetSkyEnabled(true);
}

if (!scene->SetShadowTextureSize(rendering::LightType::DIRECTIONAL,
this->directionalLightTextureSize))
if (this->directionalLightTextureSize.has_value() &&
!scene->SetShadowTextureSize(rendering::LightType::DIRECTIONAL,
*this->directionalLightTextureSize))
{
gzerr << "Unable to set directional light shadow <texture_size> to '"
<< this->directionalLightTextureSize
<< *this->directionalLightTextureSize
<< "'. Using default texture size of "
<< scene->ShadowTextureSize(rendering::LightType::DIRECTIONAL)
<< std::endl;
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/minimal_scene/MinimalScene.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <string>
#include <memory>
#include <optional>

#include <gz/common/KeyEvent.hh>
#include <gz/common/MouseEvent.hh>
Expand Down Expand Up @@ -240,7 +241,7 @@ namespace gz::gui::plugins
public: bool skyEnable = false;

/// \brief Shadow texture size for directional light
public: unsigned int directionalLightTextureSize = 2048u;
public: std::optional<unsigned int> directionalLightTextureSize;

/// \brief Horizontal FOV of the camera;
public: math::Angle cameraHFOV = math::Angle(M_PI * 0.5);
Expand Down

0 comments on commit 9cb72f6

Please sign in to comment.