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

+22 -65
View File
@@ -139,18 +139,9 @@ public partial class MeshPainter
if (spray) BuildSprayStampMaskSeeded(s.SpraySeed);
else { ResolveActiveMask(); UseResolvedStampMask(); }
if (_gpuActive)
{
BeginGpuStroke();
DrawBrushGpu(s.P, s.R, s.U, s.V, s.N);
EndGpuStroke();
}
else
{
ResetCpuDirty();
PaintStamp3D(s.P, s.R, s.U, s.V, s.N);
EndCpuStroke();
}
BeginBackendStroke();
DrawBackendStamp(s.P, s.R, s.U, s.V, s.N);
EndBackendStroke();
// Accumulate this peer's stroke dirty mask so a network checkpoint marker can commit the same
// history entry as the owner (same stamps -> same touched maps -> COW-aligned with the owner).
@@ -189,21 +180,7 @@ public partial class MeshPainter
w.Write(textureSize);
w.Write(MAP_COUNT);
var bytes = new byte[n * 4];
for (int mi = 0; mi < MAP_COUNT; mi++)
{
Color32[] px = ReadCanonical(mi);
int count = Mathf.Min(n, px.Length);
for (int i = 0; i < count; i++)
{
int o = i * 4;
bytes[o] = px[i].r;
bytes[o + 1] = px[i].g;
bytes[o + 2] = px[i].b;
bytes[o + 3] = px[i].a;
}
w.Write(bytes, 0, count * 4);
}
WriteCanonicalMaps(w);
}
compressed = Deflate(raw.ToArray());
}
@@ -217,19 +194,8 @@ public partial class MeshPainter
/// </summary>
public void ApplyPaintSnapshot(byte[] compressed, int baselineId)
{
if (!_setupValid || compressed == null || compressed.Length == 0) return;
if (!TryDecodeSnapshot(compressed, "Paint", out Color32[][] canonical)) return;
Color32[][] canonical;
try { canonical = DecodeSnapshot(compressed); }
catch (System.Exception e)
{
Debug.LogWarning($"[MeshPainter] Paint snapshot decode failed: {e.Message}", this);
return;
}
if (canonical == null) return;
// Re-seed exactly like SwitchBackend, but with externally supplied maps, so the island/dilation
// seeding path runs and the edge padding is rebuilt correctly for the loaded content.
ReseedCanonical(canonical);
SetHistoryBaseline(canonical, baselineId);
}
@@ -242,22 +208,28 @@ public partial class MeshPainter
/// </summary>
public bool LoadPaintFromSnapshot(byte[] compressed)
{
if (!_setupValid || compressed == null || compressed.Length == 0) return false;
Color32[][] canonical;
try { canonical = DecodeSnapshot(compressed); }
catch (System.Exception e)
{
Debug.LogWarning($"[MeshPainter] Carry snapshot decode failed: {e.Message}", this);
return false;
}
if (canonical == null) return false;
if (!TryDecodeSnapshot(compressed, "Carry", out Color32[][] canonical)) return false;
ReseedCanonical(canonical);
ResetHistoryToCurrent(canonical);
return true;
}
/// <summary>Guard + decode for an incoming snapshot blob; false = not ready / empty / undecodable.</summary>
private bool TryDecodeSnapshot(byte[] compressed, string context, out Color32[][] canonical)
{
canonical = null;
if (!_setupValid || compressed == null || compressed.Length == 0) return false;
try { canonical = DecodeSnapshot(compressed); }
catch (System.Exception e)
{
Debug.LogWarning($"[MeshPainter] {context} snapshot decode failed: {e.Message}", this);
return false;
}
return canonical != null;
}
private Color32[][] DecodeSnapshot(byte[] compressed)
{
byte[] raw = Inflate(compressed);
@@ -272,22 +244,7 @@ public partial class MeshPainter
// Resolution / version mismatch: ignore rather than smear; the painter keeps its state.
if (ver != SnapshotVersion || size != textureSize) return null;
int n = textureSize * textureSize;
var result = new Color32[MAP_COUNT][];
int load = Mathf.Min(maps, MAP_COUNT);
for (int mi = 0; mi < load; mi++)
{
byte[] b = r.ReadBytes(n * 4);
if (b.Length != n * 4) break; // truncated -> remaining maps stay at the material seed
var px = new Color32[n];
for (int i = 0; i < n; i++)
{
int o = i * 4;
px[i] = new Color32(b[o], b[o + 1], b[o + 2], b[o + 3]);
}
result[mi] = px;
}
return result;
return ReadCanonicalMaps(r, maps);
}
}