Refactor: extract shared helpers across scripts, trim remaining doc redundancy

Deduplication pass (44 extractions):
- New SmoothedLook: shared smoothed yaw/pitch look tick + view seeding
  (FirstPersonController, FreeCamController)
- New CharacterTeleport: disable-CC-around-teleport idiom (rescue,
  owner position apply, free-cam sync)
- New GeometryUtil: RescaleToUnitScale + TransformBounds (concealment
  meter/volume, skinned collider baker)
- Paint family: canonical map read/write shared between Net and
  Persistence, snapshot decode, backend stroke dispatch, RebuildBackend,
  ResolveSeed, chunked RPC send/gate/copy, CamoKnobs/HeightKnobs
  aggregates, SanitizeFileKey, NewMaskTexture, AdoptAlbedo, FindSlider
- Player/modes: GameMode SetPlayerControl/SetPainting/SetOrbitInputEnabled,
  InputUtil.GameplayKeyPressed, NearestClimbHit, ComputeXRay delegates to
  ComputeResolutionFreeze, FingerIK TryInPlaneAngle
- Match/misc: UnhookSessionCallbacks, SendEmptyNamedMessage, SwapScenes,
  RunSessionOpAsync, CovarianceEigen, CollectClusterPoints, MatchHud
  GUIStyle cache, HsvColorPicker rehook, VoxelCenter

Documentation pass: remove 6 triplicated doc blocks and 2 restating
inline comments left after the previous reduction.

Behavior-neutral; hot-path rasterizer loops intentionally untouched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Fable 5 committed 2026-07-02 12:33:48 +02:00
1 parent 066e308cde
commit 2243cc823e
40 files changed
+681 -724

No files matched your search

+2 -39
View File
@@ -88,7 +88,6 @@ public class ConcealmentMeter : MonoBehaviour
private readonly List<MeshCollider> _concave = new List<MeshCollider>();
private readonly List<ConcealmentVolume> _volumes = new List<ConcealmentVolume>();
// Gizmo cache.
private readonly List<Vector3> _gizPos = new List<Vector3>();
private readonly List<bool> _gizEmbedded = new List<bool>();
private float _gizVoxelWorld;
@@ -132,9 +131,7 @@ public class ConcealmentMeter : MonoBehaviour
// else a scaled player is measured at scale² (voxel world positions, broadphase box AND gizmos), which
// also corrupts EmbeddedPercent. No-op at scale 1; the uniform divide is rotation-independent, which the
// player's uniform scale guarantees. Mirrors SkinnedColliderBaker's identical fixup.
Vector3 ls = targetRenderer.transform.lossyScale;
if (ls.x != 1f || ls.y != 1f || ls.z != 1f)
RescaleBakedToUnitScale(ls);
GeometryUtil.RescaleToUnitScale(_baked, targetRenderer.transform.lossyScale, _vbuf);
_verts = _baked.vertices;
_tris = _baked.triangles;
@@ -156,7 +153,7 @@ public class ConcealmentMeter : MonoBehaviour
Matrix4x4 l2w = targetRenderer.transform.localToWorldMatrix;
// Derive the broadphase box from the ACTUAL transformed geometry, not SkinnedMeshRenderer.bounds
// (the latter is a root-bone approximation that can be badly offset for a deformed/posed rig).
Bounds worldBounds = TransformBounds(l2w, lb);
Bounds worldBounds = GeometryUtil.TransformBounds(l2w, lb);
BuildEnvironmentCandidates(worldBounds);
bool anyEnv = _convex.Count > 0 ||
@@ -213,24 +210,6 @@ public class ConcealmentMeter : MonoBehaviour
HasResult = true;
}
/// <summary>Divides the player's world scale back out of the freshly baked mesh so it is true unit-scale
/// local geometry (the space this class raises to world with). Reuses <see cref="_vbuf"/> — no per-eval alloc.</summary>
private void RescaleBakedToUnitScale(Vector3 lossyScale)
{
float ix = lossyScale.x != 0f ? 1f / lossyScale.x : 0f;
float iy = lossyScale.y != 0f ? 1f / lossyScale.y : 0f;
float iz = lossyScale.z != 0f ? 1f / lossyScale.z : 0f;
_baked.GetVertices(_vbuf);
for (int i = 0; i < _vbuf.Count; i++)
{
Vector3 v = _vbuf[i];
v.x *= ix; v.y *= iy; v.z *= iz;
_vbuf[i] = v;
}
_baked.SetVertices(_vbuf);
_baked.RecalculateBounds();
}
/// <summary>
/// Rasterizes every triangle into the XZ column grid; each column accumulates the Y values
/// where the surface crosses it (one per triangle whose XZ projection covers the column center).
@@ -389,22 +368,6 @@ public class ConcealmentMeter : MonoBehaviour
return (hits & 1) == 1;
}
/// <summary>World AABB enclosing a local AABB after an affine transform (encapsulates the 8 transformed corners).</summary>
private static Bounds TransformBounds(Matrix4x4 m, Bounds local)
{
Vector3 mn = local.min, mx = local.max;
Vector3 c0 = m.MultiplyPoint3x4(mn);
Bounds b = new Bounds(c0, Vector3.zero);
b.Encapsulate(m.MultiplyPoint3x4(new Vector3(mx.x, mn.y, mn.z)));
b.Encapsulate(m.MultiplyPoint3x4(new Vector3(mn.x, mx.y, mn.z)));
b.Encapsulate(m.MultiplyPoint3x4(new Vector3(mn.x, mn.y, mx.z)));
b.Encapsulate(m.MultiplyPoint3x4(new Vector3(mx.x, mx.y, mn.z)));
b.Encapsulate(m.MultiplyPoint3x4(new Vector3(mx.x, mn.y, mx.z)));
b.Encapsulate(m.MultiplyPoint3x4(new Vector3(mn.x, mx.y, mx.z)));
b.Encapsulate(m.MultiplyPoint3x4(mx));
return b;
}
private static float AverageScale(Transform t)
{
Vector3 s = t.lossyScale;