AMFP Enhanced
C++ reference: the code this unofficial fork added
Loading...
Searching...
No Matches
LuxComfortCam.h
Go to the documentation of this file.
1/*
2 * AMFP-2026: comfort pass, camera side (PLAN.md "Comfort pass", rows 1d, 1e, 2, 4, 5, 6, 8d).
3 * Pure helpers on top of LuxComfort.h, unit tested in tests/cpp/test_comfort_cam.cpp.
4 * Every helper is the identity at Original values (multiplier 1, FOV 70), so the stock game is
5 * untouched; callers still guard with "if(mul < 1)" so stock floats never pass through them.
6 */
7#ifndef LUX_COMFORT_CAM_H
8#define LUX_COMFORT_CAM_H
9
10#include "LuxComfort.h"
11#include <cmath>
12
13/** Base vertical FOV in radians. 70 (the slider's vanilla value) means "whatever game.cfg says"
14 * (stock: 70), so Original keeps the exact stock float; any other choice is used as given.
15 * The aspect stays width / height, so a wider screen widens the view (Hor+). */
16inline float LuxComfortBaseFovRad(float afStockFovRad, float afComfortFovDeg)
17{
18 if(afComfortFovDeg == kLuxVanillaFov) return afStockFovRad;
19 return afComfortFovDeg * 3.14159265f / 180.0f;
20}
21
22/** Factor (<= 1) that brings a 2D angular speed (rad/s, pitch and yaw) under the forced turn cap.
23 * The direction is kept, so a capped turn still heads straight at its target. 0 cap = 1. */
24inline float LuxComfortTurnSpeedScale(float afSpeedX, float afSpeedY, float afCapDeg)
25{
26 if(afCapDeg <= 0) return 1.0f;
27 float fLen = std::sqrt(afSpeedX * afSpeedX + afSpeedY * afSpeedY);
28 if(fLen <= 0) return 1.0f;
29 // The step over one second is the speed; LuxComfortLimitStep caps it to the cap.
30 float fLimited = LuxComfortLimitStep(fLen, 1.0f, afCapDeg);
31 return fLimited / fLen;
32}
33
34/** Scripted head moves (MovePlayerHeadPos) in m/s, proportional to the turn cap:
35 * Comfort (52.5 deg/s) -> 1 m/s, Reduced (105 deg/s) -> 2 m/s. 0 = no cap (vanilla). */
36inline float LuxComfortHeadMoveCap(float afTurnSpeed)
37{
38 float fCapDeg = LuxComfortTurnCapDeg(afTurnSpeed);
39 if(fCapDeg <= 0) return 0;
40 return fCapDeg / 52.5f;
41}
42
43/** Wrapped yaw / pitch change between two frames, in deg/s (for the dev bridge trace). */
44inline float LuxComfortAngularSpeedDeg(float afPrevPitch, float afPrevYaw, float afPitch, float afYaw, float afTimeStep)
45{
46 if(afTimeStep <= 0) return 0;
47 const float kPi = 3.14159265f;
48 float fDYaw = std::fmod(afYaw - afPrevYaw, 2 * kPi);
49 if(fDYaw > kPi) fDYaw -= 2 * kPi;
50 if(fDYaw < -kPi) fDYaw += 2 * kPi;
51 float fDPitch = afPitch - afPrevPitch;
52 return std::sqrt(fDYaw * fDYaw + fDPitch * fDPitch) / afTimeStep * 180.0f / kPi;
53}
54
55// Full-strength amounts that a removed share is measured against (drives the edge darkening).
56static const float kLuxCueFullRollRad = 0.35f; // about 20 degrees of tilt
57static const float kLuxCueFullFovMul = 0.25f; // a 25 % zoom pulse
58
59#endif
the comfort pass (PLAN.md "Comfort pass").
static const float kLuxVanillaFov
Definition LuxComfort.h:43
float LuxComfortLimitStep(float afStepRad, float afTimeStep, float afCapDeg)
Limit one frame's angle step (radians) to the cap; 0 cap = untouched.
Definition LuxComfort.h:145
float LuxComfortTurnCapDeg(float afTurnSpeed)
Forced turn cap in degrees per second, or 0 for no cap (vanilla).
Definition LuxComfort.h:138
float LuxComfortAngularSpeedDeg(float afPrevPitch, float afPrevYaw, float afPitch, float afYaw, float afTimeStep)
Wrapped yaw / pitch change between two frames, in deg/s (for the dev bridge trace).
static const float kLuxCueFullFovMul
static const float kLuxCueFullRollRad
float LuxComfortHeadMoveCap(float afTurnSpeed)
Scripted head moves (MovePlayerHeadPos) in m/s, proportional to the turn cap: Comfort (52....
float LuxComfortBaseFovRad(float afStockFovRad, float afComfortFovDeg)
Base vertical FOV in radians.
float LuxComfortTurnSpeedScale(float afSpeedX, float afSpeedY, float afCapDeg)
Factor (<= 1) that brings a 2D angular speed (rad/s, pitch and yaw) under the forced turn cap.