Load Zyphos fractal terrain from aquageo patch

This commit is contained in:
Meta Vens 2026-05-18 03:24:50 +01:00
commit db8f767c4a
5 changed files with 16 additions and 10 deletions

View file

@ -17,6 +17,7 @@
<ItemGroup>
<Content Include="Shaders\**\*.hlsl" CopyToOutputDirectory="PreserveNewest" TargetPath="Render\Shaders\%(RecursiveDir)%(Filename)%(Extension)" />
<Content Include="Shaders\**\*.hlsli" CopyToOutputDirectory="PreserveNewest" TargetPath="Render\Shaders\%(RecursiveDir)%(Filename)%(Extension)" />
<Content Include="Worlds\**\*.aquageo" CopyToOutputDirectory="PreserveNewest" TargetPath="Worlds\%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,5 @@
# Zyphos first Aquarium fractal terrain DSL proof.
tile PositiveZ 0 0 0 zyphos/first-fractal-terrain
height basin 0 0 30 30 0 3 1 -0.12 7 basin
ifs crater 3 2 -5 3 6 2.5 0.48 2.6 0.42 4 0.85 -0.10 19 crater
ifs ridge 2 3 6 -4 5 1.35 0.45 3.2 -0.27 3.6 0.72 0.075 31 ridge

View file

@ -9,19 +9,16 @@ namespace Aquarium.Zyphos;
public static class ZyphosFractalTerrain
{
public const string Grammar = """
# Zyphos first Aquarium fractal terrain DSL proof.
tile PositiveZ 0 0 0 zyphos/first-fractal-terrain
height basin 0 0 30 30 0 3 1 -0.12 7 basin
ifs crater 3 2 -5 3 6 2.5 0.48 2.6 0.42 4 0.85 -0.10 19 crater
ifs ridge 2 3 6 -4 5 1.35 0.45 3.2 -0.27 3.6 0.72 0.075 31 ridge
""";
private const string PatchRelativePath = "Worlds/zyphos-first-fractal-terrain.aquageo";
private static readonly Lazy<FractalOwnershipTree> Tree = new(() => FractalDslCompiler.Compile(Grammar));
private static readonly Lazy<string> PatchSource = new(() => File.ReadAllText(PatchPath));
private static readonly Lazy<FractalOwnershipTree> Tree = new(() => FractalDslCompiler.Compile(PatchSource.Value));
private static readonly Lazy<AquariumFractalSummary[]> Summaries = new(() => FractalSummaryBuilder.Build(Tree.Value));
private static readonly Lazy<AquariumSelectedCut[]> SelectedCut = new(() => FractalSelectedCutBuilder.Build(Summaries.Value, _ => 8.0f, maxEstimatedCost: 8.0f));
private static readonly Lazy<AquariumHeightFieldBrush[]> Brushes = new(() => FractalHeightBrushCompiler.CompileMany(Tree.Value.Claims));
public static string PatchPath => Path.Combine(AppContext.BaseDirectory, PatchRelativePath);
public static FractalOwnershipTree OwnershipTree => Tree.Value;
public static AquariumHeightFieldBrush[] HeightBrushes => Brushes.Value;
@ -29,5 +26,5 @@ public static class ZyphosFractalTerrain
public static string DebugDump => FractalDebugDump.Build(OwnershipTree, Summaries.Value, SelectedCut.Value);
public static string Summary =>
$"{OwnershipTree.Claims.Count} DSL claims / {OwnershipTree.Nodes.Count} node / {SelectedCut.Value.Length} cuts / {HeightBrushes.Length} shaped brushes";
$"{Path.GetFileName(PatchPath)} / {OwnershipTree.Claims.Count} DSL claims / {OwnershipTree.Nodes.Count} node / {SelectedCut.Value.Length} cuts / {HeightBrushes.Length} shaped brushes";
}