Skip to content

Commit 7e1d64f

Browse files
author
Addisu Z. Taddese
authored
Only set shadow texture size if configured by the user in the SDFormat file (#642)
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
1 parent ce5315c commit 7e1d64f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/plugins/minimal_scene/MinimalScene.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -762,11 +762,12 @@ std::string GzRenderer::Initialize(RenderThreadRhi &_rhi)
762762
scene->SetSkyEnabled(true);
763763
}
764764

765-
if (!scene->SetShadowTextureSize(rendering::LightType::DIRECTIONAL,
766-
this->directionalLightTextureSize))
765+
if (this->directionalLightTextureSize.has_value() &&
766+
!scene->SetShadowTextureSize(rendering::LightType::DIRECTIONAL,
767+
*this->directionalLightTextureSize))
767768
{
768769
gzerr << "Unable to set directional light shadow <texture_size> to '"
769-
<< this->directionalLightTextureSize
770+
<< *this->directionalLightTextureSize
770771
<< "'. Using default texture size of "
771772
<< scene->ShadowTextureSize(rendering::LightType::DIRECTIONAL)
772773
<< std::endl;

src/plugins/minimal_scene/MinimalScene.hh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <string>
2222
#include <memory>
23+
#include <optional>
2324

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

242243
/// \brief Shadow texture size for directional light
243-
public: unsigned int directionalLightTextureSize = 2048u;
244+
public: std::optional<unsigned int> directionalLightTextureSize;
244245

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

0 commit comments

Comments
 (0)