Make game viewport authority runtime-neutral

This commit is contained in:
Meta Vens 2026-07-05 19:56:18 +01:00
commit 911bb72f69
45 changed files with 424 additions and 369 deletions

View file

@ -252,9 +252,9 @@ public sealed class AetheriaRenderSplatRasterizer : MonoBehaviour
Graphics.ExecuteCommandBuffer(_commandBuffer);
}
private static Matrix4x4 BuildViewportToClip(AetheriaRuntimeRtsViewportBounds viewport)
private static Matrix4x4 BuildViewportToClip(AetheriaRuntimeViewportBounds viewport)
{
viewport ??= new AetheriaRuntimeRtsViewportBounds();
viewport ??= new AetheriaRuntimeViewportBounds();
var minX = (float)math.min(viewport.MinX, viewport.MaxX);
var minY = (float)math.min(viewport.MinY, viewport.MaxY);
var maxX = (float)math.max(viewport.MinX, viewport.MaxX);

View file

@ -43,9 +43,9 @@ public sealed class AetheriaSceneRenderSplatSource : MonoBehaviour
[SerializeField]
private AetheriaSceneRenderSplatFixture[] fixtures = Array.Empty<AetheriaSceneRenderSplatFixture>();
public AetheriaRuntimeRenderSplatsViewportDocument BuildDocument(AetheriaRuntimeRtsViewportBounds viewport)
public AetheriaRuntimeRenderSplatsViewportDocument BuildDocument(AetheriaRuntimeViewportBounds viewport)
{
viewport ??= new AetheriaRuntimeRtsViewportBounds();
viewport ??= new AetheriaRuntimeViewportBounds();
var normalizedViewport = Normalize(viewport);
var layers = BuildLayers();
var layerIndices = new Dictionary<string, int>(StringComparer.Ordinal);
@ -70,9 +70,9 @@ public sealed class AetheriaSceneRenderSplatSource : MonoBehaviour
};
}
private static AetheriaRuntimeRtsViewportBounds Normalize(AetheriaRuntimeRtsViewportBounds viewport)
private static AetheriaRuntimeViewportBounds Normalize(AetheriaRuntimeViewportBounds viewport)
{
return new AetheriaRuntimeRtsViewportBounds
return new AetheriaRuntimeViewportBounds
{
MinX = Math.Min(viewport.MinX, viewport.MaxX),
MinY = Math.Min(viewport.MinY, viewport.MaxY),

View file

@ -2,15 +2,15 @@ using System;
using GameCult.Aetheria.State.Verse;
using GameCult.Mesh;
public sealed class AetheriaUnityRtsViewportDocuments : IDisposable
public sealed class AetheriaUnityGameViewportDocuments : IDisposable
{
private readonly CultMeshReactiveDocument<AetheriaRuntimeZoneContactsDocument> _contacts;
private readonly CultMeshReactiveDocument<AetheriaRuntimeObjectsViewportDocument> _objectsViewport;
private readonly CultMeshReactiveDocument<AetheriaRuntimeRenderSplatsViewportDocument> _renderSplatsViewport;
private AetheriaUnityRtsViewportDocuments(
private AetheriaUnityGameViewportDocuments(
AetheriaClientState state,
AetheriaRuntimeRtsViewportBounds viewport,
AetheriaRuntimeViewportBounds viewport,
bool bindContacts,
bool bindObjects,
bool bindRenderSplats)
@ -26,17 +26,17 @@ public sealed class AetheriaUnityRtsViewportDocuments : IDisposable
_renderSplatsViewport = bindRenderSplats ? state.RenderSplatsViewport(viewport).Reactive() : null;
}
public AetheriaRuntimeRtsViewportBounds Viewport { get; }
public AetheriaRuntimeViewportBounds Viewport { get; }
public AetheriaRuntimeZoneContactsDocument CurrentContacts => _contacts?.Current;
public AetheriaRuntimeObjectsViewportDocument CurrentObjectsViewport => _objectsViewport?.Current;
public AetheriaRuntimeRenderSplatsViewportDocument CurrentRenderSplatsViewport => _renderSplatsViewport?.Current;
public static AetheriaUnityRtsViewportDocuments OpenMap(
public static AetheriaUnityGameViewportDocuments OpenMap(
AetheriaClientState state,
AetheriaRuntimeRtsViewportBounds viewport)
AetheriaRuntimeViewportBounds viewport)
{
return new AetheriaUnityRtsViewportDocuments(
return new AetheriaUnityGameViewportDocuments(
state,
viewport,
bindContacts: false,
@ -44,11 +44,11 @@ public sealed class AetheriaUnityRtsViewportDocuments : IDisposable
bindRenderSplats: true);
}
public static AetheriaUnityRtsViewportDocuments OpenZonePresentation(
public static AetheriaUnityGameViewportDocuments OpenZonePresentation(
AetheriaClientState state,
AetheriaRuntimeRtsViewportBounds viewport)
AetheriaRuntimeViewportBounds viewport)
{
return new AetheriaUnityRtsViewportDocuments(
return new AetheriaUnityGameViewportDocuments(
state,
viewport,
bindContacts: true,
@ -56,11 +56,11 @@ public sealed class AetheriaUnityRtsViewportDocuments : IDisposable
bindRenderSplats: false);
}
public static AetheriaUnityRtsViewportDocuments OpenRenderSplats(
public static AetheriaUnityGameViewportDocuments OpenRenderSplats(
AetheriaClientState state,
AetheriaRuntimeRtsViewportBounds viewport)
AetheriaRuntimeViewportBounds viewport)
{
return new AetheriaUnityRtsViewportDocuments(
return new AetheriaUnityGameViewportDocuments(
state,
viewport,
bindContacts: false,
@ -68,7 +68,7 @@ public sealed class AetheriaUnityRtsViewportDocuments : IDisposable
bindRenderSplats: true);
}
public bool Matches(AetheriaRuntimeRtsViewportBounds viewport)
public bool Matches(AetheriaRuntimeViewportBounds viewport)
{
return SameViewport(Viewport, viewport);
}
@ -81,8 +81,8 @@ public sealed class AetheriaUnityRtsViewportDocuments : IDisposable
}
public static bool SameViewport(
AetheriaRuntimeRtsViewportBounds left,
AetheriaRuntimeRtsViewportBounds right)
AetheriaRuntimeViewportBounds left,
AetheriaRuntimeViewportBounds right)
{
if (left == null || right == null)
return false;

View file

@ -26,7 +26,7 @@ public sealed class AetheriaUnityRenderSplatViewportSource : MonoBehaviour
private bool renderInLateUpdate = true;
private float _nextRefreshTime;
private AetheriaUnityRtsViewportDocuments _viewportDocuments;
private AetheriaUnityGameViewportDocuments _viewportDocuments;
private AetheriaRuntimeRenderSplatsViewportDocument _fallbackRenderSplatsViewport;
private string _lastWarningMessage = "";
@ -150,19 +150,19 @@ public sealed class AetheriaUnityRenderSplatViewportSource : MonoBehaviour
}
private static AetheriaRuntimeRenderSplatsViewportDocument EmptyRenderSplatsViewport(
AetheriaRuntimeRtsViewportBounds viewport)
AetheriaRuntimeViewportBounds viewport)
{
return new AetheriaRuntimeRenderSplatsViewportDocument
{
PublishedAtUtc = DateTimeOffset.UtcNow.ToString("O"),
Viewport = viewport ?? new AetheriaRuntimeRtsViewportBounds()
Viewport = viewport ?? new AetheriaRuntimeViewportBounds()
};
}
private AetheriaRuntimeRtsViewportBounds ResolveViewportBounds()
private AetheriaRuntimeViewportBounds ResolveViewportBounds()
{
var halfSize = size * 0.5f;
return new AetheriaRuntimeRtsViewportBounds
return new AetheriaRuntimeViewportBounds
{
MinX = position.x - halfSize.x,
MinY = position.y - halfSize.y,

View file

@ -77,25 +77,25 @@ public static class AetheriaUnityRuntimeClientProvider
return RuntimeClient(stateBoot, runtimeId).State;
}
public static AetheriaUnityRtsViewportDocuments MapViewportDocuments(
AetheriaRuntimeRtsViewportBounds viewport,
public static AetheriaUnityGameViewportDocuments MapViewportDocuments(
AetheriaRuntimeViewportBounds viewport,
string runtimeId = "")
{
return AetheriaUnityRtsViewportDocuments.OpenMap(RuntimeState(runtimeId), viewport);
return AetheriaUnityGameViewportDocuments.OpenMap(RuntimeState(runtimeId), viewport);
}
public static AetheriaUnityRtsViewportDocuments ZonePresentationDocuments(
AetheriaRuntimeRtsViewportBounds viewport,
public static AetheriaUnityGameViewportDocuments ZonePresentationDocuments(
AetheriaRuntimeViewportBounds viewport,
string runtimeId = "")
{
return AetheriaUnityRtsViewportDocuments.OpenZonePresentation(RuntimeState(runtimeId), viewport);
return AetheriaUnityGameViewportDocuments.OpenZonePresentation(RuntimeState(runtimeId), viewport);
}
public static AetheriaUnityRtsViewportDocuments RenderSplatViewportDocuments(
AetheriaRuntimeRtsViewportBounds viewport,
public static AetheriaUnityGameViewportDocuments RenderSplatViewportDocuments(
AetheriaRuntimeViewportBounds viewport,
string runtimeId = "")
{
return AetheriaUnityRtsViewportDocuments.OpenRenderSplats(RuntimeState(runtimeId), viewport);
return AetheriaUnityGameViewportDocuments.OpenRenderSplats(RuntimeState(runtimeId), viewport);
}
public static AetheriaUnityDaemonRenderDocuments DaemonRenderDocuments(