AMFP Enhanced
C++ reference: the code this unofficial fork added
Loading...
Searching...
No Matches
LuxScriptedMotion.h
Go to the documentation of this file.
1/*
2 * AMFP-2026: scaling for camera effects that map scripts trigger (image trail, radial blur,
3 * screen shake, FOV/aspect multiplier, roll), to reduce motion sickness. Pure functions,
4 * unit tested in tests/cpp/test_scripted_motion.cpp.
5 */
6#ifndef LUX_SCRIPTED_MOTION_H
7#define LUX_SCRIPTED_MOTION_H
8
9#include <cstring>
10
12{
16
18};
19
20/** 1 = stock strength, 0 = no effect. Unknown levels fall back to stock. */
21inline float LuxScriptedMotionScale(int alLevel)
22{
23 switch(alLevel)
24 {
25 case eLuxScriptedMotion_Reduced: return 0.35f;
26 case eLuxScriptedMotion_Off: return 0.0f;
27 default: return 1.0f;
28 }
29}
30
31/** Effects whose neutral value is 0 (trail amount, blur size, shake amount, roll angle). */
32inline float LuxScaleEffectAmount(float afAmount, float afScale)
33{
34 return afAmount * afScale;
35}
36
37/** Effects whose neutral value is 1 (FOV and aspect multipliers). */
38inline float LuxScaleEffectMul(float afMul, float afScale)
39{
40 return 1.0f + (afMul - 1.0f) * afScale;
41}
42
43static const char* const gvLuxScriptedMotionNames[eLuxScriptedMotion_LastEnum] = { "Full", "Reduced", "Off" };
44
45inline const char* LuxScriptedMotionToString(int alLevel)
46{
47 if(alLevel < 0 || alLevel >= eLuxScriptedMotion_LastEnum) return gvLuxScriptedMotionNames[0];
48 return gvLuxScriptedMotionNames[alLevel];
49}
50
51inline int LuxScriptedMotionFromString(const char* asX)
52{
53 for(int i = 0; i < eLuxScriptedMotion_LastEnum; ++i)
54 if(asX && std::strcmp(asX, gvLuxScriptedMotionNames[i]) == 0) return i;
56}
57
58#endif
float LuxScriptedMotionScale(int alLevel)
1 = stock strength, 0 = no effect.
static const char *const gvLuxScriptedMotionNames[eLuxScriptedMotion_LastEnum]
float LuxScaleEffectAmount(float afAmount, float afScale)
Effects whose neutral value is 0 (trail amount, blur size, shake amount, roll angle).
eLuxScriptedMotion
@ eLuxScriptedMotion_Full
@ eLuxScriptedMotion_LastEnum
@ eLuxScriptedMotion_Off
@ eLuxScriptedMotion_Reduced
int LuxScriptedMotionFromString(const char *asX)
float LuxScaleEffectMul(float afMul, float afScale)
Effects whose neutral value is 1 (FOV and aspect multipliers).
const char * LuxScriptedMotionToString(int alLevel)