Cut 13a: 0.5m Sion DEM, compute TerrainRenderer, tiled Box3D heightfields, and scar ledger
This commit is contained in:
parent
fb9a706b84
commit
e86fee31da
34 changed files with 3360 additions and 1033 deletions
|
|
@ -797,6 +797,87 @@ namespace RustToDust.Tests
|
|||
"Client must receive Exemplar walker snapshot even under dense 12 quad-walker contention");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Cut13a_OutOfPvsHistoricalCratersSyncViaPersistentScars_AndLiveCratersEnterWithin576mBubble()
|
||||
{
|
||||
using var host = new ServerMatchHost(IPAddress.Loopback, 0, seed: 42, ArenaMapKind.Sion, maxHumans: 12, autoRestartSec: 0);
|
||||
var ep = new IPEndPoint(IPAddress.Loopback, host.BoundPort);
|
||||
|
||||
const float histX = 700f;
|
||||
const float histZ = 700f;
|
||||
float baseHistH = host.Session.State.Terrain.SampleHeight(histX, histZ);
|
||||
|
||||
// 1. Historical out-of-PVS crater stamped before Client A joins
|
||||
((IOrdnanceTargetSink)host.Session).StampTerrainImpact(histX, histZ, craterRadius: 6f, craterDepth: 2.0f, scorchRadius: 7f);
|
||||
long nowMs = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||||
host.StepOnce(nowMs += 16);
|
||||
float scarredHistH = host.Session.State.Terrain.SampleHeight(histX, histZ);
|
||||
Assert.True(scarredHistH < baseHistH - 1.2f);
|
||||
|
||||
using var clientA = new RemoteArenaSession(ep, "Scout");
|
||||
Assert.True(PumpUntil(host, new[] { clientA }, () => clientA.IsJoined, ref nowMs, 3000));
|
||||
|
||||
// Out-of-PVS historical crater must be present immediately via PersistentScars
|
||||
Assert.Equal(scarredHistH, clientA.ViewState.Terrain.SampleHeight(histX, histZ), precision: 3);
|
||||
Assert.InRange(clientA.PredTileSync.ResidentTileCount, 1, 9);
|
||||
|
||||
// 2. Live crater stamped far outside 576m bubble (-700, 100 vs open-sky ~700, 100 = ~1400m apart)
|
||||
int slotA = clientA.LocalContenderId;
|
||||
var sion = host.Session.State.SionMap!;
|
||||
float liveX = 700f, liveZ = 100f;
|
||||
for (float x = 640f; x <= 760f; x += 8f)
|
||||
{
|
||||
if (!sion.IsInsideAnyBuildingXz(x, liveZ, padding: 10f))
|
||||
{
|
||||
liveX = x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
float baseLiveH = host.Session.State.Terrain.SampleHeight(liveX, liveZ);
|
||||
|
||||
host.Session.SetContenderPose(slotA, -700f, liveZ, 0f);
|
||||
host.StepOnce(nowMs += 16);
|
||||
((IOrdnanceTargetSink)host.Session).StampTerrainImpact(liveX, liveZ, craterRadius: 6f, craterDepth: 2.0f, scorchRadius: 7f);
|
||||
for (int t = 0; t < 10; t++)
|
||||
{
|
||||
nowMs += 16;
|
||||
host.StepOnce(nowMs);
|
||||
clientA.PumpNetwork();
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
float hostLiveH = host.Session.State.Terrain.SampleHeight(liveX, liveZ);
|
||||
Assert.True(hostLiveH < baseLiveH - 1.2f);
|
||||
Assert.Equal(baseLiveH, clientA.ViewState.Terrain.SampleHeight(liveX, liveZ), precision: 3);
|
||||
|
||||
// 3. Client A enters 576m local geometry bubble (liveX - 450m -> dist = 450m <= 576m)
|
||||
host.Session.SetContenderPose(slotA, liveX - 450f, liveZ, 0f);
|
||||
Assert.True(PumpUntil(
|
||||
host,
|
||||
new[] { clientA },
|
||||
() => MathF.Abs(clientA.ViewState.Terrain.SampleHeight(liveX, liveZ) - hostLiveH) < 0.05f,
|
||||
ref nowMs,
|
||||
3000),
|
||||
"Client must receive live TerrainStampEvent upon entering 576m bubble before reaching _predWorld 3x3 window");
|
||||
|
||||
// 4. Client A steps into (liveX, liveZ) tile -> _predWorld 3x3 window matches server Box3D crater depth 1:1
|
||||
host.Session.SetContenderPose(slotA, liveX - 20f, liveZ, 0f);
|
||||
for (int t = 0; t < 10; t++)
|
||||
{
|
||||
nowMs += 16;
|
||||
host.StepOnce(nowMs);
|
||||
clientA.BeginRenderFrame(1.0 / 60.0, 1f);
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
Assert.InRange(clientA.PredTileSync.ResidentTileCount, 1, 9);
|
||||
float rayStartY = sion.Metadata.MaxY + 25f;
|
||||
float raySpanY = -(sion.Metadata.MaxY - sion.Metadata.MinY + 60f);
|
||||
var hostHit = host.Session.CastWorldRayClosest(new Vector3(liveX, rayStartY, liveZ), new Vector3(0f, raySpanY, 0f));
|
||||
var predHit = clientA.CastWorldRayClosest(new Vector3(liveX, rayStartY, liveZ), new Vector3(0f, raySpanY, 0f));
|
||||
Assert.True(hostHit.Hit && predHit.Hit);
|
||||
Assert.True(MathF.Abs(hostHit.Point.Y - predHit.Point.Y) < 0.05f,
|
||||
$"Expected _predWorld crater impact Y ({predHit.Point.Y:F3}m) to match server ({hostHit.Point.Y:F3}m)");
|
||||
}
|
||||
|
||||
private static byte[] EncodeRudpLatestDatagram(byte[] frameBytes, uint sequence) =>
|
||||
CultNetRudpPacketCodec.Encode(new CultNetRudpPacket
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue