Fix ShieldManager's missing-envelope fallback regression
ShieldManager's fallback (no ShieldEnvelope yet, e.g. every ship prefab before the operator hand-rigs it per Q5) hard-failed to a fixed Vector3.forward direction with a per-hit Debug.LogError. That silently changed behaviour for every ship in the game until the operator edits Longinus.prefab/Djinni.prefab on their own schedule -- worse than either the deleted code or a loud one-time failure. Extract ShieldEnvelope's local-direction primitive into two static, no-component-required entry points -- SurfaceDirection(Transform, Vector3) and LegacyLocalSurfacePoint(Transform, Vector3) -- so both FieldDriver's and ShieldManager's fallbacks go through one owner instead of each re-deriving the pre-Cut-2 formula by hand. ShieldManager's fallback now reproduces the deleted normalize(shield.transform.InverseTransformPoint(point)) formula exactly via the shared static, logging once (a warning, not a per-hit error). FieldDriver's fallback is rewired onto the same static rather than its own inline copy of the maths. Documented, not silently assumed: FieldDriver's "envelope present" branch (envelope.ProjectToSurface, world-space) and its fallback (the legacy local- space formula) are only numerically identical when the carrier's transform has zero position and identity rotation -- true of the one FieldDriver carrier in the tree today, not true in general. This is a characteristic of Cut 2 as scoped by the map (FieldDriver.cs:125 reads envelope.ProjectToSurface directly, per the map's own text), not something this fix introduces or resolves; flagged so nobody assumes the two branches are interchangeable for a future non-origin, non-identity FieldDriver carrier. ShieldPanelCut2Verify.CheckLegacyFallbackFormulas pins both static entry points against an independent re-derivation of the exact pre-Cut-2 formulas, on a carrier with a non-trivial transform (nonzero position, non-identity rotation) so the check isn't vacuous. mutation_tests_shield_panel_cut2.py gained two cases: SurfaceDirection collapsing back to a fixed Vector3.forward (the exact regression fixed here), and LegacyLocalSurfacePoint collapsing to the raw, untransformed world point -- both correctly fail the probe. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
a454a5a77f
commit
7848a8a86e
5 changed files with 201 additions and 18 deletions
|
|
@ -139,6 +139,18 @@ public class FieldDriver : MonoBehaviour, IAbsorbPresenter, IGrabPresenter, IMel
|
|||
return transform.localScale;
|
||||
}
|
||||
|
||||
// Cut 2 note on the two branches below NOT being the same computation shape: envelope.
|
||||
// ProjectToSurface returns a WORLD-space point (it transforms back through rotation and
|
||||
// translation -- Cut 3's panel presenter needs that). The fallback reproduces the pre-Cut-2
|
||||
// formula exactly instead, which stayed in LOCAL space with no rotation/translation applied,
|
||||
// because that is what the shader consumes here (_Hits is uploaded and read in the field
|
||||
// mesh's own local space, not world space). The two branches are only numerically identical
|
||||
// when the carrier's transform has zero position and identity rotation -- true of the one
|
||||
// FieldDriver carrier in the tree today (FieldShieldTest.unity's cubesphere), NOT true in
|
||||
// general. This is an existing characteristic of Cut 2 as scoped by the map (FieldDriver.cs:125
|
||||
// reads envelope.ProjectToSurface(position) directly, per the map's own Cut 2 text), not
|
||||
// something introduced by this fallback -- flagging it so nobody assumes the two branches are
|
||||
// interchangeable for a future non-origin, non-identity FieldDriver carrier.
|
||||
public void AddHit(float3 position, float3 direction, float magnitude)
|
||||
{
|
||||
if (_hits.Count >= MaxHits) return;
|
||||
|
|
@ -148,7 +160,7 @@ public class FieldDriver : MonoBehaviour, IAbsorbPresenter, IGrabPresenter, IMel
|
|||
else
|
||||
{
|
||||
WarnMissingEnvelopeOnce();
|
||||
surfacePosition = (normalize(transform.InverseTransformPoint(position.ToUnity()).ToCultMath()) * transform.localScale.ToCultMath()).ToUnity();
|
||||
surfacePosition = ShieldEnvelope.LegacyLocalSurfacePoint(transform, position.ToUnity());
|
||||
}
|
||||
var hit = new FieldHit
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue