From 0bf28b48df75f4ed8d63e5843ab98278b0603e14 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 12 Jul 2026 11:55:01 +0100 Subject: [PATCH] Publish Aetheria worlds through Eve entity SoA --- Aetheria.State.Daemon/Program.cs | 6 ++ Aetheria.Unity/Packages/manifest.json | 4 +- .../Tests/DaemonRuntimeDocumentTests.cs | 33 ++++++++ Packages/manifest.json | 4 +- ...AetheriaRuntimeDaemonGameSurfaceBuilder.cs | 38 +++------ .../AetheriaRuntimeEveEntitySoaProjection.cs | 77 +++++++++++++++++++ ...heriaRuntimeEveEntitySoaProjection.cs.meta | 2 + .../Runtime/AetheriaRuntimeVerseClient.cs | 7 ++ Packages/packages-lock.json | 11 +-- 9 files changed, 146 insertions(+), 36 deletions(-) create mode 100644 Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeEveEntitySoaProjection.cs create mode 100644 Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeEveEntitySoaProjection.cs.meta diff --git a/Aetheria.State.Daemon/Program.cs b/Aetheria.State.Daemon/Program.cs index 595ff85bf..5642727a6 100644 --- a/Aetheria.State.Daemon/Program.cs +++ b/Aetheria.State.Daemon/Program.cs @@ -1338,12 +1338,18 @@ static async Task PublishDaemonApiDocumentsAsync( await node.MutableDocument(AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest) .ReplaceAsync(result.Frame) .ConfigureAwait(false); + await node.MutableDocument(AetheriaRuntimeVerseRecordKeys.ZoneRenderLatest) + .ReplaceAsync(AetheriaRuntimeGameDocuments.ZoneRender(result.Frame)) + .ConfigureAwait(false); if (result.SoaView != null && string.Equals(result.SoaView.Schema, AetheriaRuntimeDaemonSchemas.SoaView, StringComparison.Ordinal)) { await node.MutableDocument(AetheriaRuntimeVerseRecordKeys.DaemonSoaViewLatest) .ReplaceAsync(result.SoaView) .ConfigureAwait(false); + await node.MutableDocument(AetheriaRuntimeVerseRecordKeys.EveEntitySoaViewLatest) + .ReplaceAsync(AetheriaRuntimeEveEntitySoaProjection.Project(result.SoaView)) + .ConfigureAwait(false); } if (result.ProviderAdvertisement != null) diff --git a/Aetheria.Unity/Packages/manifest.json b/Aetheria.Unity/Packages/manifest.json index 1695784d8..d3e25bca9 100644 --- a/Aetheria.Unity/Packages/manifest.json +++ b/Aetheria.Unity/Packages/manifest.json @@ -8,7 +8,7 @@ "com.unity.render-pipelines.universal": "17.4.0", "org.gamecult.cultlib": "https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-source-v1.0.3-r2", "org.gamecult.eve.plugin-fields": "https://github.com/GameCult/EvePlugins.git?path=/plugins/eve-plugin-fields/unity/org.gamecult.eve.plugin-fields#eve-plugin-fields-unity-v0.1.1", - "org.gamecult.eve.surface": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#eveunity-surface-v0.1.0", - "org.gamecult.eve.unity-scene": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#ebed4096de399bcd82c3b5d5b93482ed1142f2cc" + "org.gamecult.eve.surface": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#413989371efe0180789603076711ea0ba8925dc5", + "org.gamecult.eve.unity-scene": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#413989371efe0180789603076711ea0ba8925dc5" } } diff --git a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs index 60672a60a..c248526fb 100644 --- a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs +++ b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs @@ -11,6 +11,7 @@ using System.IO.MemoryMappedFiles; using System.Linq; using UnityEngine; using EveCommandTemplate = GameCult.Eve.Surface.EveCommandTemplate; +using EveEntitySoaViewDocument = GameCult.Eve.Surface.EveEntitySoaViewDocument; using EveStyleToken = GameCult.Eve.Surface.EveStyleToken; using EveSurfaceCommandRequest = GameCult.Eve.Surface.EveSurfaceCommandRequest; using EveSurfaceComponent = GameCult.Eve.Surface.EveSurfaceComponent; @@ -484,6 +485,32 @@ public class DaemonRuntimeDocumentTests Assert.AreEqual(0, tracker.Reconcile(new[] { fact }, 11).Count); } + [Test] + public void EveWorldSurfacePointsToPortableEntitySoaInsteadOfEmbeddingEntities() + { + var run = RunWithTwoEntities(); + var frame = AetheriaRuntimeDaemonFrameDocument.Create( + run, "test-daemon", "session", 42, 1.0, 0.02); + var surface = AetheriaRuntimeDaemonGameSurfaceBuilder.Build( + frame, + new AetheriaRuntimeDaemonHealthDocument(), + AetheriaRuntimeDaemonCommandBoundaryDocument.Create("test-daemon")); + var source = AetheriaRuntimeDaemonSoaViewDocument.Create( + "test-daemon", "session", 42, 42, + new[] { new AetheriaRuntimeDaemonSoaBufferDocument { BufferId = "hot", Location = "mmf:test" } }, + new[] { new AetheriaRuntimeDaemonSoaColumnDocument { ColumnId = "position", Kind = AetheriaRuntimeDaemonSoaColumnKinds.Position, BufferId = "hot", ScalarType = "float32", ElementStride = 12, ElementCount = 2 } }); + var portable = AetheriaRuntimeEveEntitySoaProjection.Project(source); + + Assert.IsTrue(ContainsSurfaceProp(surface.Surface.Root, "entityViewPointerId", + AetheriaRuntimeVerseRecordKeys.EveEntitySoaViewLatest.ToString())); + Assert.IsTrue(ContainsSurfaceProp(surface.Surface.Root, "entityViewSchema", + EveEntitySoaViewDocument.SchemaId)); + Assert.IsFalse(ContainsSurfaceKind(surface.Surface.Root, "world.entity3d")); + Assert.AreEqual(EveEntitySoaViewDocument.SchemaId, portable.Schema); + Assert.AreEqual(42, portable.Generation); + Assert.AreEqual(AetheriaRuntimeDaemonSoaColumnKinds.Position, portable.Columns.Single().Semantic); + } + [Test] public void TickRunnerAppliesObservedCommandsAndPublishesFrame() { @@ -5490,6 +5517,12 @@ public class DaemonRuntimeDocumentTests return component.Children.Any(child => ContainsSurfaceProp(child, key, value)); } + private static bool ContainsSurfaceKind(AetheriaRuntimeSurfaceComponent component, string kind) + { + return string.Equals(component.Kind, kind, StringComparison.Ordinal) || + component.Children.Any(child => ContainsSurfaceKind(child, kind)); + } + private static bool ContainsSurfaceStateBinding( AetheriaRuntimeSurfaceComponent component, string targetProp, diff --git a/Packages/manifest.json b/Packages/manifest.json index 176e06ab9..6d66eb722 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -22,9 +22,9 @@ "org.gamecult.aetheria.state": "file:org.gamecult.aetheria.state", "org.gamecult.cultmath": "file:../../CultMath", "org.gamecult.cultlib": "https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-source-v1.0.3-r2", - "org.gamecult.eve.surface": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#eveunity-surface-v0.1.0", + "org.gamecult.eve.surface": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#413989371efe0180789603076711ea0ba8925dc5", "org.gamecult.eve.plugin-fields": "https://github.com/GameCult/EvePlugins.git?path=/plugins/eve-plugin-fields/unity/org.gamecult.eve.plugin-fields#eve-plugin-fields-unity-v0.1.1", - "org.gamecult.eve.unity-scene": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.1.4", + "org.gamecult.eve.unity-scene": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#413989371efe0180789603076711ea0ba8925dc5", "org.gamecult.eve.unity-uitoolkit": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-uitoolkit#eveunity-uitoolkit-v0.1.0", "com.unity.modules.accessibility": "1.0.0", "com.unity.modules.adaptiveperformance": "1.0.0", diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs index ad079f0ec..0860ae824 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; +using GameCult.Eve.Surface; #nullable enable @@ -390,6 +391,10 @@ namespace GameCult.Aetheria.State.Verse { ["label"] = string.IsNullOrWhiteSpace(zone.Name) ? "Starbridge" : zone.Name, ["statePointerId"] = AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest.ToString(), + ["entityViewPointerId"] = AetheriaRuntimeVerseRecordKeys.EveEntitySoaViewLatest.ToString(), + ["entityViewSchema"] = EveEntitySoaViewDocument.SchemaId, + ["zoneRenderPointerId"] = AetheriaRuntimeVerseRecordKeys.ZoneRenderLatest.ToString(), + ["zoneRenderSchema"] = AetheriaRuntimeDaemonSchemas.ZoneRender, ["assetManifest"] = AetheriaRuntimeVerseRecordKeys.EveAssetCatalog.ToString(), ["inputCapability"] = AetheriaRuntimeVerseRecordKeys.PilotInputCapability.ToString(), ["inputProfile"] = "rts.pointer-keyboard.v1", @@ -397,20 +402,11 @@ namespace GameCult.Aetheria.State.Verse ["zoneIndex"] = zone.ZoneIndex.ToString(CultureInfo.InvariantCulture), ["runId"] = run.RunId ?? "" }; - var entities = (zone.Entities ?? Array.Empty()) - .Where(entity => entity != null && entity.IsActive) - .Select(entity => PlayableWorldEntity( - entity, - run, - zone, - run.CurrentEntityKey, - AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault)) - .ToArray(); return new AetheriaRuntimeSurfaceComponent( id, "world.scene2d", props, - entities, + Array.Empty(), AetheriaRuntimeSurfaceStateBindings.FromProps(props), Array.Empty(), Layout(("position", "absolute"), ("inset", "0"), ("width", "100%"), ("height", "100%")), @@ -575,6 +571,10 @@ namespace GameCult.Aetheria.State.Verse { ["label"] = string.IsNullOrWhiteSpace(zone.Name) ? "Aetheria World" : zone.Name, ["statePointerId"] = AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest.ToString(), + ["entityViewPointerId"] = AetheriaRuntimeVerseRecordKeys.EveEntitySoaViewLatest.ToString(), + ["entityViewSchema"] = EveEntitySoaViewDocument.SchemaId, + ["zoneRenderPointerId"] = AetheriaRuntimeVerseRecordKeys.ZoneRenderLatest.ToString(), + ["zoneRenderSchema"] = AetheriaRuntimeDaemonSchemas.ZoneRender, ["assetManifest"] = AetheriaRuntimeVerseRecordKeys.EveAssetCatalog.ToString(), ["inputProfile"] = "arpg.pointer-keyboard.v1", ["cameraRig"] = "arpg.orbital-follow.v1", @@ -591,27 +591,11 @@ namespace GameCult.Aetheria.State.Verse ["runId"] = run.RunId ?? "" }; - var entities = (zone.Entities ?? Array.Empty()) - .Where(candidate => candidate != null && candidate.IsActive) - .Select(candidate => PlayableWorldEntity( - candidate, - run, - zone, - currentEntityKey, - simulationSettings)) - .Concat((zone.PhysicalPayloads ?? Array.Empty()) - .Where(projectile => projectile != null && projectile.LifetimeSeconds > 0) - .Select(projectile => PlayableWorldProjectile(projectile, run, zone))) - .Concat((zone.DroppedPickups ?? Array.Empty()) - .Where(pickup => pickup != null && pickup.AgeSeconds < pickup.LifetimeSeconds) - .Select(pickup => PlayableWorldPickup(pickup, run, zone))) - .ToArray(); - return new AetheriaRuntimeSurfaceComponent( id, "world.scene3d", props, - entities, + Array.Empty(), AetheriaRuntimeSurfaceStateBindings.FromProps(props), Array.Empty(), Layout( diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeEveEntitySoaProjection.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeEveEntitySoaProjection.cs new file mode 100644 index 000000000..977881d5e --- /dev/null +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeEveEntitySoaProjection.cs @@ -0,0 +1,77 @@ +using System; +using System.Linq; +using GameCult.Eve.Surface; + +#nullable enable + +namespace GameCult.Aetheria.State.Verse +{ + public static class AetheriaRuntimeEveEntitySoaProjection + { + public static EveEntitySoaViewDocument Project(AetheriaRuntimeDaemonSoaViewDocument source) + { + if (source == null) throw new ArgumentNullException(nameof(source)); + return new EveEntitySoaViewDocument + { + ProviderId = "aetheria.daemon", + ViewId = "pilot", + FrameId = source.FrameId, + Generation = source.Generation, + PublishedAtUtc = source.PublishedAtUtc, + Backend = source.Backend, + SynchronizationMode = source.SynchronizationMode, + Buffers = (source.Buffers ?? Array.Empty()) + .Select(buffer => new EveEntitySoaBuffer + { + BufferId = buffer.BufferId, + Backend = buffer.Backend, + Location = buffer.Location, + ByteOffset = buffer.ByteOffset, + ByteLength = buffer.ByteLength, + Generation = buffer.Generation + }).ToArray(), + Columns = (source.Columns ?? Array.Empty()) + .Select(column => new EveEntitySoaColumn + { + ColumnId = column.ColumnId, + Semantic = column.Kind, + BufferId = column.BufferId, + ScalarType = column.ScalarType, + ByteOffset = column.ByteOffset, + ElementStride = column.ElementStride, + ElementCount = column.ElementCount, + Unit = column.Unit, + CoordinateSpace = column.CoordinateSpace + }).ToArray(), + DirtyRanges = (source.DirtyRanges ?? Array.Empty()) + .Select(range => new EveEntitySoaDirtyRange + { + ColumnId = range.ColumnId, + StartIndex = range.StartIndex, + Count = range.Count, + Generation = range.Generation + }).ToArray(), + RenderGroups = (source.RenderGroups ?? Array.Empty()) + .Select(group => new EveEntityRenderGroup + { + GroupId = group.GroupId, + MeshAssetRef = group.MeshAsset.Uri, + MaterialAssetRef = group.MaterialAsset.Uri, + SubMeshIndex = group.SubMeshIndex, + Layer = group.Layer, + InstanceCount = Math.Max(group.InstanceCount, 0), + DefaultScale = group.DefaultScale, + BoundsCenterX = group.BoundsCenterX, + BoundsCenterY = group.BoundsCenterY, + BoundsCenterZ = group.BoundsCenterZ, + BoundsSizeX = Math.Max(group.BoundsSizeX, 0), + BoundsSizeY = Math.Max(group.BoundsSizeY, 0), + BoundsSizeZ = Math.Max(group.BoundsSizeZ, 0), + ShadowMode = group.ShadowMode, + ReceiveShadows = group.ReceiveShadows, + Lod = group.Lod + }).ToArray() + }; + } + } +} diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeEveEntitySoaProjection.cs.meta b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeEveEntitySoaProjection.cs.meta new file mode 100644 index 000000000..fc3f63314 --- /dev/null +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeEveEntitySoaProjection.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 6a9f9d5385753c848b28b1add6461006 \ No newline at end of file diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs index c3d83091b..2343b6379 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs @@ -50,6 +50,12 @@ namespace GameCult.Aetheria.State.Verse public static CultRecordKey DaemonSoaViewLatest { get; } = new CultRecordKey("daemon:aetheria.soa_view.latest.v1"); + public static CultRecordKey EveEntitySoaViewLatest { get; } = + new CultRecordKey("eve:entity-view:aetheria.daemon.pilot"); + + public static CultRecordKey ZoneRenderLatest { get; } = + new CultRecordKey("daemon:aetheria.zone_render.latest.v1"); + public static CultRecordKey StarbridgeScenarioLatest { get; } = new CultRecordKey("starbridge:aetheria.scenario.latest.v1"); @@ -178,6 +184,7 @@ namespace GameCult.Aetheria.State.Verse typeof(EveSurfaceCommandRequest), typeof(EveCommandReceiptDocument), typeof(EveAssetCatalogDocument), + typeof(EveEntitySoaViewDocument), typeof(AetheriaRuntimeDaemonCommandDocument), typeof(AetheriaRuntimeEveCommandDocument), typeof(AetheriaRuntimeCommittedCommandFactDocument) diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index b1b0174cc..67082c705 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -331,24 +331,25 @@ "hash": "0b099274a4e2b4c301eced4322166837792f585a" }, "org.gamecult.eve.surface": { - "version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#eveunity-surface-v0.1.0", + "version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#413989371efe0180789603076711ea0ba8925dc5", "depth": 0, "source": "git", "dependencies": { "org.gamecult.cultlib": "1.0.3" }, - "hash": "e10821f1cc81f619479c6507438f6a097d1f0ce2" + "hash": "413989371efe0180789603076711ea0ba8925dc5" }, "org.gamecult.eve.unity-scene": { - "version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.1.4", + "version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#413989371efe0180789603076711ea0ba8925dc5", "depth": 0, "source": "git", "dependencies": { "org.gamecult.cultlib": "1.0.3", "org.gamecult.eve.plugin-fields": "0.1.1", - "org.gamecult.eve.surface": "0.1.0" + "org.gamecult.eve.surface": "0.1.0", + "com.unity.mathematics": "1.3.2" }, - "hash": "093eb80d6c2a6da216b9e6b3fb921494e427102c" + "hash": "413989371efe0180789603076711ea0ba8925dc5" }, "org.gamecult.eve.unity-uitoolkit": { "version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-uitoolkit#eveunity-uitoolkit-v0.1.0",