refactor(content): share EnvCell geometry identity
This commit is contained in:
parent
05a22dee99
commit
86fadf8661
3 changed files with 73 additions and 8 deletions
|
|
@ -0,0 +1,42 @@
|
|||
using AcDream.Core.Rendering.Wb;
|
||||
|
||||
namespace AcDream.Core.Tests.Rendering.Wb;
|
||||
|
||||
public sealed class EnvCellGeometryIdentityTests
|
||||
{
|
||||
[Fact]
|
||||
public void Compute_EmptySurfaces_MatchesExtractedWorldBuilderValue()
|
||||
{
|
||||
Assert.Equal(
|
||||
0x2_0000_47D6UL,
|
||||
EnvCellGeometryIdentity.Compute(0x42, 7, Array.Empty<ushort>()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compute_OrderedSurfaces_MatchesExtractedWorldBuilderValue()
|
||||
{
|
||||
Assert.Equal(
|
||||
0x2_20A7_A46CUL,
|
||||
EnvCellGeometryIdentity.Compute(0x42, 7, new ushort[] { 1, 2, 3 }));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compute_SurfaceOrderIsPartOfIdentity()
|
||||
{
|
||||
var forward = EnvCellGeometryIdentity.Compute(1, 1, new ushort[] { 10, 20 });
|
||||
var reverse = EnvCellGeometryIdentity.Compute(1, 1, new ushort[] { 20, 10 });
|
||||
|
||||
Assert.NotEqual(forward, reverse);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Compute_AlwaysUsesDeduplicatedGeometryNamespace()
|
||||
{
|
||||
var id = EnvCellGeometryIdentity.Compute(
|
||||
uint.MaxValue,
|
||||
ushort.MaxValue,
|
||||
new ushort[] { ushort.MaxValue, ushort.MaxValue });
|
||||
|
||||
Assert.NotEqual(0UL, id & 0x2_0000_0000UL);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue