Refactor Assets/Scripts: trim restating comments, minor structure cleanups

Sweep over 48 files (Editor/ excluded): remove comments that restate the
code, condense class summaries, fix three stale doc statements
(HsvColorPicker alpha bar, PaintHud layoutPrefab, MasterVolume
FallbackDefault). Inline two single-use wrappers (IsPointerOverUi,
BuildModes), drop an unused using, replace a magic literal with the
existing ParallaxBase constant, and convert ~10 UnityEngine.Object null
checks to the implicit-bool convention. No serialized fields, signatures,
RPC/NetworkVariable names, defaults, or #if blocks touched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Fable 5 committed 2026-07-08 08:29:18 +02:00
1 parent eeee5fc2f0
commit 6c03e5d3f6
48 files changed
+289 -481

No files matched your search

@@ -20,7 +20,6 @@ public partial class MeshPainter
}
}
/// <summary>Switches the backend at runtime, carrying over all painted maps.</summary>
private void SwitchBackend(bool toGpu)
{
var canonical = new Color32[MAP_COUNT][];
@@ -66,7 +65,6 @@ public partial class MeshPainter
if (!_backendSeeded) ReseedCanonical(null);
}
/// <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();
@@ -75,7 +73,6 @@ public partial class MeshPainter
_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)
@@ -85,7 +85,7 @@ public partial class MeshPainter
if (!DeferInitialSeed) SeedGpuMap(mi, canonical); // deferred: RTs stay unseeded until the snapshot re-seed
// Color maps render to the display RT; the MS map exposes its packed final RT.
AssignMapTexture(mi, gm.final != null ? gm.final : gm.display);
AssignMapTexture(mi, gm.final ? gm.final : gm.display);
}
return true;
}
@@ -133,7 +133,7 @@ public partial class MeshPainter
{
SeedGpuMap(mi, canonical);
var gm = _gpu[mi];
AssignMapTexture(mi, gm.final != null ? gm.final : gm.display);
AssignMapTexture(mi, gm.final ? gm.final : gm.display);
}
}
@@ -426,11 +426,11 @@ public partial class MeshPainter
Graphics.Blit(gm.display, gm.temp, _dilateMat, 0);
var swap = gm.display; gm.display = gm.temp; gm.temp = swap;
if (gm.final == null) AssignMapTexture(mi, gm.display);
if (!gm.final) AssignMapTexture(mi, gm.display);
}
// MS: pack the work layout (R=metallic, G=smoothness) into the URP final layout.
if (gm.final != null) PackMs(gm);
if (gm.final) PackMs(gm);
}
GL.sRGBWrite = _prevSRGB;
@@ -73,7 +73,6 @@ public partial class MeshPainter
/// <summary>True if anyone is listening for replicated stamps (the owner is networked + painting).</summary>
private bool WantsStampCapture => OnStampCommitted != null;
/// <summary>Builds the replicated stamp from the current brush state + resolved placement and raises the event.</summary>
private void EmitStamp(Vector3 p, float r, Vector3 u, Vector3 v, Vector3 n)
{
var handler = OnStampCommitted;
@@ -381,7 +381,6 @@ public partial class MeshPainter
return dst;
}
/// <summary>Bilinear blend of four byte samples (rounded, clamped to 0..255).</summary>
private static byte Bilerp(byte c00, byte c10, byte c01, byte c11, float fx, float fy)
{
float top = c00 + (c10 - c00) * fx;
@@ -296,7 +296,7 @@ public partial class MeshPainter
for (int i = 0; i < count; i++)
{
TerrainLayer L = layers[i];
if (L == null) continue;
if (!L) continue;
float w = weights[0, 0, i];
if (w <= 0f) continue;
@@ -437,7 +437,7 @@ public partial class MeshPainter
private static Color SampleTexel(Texture tex, Vector2 uv, bool srgb)
{
Texture2D t2d = tex as Texture2D;
if (t2d != null && t2d.isReadable)
if (t2d && t2d.isReadable)
return t2d.GetPixelBilinear(uv.x, uv.y);
int w = Mathf.Max(1, tex.width), h = Mathf.Max(1, tex.height);
@@ -260,8 +260,8 @@ public partial class MeshPainter
{
_materialInstance.EnableKeyword("_PARALLAXMAP");
_materialInstance.EnableKeyword("_NORMALMAP");
if (GetMatFloat(ParallaxId, 0.02f) < 0.02f)
SetMatFloat(ParallaxId, 0.02f);
if (GetMatFloat(ParallaxId, ParallaxBase) < ParallaxBase)
SetMatFloat(ParallaxId, ParallaxBase);
}
}
@@ -7,16 +7,9 @@ using UnityEngine.InputSystem;
using Random = UnityEngine.Random; // System (for Action) also defines Random -> keep the UnityEngine one
/// <summary>
/// Live mesh painting in Play mode. Three paint maps are driven at once (each toggleable): albedo
/// (_BaseMap), an HDRP-style mask map (R = metallic, G = occlusion, A = smoothness; one texture bound
/// to BOTH _MetallicGlossMap and _OcclusionMap) and emission (_EmissionMap). Two backends, switchable
/// live via <see cref="useGpu"/>: GPU shader painting into RenderTextures (fast, default) and CPU
/// rasterization (identical result). Both paint seamlessly across UV seams because the brush is
/// evaluated in 3D local space around the hit point, capturing triangles on both sides of a seam.
///
/// The brush is a square stamp in the surface tangent plane shaped by a grayscale mask (mask value =
/// per-texel opacity); an empty mask list falls back to a procedural circle (classic round brush).
/// A non-destructive preview (<see cref="previewMode"/>) shows size + mask at the hover point.
/// Live Play-mode mesh painting of albedo, an HDRP-style mask map (metallic/occlusion/smoothness)
/// and emission, with live-switchable GPU/CPU backends (<see cref="useGpu"/>) that paint identically
/// and seamlessly across UV seams: the masked square brush is evaluated in 3D local space at the hit.
/// </summary>
[DisallowMultipleComponent]
public partial class MeshPainter : MonoBehaviour
@@ -727,7 +720,6 @@ public partial class MeshPainter : MonoBehaviour
// --- Brush preview ---
/// <summary>Creates the preview material and the unit quad used by the flat-decal mode.</summary>
private void SetupPreview()
{
if (!previewShader) previewShader = Shader.Find("Hidden/MeshPaintPreview");
@@ -860,7 +852,7 @@ public partial class MeshPainter : MonoBehaviour
return;
// Don't paint through the in-game UI (a HUD click must not also stamp the mesh behind it).
if (pressed && IsPointerOverUi())
if (pressed && InputUtil.PointerOverUi())
pressed = false;
// Brush preview at the hover point - independent of painting AND of the pipette, so the
@@ -946,7 +938,6 @@ public partial class MeshPainter : MonoBehaviour
_hasLastScreen = true;
}
/// <summary>Raycasts at a screen position and stamps the masked square brush onto the mesh hit point.</summary>
private void PaintAtScreen(Vector2 screenPos)
{
if (!TryComputeBrushPlacement(screenPos, out Vector3 pLocal, out float radiusLocal,
@@ -1132,7 +1123,6 @@ public partial class MeshPainter : MonoBehaviour
// --- Channels (shared by both backends) ---
/// <summary>True if at least one paint channel is enabled (used to gate the per-frame stroke).</summary>
private bool AnyChannelActive()
{
for (int mi = 0; mi < MAP_COUNT; mi++)
@@ -1224,9 +1214,6 @@ public partial class MeshPainter : MonoBehaviour
BrushSizeChanged?.Invoke();
}
/// <summary>True if the pointer is currently over an interactive UI element (raycast target).</summary>
private static bool IsPointerOverUi() => InputUtil.PointerOverUi();
private void OnDestroy()
{
if (_bakedMesh && !_baker) Destroy(_bakedMesh); // _baker owns its mesh; only free our own