Make editor scene view a compositor preview
This commit is contained in:
parent
5e9a783d36
commit
66cd8e81c0
5 changed files with 162 additions and 9 deletions
|
|
@ -312,12 +312,17 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!presentationControls.IncludesVideo(window.StreamId))
|
||||
if (!presentationControls.IncludesVideo(window.StreamId) ||
|
||||
!sceneEditor.IncludesVideoSource(window.StreamId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
intents.Add(BuildSurfaceIntent(window, observation, presentationControls.VideoOpacity(window.StreamId)));
|
||||
intents.Add(BuildSurfaceIntent(
|
||||
window,
|
||||
observation,
|
||||
presentationControls.VideoOpacity(window.StreamId),
|
||||
sceneEditor.PlacementForSource(window.StreamId)));
|
||||
}
|
||||
|
||||
var frame = fieldLowering.BuildFieldEvidenceFrame(windows, observations, constraints, intents);
|
||||
|
|
@ -343,7 +348,11 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
|
|||
}
|
||||
}
|
||||
|
||||
private static MimirSurfaceIntent BuildSurfaceIntent(MimirRollingStreamWindow window, MimirObservation observation, float opacity = 1.0f)
|
||||
private static MimirSurfaceIntent BuildSurfaceIntent(
|
||||
MimirRollingStreamWindow window,
|
||||
MimirObservation observation,
|
||||
float opacity = 1.0f,
|
||||
MimirCompositorPlacement? placement = null)
|
||||
{
|
||||
if (window.SourceKind == MimirStreamKind.Audio)
|
||||
{
|
||||
|
|
@ -366,7 +375,10 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
|
|||
SupportPolicy: new MimirSurfaceSupportPolicy("program-composite", 0.0, window.Duration.TotalSeconds),
|
||||
MaterialGraph: new MimirSurfaceMaterialIntent("program-video", "source-evidence", Math.Clamp(opacity, 0.0f, 1.0f)),
|
||||
UpdateBudget: new MimirSurfaceUpdateBudget(0.0, 1, Math.Max(0, window.Payload.ByteLength)),
|
||||
Purpose: MimirSurfaceIntentPurpose.Production);
|
||||
Purpose: MimirSurfaceIntentPurpose.Production)
|
||||
{
|
||||
Placement = placement,
|
||||
};
|
||||
}
|
||||
|
||||
private AquariumFieldEvidenceFrame AddLeapGeometryFieldEvidence(
|
||||
|
|
@ -893,6 +905,7 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
|
|||
scene.Text("scene.view-program", DescribeProgramVideo, "mono");
|
||||
scene.Text("scene.view-sync", () => $"{synchronization.Summary()} | {synchronization.SourceCount} sources | poll {lastPollCount} | ingested {synchronization.IngestedSamples}", "caption");
|
||||
scene.Text("scene.view-audio", () => $"{DescribeAudioSyncState()} | aligned {DescribeAlignedAudio()}", "caption");
|
||||
scene.Preview("scene.view-preview", "Program Preview", () => sceneEditor.PreviewItems, weight: 1.8f);
|
||||
scene.Card("scene.view-frame", frame =>
|
||||
{
|
||||
frame.Text("scene.view-frame-title", "Program Surface", "strong");
|
||||
|
|
@ -940,6 +953,11 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
|
|||
inspector.Slider("transform.rotation", "Rotation", () => sceneEditor.SelectedNode?.Transform.RotationRadians ?? 0.0f, sceneEditor.SetSelectedRotation, -MathF.PI, MathF.PI, "0.00");
|
||||
inspector.Slider("transform.scale-x", "Scale X", () => sceneEditor.SelectedNode?.Transform.Scale.X ?? 1.0f, sceneEditor.SetSelectedScaleX, 0.05f, 8.0f, "0.00");
|
||||
inspector.Slider("transform.scale-y", "Scale Y", () => sceneEditor.SelectedNode?.Transform.Scale.Y ?? 1.0f, sceneEditor.SetSelectedScaleY, 0.05f, 8.0f, "0.00");
|
||||
inspector.Text("inspector.program-placement", "Program Frame", "strong");
|
||||
inspector.Slider("program.x", "X", () => sceneEditor.SelectedProgramX, sceneEditor.SetSelectedProgramX, 0.0f, 1.0f, "0.000");
|
||||
inspector.Slider("program.y", "Y", () => sceneEditor.SelectedProgramY, sceneEditor.SetSelectedProgramY, 0.0f, 1.0f, "0.000");
|
||||
inspector.Slider("program.w", "W", () => sceneEditor.SelectedProgramWidth, sceneEditor.SetSelectedProgramWidth, 0.01f, 1.0f, "0.000");
|
||||
inspector.Slider("program.h", "H", () => sceneEditor.SelectedProgramHeight, sceneEditor.SetSelectedProgramHeight, 0.01f, 1.0f, "0.000");
|
||||
inspector.Row("transform.reset", reset =>
|
||||
{
|
||||
reset.Button("transform.reset-node", "Reset Transform", sceneEditor.ResetSelectedTransform);
|
||||
|
|
|
|||
|
|
@ -243,6 +243,14 @@ public readonly record struct MimirSurfaceMaterialIntent(
|
|||
string Role,
|
||||
double Confidence);
|
||||
|
||||
public readonly record struct MimirCompositorPlacement(
|
||||
float CenterX,
|
||||
float CenterY,
|
||||
float Width,
|
||||
float Height,
|
||||
float RotationRadians,
|
||||
int Layer);
|
||||
|
||||
public readonly record struct MimirSurfaceUpdateBudget(
|
||||
double MaximumUpdateHz,
|
||||
int MaximumObservations,
|
||||
|
|
@ -256,7 +264,10 @@ public sealed record MimirSurfaceIntent(
|
|||
MimirSurfaceSupportPolicy SupportPolicy,
|
||||
MimirSurfaceMaterialIntent MaterialGraph,
|
||||
MimirSurfaceUpdateBudget UpdateBudget,
|
||||
MimirSurfaceIntentPurpose Purpose);
|
||||
MimirSurfaceIntentPurpose Purpose)
|
||||
{
|
||||
public MimirCompositorPlacement? Placement { get; init; }
|
||||
}
|
||||
|
||||
public static class MimirFensalirBridgeMapper
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1253,12 +1253,28 @@ public sealed class MimirFensalirFieldLowering(MimirFensalirLoweringOptions? opt
|
|||
private AquariumFieldSupport SupportForSurfaceIntent(MimirSurfaceIntent intent)
|
||||
{
|
||||
var age = Math.Max(0.0f, (float)intent.SupportPolicy.MaximumAgeSeconds);
|
||||
var radius = Math.Max(options.DefaultSupportRadius, age);
|
||||
if (intent.Placement is { } placement)
|
||||
{
|
||||
var radius = new Vector3(
|
||||
Math.Max(options.DefaultSupportRadius, placement.Width * 0.5f),
|
||||
Math.Max(options.DefaultSupportRadius, placement.Height * 0.5f),
|
||||
Math.Max(options.DefaultSupportRadius, age));
|
||||
return new AquariumFieldSupport(
|
||||
Center: new Vector3(placement.CenterX, placement.CenterY, 0.0f),
|
||||
Radius: radius,
|
||||
LocalFrame: Matrix4x4.CreateRotationZ(placement.RotationRadians),
|
||||
ConservativeRadius: Math.Max(radius.X, Math.Max(radius.Y, radius.Z)),
|
||||
ProjectedError: 0.0f,
|
||||
Curvature: 0.0f,
|
||||
TemporalUncertainty: age);
|
||||
}
|
||||
|
||||
var fallbackRadius = Math.Max(options.DefaultSupportRadius, age);
|
||||
return new AquariumFieldSupport(
|
||||
Center: Vector3.Zero,
|
||||
Radius: new Vector3(options.DefaultSupportRadius, options.DefaultSupportRadius, radius),
|
||||
Radius: new Vector3(options.DefaultSupportRadius, options.DefaultSupportRadius, fallbackRadius),
|
||||
LocalFrame: Matrix4x4.Identity,
|
||||
ConservativeRadius: radius,
|
||||
ConservativeRadius: fallbackRadius,
|
||||
ProjectedError: 0.0f,
|
||||
Curvature: 0.0f,
|
||||
TemporalUncertainty: age);
|
||||
|
|
|
|||
|
|
@ -2,11 +2,14 @@ using System.Numerics;
|
|||
using Aquarium.Engine;
|
||||
using Aquarium.Engine.Input;
|
||||
using Aquarium.Engine.Render;
|
||||
using Aquarium.Engine.Ui;
|
||||
|
||||
namespace Mimir.Runtime.Synchronization;
|
||||
|
||||
public sealed class MimirSceneEditorState
|
||||
{
|
||||
private const float ProgramWorldWidth = 12.8f;
|
||||
private const float ProgramWorldHeight = 7.2f;
|
||||
private readonly List<MimirSceneEditorNode> nodes = [];
|
||||
private readonly Dictionary<string, bool> expandedGroups = new(StringComparer.Ordinal)
|
||||
{
|
||||
|
|
@ -66,6 +69,25 @@ public sealed class MimirSceneEditorState
|
|||
public IReadOnlyList<MimirSceneEditorNode> VisibleNodes =>
|
||||
nodes.Where(node => node.Visible).ToArray();
|
||||
|
||||
public IReadOnlyList<AquariumUiPreviewItem> PreviewItems =>
|
||||
nodes
|
||||
.Where(static node => node.Visible && node.Kind != MimirSceneEditorNodeKind.Camera)
|
||||
.OrderBy(static node => node.Layer)
|
||||
.Select(node =>
|
||||
{
|
||||
var placement = PlacementForNode(node);
|
||||
return new AquariumUiPreviewItem(
|
||||
node.Id,
|
||||
node.DisplayName,
|
||||
placement.CenterX - placement.Width * 0.5f,
|
||||
placement.CenterY - placement.Height * 0.5f,
|
||||
placement.Width,
|
||||
placement.Height,
|
||||
string.Equals(node.Id, SelectedNodeId, StringComparison.Ordinal),
|
||||
node.Kind == MimirSceneEditorNodeKind.SensorFeedPanel ? "cool" : node.Kind == MimirSceneEditorNodeKind.SdfTextPanel ? "warm" : "neutral");
|
||||
})
|
||||
.ToArray();
|
||||
|
||||
public Vector3 CameraPosition => nodes
|
||||
.First(node => node.Kind == MimirSceneEditorNodeKind.Camera)
|
||||
.Transform.Position;
|
||||
|
|
@ -102,6 +124,7 @@ public sealed class MimirSceneEditorState
|
|||
0.0f,
|
||||
new Vector2(2.8f, 1.6f)))
|
||||
{
|
||||
Layer = index,
|
||||
SourceId = buffer.Descriptor.SourceId,
|
||||
});
|
||||
}
|
||||
|
|
@ -243,6 +266,52 @@ public sealed class MimirSceneEditorState
|
|||
}
|
||||
}
|
||||
|
||||
public float SelectedProgramX => SelectedNode is { } selected ? PlacementForNode(selected).CenterX : 0.5f;
|
||||
|
||||
public float SelectedProgramY => SelectedNode is { } selected ? PlacementForNode(selected).CenterY : 0.5f;
|
||||
|
||||
public float SelectedProgramWidth => SelectedNode is { } selected ? PlacementForNode(selected).Width : 0.1f;
|
||||
|
||||
public float SelectedProgramHeight => SelectedNode is { } selected ? PlacementForNode(selected).Height : 0.1f;
|
||||
|
||||
public void SetSelectedProgramX(float value)
|
||||
{
|
||||
if (SelectedNode is { } selected)
|
||||
{
|
||||
SetNodeProgramPlacement(selected, PlacementForNode(selected) with { CenterX = value });
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSelectedProgramY(float value)
|
||||
{
|
||||
if (SelectedNode is { } selected)
|
||||
{
|
||||
SetNodeProgramPlacement(selected, PlacementForNode(selected) with { CenterY = value });
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSelectedProgramWidth(float value)
|
||||
{
|
||||
if (SelectedNode is { } selected)
|
||||
{
|
||||
SetNodeProgramPlacement(selected, PlacementForNode(selected) with { Width = value });
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSelectedProgramHeight(float value)
|
||||
{
|
||||
if (SelectedNode is { } selected)
|
||||
{
|
||||
SetNodeProgramPlacement(selected, PlacementForNode(selected) with { Height = value });
|
||||
}
|
||||
}
|
||||
|
||||
public bool IncludesVideoSource(string sourceId) =>
|
||||
NodeForSource(sourceId) is not { } node || node.Visible;
|
||||
|
||||
public MimirCompositorPlacement? PlacementForSource(string sourceId) =>
|
||||
NodeForSource(sourceId) is { } node ? PlacementForNode(node) : null;
|
||||
|
||||
public void ResetSelectedTransform()
|
||||
{
|
||||
if (SelectedNode is { } selected && !selected.Locked)
|
||||
|
|
@ -431,7 +500,7 @@ public sealed class MimirSceneEditorState
|
|||
|
||||
private void ApplyScreenDelta(MimirSceneEditorNode selected, Vector2 screenDelta, float deltaSeconds)
|
||||
{
|
||||
var worldDelta = new Vector2(screenDelta.X, -screenDelta.Y) * 0.012f;
|
||||
var worldDelta = new Vector2(screenDelta.X, -screenDelta.Y) * (ProgramWorldWidth / 960.0f);
|
||||
switch (GizmoMode)
|
||||
{
|
||||
case MimirSceneEditorGizmoMode.Translate:
|
||||
|
|
@ -534,6 +603,42 @@ public sealed class MimirSceneEditorState
|
|||
|
||||
private static string FeedNodeId(string sourceId) =>
|
||||
$"feed:{sourceId}";
|
||||
|
||||
private MimirSceneEditorNode? NodeForSource(string sourceId) =>
|
||||
nodes.FirstOrDefault(node =>
|
||||
node.Kind == MimirSceneEditorNodeKind.SensorFeedPanel &&
|
||||
string.Equals(node.SourceId, sourceId, StringComparison.Ordinal));
|
||||
|
||||
private static MimirCompositorPlacement PlacementForNode(MimirSceneEditorNode node)
|
||||
{
|
||||
var transform = node.Transform;
|
||||
return new MimirCompositorPlacement(
|
||||
CenterX: Math.Clamp(0.5f + transform.Position.X / ProgramWorldWidth, 0.0f, 1.0f),
|
||||
CenterY: Math.Clamp(0.5f - transform.Position.Y / ProgramWorldHeight, 0.0f, 1.0f),
|
||||
Width: Math.Clamp(transform.Scale.X / ProgramWorldWidth, 0.01f, 1.0f),
|
||||
Height: Math.Clamp(transform.Scale.Y / ProgramWorldHeight, 0.01f, 1.0f),
|
||||
RotationRadians: transform.RotationRadians,
|
||||
Layer: node.Layer);
|
||||
}
|
||||
|
||||
private static void SetNodeProgramPlacement(MimirSceneEditorNode node, MimirCompositorPlacement placement)
|
||||
{
|
||||
if (node.Locked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var centerX = Math.Clamp(placement.CenterX, 0.0f, 1.0f);
|
||||
var centerY = Math.Clamp(placement.CenterY, 0.0f, 1.0f);
|
||||
var width = Math.Clamp(placement.Width, 0.01f, 1.0f);
|
||||
var height = Math.Clamp(placement.Height, 0.01f, 1.0f);
|
||||
node.Transform = node.Transform with
|
||||
{
|
||||
Position = new Vector3((centerX - 0.5f) * ProgramWorldWidth, (0.5f - centerY) * ProgramWorldHeight, node.Transform.Position.Z),
|
||||
Scale = new Vector2(width * ProgramWorldWidth, height * ProgramWorldHeight),
|
||||
RotationRadians = placement.RotationRadians,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class MimirSceneEditorNode(
|
||||
|
|
@ -559,6 +664,8 @@ public sealed class MimirSceneEditorNode(
|
|||
|
||||
public bool Locked { get; set; }
|
||||
|
||||
public int Layer { get; set; }
|
||||
|
||||
public string SourceId { get; init; } = "";
|
||||
|
||||
public string Text { get; set; } = "";
|
||||
|
|
|
|||
|
|
@ -283,3 +283,4 @@
|
|||
{"ts": "2026-05-31T21:48:00+01:00", "type": "verification", "status": "ok", "note": "Nightwing now has two wireless PS Moves connected and trusted: 00:07:04:a6:be:5f appears as bluetooth /dev/hidraw2 plus /dev/input/js1, and 00:06:f5:23:e2:d1 appears as bluetooth /dev/hidraw3 plus /dev/input/js2. A third cabled Move remains visible separately as usb /dev/hidraw1 plus /dev/input/js0. Bluetooth hidraw nodes are root-only on this boot, so multi-Move LED actuation needs a udev permission rule or privileged helper before non-root scripts can drive both lights."}
|
||||
{"ts": "2026-05-31T21:58:29+01:00", "type": "implementation", "status": "ok", "note": "Added tools/music_keyed_move_chirp_sync.py as the first music-keyed audiovisual calibration word planner. It reuses the Perlines-style whitened broadband spectral-rise onset path, autocorrelates onset for tempo, estimates a lightweight root from recent fundamentals, quantizes chirps to a minor-pentatonic scale, and schedules unique per-Move color pulses from one shared JSON receipt. Synthetic dry-run produced 120 BPM/A with high confidence; live Scarlett dry-run produced a slower 92.31 BPM grid, and Dirtyphonics double-time mode with --tempo-grid doubletime --tempo-max-bpm 260 produced a 171.43 BPM grid. Non-dry multi-Move actuation still needs hidraw permission/root-helper work for bluetooth /dev/hidraw2 and /dev/hidraw3."}
|
||||
{"ts":"2026-05-31T21:48:00+01:00","type":"implementation","status":"ok","note":"Mimir's Eve/CultUI editor surface now uses editor anatomy instead of dashboard columns: Scene Graph left, Scene View center, thin Asset Browser below the view, and Inspector right. The old Program/Sync rail was removed from the inspector side so telemetry no longer steals editor hierarchy. Headless empty-runtime capture verified the shell at 1280x720 with no sibling overlap.","files":["src/Mimir.Runtime/MimirRuntime.cs"],"source":"dotnet build src/Mimir.App/Mimir.App.csproj --no-restore; Mimir.App --headless --headless-width 1280 --headless-height 720 --capture-frame artifacts/runtime/mimir-editor-shell-final-headless.png"}
|
||||
{"ts":"2026-05-31T22:06:00+01:00","type":"implementation","status":"ok","note":"Mimir's editor scene view now behaves as a compositor/program preview rather than a dashboard readout: SceneEditorState owns normalized program-frame placement for visible nodes, the CultUI preview renders those rectangles, inspector X/Y/W/H controls mutate the same node transforms as mouse-drag input, and video surface intents carry that placement into Fensalir field support. This makes outgoing element arrangement an editor-owned state path instead of a presentationControls-only opacity/layer list.","files":["src/Mimir.Runtime/MimirRuntime.cs","src/Mimir.Runtime/Synchronization/MimirSceneEditorState.cs","src/Mimir.Runtime/Synchronization/MimirFensalirBridgeContracts.cs","src/Mimir.Runtime/Synchronization/MimirFensalirFieldLowering.cs"],"source":"dotnet build src/Mimir.App/Mimir.App.csproj --no-restore; Mimir.App --headless --headless-width 1280 --headless-height 720 --capture-frame artifacts/runtime/mimir-editor-compositor-preview-headless.png"}
|
||||
|
|
|
|||
Loading…
Reference in a new issue