feat(editor): persist graphics settings and shadow overrides

This commit is contained in:
2026-04-19 00:01:49 +08:00
parent 9ca7960346
commit 8257403036
31 changed files with 1233 additions and 134 deletions

View File

@@ -156,7 +156,7 @@ TEST(CameraComponent_Test, DeserializeLegacyColorScalePostProcessFields) {
ASSERT_EQ(camera.GetPostProcessPasses().size(), 2u);
EXPECT_EQ(
camera.GetPostProcessPasses()[0].type,
XCEngine::Rendering::FullscreenPassType::ColorScale);
XCEngine::Rendering::FullscreenPassType::ColorScale);
EXPECT_TRUE(camera.IsColorScalePostProcessEnabled());
EXPECT_FLOAT_EQ(camera.GetColorScalePostProcessPasses()[0].x, 0.55f);
EXPECT_FLOAT_EQ(camera.GetColorScalePostProcessPasses()[1].y, 0.95f);
@@ -193,6 +193,12 @@ TEST(LightComponent_Test, DefaultValues) {
EXPECT_FLOAT_EQ(light.GetRange(), 10.0f);
EXPECT_FLOAT_EQ(light.GetSpotAngle(), 30.0f);
EXPECT_FALSE(light.GetCastsShadows());
EXPECT_FALSE(light.GetOverridesDirectionalShadowSettings());
EXPECT_FLOAT_EQ(light.GetDirectionalShadowReceiverDepthBias(), 0.0010f);
EXPECT_FLOAT_EQ(light.GetDirectionalShadowNormalBiasScale(), 2.0f);
EXPECT_FLOAT_EQ(light.GetDirectionalShadowStrength(), 0.85f);
EXPECT_FLOAT_EQ(light.GetDirectionalShadowDepthBiasFactor(), 2.5f);
EXPECT_EQ(light.GetDirectionalShadowDepthBiasUnits(), 4);
}
TEST(LightComponent_Test, SetterClamping) {
@@ -205,6 +211,44 @@ TEST(LightComponent_Test, SetterClamping) {
EXPECT_FLOAT_EQ(light.GetIntensity(), 0.0f);
EXPECT_FLOAT_EQ(light.GetRange(), 0.001f);
EXPECT_FLOAT_EQ(light.GetSpotAngle(), 179.0f);
light.SetDirectionalShadowReceiverDepthBias(-1.0f);
light.SetDirectionalShadowNormalBiasScale(-2.0f);
light.SetDirectionalShadowStrength(5.0f);
light.SetDirectionalShadowDepthBiasFactor(-3.0f);
light.SetDirectionalShadowDepthBiasUnits(-4);
EXPECT_FLOAT_EQ(light.GetDirectionalShadowReceiverDepthBias(), 0.0010f);
EXPECT_FLOAT_EQ(light.GetDirectionalShadowNormalBiasScale(), 2.0f);
EXPECT_FLOAT_EQ(light.GetDirectionalShadowStrength(), 1.0f);
EXPECT_FLOAT_EQ(light.GetDirectionalShadowDepthBiasFactor(), 2.5f);
EXPECT_EQ(light.GetDirectionalShadowDepthBiasUnits(), 0);
}
TEST(LightComponent_Test, SerializeRoundTripPreservesDirectionalShadowOverrides) {
LightComponent source;
source.SetLightType(LightType::Directional);
source.SetCastsShadows(true);
source.SetOverridesDirectionalShadowSettings(true);
source.SetDirectionalShadowReceiverDepthBias(0.0025f);
source.SetDirectionalShadowNormalBiasScale(1.75f);
source.SetDirectionalShadowStrength(0.72f);
source.SetDirectionalShadowDepthBiasFactor(3.5f);
source.SetDirectionalShadowDepthBiasUnits(6);
std::stringstream stream;
source.Serialize(stream);
LightComponent target;
target.Deserialize(stream);
EXPECT_TRUE(target.GetCastsShadows());
EXPECT_TRUE(target.GetOverridesDirectionalShadowSettings());
EXPECT_FLOAT_EQ(target.GetDirectionalShadowReceiverDepthBias(), 0.0025f);
EXPECT_FLOAT_EQ(target.GetDirectionalShadowNormalBiasScale(), 1.75f);
EXPECT_FLOAT_EQ(target.GetDirectionalShadowStrength(), 0.72f);
EXPECT_FLOAT_EQ(target.GetDirectionalShadowDepthBiasFactor(), 3.5f);
EXPECT_EQ(target.GetDirectionalShadowDepthBiasUnits(), 6);
}
} // namespace