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:
1 parent
066e308cde
commit
2243cc823e
40 files changed
+681
-724
No files matched your search
@@ -0,0 +1,43 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>Shared mesh/bounds geometry helpers.</summary>
|
||||
public static class GeometryUtil
|
||||
{
|
||||
/// <summary>Divides a world scale back out of a freshly baked mesh so it is true unit-scale local
|
||||
/// geometry (BakeMesh freezes the transform's lossyScale into the vertices). No-op at scale 1;
|
||||
/// <paramref name="scratch"/> is reused so nothing is allocated per bake.</summary>
|
||||
public static void RescaleToUnitScale(Mesh baked, Vector3 lossyScale, List<Vector3> scratch)
|
||||
{
|
||||
if (lossyScale.x == 1f && lossyScale.y == 1f && lossyScale.z == 1f) return;
|
||||
|
||||
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(scratch);
|
||||
for (int i = 0; i < scratch.Count; i++)
|
||||
{
|
||||
Vector3 v = scratch[i];
|
||||
v.x *= ix; v.y *= iy; v.z *= iz;
|
||||
scratch[i] = v;
|
||||
}
|
||||
baked.SetVertices(scratch);
|
||||
baked.RecalculateBounds();
|
||||
}
|
||||
|
||||
/// <summary>World AABB enclosing a local AABB after an affine transform (encapsulates the 8 transformed corners).</summary>
|
||||
public 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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user