fix(rendering): preserve exact scene traversal order
This commit is contained in:
parent
06e7754619
commit
e0f36caa70
12 changed files with 500 additions and 77 deletions
|
|
@ -137,6 +137,74 @@ public sealed class StaticRenderProjectionJournalTests
|
|||
StaticRenderProjectionJournal.StaticEntityId(otherLandblock, 42));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Reconcile_PreservesResidentTraversalOrderInSortKeys()
|
||||
{
|
||||
const uint secondLandblock = 0x5678FFFFu;
|
||||
var journal = new RenderProjectionJournal(Generation(10));
|
||||
var statics = new StaticRenderProjectionJournal(journal);
|
||||
WorldEntity first = Entity(99);
|
||||
WorldEntity liveGap = Entity(77, serverGuid: 0x80000077u);
|
||||
WorldEntity second = Entity(1);
|
||||
LandblockBuild firstBuild = Build(
|
||||
LandblockId,
|
||||
[first, liveGap, second],
|
||||
includeShell: false);
|
||||
LandblockBuild secondBuild = Build(
|
||||
secondLandblock,
|
||||
[Entity(500)],
|
||||
includeShell: false);
|
||||
|
||||
statics.Reconcile(firstBuild, Publication(firstBuild));
|
||||
statics.Reconcile(
|
||||
secondBuild,
|
||||
Publication(secondBuild, renderTraversalOrder: 2));
|
||||
|
||||
Assert.True(statics.TryGet(
|
||||
StaticRenderProjectionJournal.StaticEntityId(
|
||||
LandblockId,
|
||||
first.Id),
|
||||
out RenderProjectionRecord firstRecord));
|
||||
Assert.True(statics.TryGet(
|
||||
StaticRenderProjectionJournal.StaticEntityId(
|
||||
LandblockId,
|
||||
second.Id),
|
||||
out RenderProjectionRecord secondRecord));
|
||||
Assert.True(statics.TryGet(
|
||||
StaticRenderProjectionJournal.StaticEntityId(
|
||||
secondLandblock,
|
||||
500),
|
||||
out RenderProjectionRecord laterLandblockRecord));
|
||||
Assert.True(firstRecord.SortKey.Value < secondRecord.SortKey.Value);
|
||||
Assert.True(
|
||||
secondRecord.SortKey.Value
|
||||
< laterLandblockRecord.SortKey.Value);
|
||||
Assert.Equal(
|
||||
2u,
|
||||
unchecked((uint)secondRecord.SortKey.Value));
|
||||
|
||||
LandblockBuild reordered = Build(
|
||||
LandblockId,
|
||||
[second, first],
|
||||
includeShell: false);
|
||||
statics.Reconcile(reordered, Publication(reordered));
|
||||
|
||||
Assert.True(statics.TryGet(
|
||||
StaticRenderProjectionJournal.StaticEntityId(
|
||||
LandblockId,
|
||||
first.Id),
|
||||
out firstRecord));
|
||||
Assert.True(statics.TryGet(
|
||||
StaticRenderProjectionJournal.StaticEntityId(
|
||||
LandblockId,
|
||||
second.Id),
|
||||
out secondRecord));
|
||||
Assert.True(secondRecord.SortKey.Value < firstRecord.SortKey.Value);
|
||||
Assert.Equal(
|
||||
2uL,
|
||||
laterLandblockRecord.SortKey.Value >> 32);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StaleFarPublication_DoesNotMutateProjectionJournal()
|
||||
{
|
||||
|
|
@ -307,14 +375,16 @@ public sealed class StaticRenderProjectionJournalTests
|
|||
|
||||
private static GpuLandblockSpatialPublication Publication(
|
||||
LandblockBuild build,
|
||||
bool requiresActivation = true) =>
|
||||
bool requiresActivation = true,
|
||||
uint renderTraversalOrder = 1) =>
|
||||
new(
|
||||
build.LandblockId,
|
||||
build.Landblock,
|
||||
build.EnvCells?.Shells.Select(shell => shell.GeometryId).ToArray()
|
||||
?? [],
|
||||
build.Landblock.Entities.Where(entity => entity.ServerGuid == 0).ToArray(),
|
||||
requiresActivation);
|
||||
requiresActivation,
|
||||
renderTraversalOrder);
|
||||
|
||||
private static LandblockBuild Build(
|
||||
uint landblockId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue