acdream/tests/AcDream.Core.Tests/Rendering/CameraDiagnosticsTests.cs
Erik fcea05f808 fix(render): Phase A8.F — camera sweep uses retail moverFlags 0x5c (PathClipped hard-stop)
Code review found the probe passed ObjectInfoState.None; retail's
SmartBox::update_viewer calls init_object(player, 0x5c) =
IsViewer|PathClipped|FreeRotate|PerfectClip (pseudo-C :92864). PathClipped makes
the sweep hard-stop at first contact (TransitionTypes.cs:811) instead of
edge-sliding around corners (which would re-trigger the A8.F camera-cell
instability); IsViewer lets the eye pass through creatures, colliding only with
world geometry. Resolves the spec's slide-vs-stop open question. Also reset
CollideCamera in the Defaults_AreRetailValues baseline test (review: maintenance
trap). Spec §5.1/§11.1 synced.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 19:11:53 +02:00

63 lines
2.4 KiB
C#

using AcDream.Core.Rendering;
using Xunit;
namespace AcDream.Core.Tests.Rendering;
public class CameraDiagnosticsTests
{
// NOTE: These tests assume the env vars ACDREAM_RETAIL_CHASE and
// ACDREAM_CAMERA_ALIGN_SLOPE are NOT set when running the test
// suite. Static class is initialised on first access; values reflect
// the env state at that time.
[Fact]
public void Defaults_AreRetailValues()
{
// Reset to defaults explicitly (test isolation; another test may
// have flipped these earlier in the run).
CameraDiagnostics.TranslationStiffness = 0.45f;
CameraDiagnostics.RotationStiffness = 0.45f;
CameraDiagnostics.MouseLowPassWindowSec = 0.25f;
CameraDiagnostics.CameraAdjustmentSpeed = 40.0f;
CameraDiagnostics.AlignToSlope = true;
CameraDiagnostics.UseRetailChaseCamera = true;
CameraDiagnostics.CollideCamera = true;
Assert.Equal(0.45f, CameraDiagnostics.TranslationStiffness);
Assert.Equal(0.45f, CameraDiagnostics.RotationStiffness);
Assert.Equal(0.25f, CameraDiagnostics.MouseLowPassWindowSec);
Assert.Equal(40.0f, CameraDiagnostics.CameraAdjustmentSpeed);
Assert.True(CameraDiagnostics.AlignToSlope);
// 2026-05-18 ship: retail chase camera is the default. The
// legacy camera remains opt-in via the DebugPanel toggle until
// the follow-up deletion commit.
Assert.True(CameraDiagnostics.UseRetailChaseCamera);
Assert.True(CameraDiagnostics.CollideCamera);
}
[Fact]
public void Setters_PersistRuntimeChanges()
{
CameraDiagnostics.TranslationStiffness = 0.8f;
CameraDiagnostics.UseRetailChaseCamera = false;
Assert.Equal(0.8f, CameraDiagnostics.TranslationStiffness);
Assert.False(CameraDiagnostics.UseRetailChaseCamera);
// Reset so other tests aren't poisoned.
CameraDiagnostics.TranslationStiffness = 0.45f;
CameraDiagnostics.UseRetailChaseCamera = true;
}
[Fact]
public void CollideCamera_DefaultOn_AndPersistsRuntimeChanges()
{
CameraDiagnostics.CollideCamera = true;
Assert.True(CameraDiagnostics.CollideCamera);
CameraDiagnostics.CollideCamera = false;
Assert.False(CameraDiagnostics.CollideCamera);
CameraDiagnostics.CollideCamera = true; // reset so other tests aren't poisoned
}
}