Refactor scripts: dedup remainder, remove dead code, perf hardening
Iteration 4 over Assets/Scripts (no component/file splits, no Unity assets touched): Dedup: - Route inline cursor-release, material guards, Ctrl-held and undo/redo input through existing InputUtil / SetMatFloat helpers - Add ungated InputUtil.KeyPressedThisFrame; GameplayKeyPressed builds on it - Unify FindDeep/FindDeepChild into GeometryUtil.FindDeep Dead code / stale docs: - Remove unused code-gen bake path (HsvColorPicker.Build, PaintHud factory) - Drop unreferenced symbols (SubPhaseChanged event, LocalPhaseDuration, IsLocalSceneMain, MouseSensitivity.Changed, IsPaused, InSession, NetworkControlled, PreviousPose, JointCount, voxel-count accessors) - Fix incorrect PlayerRole / PaintHud / Pick / PlayerPose docs Perf / robustness (behaviour-neutral): - ConcealmentMeter.Evaluate: reuse vertex/topology buffers, two-pointer crossing count - BuildMeshCaches: alloc-free vertex copy, cached topology/UVs - Guard all PlayerPaintSync LogSync sites behind logSync - Cache LocalViewerIsHunter / controller / CanShoot / TypingGuard lookups; dedup LocalIsHunter with MatchHud - Change-guard RefreshEmissionColor and HeroCutout.Disarm - Cache scene/countdown string comparisons per frame - Grow NonAlloc buffers and log-once on saturation Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
2243cc823e
commit
382bfb36df
32 files changed
+292
-348
No files matched your search
@@ -90,25 +90,20 @@ public partial class MeshPainter
|
||||
|
||||
private static bool MapIsLinear(int mi) => mi == MAP_MSO;
|
||||
|
||||
private string[] MapProps(int mi)
|
||||
// Material slots per map, as pre-hashed IDs (this runs per stroke end - no per-call allocations).
|
||||
// MSO: one mask map drives three URP slots: _MetallicGlossMap (R/A) + _OcclusionMap (G) +
|
||||
// _ParallaxMap (G = occlusion reused as a 0.5-centred height for parallax/relief).
|
||||
private static readonly int[][] MapPropIds =
|
||||
{
|
||||
switch (mi)
|
||||
{
|
||||
case MAP_ALBEDO: return new[] { "_BaseMap", "_MainTex" };
|
||||
// One mask map drives three URP slots: _MetallicGlossMap (R/A) + _OcclusionMap (G) +
|
||||
// _ParallaxMap (G = occlusion reused as a 0.5-centred height for parallax/relief).
|
||||
case MAP_MSO: return new[] { "_MetallicGlossMap", "_OcclusionMap", "_ParallaxMap" };
|
||||
default: return new[] { "_EmissionMap" };
|
||||
}
|
||||
}
|
||||
new[] { BaseMapId, MainTexId }, // MAP_ALBEDO
|
||||
new[] { MetallicGlossMapId, OcclusionMapId, ParallaxMapId }, // MAP_MSO
|
||||
new[] { EmissionMapId }, // MAP_EM
|
||||
};
|
||||
|
||||
private void AssignMapTexture(int mi, Texture tex)
|
||||
{
|
||||
if (!_materialInstance) return;
|
||||
foreach (var p in MapProps(mi))
|
||||
{
|
||||
int id = Shader.PropertyToID(p);
|
||||
foreach (int id in MapPropIds[mi])
|
||||
if (_materialInstance.HasProperty(id)) _materialInstance.SetTexture(id, tex);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user