FireControl.RoundEnd states a round's end; DrawAhead draws rounds as pure statics
RoundEnd(shot, known) is the one statement of when a ballistic round's drawn flight ends: arrival for a hit, burst or unpublished outcome, the frozen range (never short of arrival) for a miss. RoundAt takes the known outcome and clamps at RoundEnd. DrawAhead gains Round, RoundStop, RoundOver (pure, no state) so the blend, stop and done rules are headless-testable. Seven new tests (ten cases). Unity build: Projectile.cs still calls the old RoundAt, so this commit does not compile in Unity (the headless test project does not include Projectile). The next commit moves Projectile onto the statics. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e56f9c8be5
commit
60aacfdc35
3 changed files with 313 additions and 26 deletions
|
|
@ -5,8 +5,9 @@
|
|||
using CultMath;
|
||||
using static CultMath.math;
|
||||
|
||||
// Where a presenter draws the latest sim state when the frame falls Lead sim seconds after the last step. Pure reads
|
||||
// of the simulation for presenters (never called by ServerShared): the sim owns every pose and no presenter stores
|
||||
// Where a presenter draws the latest sim state when the frame falls Lead sim seconds after the last step: ships by
|
||||
// their last step's velocity, ballistic rounds on FireControl's RoundAt and RoundEnd. Pure reads of the simulation for
|
||||
// presenters (never called by ServerShared, no state of their own): the sim owns every pose and no presenter stores
|
||||
// one, a previous state or a velocity of its own.
|
||||
public static class DrawAhead
|
||||
{
|
||||
|
|
@ -37,4 +38,24 @@ public static class DrawAhead
|
|||
t.w * q.z + t.x * q.y - t.y * q.x + t.z * q.w,
|
||||
t.w * q.w - t.x * q.x - t.y * q.y - t.z * q.z));
|
||||
}
|
||||
|
||||
// A ballistic round at a sim time (the clock's Zone.Time + Lead): on FireControl's line for what the sim has published
|
||||
// of its outcome, with the barrel's offset from that line decaying to nothing over blendTime sim seconds from FireTime.
|
||||
public static float3 Round(in PendingShot shot, ShotResult? known, float3 barrel, float blendTime, float time) =>
|
||||
Lifted(shot, FireControl.RoundAt(shot, known, time), barrel, blendTime, time);
|
||||
|
||||
// Where a round that hit or burst stops: the outcome's burst point, else where it arrives on its line.
|
||||
public static float3 RoundStop(in PendingShot shot, ShotOutcome outcome, float3 barrel, float blendTime) =>
|
||||
Lifted(shot, outcome.HasBurstPoint ? outcome.BurstPoint : FireControl.RoundAt(shot, outcome.Result, shot.ArrivalTime),
|
||||
barrel, blendTime, shot.ArrivalTime);
|
||||
|
||||
// Whether the drawn flight is over by time: only a published miss ends by the clock. A hit or burst ends on ShotResolved.
|
||||
public static bool RoundOver(in PendingShot shot, ShotResult? known, float time) =>
|
||||
known == ShotResult.Miss && time >= FireControl.RoundEnd(shot, ShotResult.Miss);
|
||||
|
||||
private static float3 Lifted(in PendingShot shot, float2 planar, float3 barrel, float blendTime, float time)
|
||||
{
|
||||
var blend = blendTime > 0 ? saturate(1 - (time - shot.FireTime) / blendTime) : 0f;
|
||||
return float3(planar.x, shot.FireOrigin.y, planar.y) + (barrel - shot.FireOrigin) * blend;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue