Publish managed viewports from exact demand
This commit is contained in:
parent
a385f3c43e
commit
fc2255099f
4 changed files with 129 additions and 15 deletions
|
|
@ -11,6 +11,7 @@ using System.Globalization;
|
|||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
var options = AetheriaDaemonHostOptions.Parse(args);
|
||||
var startedAtUtc = DateTimeOffset.UtcNow.ToString("O");
|
||||
|
|
@ -50,10 +51,13 @@ using var physicsPersistence = await AetheriaYmirPersistenceCoordinator.OpenAsyn
|
|||
latestFrame).ConfigureAwait(false);
|
||||
using var cultMeshRudpHost = StartClientCultMeshHost(node, options, () => latestFrame);
|
||||
using var clientSubscriptions = new CultNetDatabaseSubscriptionServer(cultMeshRudpHost, node.Database);
|
||||
var managedViewportDemand = new AetheriaManagedViewportDemandState();
|
||||
clientSubscriptions.DemandChanged += managedViewportDemand.Observe;
|
||||
if (traceClientRudp)
|
||||
clientSubscriptions.DemandChanged += demand => Console.WriteLine(
|
||||
$"CultMesh body demand consumer={demand.ConsumerRuntimeId} subscription={demand.SubscriptionId} " +
|
||||
$"CultMesh state demand consumer={demand.ConsumerRuntimeId} subscription={demand.SubscriptionId} " +
|
||||
$"active={demand.Active} sameMachine={demand.SameMachine} " +
|
||||
$"records=[{string.Join(",", demand.RecordKeys)}] schemas=[{string.Join(",", demand.SchemaIds)}] " +
|
||||
$"bodies=[{string.Join(",", demand.BodyIds)}] transports=[{string.Join(",", demand.SupportedBodyTransports)}]");
|
||||
using var bodyDemand = new CultMeshBodyDemandTracker(clientSubscriptions);
|
||||
using var soaPublisher = new AetheriaRuntimeDaemonSoaFramePublisher(
|
||||
|
|
@ -142,6 +146,7 @@ while (!stopped.Task.IsCompleted)
|
|||
publication,
|
||||
reactiveSurfaceState,
|
||||
publishTopology: false);
|
||||
await PublishDemandedManagedViewportsAsync(node, options, tick.Frame, managedViewportDemand).ConfigureAwait(false);
|
||||
nextApiPublicationUtc = DateTimeOffset.UtcNow.Add(options.ApiPublicationInterval);
|
||||
}
|
||||
if (tick.Frame.FrameId % (traceClientRudp ? 10 : 120) == 0)
|
||||
|
|
@ -1516,6 +1521,71 @@ static bool TryGetDouble(
|
|||
double.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out value);
|
||||
}
|
||||
|
||||
static async Task PublishDemandedManagedViewportsAsync(
|
||||
AetheriaStateNode node,
|
||||
AetheriaDaemonHostOptions options,
|
||||
AetheriaRuntimeDaemonFrameDocument frame,
|
||||
AetheriaManagedViewportDemandState demand)
|
||||
{
|
||||
foreach (var request in demand.Snapshot())
|
||||
{
|
||||
if (!TryGetGameViewportRequest(
|
||||
new CultNetSnapshotRequestMessage
|
||||
{
|
||||
RecordKeys = request.RecordKeys.ToArray(),
|
||||
SchemaIds = request.SchemaIds.ToArray()
|
||||
},
|
||||
out var recordKey,
|
||||
out var schemaId,
|
||||
out var viewport))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
CultNetDocumentPutRawMessage put;
|
||||
var messageId = $"aetheria-managed-viewport:{frame.FrameId}:{recordKey}";
|
||||
var messageOptions = new CultNetDocumentMessageOptions
|
||||
{
|
||||
SourceRuntimeId = options.DaemonId,
|
||||
SourceRole = "aetheria-daemon"
|
||||
};
|
||||
if (string.Equals(schemaId, AetheriaRuntimeDaemonSchemas.RenderSplatsViewport, StringComparison.Ordinal))
|
||||
{
|
||||
put = node.Database.Documents.CreateRawDocumentPutMessage(
|
||||
messageId,
|
||||
new CultRecordHandle<GameCult.Eve.PluginFields.EveFieldsSplatsDocument>(new CultRecordKey(recordKey)),
|
||||
AetheriaRuntimeGameDocuments.RenderSplatsViewport(frame, viewport),
|
||||
messageOptions);
|
||||
}
|
||||
else if (string.Equals(schemaId, AetheriaRuntimeDaemonSchemas.GravityViewport, StringComparison.Ordinal))
|
||||
{
|
||||
put = node.Database.Documents.CreateRawDocumentPutMessage(
|
||||
messageId,
|
||||
new CultRecordHandle<AetheriaRuntimeGravityViewportDocument>(new CultRecordKey(recordKey)),
|
||||
AetheriaRuntimeGameDocuments.GravityViewport(frame, viewport),
|
||||
messageOptions);
|
||||
}
|
||||
else if (string.Equals(schemaId, AetheriaRuntimeDaemonSchemas.ObjectsViewport, StringComparison.Ordinal))
|
||||
{
|
||||
put = node.Database.Documents.CreateRawDocumentPutMessage(
|
||||
messageId,
|
||||
new CultRecordHandle<AetheriaRuntimeObjectsViewportDocument>(new CultRecordKey(recordKey)),
|
||||
AetheriaRuntimeGameDocuments.ObjectsViewport(frame, viewport),
|
||||
messageOptions);
|
||||
}
|
||||
else
|
||||
{
|
||||
put = node.Database.Documents.CreateRawDocumentPutMessage(
|
||||
messageId,
|
||||
new CultRecordHandle<AetheriaRuntimeGameViewportDocument>(new CultRecordKey(recordKey)),
|
||||
AetheriaRuntimeGameDocuments.Viewport(frame, viewport),
|
||||
messageOptions);
|
||||
}
|
||||
|
||||
await node.Database.ApplyPutAsync(put).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
static async Task PublishHotEntityStateAsync(
|
||||
AetheriaStateNode node,
|
||||
AetheriaRuntimeDaemonSoaFramePublisher publisher,
|
||||
|
|
@ -3167,6 +3237,50 @@ internal sealed record AetheriaPreparedPublication(
|
|||
AetheriaRuntimeDaemonTickResult Publication,
|
||||
IReadOnlyList<AetheriaYmirZonePersistenceCapture> Physics);
|
||||
|
||||
internal sealed class AetheriaManagedViewportDemandState
|
||||
{
|
||||
private readonly ConcurrentDictionary<string, AetheriaManagedViewportDemand> _active =
|
||||
new(StringComparer.Ordinal);
|
||||
|
||||
public void Observe(CultNetDatabaseSubscriptionDemand demand)
|
||||
{
|
||||
var key = demand.ConsumerRuntimeId + "\u001f" + demand.SubscriptionId;
|
||||
if (!demand.Active)
|
||||
{
|
||||
_active.TryRemove(key, out _);
|
||||
return;
|
||||
}
|
||||
|
||||
if (demand.RecordKeys.Count == 0)
|
||||
return;
|
||||
_active[key] = new AetheriaManagedViewportDemand(
|
||||
demand.RecordKeys.ToArray(),
|
||||
demand.SchemaIds.ToArray());
|
||||
}
|
||||
|
||||
public IReadOnlyList<AetheriaManagedViewportDemand> Snapshot() =>
|
||||
_active.Values
|
||||
.GroupBy(
|
||||
demand => string.Join("\u001f", demand.RecordKeys) + "\u001e" + string.Join("\u001f", demand.SchemaIds),
|
||||
StringComparer.Ordinal)
|
||||
.Select(group => group.First())
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
internal sealed class AetheriaManagedViewportDemand
|
||||
{
|
||||
public AetheriaManagedViewportDemand(
|
||||
IReadOnlyList<string> recordKeys,
|
||||
IReadOnlyList<string> schemaIds)
|
||||
{
|
||||
RecordKeys = recordKeys;
|
||||
SchemaIds = schemaIds;
|
||||
}
|
||||
|
||||
public IReadOnlyList<string> RecordKeys { get; }
|
||||
public IReadOnlyList<string> SchemaIds { get; }
|
||||
}
|
||||
|
||||
internal sealed class AetheriaReactiveSurfacePublicationState
|
||||
{
|
||||
private long? _version;
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@
|
|||
"com.unity.modules.physics": "1.0.0",
|
||||
"com.unity.modules.uielements": "1.0.0",
|
||||
"com.unity.render-pipelines.universal": "17.4.0",
|
||||
"org.gamecult.cultlib": "https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-v1.0.29",
|
||||
"org.gamecult.cultlib": "https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-v1.0.30",
|
||||
"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.2.3",
|
||||
"org.gamecult.eve.surface": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#eveunity-surface-v0.2.4",
|
||||
"org.gamecult.eve.unity-scene": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.87"
|
||||
"org.gamecult.eve.unity-scene": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.88"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,11 +127,11 @@
|
|||
}
|
||||
},
|
||||
"org.gamecult.cultlib": {
|
||||
"version": "https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-v1.0.29",
|
||||
"version": "https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-v1.0.30",
|
||||
"depth": 0,
|
||||
"source": "git",
|
||||
"dependencies": {},
|
||||
"hash": "a1f25af2e0f66001270819737f3062133d91d199"
|
||||
"hash": "0ef59b50c27ac019929f5e68bcd602983a190062"
|
||||
},
|
||||
"org.gamecult.eve.plugin-fields": {
|
||||
"version": "https://github.com/GameCult/EvePlugins.git?path=/plugins/eve-plugin-fields/unity/org.gamecult.eve.plugin-fields#eve-plugin-fields-unity-v0.2.3",
|
||||
|
|
@ -152,18 +152,18 @@
|
|||
"hash": "e08fa08335f99e9edddeb706912eecfad07cb281"
|
||||
},
|
||||
"org.gamecult.eve.unity-scene": {
|
||||
"version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.87",
|
||||
"version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.88",
|
||||
"depth": 0,
|
||||
"source": "git",
|
||||
"dependencies": {
|
||||
"org.gamecult.cultlib": "1.0.29",
|
||||
"org.gamecult.cultlib": "1.0.30",
|
||||
"org.gamecult.eve.plugin-fields": "0.2.3",
|
||||
"org.gamecult.eve.surface": "0.2.4",
|
||||
"com.unity.mathematics": "1.3.2",
|
||||
"com.unity.render-pipelines.universal": "17.4.0",
|
||||
"com.unity.modules.particlesystem": "1.0.0"
|
||||
},
|
||||
"hash": "ab226e4f5f15b935a3f692b1eaad55e0c618a4ee"
|
||||
"hash": "3ce813e29dcc5342b51985187de26c62eb8c90b4"
|
||||
},
|
||||
"com.unity.modules.assetbundle": {
|
||||
"version": "1.0.0",
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@ $manifest = Get-Content (Join-Path $ProjectPath "Packages/manifest.json") -Raw |
|
|||
$lock = Get-Content (Join-Path $ProjectPath "Packages/packages-lock.json") -Raw | ConvertFrom-Json
|
||||
$expected = @{
|
||||
"org.gamecult.cultlib" = @(
|
||||
"https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-v1.0.29",
|
||||
"a1f25af2e0f66001270819737f3062133d91d199")
|
||||
"https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-v1.0.30",
|
||||
"0ef59b50c27ac019929f5e68bcd602983a190062")
|
||||
"org.gamecult.eve.surface" = @(
|
||||
"https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#eveunity-surface-v0.2.4",
|
||||
"e08fa08335f99e9edddeb706912eecfad07cb281")
|
||||
"org.gamecult.eve.unity-scene" = @(
|
||||
"https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.87",
|
||||
"ab226e4f5f15b935a3f692b1eaad55e0c618a4ee")
|
||||
"https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.88",
|
||||
"3ce813e29dcc5342b51985187de26c62eb8c90b4")
|
||||
}
|
||||
|
||||
foreach ($packageName in $expected.Keys) {
|
||||
|
|
@ -34,7 +34,7 @@ foreach ($packageName in $expected.Keys) {
|
|||
|
||||
$cultLibPackage = Get-ChildItem (Join-Path $ProjectPath "Library/PackageCache") -Directory |
|
||||
Where-Object Name -Like "org.gamecult.cultlib@*" |
|
||||
Where-Object { (Get-Content (Join-Path $_.FullName "package.json") -Raw | ConvertFrom-Json).version -eq "1.0.29" } |
|
||||
Where-Object { (Get-Content (Join-Path $_.FullName "package.json") -Raw | ConvertFrom-Json).version -eq "1.0.30" } |
|
||||
Select-Object -First 1
|
||||
if (-not $cultLibPackage) { throw "Resolved CultLib package is missing from Library/PackageCache." }
|
||||
|
||||
|
|
@ -68,9 +68,9 @@ foreach ($requiredInputContract in @("PayloadKeys", "CurrentValue", "ActionBar",
|
|||
|
||||
$scenePackage = Get-ChildItem (Join-Path $ProjectPath "Library/PackageCache") -Directory |
|
||||
Where-Object Name -Like "org.gamecult.eve.unity-scene@*" |
|
||||
Where-Object { (Get-Content (Join-Path $_.FullName "package.json") -Raw | ConvertFrom-Json).version -eq "0.3.87" } |
|
||||
Where-Object { (Get-Content (Join-Path $_.FullName "package.json") -Raw | ConvertFrom-Json).version -eq "0.3.88" } |
|
||||
Select-Object -First 1
|
||||
if (-not $scenePackage) { throw "Resolved Eve Unity scene 0.3.87 package is missing from Library/PackageCache." }
|
||||
if (-not $scenePackage) { throw "Resolved Eve Unity scene 0.3.88 package is missing from Library/PackageCache." }
|
||||
$advertisedInputSource = Get-Content (Join-Path $scenePackage.FullName "Runtime/EveUnityAdvertisedInputAction.cs") -Raw
|
||||
$inputDriverSource = Get-Content (Join-Path $scenePackage.FullName "Runtime/EveUnityPlayableWorldInputDriver.cs") -Raw
|
||||
$actionBarSource = Get-Content (Join-Path $scenePackage.FullName "Runtime/EveUnityInputActionBar.cs") -Raw
|
||||
|
|
|
|||
Loading…
Reference in a new issue