From 7e1d64fc2557d22d97e2aff62bb1859e29bb0c6d Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Mon, 16 Sep 2024 17:49:29 -0500 Subject: [PATCH] Only set shadow texture size if configured by the user in the SDFormat file (#642) Signed-off-by: Addisu Z. Taddese --- src/plugins/minimal_scene/MinimalScene.cc | 7 ++++--- src/plugins/minimal_scene/MinimalScene.hh | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/minimal_scene/MinimalScene.cc b/src/plugins/minimal_scene/MinimalScene.cc index aa34a15a7..6479d69c1 100644 --- a/src/plugins/minimal_scene/MinimalScene.cc +++ b/src/plugins/minimal_scene/MinimalScene.cc @@ -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 to '" - << this->directionalLightTextureSize + << *this->directionalLightTextureSize << "'. Using default texture size of " << scene->ShadowTextureSize(rendering::LightType::DIRECTIONAL) << std::endl; diff --git a/src/plugins/minimal_scene/MinimalScene.hh b/src/plugins/minimal_scene/MinimalScene.hh index 46a7b7e40..ee61b96a9 100644 --- a/src/plugins/minimal_scene/MinimalScene.hh +++ b/src/plugins/minimal_scene/MinimalScene.hh @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -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 directionalLightTextureSize; /// \brief Horizontal FOV of the camera; public: math::Angle cameraHFOV = math::Angle(M_PI * 0.5);