diff --git a/ogre2/src/Ogre2Scene.cc b/ogre2/src/Ogre2Scene.cc index 28edfcff5..d7bc1ff91 100644 --- a/ogre2/src/Ogre2Scene.cc +++ b/ogre2/src/Ogre2Scene.cc @@ -1638,7 +1638,7 @@ unsigned int Ogre2Scene::ShadowTextureSize(LightType _lightType) const case LightType::EMPTY: gzerr << "Invalid light type [" << static_cast(_lightType) << "]" << std::endl; - return 0; + return 0u; } } diff --git a/test/common_test/Scene_TEST.cc b/test/common_test/Scene_TEST.cc index 1824ea203..570e2d738 100644 --- a/test/common_test/Scene_TEST.cc +++ b/test/common_test/Scene_TEST.cc @@ -766,12 +766,18 @@ TEST_F(SceneTest, ShadowTextureSize) // Currently only support setting shadow texture size for // directional light // If set shadow texture size for other light types, it is ignored + auto spotLight = scene->CreateSpotLight("spot_light"); + auto pointLight = scene->CreatePointLight("point_light"); + EXPECT_FALSE(scene->SetShadowTextureSize(LightType::POINT, 4096u)); EXPECT_EQ(scene->ShadowTextureSize(LightType::POINT), 2048u); EXPECT_FALSE(scene->SetShadowTextureSize(LightType::SPOT, 4096u)); EXPECT_EQ(scene->ShadowTextureSize(LightType::SPOT), 2048u); + EXPECT_FALSE(scene->SetShadowTextureSize(LightType::EMPTY, 4096u)); + EXPECT_EQ(scene->ShadowTextureSize(LightType::EMPTY), 0u); + // If set shadow texture size to a valid value, change it EXPECT_TRUE(scene->SetShadowTextureSize(LightType::DIRECTIONAL, 8192u)); EXPECT_EQ(scene->ShadowTextureSize(LightType::DIRECTIONAL), 8192u); @@ -779,4 +785,9 @@ TEST_F(SceneTest, ShadowTextureSize) // If set shadow texture size to an invalid value, use default EXPECT_FALSE(scene->SetShadowTextureSize(LightType::DIRECTIONAL, 1000u)); EXPECT_EQ(scene->ShadowTextureSize(LightType::DIRECTIONAL), 8192u); + + // If set shadow texture size to a value larger than maxTexSize, + // use default + EXPECT_FALSE(scene->SetShadowTextureSize(LightType::DIRECTIONAL, 32768u)); + EXPECT_EQ(scene->ShadowTextureSize(LightType::DIRECTIONAL), 8192u); }