Draw every moving body at the drawn time T = ExactTime + Lead
Planets, belts, wells, loot, mines, stations, the chunk reticle and the flow clock are evaluated through DrawAhead (Time, Orbit, Height, Position) at one drawn time; the rail law lives once in Zone.Offset; OrbitPositionAt, GetHeight, ChunkPose, EvaluateBelt and RideHeight take a time. Fixes the planet jumping against a co-moving ship at display rates above the step rate. Not yet built or run (Unity presenter files are verified by compile only on Starfire). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
09ec04a8d5
commit
b57207045d
14 changed files with 429 additions and 62 deletions
|
|
@ -32,9 +32,10 @@ public static class GravityLowering
|
|||
|
||||
/// <summary>
|
||||
/// Fills one record per body of the zone (a null zone has none) and sets the shader globals. The buffer is the
|
||||
/// caller's, (re)allocated to the body count (at least one, so the global is always bound).
|
||||
/// caller's, (re)allocated to the body count (at least one, so the global is always bound). Wells are lowered at the
|
||||
/// drawn time (DrawAhead.Time), the same T the planets and a ship's ride height use.
|
||||
/// </summary>
|
||||
public static void Lower(Zone zone, ref ComputeBuffer wells)
|
||||
public static void Lower(Zone zone, float lead, ref ComputeBuffer wells)
|
||||
{
|
||||
var count = zone?.PlanetInstances.Count ?? 0;
|
||||
var capacity = Mathf.Max(count, 1);
|
||||
|
|
@ -50,7 +51,7 @@ public static class GravityLowering
|
|||
foreach (var body in zone.PlanetInstances.Values)
|
||||
_records[i++] = new WellRecord
|
||||
{
|
||||
Position = new Vector2(body.Orbit.Position.x, body.Orbit.Position.y),
|
||||
Position = DrawAhead.Orbit(zone, body.BodyData.Orbit.Key, lead).ToUnity(),
|
||||
Strength = body.WellStrength,
|
||||
CoreRadius = body.RocheLimit,
|
||||
Reference = zone.WellReference(body)
|
||||
|
|
|
|||
|
|
@ -106,10 +106,12 @@ public class VolumeSampling : MonoBehaviour
|
|||
static GlobalKeyword KeywordFlowSlope => _keywordFlowSlope ??= GlobalKeyword.Create("FLOW_SLOPE");
|
||||
|
||||
/// <summary>
|
||||
/// The time the flow runs on: the zone's own (so drift stops with the sim and follows sim speed), or on menus,
|
||||
/// where no zone exists, the presentation clock.
|
||||
/// The time the flow runs on: the zone's drawn time (DrawAhead.Time, so drift stops with the sim and follows sim
|
||||
/// speed), or on menus, where no zone exists, the presentation clock.
|
||||
/// </summary>
|
||||
public static double FlowClock => ActionGameManager.Instance?.Zone?.ExactTime ?? Time.timeSinceLevelLoad;
|
||||
public static double FlowClock => ActionGameManager.Instance?.Zone is { } zone
|
||||
? DrawAhead.Time(zone, ActionGameManager.Clock.Lead)
|
||||
: Time.timeSinceLevelLoad;
|
||||
|
||||
/// <summary>
|
||||
/// The one place that sets the flow uniforms and keywords: every shader flow term derives from FlowSettings and
|
||||
|
|
|
|||
|
|
@ -520,7 +520,8 @@ public class ZoneRenderer : MonoBehaviour
|
|||
void Update()
|
||||
{
|
||||
var maxDepth = 0f;
|
||||
GravityLowering.Lower(Zone, ref _gravityWells);
|
||||
var lead = ActionGameManager.Clock.Lead;
|
||||
GravityLowering.Lower(Zone, lead, ref _gravityWells);
|
||||
foreach (var loot in _floatingItems.Values)
|
||||
{
|
||||
loot.ViewOrigin = PerspectiveEntity.Position;
|
||||
|
|
@ -542,11 +543,11 @@ public class ZoneRenderer : MonoBehaviour
|
|||
foreach (var (key, belt) in Zone.AsteroidBelts)
|
||||
{
|
||||
// Cut 1 (docs/mining-cut.md): belts have no stored pose any more. The renderer fills its own buffer
|
||||
// from Zone.EvaluateBelt, at the current zone time, every frame.
|
||||
var orbitPosition = Zone.GetOrbitPosition(Zone.Orbits[belt.Data.Orbit.Key].Data.Parent.Key);
|
||||
var height = Zone.GetHeight(orbitPosition);
|
||||
// from Zone.EvaluateBelt, at the drawn time (DrawAhead.Time), every frame.
|
||||
var orbitPosition = DrawAhead.Orbit(Zone, Zone.Orbits[belt.Data.Orbit.Key].Data.Parent.Key, lead);
|
||||
var height = DrawAhead.Height(Zone, orbitPosition, lead);
|
||||
var transforms = _beltTransforms[key];
|
||||
Zone.EvaluateBelt(key, transforms);
|
||||
Zone.EvaluateBelt(key, transforms, DrawAhead.Time(Zone, lead));
|
||||
if(isVisible(new Bounds(
|
||||
new Vector3(orbitPosition.x,height,orbitPosition.y),
|
||||
new Vector3(belt.Radius * 2,100,belt.Radius * 2))))
|
||||
|
|
@ -579,8 +580,8 @@ public class ZoneRenderer : MonoBehaviour
|
|||
foreach (var planet in Planets)
|
||||
{
|
||||
var planetInstance = Zone.PlanetInstances[planet.Key];
|
||||
var p = Zone.GetOrbitPosition(planetInstance.BodyData.Orbit.Key);
|
||||
var height = Zone.GetHeight(p);
|
||||
var p = DrawAhead.Orbit(Zone, planetInstance.BodyData.Orbit.Key, lead);
|
||||
var height = DrawAhead.Height(Zone, p, lead);
|
||||
if (-height > maxDepth) maxDepth = -height;
|
||||
planet.Value.transform.position = new Vector3(p.x, 0, p.y);
|
||||
planet.Value.Body.transform.localPosition = new Vector3(0, height + planetInstance.BodyRadius * 2, 0);
|
||||
|
|
@ -589,7 +590,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
{
|
||||
if (!(planet.Value is SunObject))
|
||||
{
|
||||
var toParent = normalize(Zone.GetOrbitPosition(Zone.Orbits[planetInstance.BodyData.Orbit.Key].Data.Parent.Key) - p);
|
||||
var toParent = normalize(DrawAhead.Orbit(Zone, Zone.Orbits[planetInstance.BodyData.Orbit.Key].Data.Parent.Key, lead) - p);
|
||||
gasGiantObject.SunMaterial.LightingDirection = new Vector3(toParent.x, 0, toParent.y);
|
||||
}
|
||||
}
|
||||
|
|
@ -716,7 +717,7 @@ public class AsteroidBeltUI
|
|||
|
||||
public void Update(float4[] transforms, float height)
|
||||
{
|
||||
var parentPosition = _zone.GetOrbitPosition(_orbitParent);
|
||||
var parentPosition = DrawAhead.Orbit(_zone, _orbitParent, ActionGameManager.Clock.Lead);
|
||||
for (var i = 0; i < transforms.Length; i++)
|
||||
{
|
||||
var transform = transforms[i];
|
||||
|
|
|
|||
Loading…
Reference in a new issue