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
@@ -53,12 +53,7 @@ public class FirstPersonController : MonoBehaviour
|
||||
CinemachineCamera _vcam;
|
||||
PlayerCharacterController _player; // body whose yaw we pin to the camera while active
|
||||
PlayerPoseController _poseController; // supplies the active pose's per-pose first-person eye offset
|
||||
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 the freecam
|
||||
bool _resolved;
|
||||
|
||||
void Awake()
|
||||
@@ -89,7 +84,7 @@ public class FirstPersonController : MonoBehaviour
|
||||
SyncToCurrentView();
|
||||
InputUtil.SetCursorLocked(true);
|
||||
ApplyTransform(); // place at the eye on the same frame so the blend starts from there
|
||||
if (_player) _player.FaceYaw = _displayYaw; // body faces the camera from frame one
|
||||
if (_player) _player.FaceYaw = _look.DisplayYaw; // body faces the camera from frame one
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -105,32 +100,18 @@ public class FirstPersonController : MonoBehaviour
|
||||
// LateUpdate so the player has already moved the CameraTarget this frame.
|
||||
LookTick();
|
||||
ApplyTransform();
|
||||
if (_player) _player.FaceYaw = _displayYaw; // keep the body's yaw locked to the camera
|
||||
if (_player) _player.FaceYaw = _look.DisplayYaw; // keep the body's yaw locked to the camera
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void ApplyTransform()
|
||||
{
|
||||
Quaternion rot = Quaternion.Euler(_displayPitch, _displayYaw, 0f);
|
||||
Quaternion rot = _look.Rotation;
|
||||
if (cameraTarget)
|
||||
{
|
||||
// Sit at the first-person eye anchor, then raise/lower the eye by the active pose's first-person
|
||||
@@ -151,18 +132,9 @@ public class FirstPersonController : MonoBehaviour
|
||||
{
|
||||
var cam = Camera.main;
|
||||
if (cam)
|
||||
{
|
||||
Vector3 e = cam.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 never lags/jumps to catch up.
|
||||
_displayYaw = _yaw;
|
||||
_displayPitch = _pitch;
|
||||
_yawSmoothRef = 0f;
|
||||
_pitchSmoothRef = 0f;
|
||||
_look.SyncTo(cam.transform.rotation, maxPitch);
|
||||
else
|
||||
_look.Snap(); // no camera: keep the current angles but still snap the smoothed state
|
||||
}
|
||||
|
||||
void SetMeshHidden(bool hidden)
|
||||
|
||||
Reference in new issue
Block a user