# V2 Camera Shake

The camera shake layer evaluates deterministic shake events against a base
`FV2CameraModeSpec`. It supports Perlin noise shake, damped spring shake, and
directional impact shake with configurable amplitude, frequency, duration, and
falloff.

## Runtime Surface

- `FV2CameraShakeConfig` configures global amplitude and frequency scales,
  location and rotation clamps, default falloff distance, allowed duration
  bounds, and per-pattern enable flags.
- `FV2CameraShakeState` carries the base camera mode, delta seconds, and global
  time seconds for deterministic evaluation.
- `FV2CameraShakeEvent` carries shake id, pattern, source location, impact
  direction, amplitude, frequency, duration, elapsed time, falloff distance,
  spring damping, looping state, and active state.
- `FV2CameraShakeEvaluation` returns accumulated location and rotation offsets,
  total amplitude, active and completed counts, per-pattern flags, the original
  `BaseModeSpec`, the shaken `ModeSpec`, and validation issues.

## Shake Rules

1. Invalid config, state, or event data is blocking.
2. Inactive events do not contribute offsets.
3. Non-looping events fade by remaining lifetime and report `ShakeExpired` when
   they have completed.
4. Falloff uses event falloff distance when set, otherwise the config default.
5. Perlin noise uses deterministic `FMath::PerlinNoise1D` offsets seeded by
   shake id.
6. Spring shake uses a damped sine response.
7. Directional impact shake pushes along the normalized impact direction.
8. Accumulated offsets are clamped by configured location and rotation limits.

## Camera Manager Export

`EvaluateCameraShake` stores the unmodified base camera in `BaseModeSpec` and
the offset camera in `ModeSpec`. `BuildCameraShakeMode` uses `BaseModeSpec`, so
custom exports do not apply shake offsets twice.

## Validation Commands

Run these targeted checks when touching camera shake:

```bash
python3 V2/ue/Tools/check-v2-camera-shake.py
python3 V2/ue/Tools/check-v2-camera-manager.py
python3 V2/ue/Tools/check-v2-ci-workflow.py
python3 -m json.tool V2/ue/Content/V2/Gameplay/Camera/CameraShake_V2_Contract.json
python3 -m py_compile V2/ue/Tools/check-v2-camera-shake.py
```
