Smooth free-camera flight and look
FreeCamController: ease movement via dt-correct Vector3.SmoothDamp on a world-space velocity (accel/decel ramp) and lag the look with Mathf.SmoothDampAngle. Both are framerate-independent and collapse to instant at smoothTime 0; smoothed state is snapped on activation (SyncToCurrentView) so entering freecam never jumps to catch up. Bundles accumulated deferred work: PlayerScaler uniform-scale helper, scale-aware wall/ceiling climb probes and the double-scale skinned-collider bake fix, plus user content authoring (Sit pose + animation, font SDF, scene/prefab edits). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
f66ebbf10a
commit
8c89e95014
14 files changed
+12083
-360
No files matched your search
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
@@ -30,6 +31,7 @@ public class SkinnedColliderBaker : MonoBehaviour
|
||||
private MeshCollider _collider;
|
||||
private Mesh _baked;
|
||||
private float _timer;
|
||||
private readonly List<Vector3> _vbuf = new List<Vector3>(); // reused vertex scratch so the scale fixup allocates nothing per bake
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -62,10 +64,39 @@ public class SkinnedColliderBaker : MonoBehaviour
|
||||
{
|
||||
if (!_skinned) return;
|
||||
_skinned.BakeMesh(_baked);
|
||||
|
||||
// BakeMesh freezes the bone deformation — which already carries this transform's world scale —
|
||||
// into the mesh. The MeshCollider below then applies the same lossyScale a SECOND time, so a
|
||||
// scaled player (see PlayerScaler) would get a collider half/double the size of the visible
|
||||
// mesh. Divide the scale back out so the baked mesh is true scale-1 local geometry (the contract
|
||||
// this class already documents): the MeshCollider re-applies it exactly once (matching the
|
||||
// renderer), and MeshPainter / ConcealmentMeter — which raise the baked mesh to world via
|
||||
// localToWorldMatrix — stay correct at any player scale. No-op (and untouched) at scale 1; the
|
||||
// uniform divide is rotation-independent, which the player's uniform scale guarantees.
|
||||
Vector3 ls = transform.lossyScale;
|
||||
if (ls.x != 1f || ls.y != 1f || ls.z != 1f)
|
||||
RescaleToUnitScale(ls);
|
||||
|
||||
_collider.sharedMesh = null; // force a physics re-cook of the new geometry
|
||||
_collider.sharedMesh = _baked;
|
||||
}
|
||||
|
||||
private void RescaleToUnitScale(Vector3 lossyScale)
|
||||
{
|
||||
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(_vbuf);
|
||||
for (int i = 0; i < _vbuf.Count; i++)
|
||||
{
|
||||
Vector3 v = _vbuf[i];
|
||||
v.x *= ix; v.y *= iy; v.z *= iz;
|
||||
_vbuf[i] = v;
|
||||
}
|
||||
_baked.SetVertices(_vbuf);
|
||||
_baked.RecalculateBounds();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (_baked) Destroy(_baked);
|
||||
|
||||
Reference in new issue
Block a user