Complete portable planetary presentation contracts
This commit is contained in:
parent
42fef7cdd7
commit
102403efac
74 changed files with 1166 additions and 31 deletions
2
tests/CultMath.Tests/AdvancedErosionFilterTests.cs.meta
Normal file
2
tests/CultMath.Tests/AdvancedErosionFilterTests.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a7c85309318ae3f4ba75ac28a4f661cf
|
||||
2
tests/CultMath.Tests/ErosionFrequencyBandsTests.cs.meta
Normal file
2
tests/CultMath.Tests/ErosionFrequencyBandsTests.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 095f8ed13d2f2f74baefd23310395256
|
||||
|
|
@ -78,6 +78,8 @@ public sealed class HlslMirrorTests
|
|||
Assert.Contains("cultmath_planetary_field_sample", planetary);
|
||||
Assert.Contains("cultmath_planetary_equirectangular_forward", planetary);
|
||||
Assert.Contains("cultmath_planetary_equal_earth_forward", planetary);
|
||||
Assert.Contains("cultmath_planetary_projection_forward", planetary);
|
||||
Assert.Contains("cultmath_planetary_projection_inverse", planetary);
|
||||
Assert.Contains("CultMathPlanetarySurfaceSample", planetary);
|
||||
}
|
||||
|
||||
|
|
|
|||
2
tests/CultMath.Tests/PlanetaryFieldTests.cs.meta
Normal file
2
tests/CultMath.Tests/PlanetaryFieldTests.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c747cfda80df21d41a57412d8d07c08a
|
||||
25
tests/CultMath.Tests/PlanetaryGpuPageTests.cs
Normal file
25
tests/CultMath.Tests/PlanetaryGpuPageTests.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using Xunit;
|
||||
|
||||
namespace CultMath.Tests;
|
||||
|
||||
public sealed class PlanetaryGpuPageTests
|
||||
{
|
||||
[Fact]
|
||||
public void UploadContentUsesCanonicalDirectionsSpacingAndMetadata()
|
||||
{
|
||||
var layout = new PlanetaryPageLayout(new(PlanetaryCubeFace.NegativeY, 3, 4, 2), 9, 2);
|
||||
var content = PlanetaryGpuPageBuilder.BuildContent(layout, 8.4f);
|
||||
Assert.Equal(layout.StorageSize * layout.StorageSize, content.Inputs.Length);
|
||||
Assert.True(content.ParentSampleSpacing > content.SampleSpacing);
|
||||
var first = content.Inputs[0];
|
||||
Assert.Equal(PlanetaryPageSampling.Direction(layout, 0, 0), first.DirectionRadius.xyz);
|
||||
Assert.Equal(8.4f, first.DirectionRadius.w);
|
||||
Assert.Equal(content.SampleSpacing, first.Sampling.x);
|
||||
Assert.Equal(content.ParentSampleSpacing, first.Sampling.y);
|
||||
|
||||
var metadata = PlanetaryGpuPageBuilder.Metadata(content, 37, 0.25f);
|
||||
Assert.Equal(new float4((int)layout.Tile.Face, layout.Tile.Level, layout.Tile.X, layout.Tile.Y), metadata.Address);
|
||||
Assert.Equal(new float4(37, layout.StorageSize, layout.InteriorSize, layout.BorderSize), metadata.Layout);
|
||||
Assert.Equal(0.25f, metadata.State.y);
|
||||
}
|
||||
}
|
||||
2
tests/CultMath.Tests/PlanetaryGpuPageTests.cs.meta
Normal file
2
tests/CultMath.Tests/PlanetaryGpuPageTests.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 87266638e8010f546ab6c430a712868b
|
||||
52
tests/CultMath.Tests/PlanetaryMapTileEncodingTests.cs
Normal file
52
tests/CultMath.Tests/PlanetaryMapTileEncodingTests.cs
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
using System.IO;
|
||||
using Xunit;
|
||||
|
||||
namespace CultMath.Tests;
|
||||
|
||||
public sealed class PlanetaryMapTileEncodingTests
|
||||
{
|
||||
[Fact]
|
||||
public void BinaryTileRoundTripsIdentityValidityAndSurfaceEvidence()
|
||||
{
|
||||
var field = PlanetaryFieldDefinition.Create(5, 10, 3, AdvancedErosionParameters.Default);
|
||||
var layout = new PlanetaryMapTileLayout(new(PlanetaryProjectionKind.EqualEarth), 1, 1, 0, 5, 1);
|
||||
var key = new PlanetaryMapTileKey(field.FieldVersion, 2, 17, layout, PlanetaryQueryScale.AtFootprint(0.25f, 0.1f));
|
||||
var tile = PlanetaryMapTileBaker.Bake(field, key, new FlatField());
|
||||
using var bytes = new MemoryStream();
|
||||
PlanetaryMapTileEncoding.Write(bytes, tile, leaveOpen: true);
|
||||
bytes.Position = 0;
|
||||
var decoded = PlanetaryMapTileEncoding.Read(bytes);
|
||||
|
||||
Assert.Equal(tile.Key, decoded.Key);
|
||||
Assert.Equal(tile.Validity, decoded.Validity);
|
||||
for (var i = 0; i < tile.Samples.Length; i++)
|
||||
if (tile.Validity[i]) Assert.Equal(tile.Samples[i], decoded.Samples[i]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DecoderRejectsForeignMagicAndVersions()
|
||||
{
|
||||
Assert.Throws<InvalidDataException>(() => PlanetaryMapTileEncoding.Read(new MemoryStream(new byte[] { 1, 2, 3, 4, 1, 0, 0, 0 })));
|
||||
var bytes = new byte[] { (byte)'C', (byte)'M', (byte)'P', (byte)'T', 99, 0, 0, 0 };
|
||||
Assert.Throws<InvalidDataException>(() => PlanetaryMapTileEncoding.Read(new MemoryStream(bytes)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DecoderRejectsTrailingBytes()
|
||||
{
|
||||
var field = PlanetaryFieldDefinition.Create(2, 1, 0, AdvancedErosionParameters.Default);
|
||||
var layout = new PlanetaryMapTileLayout(new(PlanetaryProjectionKind.Equirectangular), 0, 0, 0, 2, 0);
|
||||
var key = new PlanetaryMapTileKey(field.FieldVersion, 1, 0, layout, PlanetaryQueryScale.AtFootprint(1));
|
||||
var tile = PlanetaryMapTileBaker.Bake(field, key, new FlatField());
|
||||
using var bytes = new MemoryStream();
|
||||
PlanetaryMapTileEncoding.Write(bytes, tile, leaveOpen: true);
|
||||
bytes.WriteByte(0xff);
|
||||
bytes.Position = 0;
|
||||
Assert.Throws<InvalidDataException>(() => PlanetaryMapTileEncoding.Read(bytes));
|
||||
}
|
||||
|
||||
private readonly struct FlatField : IPlanetaryBaseField
|
||||
{
|
||||
public PlanetaryBaseFieldSample Sample(float3 direction) => new(0, float3.zero, 0, float3.zero, 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e916ef83478d48b43ac99777f5e0f731
|
||||
2
tests/CultMath.Tests/PlanetaryPageTests.cs.meta
Normal file
2
tests/CultMath.Tests/PlanetaryPageTests.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7c3ae5598d3b9164a9bd3a736a22ba9a
|
||||
2
tests/CultMath.Tests/PlanetaryPatchTests.cs.meta
Normal file
2
tests/CultMath.Tests/PlanetaryPatchTests.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 36840ef44326f84409f850163b00e1f7
|
||||
2
tests/CultMath.Tests/PlanetaryProjectionTests.cs.meta
Normal file
2
tests/CultMath.Tests/PlanetaryProjectionTests.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f370036bb1663524fb4a4d47dfd50401
|
||||
2
tests/CultMath.Tests/PlanetaryQueryTests.cs.meta
Normal file
2
tests/CultMath.Tests/PlanetaryQueryTests.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 93cf8771fdd520b41a4e931a6566a80a
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d34c0018ee2b700448b16540eca8ebcf
|
||||
2
tests/CultMath.Tests/PlanetaryResidencyTests.cs.meta
Normal file
2
tests/CultMath.Tests/PlanetaryResidencyTests.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9ece3b02dbd3d7448baabee7f1fba0ab
|
||||
|
|
@ -52,4 +52,12 @@ public sealed class PlanetaryTopologyTests
|
|||
Assert.NotEqual(edge, border);
|
||||
Assert.Equal(1, math.length(border), 5);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NormalizedCubeBaselineSharesFaceEdges()
|
||||
{
|
||||
var a = PlanetaryTopology.NormalizedCubeDirection(new(PlanetaryCubeFace.PositiveZ, 1, -0.4));
|
||||
var b = PlanetaryTopology.NormalizedCubeDirection(new(PlanetaryCubeFace.PositiveX, -1, -0.4));
|
||||
Assert.InRange(math.distance(a, b), 0, 1.0e-6f);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
tests/CultMath.Tests/PlanetaryTopologyTests.cs.meta
Normal file
2
tests/CultMath.Tests/PlanetaryTopologyTests.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: be3b0ec07fe65344db889d1e98448113
|
||||
2
tests/CultMath.Tests/SphericalErosionTests.cs.meta
Normal file
2
tests/CultMath.Tests/SphericalErosionTests.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 60eb9e9e9f8ae2948b13403f5080168e
|
||||
Reference in a new issue