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
@@ -57,12 +57,7 @@ public class FreeCamController : MonoBehaviour
|
||||
|
||||
CharacterController _controller;
|
||||
CinemachineCamera _vcam;
|
||||
float _yaw; // look target (raw input accumulates here)
|
||||
float _pitch;
|
||||
float _displayYaw; // smoothed value actually applied to the transform
|
||||
float _displayPitch;
|
||||
float _yawSmoothRef;
|
||||
float _pitchSmoothRef;
|
||||
SmoothedLook _look; // yaw/pitch accumulator + smoothing shared with first person
|
||||
Vector3 _moveVelocity; // smoothed world-space flight velocity
|
||||
Vector3 _moveVelocityRef;
|
||||
bool _ignoredPlayer;
|
||||
@@ -110,24 +105,10 @@ public class FreeCamController : MonoBehaviour
|
||||
void LookTick()
|
||||
{
|
||||
Vector2 delta = InputUtil.ReadMouseDelta() * MouseSensitivity.Multiplier;
|
||||
_yaw += delta.x * horizontalSensitivity;
|
||||
float vs = verticalSensitivity * (invertY ? 1f : -1f);
|
||||
_pitch = Mathf.Clamp(_pitch + delta.y * vs, -maxPitch, maxPitch);
|
||||
|
||||
if (lookSmoothTime > 0f)
|
||||
{
|
||||
// SmoothDampAngle is frame-rate-independent and wraps yaw correctly.
|
||||
_displayYaw = Mathf.SmoothDampAngle(_displayYaw, _yaw, ref _yawSmoothRef, lookSmoothTime);
|
||||
_displayPitch = Mathf.SmoothDampAngle(_displayPitch, _pitch, ref _pitchSmoothRef, lookSmoothTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
_displayYaw = _yaw;
|
||||
_displayPitch = _pitch;
|
||||
}
|
||||
_look.Tick(delta, horizontalSensitivity, verticalSensitivity, invertY, maxPitch, lookSmoothTime);
|
||||
|
||||
// Rotation is unconstrained by the CharacterController; only position is.
|
||||
transform.rotation = Quaternion.Euler(_displayPitch, _displayYaw, 0f);
|
||||
transform.rotation = _look.Rotation;
|
||||
}
|
||||
|
||||
void MoveTick()
|
||||
@@ -153,22 +134,9 @@ public class FreeCamController : MonoBehaviour
|
||||
var cam = Camera.main;
|
||||
if (!cam) return;
|
||||
|
||||
// CharacterController forbids direct transform writes while enabled, so toggle it for the teleport.
|
||||
bool wasEnabled = _controller.enabled;
|
||||
_controller.enabled = false;
|
||||
transform.SetPositionAndRotation(cam.transform.position, cam.transform.rotation);
|
||||
_controller.enabled = wasEnabled;
|
||||
CharacterTeleport.Move(_controller, transform, cam.transform.position, cam.transform.rotation);
|
||||
|
||||
Vector3 e = transform.rotation.eulerAngles;
|
||||
_yaw = e.y;
|
||||
float p = e.x > 180f ? e.x - 360f : e.x;
|
||||
_pitch = Mathf.Clamp(p, -maxPitch, maxPitch);
|
||||
|
||||
// Snap the smoothed state to the fresh pose so entering freecam never lags/jumps to catch up.
|
||||
_displayYaw = _yaw;
|
||||
_displayPitch = _pitch;
|
||||
_yawSmoothRef = 0f;
|
||||
_pitchSmoothRef = 0f;
|
||||
_look.SyncTo(transform.rotation, maxPitch);
|
||||
_moveVelocity = Vector3.zero;
|
||||
_moveVelocityRef = Vector3.zero;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user