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

+33 -7
View File
@@ -26,11 +26,7 @@ public partial class MeshPainter
var canonical = new Color32[MAP_COUNT][];
for (int mi = 0; mi < MAP_COUNT; mi++) canonical[mi] = ReadCanonical(mi);
if (_gpuActive) TeardownGpu();
else TeardownCpu();
SetupBackend(toGpu, canonical);
_hasLastScreen = false;
RebuildBackend(toGpu, canonical);
Debug.Log($"[MeshPainter] Backend switched -> {(toGpu ? "GPU" : "CPU")} painting.", this);
}
@@ -40,14 +36,44 @@ public partial class MeshPainter
/// late-join snapshot / undo). Runs the island/dilation seeding path so edge padding is rebuilt for
/// the new content. The input arrays are never mutated (SetupBackend clones its seed).
/// </summary>
private void ReseedCanonical(Color32[][] canonical)
private void ReseedCanonical(Color32[][] canonical) => RebuildBackend(useGpu, canonical);
/// <summary>Tears down the active backend and sets up the requested one on the given maps.</summary>
private void RebuildBackend(bool gpu, Color32[][] canonical)
{
if (_gpuActive) TeardownGpu();
else TeardownCpu();
SetupBackend(useGpu, canonical);
SetupBackend(gpu, canonical);
_hasLastScreen = false;
}
/// <summary>Seed source for a map: the supplied canonical data when valid, else the material seed.</summary>
private Color32[] ResolveSeed(int mi, Color32[][] canonical)
{
return (canonical != null && canonical[mi] != null && canonical[mi].Length == textureSize * textureSize)
? canonical[mi] : _seedCanonical[mi];
}
// Backend-agnostic stroke dispatch (GPU vs CPU), shared by local painting and replayed net stamps.
private void BeginBackendStroke()
{
if (_gpuActive) BeginGpuStroke();
else ResetCpuDirty();
}
private void DrawBackendStamp(Vector3 pLocal, float radiusLocal, Vector3 u, Vector3 v, Vector3 n)
{
if (_gpuActive) DrawBrushGpu(pLocal, radiusLocal, u, v, n);
else PaintStamp3D(pLocal, radiusLocal, u, v, n);
}
private void EndBackendStroke()
{
if (_gpuActive) EndGpuStroke();
else EndCpuStroke();
}
/// <summary>Reads a map from the active backend into canonical (material) layout.</summary>
private Color32[] ReadCanonical(int mi)
{