diff options
author | Chris Robinson <[email protected]> | 2022-03-10 17:47:42 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2022-03-10 17:47:42 -0800 |
commit | 609ee742115aa10139d5e4c3f8915306751c227f (patch) | |
tree | ca4996cb505b7c74e6747680257151d95c0d0a9b | |
parent | cfae2cc254037fab1acb290d133625b4f6e1d710 (diff) |
Add a config option for reverse-z
The same as the __ALSOFT_REVERSE_Z env var, but in the config file. Should only
be used for per-game config files (either along side the executable, or setting
the ALSOFT_CONF env var when launching the app).
-rw-r--r-- | alc/alc.cpp | 12 | ||||
-rw-r--r-- | alc/alu.cpp | 26 | ||||
-rw-r--r-- | alc/alu.h | 15 | ||||
-rw-r--r-- | alsoftrc.sample | 13 |
4 files changed, 41 insertions, 25 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp index 90da2614..4ba47aea 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -1120,7 +1120,17 @@ void alc_initconfig(void) if(auto limopt = ConfigValueBool(nullptr, nullptr, "rt-time-limit")) AllowRTTimeLimit = *limopt; - aluInit(); + CompatFlagBitset compatflags{}; + if(auto optval = al::getenv("__ALSOFT_REVERSE_Z")) + { + if(al::strcasecmp(optval->c_str(), "true") == 0 + || strtol(optval->c_str(), nullptr, 0) == 1) + compatflags.set(CompatFlags::ReverseZ); + } + else if(GetConfigValueBool(nullptr, "game_compat", "reverse-z", false)) + compatflags.set(CompatFlags::ReverseZ); + + aluInit(compatflags); Voice::InitMixer(ConfigValueStr(nullptr, nullptr, "resampler")); auto traperr = al::getenv("ALSOFT_TRAP_ERROR"); diff --git a/alc/alu.cpp b/alc/alu.cpp index 67727bd5..203fd9b6 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -125,26 +125,15 @@ float InitConeScale() } return ret; } - -float InitZScale() -{ - float ret{1.0f}; - if(auto optval = al::getenv("__ALSOFT_REVERSE_Z")) - { - if(al::strcasecmp(optval->c_str(), "true") == 0 - || strtol(optval->c_str(), nullptr, 0) == 1) - ret *= -1.0f; - } - return ret; -} - -} // namespace - /* Cone scalar */ const float ConeScale{InitConeScale()}; -/* Localized Z scalar for mono sources */ -const float ZScale{InitZScale()}; +/* Localized Z scalar for mono sources (initialized in aluInit, after + * configuration is loaded). + */ +float ZScale{1.0f}; + +} // namespace namespace { @@ -253,9 +242,10 @@ inline ResamplerFunc SelectResampler(Resampler resampler, uint increment) } // namespace -void aluInit(void) +void aluInit(CompatFlagBitset flags) { MixDirectHrtf = SelectHrtfMixer(); + ZScale = flags.test(CompatFlags::ReverseZ) ? -1.0f : 1.0f; } @@ -1,6 +1,8 @@ #ifndef ALU_H #define ALU_H +#include <bitset> + #include "aloptional.h" struct ALCcontext; @@ -13,7 +15,14 @@ enum class StereoEncoding : unsigned char; constexpr float GainMixMax{1000.0f}; /* +60dB */ -void aluInit(void); +enum CompatFlags : uint8_t { + ReverseZ, + + Count +}; +using CompatFlagBitset = std::bitset<CompatFlags::Count>; + +void aluInit(CompatFlagBitset flags); /* aluInitRenderer * @@ -24,8 +33,4 @@ void aluInitRenderer(ALCdevice *device, int hrtf_id, al::optional<StereoEncoding void aluInitEffectPanning(EffectSlot *slot, ALCcontext *context); - -extern const float ConeScale; -extern const float ZScale; - #endif diff --git a/alsoftrc.sample b/alsoftrc.sample index ab0345d9..eebd3de7 100644 --- a/alsoftrc.sample +++ b/alsoftrc.sample @@ -583,6 +583,17 @@ ## EAX extensions stuff ## [eax] -##enable: + +## enable: (global) # Sets whether to enable EAX extensions or not. #enable = true + +## +## Per-game compatibility options (these should only be set in per-game config +## files, *NOT* system- or user-level!) +## +[game_compat] + +## reverse-z: (global) +# Reverses the local Z (front-back) position of 3D sound sources. +#reverse-z = false |