XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEEDToolBox

【WinUI】XFE精英危险工具箱

公开
关注 0 Fork 0 Star 0
UTF-8
using XFEEDToolBox.Core.Rendering;
using XFEExtension.NetCore.XUnit.Attributes;

namespace XFEEDToolBox.Test;

[TestFixture]
public sealed class GalaxyOriginalBackgroundTests
{
    [Test] public void EmbeddedGdmRetainsIndependentIntegerMapsAndOriginalSolCoordinateFrame()
    {
        var source=GalaxyOriginalDensity.Reference;
        Check.Equal(49985d,source.Origin.X);Check.Equal(40985d,source.Origin.Y);Check.Equal(24105d,source.Origin.Z);
        Check.Equal(4934742U,source.Coefficients[0]);Check.Equal(100000U,source.Coefficients[11]);
        Check.Equal(5367098788688UL,GalaxyOriginalDensityMap.CellAddress(49985,40985,24105));
        var sol=GalaxyOriginalDensityMap.CellAddress(49985,40985,24105);
        Check.Equal(526U,source.HeightIntegral(sol));Check.Equal(.9424896f,source.StellarDensity(sol));
        Check.Equal(.2746277f,source.MilkyWaySurface(sol));Check.Equal(.73916626f,source.DustDensity(sol));
        var centre=GalaxyOriginalDensityMap.CellAddress(50000,40955,50000);
        Check.That(source.StellarDensity(centre)>100,"Original density must retain values above1; the overview normalization is a different format.");
        Check.Equal(0f,source.StellarDensity(0));Check.Equal(0f,source.MilkyWaySurface(0));Check.Equal(0f,source.DustDensity(0));
    }
    [Test] public void AuthoredCloudAtlasIsThreeByFiveAndKeepsOriginalPaddedMipChains()
    {
        var source=GalaxyOriginalMilkyWay.Reference;Check.Equal(4,source.Textures.Count);Check.Equal(15,source.AtlasTiles.Count);
        Check.Equal(3,GalaxyOriginalMilkyWayResources.AtlasColumns);Check.Equal(5,GalaxyOriginalMilkyWayResources.AtlasRows);
        Check.That(source.AtlasTiles.SequenceEqual(Enumerable.Range(0,5).SelectMany(row=>Enumerable.Range(0,3).Select(column=>(column<<8)|row))),"Atlas coordinates must follow the actual original ushort table, not texture aspect ratio.");
        var atlas=source.Textures[0];Check.Equal(1280,atlas.Width);Check.Equal(2048,atlas.Height);Check.Equal(12,atlas.Mips.Count);
        Check.Equal(1786880,atlas.PayloadBytes);
        foreach(var texture in source.Textures)
        foreach(var level in Enumerable.Range(0,texture.Mips.Count))
        {
            var mip=texture.Mips[level];var rows=(Math.Max(1,texture.Height>>level)+3)/4;var columns=(Math.Max(1,texture.Width>>level)+3)/4;
            Check.That(mip.RowPitch>=columns*8&&mip.SliceBytes>=mip.RowPitch*rows,"Original BC1 row padding must remain valid at every mip.");
        }
    }
    [Test] public void OriginalCloudJobIsDeterministicAndUsesSourceDensityRatherThanFakeStars()
    {
        var window=GalaxyOriginalClouds.Window(new(0,0,0));var layer=GalaxyOriginalClouds.Generate(window);
        Check.Equal(new GalaxyOriginalCloudWindow(0,32955,0,100000,48955,100000,1066,0,false),window);
        Check.Equal(141376,layer.SampledCells);Check.Equal(15824,layer.Clouds.Count);
        Check.That(layer.Clouds.All(c=>float.IsFinite(c.AbsolutePosition.X+c.AbsolutePosition.Y+c.AbsolutePosition.Z+c.Rotation)&&c.Alpha>.001f&&c.Size>=.75f&&c.Size<=1.5f&&c.AtlasIndex is >=0 and <=2));
        Check.Equal(layer.Clouds[0],GalaxyOriginalClouds.Generate(window).Clouds[0]);
        var dust=GalaxyOriginalClouds.Generate(GalaxyOriginalClouds.Window(new(0,0,0),0,true));
        Check.Equal(8836,dust.SampledCells);Check.Equal(140,dust.Clouds.Count);
        Check.That(dust.Clouds.All(c=>c.AtlasIndex is >=3 and <=5&&c.Alpha>0));
        using var cancellation=new CancellationTokenSource();cancellation.Cancel();var cancelled=false;
        try{GalaxyOriginalClouds.Generate(window,cancellation.Token);}catch(OperationCanceledException){cancelled=true;}
        Check.That(cancelled,"Generation must stop before publishing a cancelled layer.");
    }
}