refactor(render): Stage 3 T3.1 — delete FindCameraCell AABB grace-frame fallback
ComputeVisibilityFromRoot(null, …) now returns null (outdoor root) instead of calling FindCameraCell(fallbackPos). Retail CellManager::ChangePosition (0x004559B0) reads the transition-owned curr_cell — it does NOT re-derive from a static position. W2a guarantees CurrCell is set from the first tick, so the AABB fallback is dead. Deleted: FindCameraCell (389–446), _lastCameraCell, _cellSwitchGraceFrames, CellSwitchGraceFrameCount. GetVisibleCells retains a brute-force AABB scan for test-compat; ComputeVisibility stays for the same reason. Updated 3 null-root tests in CellVisibilityFromRootTests to assert the new null-returns-null behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
fcea816391
commit
6a1fbbd44e
2 changed files with 76 additions and 177 deletions
|
|
@ -1,9 +1,9 @@
|
|||
// CellVisibilityFromRootTests.cs — UCG W2 Task 2: tests for
|
||||
// CellVisibilityFromRootTests.cs — UCG W2 Task 2 + Stage 3: tests for
|
||||
// CellVisibility.ComputeVisibilityFromRoot.
|
||||
//
|
||||
// Two acceptance criteria (from the W2 Task 2 spec):
|
||||
// (a) ComputeVisibilityFromRoot(null, pos) is fallback-equivalent to
|
||||
// ComputeVisibility(pos) — same CameraCell answer.
|
||||
// Acceptance criteria (Stage 3 — W2 null-fallback deleted):
|
||||
// (a) ComputeVisibilityFromRoot(null, pos) returns NULL (outdoor root), regardless
|
||||
// of whether any cells are registered. The AABB FindCameraCell fallback is gone.
|
||||
// (b) ComputeVisibilityFromRoot(root, pos) with a registered root returns
|
||||
// a result whose CameraCell is that root, regardless of whether 'pos'
|
||||
// is geometrically inside it.
|
||||
|
|
@ -43,60 +43,53 @@ public class CellVisibilityFromRootTests
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// (a) Fallback equivalence: null root → same answer as ComputeVisibility
|
||||
// (a) Stage 3: null root → null (outdoor root), not a position fallback
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
[Fact]
|
||||
public void ComputeVisibilityFromRoot_NullRoot_FallsBackToPositionBased()
|
||||
public void ComputeVisibilityFromRoot_NullRoot_ReturnsNull_WhenCellExists()
|
||||
{
|
||||
// Arrange: one cell covering [0,10]^3, position inside it.
|
||||
// Stage 3: null root → outdoor root → null result, even when a cell covers the
|
||||
// fallback position. Pre-Stage 3 this called FindCameraCell(pos); now the caller
|
||||
// must supply the root (physics CellGraph.CurrCell). Retail: CellManager::ChangePosition
|
||||
// reads the transition-owned curr_cell — it does not re-derive from a static position.
|
||||
var cv = new CellVisibility();
|
||||
var cell = MakeCell(0xA9B40101u, Vector3.Zero, new Vector3(10, 10, 10));
|
||||
cv.AddCell(cell);
|
||||
|
||||
var pos = new Vector3(5, 5, 5); // inside the cell
|
||||
var pos = new Vector3(5, 5, 5); // inside the cell — null root overrides
|
||||
|
||||
// Act: null-root and direct-position paths must agree on CameraCell.
|
||||
var fromPos = cv.ComputeVisibility(pos);
|
||||
var fromNull = cv.ComputeVisibilityFromRoot(null, pos);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(fromPos);
|
||||
Assert.NotNull(fromNull);
|
||||
Assert.Equal(fromPos!.CameraCell?.CellId, fromNull!.CameraCell?.CellId);
|
||||
Assert.Equal(cell.CellId, fromNull.CameraCell?.CellId);
|
||||
// Stage 3: null root → null (outdoor root path).
|
||||
Assert.Null(fromNull);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ComputeVisibilityFromRoot_NullRoot_NoCells_ReturnsNull()
|
||||
{
|
||||
// With no cells registered both paths return null.
|
||||
// With no cells registered and null root: always null (outdoor root).
|
||||
var cv = new CellVisibility();
|
||||
var posOutdoors = new Vector3(100, 100, 100);
|
||||
|
||||
var fromPos = cv.ComputeVisibility(posOutdoors);
|
||||
var fromNull = cv.ComputeVisibilityFromRoot(null, posOutdoors);
|
||||
|
||||
Assert.Null(fromPos);
|
||||
Assert.Null(fromNull);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ComputeVisibilityFromRoot_NullRoot_PositionOutsideAllCells_ReturnsNull()
|
||||
{
|
||||
// Cell exists but position is outside it — both paths produce null CameraCell.
|
||||
// Cell exists but null root: always null regardless of position.
|
||||
var cv = new CellVisibility();
|
||||
var cell = MakeCell(0xA9B40102u, Vector3.Zero, new Vector3(5, 5, 5));
|
||||
cv.AddCell(cell);
|
||||
|
||||
var posOutside = new Vector3(100, 100, 100);
|
||||
|
||||
var fromPos = cv.ComputeVisibility(posOutside);
|
||||
var fromNull = cv.ComputeVisibilityFromRoot(null, posOutside);
|
||||
|
||||
// Both should return null (no grace frames built up yet)
|
||||
Assert.Null(fromPos?.CameraCell);
|
||||
Assert.Null(fromNull?.CameraCell);
|
||||
Assert.Null(fromNull);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue