SpringRig: a return to Full mid-ease continues from the drawn pose; ease 0.75 s; bounds checked at both scales

Findings of cut-whale-rig-s1.s3 (ease-reentry-pops, ease-moves-fast, bounds-scale-one-sided).
- Present keeps a copy of the bone positions it drew and seeds the solver from it when the level returns to Full while the ease is
  part way (_restWeight < 1); a first Initialize, a fully eased return and a root jump still reset to rest.
- BlendSeconds 0.25 -> 0.75.
- SpringRig gets a serialized TextAsset Rig: Awake (and an Initialize() for editor code, where Awake does not run) builds the rig from it
  and the object's mesh.
- reentry-is-continuous: leave Full for 3 and for 8 frames and return; the returning frame's tip motion beyond rigid is under 0.41 of the
  chain. Margin rule: shipped worst 0.172, reset-to-rest mutant 0.970 (3 frames) and 1.207 (8), geometric mean 0.41.
- bounds-follow-the-swim runs at scale 1.5 and 0.6; a BoundsJob that ignores scale puts a vertex 1.24 outside at 0.6.
- freeze-and-reset derives its ease frame count from BlendSeconds.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
nibu-hands 2026-12-01 11:00:32 +01:00 • committed by soul
commit c24f76f47a
3 changed files with 79 additions and 11 deletions

View file

@ -62,6 +62,7 @@ namespace Aetheria.EditorTools
int failed = 0;
foreach (var (name, body) in checks)
{
("reentry-is-continuous", ReentryIsContinuous),
string verdict;
try { verdict = body(); }
catch (Exception e) { verdict = "exception: " + e; }
@ -302,7 +303,7 @@ namespace Aetheria.EditorTools
if (snap > 0.15) return $"the first frozen frame moved a tip {snap:P0} of its chain (a snap, not an ease)";
t += Dt;
w.Swim.AmplitudeDegrees = 15;
for (int i = 0; i < 30; i++, t += Dt) w.Present(t, new Vector3(Mathf.Sin((float)t * 5), 0, 0), Quaternion.identity, 1); // the ease ends at BlendSeconds
for (int i = 0, eased = (int)math.ceil(w.BlendSeconds / Dt) + 2; i < eased; i++, t += Dt) w.Present(t, new Vector3(Mathf.Sin((float)t * 5), 0, 0), Quaternion.identity, 1); // the ease ends at BlendSeconds
int jobs = w.SolveJobsScheduled;
double rest = 0;
for (int i = 0; i < 10; i++, t += Dt)
@ -619,8 +620,11 @@ namespace Aetheria.EditorTools
return jumped.Resets == 3 ? null : $"a jump of 500 u at scale 4 reset {jumped.Resets - 1} extra times, expected 2 (out and back)";
}
// Bounds follow the pose: every skinned vertex stays inside the renderer's bounds at a swim amplitude that moves the body.
static string BoundsFollowTheSwim()
// Bounds follow the pose: every skinned vertex stays inside the renderer's bounds at a swim amplitude that moves the body, at a
// scale above 1 (a bounds job that ignores scale is too large, which still holds every vertex) and below it (too small).
static string BoundsFollowTheSwim() => BoundsCase(1.5f) ?? BoundsCase(0.6f);
static string BoundsCase(float scale)
{
var s = new Synth { Gravity = 0.5f, Stiffness = 2, Colliders = new JArray() };
var go = new GameObject("boundsTest");
@ -636,7 +640,7 @@ namespace Aetheria.EditorTools
double worst = 0; Bounds first = default, last = default;
for (int f = 0; f < 300; f++)
{
rig.Present(f * Dt, new Vector3(0, 0, f * 0.05f), Quaternion.Euler(0, f * 0.5f, 0), 1.5f);
rig.Present(f * Dt, new Vector3(0, 0, f * 0.05f), Quaternion.Euler(0, f * 0.5f, 0), scale);
var b = rig.Renderer.localBounds;
if (f == 0) first = b; last = b;
for (int v = 0; v < verts.Count; v++)
@ -647,8 +651,52 @@ namespace Aetheria.EditorTools
worst = math.max(worst, math.cmax(outside));
}
}
if (worst > 1e-3) return $"a skinned vertex lies {worst} outside the bounds";
return first.size != last.size ? null : "the bounds never changed (vacuous)";
if (worst > 1e-3) return $"at scale {scale} a skinned vertex lies {worst} outside the bounds";
return first.size != last.size ? null : $"at scale {scale} the bounds never changed (vacuous)";
}
// Returning to Full part way through the ease continues from the pose last drawn: the returning frame moves a tip, relative to its
// chain root, a small part of the chain; a reset to rest moves it by nearly all of the distance the tip had left (Soul read 96% of
// the chain after 3 frames out with the old quarter-second ease). Readings with the 0.75 s ease, the largest over the two cases
// (3 and 8 frames out): shipped 0.172; the reset-to-rest mutant least 0.970 (0.970 and 1.207). The bound is
// lodur:ruling:deterministic-bound-margin's geometric mean sqrt(0.172 x 0.970) = 0.41, a separation of 2.4 on each side.
const double ReentryBound = 0.41;
static string ReentryIsContinuous()
{
var shortOut = ReentryCase(3);
var longOut = ReentryCase(8); // both run, so both readings are logged
return shortOut ?? longOut;
}
static string ReentryCase(int framesOut)
{
var cam = new GameObject("lodCam").AddComponent<Camera>();
Scrap.Add(cam.gameObject);
cam.fieldOfView = 60;
var s = new Synth { Gravity = 0, Stiffness = 4 };
var w = Whale(s, out var data);
w.LodCamera = cam;
w.Swim.AmplitudeDegrees = 0;
var chains = Enumerable.Range(0, data.ChainCount).Select(c => data.ChainBones(c)).ToArray();
float3[] Rel() => chains.Select(b => w.BonePosition(b[b.Count - 1]) - w.BonePosition(b[0])).ToArray();
double chainLength = (s.Joints - 1) * math.length(s.Seg);
cam.transform.position = new Vector3(0, 0, -50);
double t = 0;
Vector3 At() => new Vector3(Mathf.Sin((float)t * 5) * 3.2f, 0, 0);
for (; t < 3; t += Dt) w.Present(t, At(), Quaternion.identity, 1);
if (w.Level != SpringLod.Full) return "near whale is not Full";
cam.transform.position = new Vector3(0, 0, -300);
for (int i = 0; i < framesOut; i++, t += Dt) w.Present(t, At(), Quaternion.identity, 1);
if (w.Level != SpringLod.Frozen) return "far whale is not Frozen";
var drawn = Rel();
cam.transform.position = new Vector3(0, 0, -50);
if (w.Present(t, At(), Quaternion.identity, 1) != SpringLod.Full) return "near whale did not return to Full";
var back = Rel();
double moved = 0;
for (int c = 0; c < drawn.Length; c++) moved = math.max(moved, math.distance(back[c], drawn[c]) / chainLength);
Debug.Log($"{Tag} reentry after {framesOut} frames out: the returning frame moved a tip {moved:P1} of its chain (bound {ReentryBound:P1})");
return moved <= ReentryBound ? null : $"returning after {framesOut} frames out moved a tip {moved:P0} of its chain in one frame (a reset to rest, not a continuation)";
}
// Hovering at the Full threshold must not flip the level every frame.