Summarize fractal brush nodes

This commit is contained in:
Meta Vens 2026-05-18 02:39:18 +01:00
commit f014b91ce7
4 changed files with 98 additions and 4 deletions

View file

@ -243,10 +243,10 @@ Goal: make every LOD subtree renderable without its children.
Tasks:
- [ ] Add summary builder for 2D brush tree nodes.
- [ ] Track max height/form error.
- [ ] Track max material delta placeholder.
- [ ] Track coverage and estimated cost.
- [x] Add summary builder for 2D brush tree nodes.
- [x] Track max height/form error.
- [x] Track max material delta placeholder.
- [x] Track coverage and estimated cost.
- [ ] Add parent fallback payload.
- [ ] Add summary serialization.
- [ ] Add debug overlay for summary bounds/error.

View file

@ -0,0 +1,39 @@
using Aquarium.Engine.Fractal;
namespace Aquarium.Engine.Fractal.Grammar;
public static class FractalSummaryBuilder
{
public static AquariumFractalSummary[] Build(FractalOwnershipTree tree)
{
ArgumentNullException.ThrowIfNull(tree);
var summaries = new AquariumFractalSummary[tree.Nodes.Count];
for (var nodeIndex = 0; nodeIndex < tree.Nodes.Count; nodeIndex++)
{
var node = tree.Nodes[nodeIndex];
var maxHeightError = 0.0f;
var estimatedCost = 0.0f;
for (var claimIndex = node.FirstClaimIndex; claimIndex < node.FirstClaimIndex + node.ClaimCount; claimIndex++)
{
var claim = tree.Claims[claimIndex];
if (claim.PayloadKind == AquariumFractalPayloadKind.Height)
{
maxHeightError += MathF.Abs(claim.Amplitude);
}
estimatedCost += 1.0f;
}
summaries[nodeIndex] = new AquariumFractalSummary(
node.Key,
node.BoundsMinMax,
maxHeightError,
MaxMaterialDelta: 0.0f,
estimatedCost,
DescendantCount: node.ChildCount + node.ClaimCount);
}
return summaries;
}
}

View file

@ -123,3 +123,4 @@
{"timestamp":"2026-05-18T03:55:00+01:00","topic":"fractal-semantic-contracts-first-slice","lesson":"The fractal system now has portable semantic rows before backend lowering: stable keys, domains, brush claims, operation nodes, summaries, contribution state, and selected-cut rows live in contracts, while the pure fractal core owns deterministic cube-tile grammar keys and a flat-union ownership tree builder. This is deliberately not a full CSG kernel yet; it is the first authority boundary that keeps authored claims visible before renderer packets flatten them.","files":["src/Aquarium.Engine.Contracts/Fractal/AquariumFractalContracts.cs","src/Aquarium.Engine.Fractal/Grammar/FractalStableKeyBuilder.cs","src/Aquarium.Engine.Fractal/Grammar/FractalOwnershipTreeBuilder.cs","tests/Aquarium.Engine.Fractal.Tests/FractalGrammarContractTests.cs"],"source":"fourth fractal implementation slice established semantic claim and ownership-tree contract rows"}
{"timestamp":"2026-05-18T02:36:48+01:00","topic":"face-realtime-voice-first-slice","lesson":"Aquarium's first Face voice slice keeps ownership narrow: the engine owns a generic queued PCM playback lane, while Epiphany owns a native Face realtime session controller and persists only loopback URI, thread id, voice, and prompt in CultCache live state. The current transport is explicitly a Codex app-server WebSocket JSON-RPC compatibility edge for text input and streamed audio output, not full microphone/WebRTC capture yet. Speech remains an ephemeral Face surface and must not mutate durable memory, evidence, project state, or code authority automatically.","files":["src/Aquarium.Engine.Contracts/Audio/AquariumAudio.cs","src/Aquarium.Engine.Contracts/AquariumRuntimeContracts.cs","src/Aquarium.Engine/Audio/AquariumSynthHost.cs","src/Aquarium.Epiphany/Voice/RealtimeFaceVoiceSession.cs","src/Aquarium.Epiphany/AquariumRuntime.cs","src/Aquarium.Epiphany/State/AquariumLiveState.cs","state/map.yaml"],"source":"user asked to start Aquarium-Engine work on Codex realtime voice for talking to Faces inside Aquarium"}
{"timestamp":"2026-05-18T04:07:00+01:00","topic":"fractal-height-claim-lowering","lesson":"Semantic height claims now lower into the live shaped height-field brush contract through `FractalHeightBrushCompiler`. This keeps the current renderer path useful without making the renderer own grammar semantics: claims remain authored meaning, height brushes remain backend output, and non-height payloads fail fast instead of sneaking through a height-only adapter.","files":["src/Aquarium.Engine.Fractal/Brushes/FractalHeightBrushCompiler.cs","tests/Aquarium.Engine.Fractal.Tests/FractalHeightBrushCompilerTests.cs","research/rendering/fractal-brush-implementation-roadmap.md"],"source":"fifth fractal implementation slice added the first semantic-claim-to-renderer-packet lowering path"}
{"timestamp":"2026-05-18T04:22:00+01:00","topic":"fractal-node-summary-first-slice","lesson":"Flat semantic ownership trees now produce conservative node summaries. The first summary builder carries node bounds, sum-of-absolute height amplitude as max height error, a material-delta placeholder, estimated claim cost, and descendant count. This is intentionally conservative rather than clever, giving future LOD/cache work a renderable parent fallback before child refinement or eviction exists.","files":["src/Aquarium.Engine.Fractal/Grammar/FractalSummaryBuilder.cs","tests/Aquarium.Engine.Fractal.Tests/FractalSummaryBuilderTests.cs","research/rendering/fractal-brush-implementation-roadmap.md"],"source":"sixth fractal implementation slice established parent summary rows for semantic brush trees"}

View file

@ -0,0 +1,54 @@
using System.Numerics;
using Aquarium.Engine.Fractal;
using Aquarium.Engine.Fractal.Grammar;
namespace Aquarium.Engine.Fractal.Tests;
public sealed class FractalSummaryBuilderTests
{
[Fact]
public void SummaryConservativelyCoversFlatHeightClaims()
{
var domainKey = new AquariumFractalKey("domain/tile");
var rootKey = new AquariumFractalKey("domain/tile/root");
var domain = new AquariumFractalDomain(domainKey, AquariumFractalDomainKind.CubeSphereTile, default, Vector4.Zero, Vector4.Zero);
var claims = new[]
{
Claim("claim/a", domainKey, rootKey, Vector2.Zero, Vector2.One, 0.5f),
Claim("claim/b", domainKey, rootKey, new Vector2(3.0f, 0.0f), new Vector2(2.0f, 1.0f), -1.25f),
};
var tree = FractalOwnershipTreeBuilder.BuildFlatUnion(domain, rootKey, claims);
var summaries = FractalSummaryBuilder.Build(tree);
Assert.Single(summaries);
Assert.Equal(rootKey, summaries[0].NodeKey);
Assert.Equal(new Vector4(-1.0f, -2.0f, 5.0f, 2.0f), summaries[0].BoundsMinMax);
Assert.Equal(1.75f, summaries[0].MaxHeightError);
Assert.Equal(2.0f, summaries[0].EstimatedCost);
Assert.Equal(2, summaries[0].DescendantCount);
}
private static AquariumBrushClaim Claim(
string key,
AquariumFractalKey domainKey,
AquariumFractalKey nodeKey,
Vector2 center,
Vector2 radii,
float amplitude)
{
return new AquariumBrushClaim(
new AquariumFractalKey(key),
domainKey,
nodeKey,
AquariumFractalPayloadKind.Height,
center,
radii,
RotationRadians: 0.0f,
Falloff: 3.0f,
ShapePower: 1.0f,
Amplitude: amplitude,
Seed: 0,
Tags: "summary");
}
}