mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
* BugFix: Correct convexDecomp compilation by setting the LINUX flag when necessary.
* BugFix: Update OpenAL to correct a compilation error on Linux.
This commit is contained in:
parent
e071f1d901
commit
7380161054
234 changed files with 30864 additions and 7523 deletions
|
|
@ -1,12 +1,23 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "AL/efx.h"
|
||||
|
||||
#include "alc/effects/base.h"
|
||||
#include "aloptional.h"
|
||||
#include "effects.h"
|
||||
#include "effects/base.h"
|
||||
|
||||
#ifdef ALSOFT_EAX
|
||||
#include <cassert>
|
||||
|
||||
#include "alnumeric.h"
|
||||
|
||||
#include "al/eax_exception.h"
|
||||
#include "al/eax_utils.h"
|
||||
#endif // ALSOFT_EAX
|
||||
|
||||
|
||||
namespace {
|
||||
|
|
@ -126,3 +137,343 @@ EffectProps genDefaultProps() noexcept
|
|||
DEFINE_ALEFFECT_VTABLE(Fshifter);
|
||||
|
||||
const EffectProps FshifterEffectProps{genDefaultProps()};
|
||||
|
||||
#ifdef ALSOFT_EAX
|
||||
namespace {
|
||||
|
||||
using EaxFrequencyShifterEffectDirtyFlagsValue = std::uint_least8_t;
|
||||
|
||||
struct EaxFrequencyShifterEffectDirtyFlags
|
||||
{
|
||||
using EaxIsBitFieldStruct = bool;
|
||||
|
||||
EaxFrequencyShifterEffectDirtyFlagsValue flFrequency : 1;
|
||||
EaxFrequencyShifterEffectDirtyFlagsValue ulLeftDirection : 1;
|
||||
EaxFrequencyShifterEffectDirtyFlagsValue ulRightDirection : 1;
|
||||
}; // EaxFrequencyShifterEffectDirtyFlags
|
||||
|
||||
|
||||
class EaxFrequencyShifterEffect final :
|
||||
public EaxEffect
|
||||
{
|
||||
public:
|
||||
EaxFrequencyShifterEffect();
|
||||
|
||||
void dispatch(const EaxEaxCall& eax_call) override;
|
||||
|
||||
// [[nodiscard]]
|
||||
bool apply_deferred() override;
|
||||
|
||||
private:
|
||||
EAXFREQUENCYSHIFTERPROPERTIES eax_{};
|
||||
EAXFREQUENCYSHIFTERPROPERTIES eax_d_{};
|
||||
EaxFrequencyShifterEffectDirtyFlags eax_dirty_flags_{};
|
||||
|
||||
void set_eax_defaults();
|
||||
|
||||
void set_efx_frequency();
|
||||
void set_efx_left_direction();
|
||||
void set_efx_right_direction();
|
||||
void set_efx_defaults();
|
||||
|
||||
void get(const EaxEaxCall& eax_call);
|
||||
|
||||
void validate_frequency(float flFrequency);
|
||||
void validate_left_direction(unsigned long ulLeftDirection);
|
||||
void validate_right_direction(unsigned long ulRightDirection);
|
||||
void validate_all(const EAXFREQUENCYSHIFTERPROPERTIES& all);
|
||||
|
||||
void defer_frequency(float flFrequency);
|
||||
void defer_left_direction(unsigned long ulLeftDirection);
|
||||
void defer_right_direction(unsigned long ulRightDirection);
|
||||
void defer_all(const EAXFREQUENCYSHIFTERPROPERTIES& all);
|
||||
|
||||
void defer_frequency(const EaxEaxCall& eax_call);
|
||||
void defer_left_direction(const EaxEaxCall& eax_call);
|
||||
void defer_right_direction(const EaxEaxCall& eax_call);
|
||||
void defer_all(const EaxEaxCall& eax_call);
|
||||
|
||||
void set(const EaxEaxCall& eax_call);
|
||||
}; // EaxFrequencyShifterEffect
|
||||
|
||||
|
||||
class EaxFrequencyShifterEffectException :
|
||||
public EaxException
|
||||
{
|
||||
public:
|
||||
explicit EaxFrequencyShifterEffectException(
|
||||
const char* message)
|
||||
:
|
||||
EaxException{"EAX_FREQUENCY_SHIFTER_EFFECT", message}
|
||||
{
|
||||
}
|
||||
}; // EaxFrequencyShifterEffectException
|
||||
|
||||
|
||||
EaxFrequencyShifterEffect::EaxFrequencyShifterEffect()
|
||||
: EaxEffect{AL_EFFECT_FREQUENCY_SHIFTER}
|
||||
{
|
||||
set_eax_defaults();
|
||||
set_efx_defaults();
|
||||
}
|
||||
|
||||
void EaxFrequencyShifterEffect::dispatch(const EaxEaxCall& eax_call)
|
||||
{
|
||||
eax_call.is_get() ? get(eax_call) : set(eax_call);
|
||||
}
|
||||
|
||||
void EaxFrequencyShifterEffect::set_eax_defaults()
|
||||
{
|
||||
eax_.flFrequency = EAXFREQUENCYSHIFTER_DEFAULTFREQUENCY;
|
||||
eax_.ulLeftDirection = EAXFREQUENCYSHIFTER_DEFAULTLEFTDIRECTION;
|
||||
eax_.ulRightDirection = EAXFREQUENCYSHIFTER_DEFAULTRIGHTDIRECTION;
|
||||
|
||||
eax_d_ = eax_;
|
||||
}
|
||||
|
||||
void EaxFrequencyShifterEffect::set_efx_frequency()
|
||||
{
|
||||
const auto frequency = clamp(
|
||||
eax_.flFrequency,
|
||||
AL_FREQUENCY_SHIFTER_MIN_FREQUENCY,
|
||||
AL_FREQUENCY_SHIFTER_MAX_FREQUENCY);
|
||||
|
||||
al_effect_props_.Fshifter.Frequency = frequency;
|
||||
}
|
||||
|
||||
void EaxFrequencyShifterEffect::set_efx_left_direction()
|
||||
{
|
||||
const auto left_direction = clamp(
|
||||
static_cast<ALint>(eax_.ulLeftDirection),
|
||||
AL_FREQUENCY_SHIFTER_MIN_LEFT_DIRECTION,
|
||||
AL_FREQUENCY_SHIFTER_MAX_LEFT_DIRECTION);
|
||||
|
||||
const auto efx_left_direction = DirectionFromEmum(left_direction);
|
||||
assert(efx_left_direction.has_value());
|
||||
al_effect_props_.Fshifter.LeftDirection = *efx_left_direction;
|
||||
}
|
||||
|
||||
void EaxFrequencyShifterEffect::set_efx_right_direction()
|
||||
{
|
||||
const auto right_direction = clamp(
|
||||
static_cast<ALint>(eax_.ulRightDirection),
|
||||
AL_FREQUENCY_SHIFTER_MIN_RIGHT_DIRECTION,
|
||||
AL_FREQUENCY_SHIFTER_MAX_RIGHT_DIRECTION);
|
||||
|
||||
const auto efx_right_direction = DirectionFromEmum(right_direction);
|
||||
assert(efx_right_direction.has_value());
|
||||
al_effect_props_.Fshifter.RightDirection = *efx_right_direction;
|
||||
}
|
||||
|
||||
void EaxFrequencyShifterEffect::set_efx_defaults()
|
||||
{
|
||||
set_efx_frequency();
|
||||
set_efx_left_direction();
|
||||
set_efx_right_direction();
|
||||
}
|
||||
|
||||
void EaxFrequencyShifterEffect::get(const EaxEaxCall& eax_call)
|
||||
{
|
||||
switch(eax_call.get_property_id())
|
||||
{
|
||||
case EAXFREQUENCYSHIFTER_NONE:
|
||||
break;
|
||||
|
||||
case EAXFREQUENCYSHIFTER_ALLPARAMETERS:
|
||||
eax_call.set_value<EaxFrequencyShifterEffectException>(eax_);
|
||||
break;
|
||||
|
||||
case EAXFREQUENCYSHIFTER_FREQUENCY:
|
||||
eax_call.set_value<EaxFrequencyShifterEffectException>(eax_.flFrequency);
|
||||
break;
|
||||
|
||||
case EAXFREQUENCYSHIFTER_LEFTDIRECTION:
|
||||
eax_call.set_value<EaxFrequencyShifterEffectException>(eax_.ulLeftDirection);
|
||||
break;
|
||||
|
||||
case EAXFREQUENCYSHIFTER_RIGHTDIRECTION:
|
||||
eax_call.set_value<EaxFrequencyShifterEffectException>(eax_.ulRightDirection);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw EaxFrequencyShifterEffectException{"Unsupported property id."};
|
||||
}
|
||||
}
|
||||
|
||||
void EaxFrequencyShifterEffect::validate_frequency(
|
||||
float flFrequency)
|
||||
{
|
||||
eax_validate_range<EaxFrequencyShifterEffectException>(
|
||||
"Frequency",
|
||||
flFrequency,
|
||||
EAXFREQUENCYSHIFTER_MINFREQUENCY,
|
||||
EAXFREQUENCYSHIFTER_MAXFREQUENCY);
|
||||
}
|
||||
|
||||
void EaxFrequencyShifterEffect::validate_left_direction(
|
||||
unsigned long ulLeftDirection)
|
||||
{
|
||||
eax_validate_range<EaxFrequencyShifterEffectException>(
|
||||
"Left Direction",
|
||||
ulLeftDirection,
|
||||
EAXFREQUENCYSHIFTER_MINLEFTDIRECTION,
|
||||
EAXFREQUENCYSHIFTER_MAXLEFTDIRECTION);
|
||||
}
|
||||
|
||||
void EaxFrequencyShifterEffect::validate_right_direction(
|
||||
unsigned long ulRightDirection)
|
||||
{
|
||||
eax_validate_range<EaxFrequencyShifterEffectException>(
|
||||
"Right Direction",
|
||||
ulRightDirection,
|
||||
EAXFREQUENCYSHIFTER_MINRIGHTDIRECTION,
|
||||
EAXFREQUENCYSHIFTER_MAXRIGHTDIRECTION);
|
||||
}
|
||||
|
||||
void EaxFrequencyShifterEffect::validate_all(
|
||||
const EAXFREQUENCYSHIFTERPROPERTIES& all)
|
||||
{
|
||||
validate_frequency(all.flFrequency);
|
||||
validate_left_direction(all.ulLeftDirection);
|
||||
validate_right_direction(all.ulRightDirection);
|
||||
}
|
||||
|
||||
void EaxFrequencyShifterEffect::defer_frequency(
|
||||
float flFrequency)
|
||||
{
|
||||
eax_d_.flFrequency = flFrequency;
|
||||
eax_dirty_flags_.flFrequency = (eax_.flFrequency != eax_d_.flFrequency);
|
||||
}
|
||||
|
||||
void EaxFrequencyShifterEffect::defer_left_direction(
|
||||
unsigned long ulLeftDirection)
|
||||
{
|
||||
eax_d_.ulLeftDirection = ulLeftDirection;
|
||||
eax_dirty_flags_.ulLeftDirection = (eax_.ulLeftDirection != eax_d_.ulLeftDirection);
|
||||
}
|
||||
|
||||
void EaxFrequencyShifterEffect::defer_right_direction(
|
||||
unsigned long ulRightDirection)
|
||||
{
|
||||
eax_d_.ulRightDirection = ulRightDirection;
|
||||
eax_dirty_flags_.ulRightDirection = (eax_.ulRightDirection != eax_d_.ulRightDirection);
|
||||
}
|
||||
|
||||
void EaxFrequencyShifterEffect::defer_all(
|
||||
const EAXFREQUENCYSHIFTERPROPERTIES& all)
|
||||
{
|
||||
defer_frequency(all.flFrequency);
|
||||
defer_left_direction(all.ulLeftDirection);
|
||||
defer_right_direction(all.ulRightDirection);
|
||||
}
|
||||
|
||||
void EaxFrequencyShifterEffect::defer_frequency(
|
||||
const EaxEaxCall& eax_call)
|
||||
{
|
||||
const auto& frequency =
|
||||
eax_call.get_value<
|
||||
EaxFrequencyShifterEffectException, const decltype(EAXFREQUENCYSHIFTERPROPERTIES::flFrequency)>();
|
||||
|
||||
validate_frequency(frequency);
|
||||
defer_frequency(frequency);
|
||||
}
|
||||
|
||||
void EaxFrequencyShifterEffect::defer_left_direction(
|
||||
const EaxEaxCall& eax_call)
|
||||
{
|
||||
const auto& left_direction =
|
||||
eax_call.get_value<
|
||||
EaxFrequencyShifterEffectException, const decltype(EAXFREQUENCYSHIFTERPROPERTIES::ulLeftDirection)>();
|
||||
|
||||
validate_left_direction(left_direction);
|
||||
defer_left_direction(left_direction);
|
||||
}
|
||||
|
||||
void EaxFrequencyShifterEffect::defer_right_direction(
|
||||
const EaxEaxCall& eax_call)
|
||||
{
|
||||
const auto& right_direction =
|
||||
eax_call.get_value<
|
||||
EaxFrequencyShifterEffectException, const decltype(EAXFREQUENCYSHIFTERPROPERTIES::ulRightDirection)>();
|
||||
|
||||
validate_right_direction(right_direction);
|
||||
defer_right_direction(right_direction);
|
||||
}
|
||||
|
||||
void EaxFrequencyShifterEffect::defer_all(
|
||||
const EaxEaxCall& eax_call)
|
||||
{
|
||||
const auto& all =
|
||||
eax_call.get_value<
|
||||
EaxFrequencyShifterEffectException, const EAXFREQUENCYSHIFTERPROPERTIES>();
|
||||
|
||||
validate_all(all);
|
||||
defer_all(all);
|
||||
}
|
||||
|
||||
// [[nodiscard]]
|
||||
bool EaxFrequencyShifterEffect::apply_deferred()
|
||||
{
|
||||
if (eax_dirty_flags_ == EaxFrequencyShifterEffectDirtyFlags{})
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
eax_ = eax_d_;
|
||||
|
||||
if (eax_dirty_flags_.flFrequency)
|
||||
{
|
||||
set_efx_frequency();
|
||||
}
|
||||
|
||||
if (eax_dirty_flags_.ulLeftDirection)
|
||||
{
|
||||
set_efx_left_direction();
|
||||
}
|
||||
|
||||
if (eax_dirty_flags_.ulRightDirection)
|
||||
{
|
||||
set_efx_right_direction();
|
||||
}
|
||||
|
||||
eax_dirty_flags_ = EaxFrequencyShifterEffectDirtyFlags{};
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void EaxFrequencyShifterEffect::set(const EaxEaxCall& eax_call)
|
||||
{
|
||||
switch(eax_call.get_property_id())
|
||||
{
|
||||
case EAXFREQUENCYSHIFTER_NONE:
|
||||
break;
|
||||
|
||||
case EAXFREQUENCYSHIFTER_ALLPARAMETERS:
|
||||
defer_all(eax_call);
|
||||
break;
|
||||
|
||||
case EAXFREQUENCYSHIFTER_FREQUENCY:
|
||||
defer_frequency(eax_call);
|
||||
break;
|
||||
|
||||
case EAXFREQUENCYSHIFTER_LEFTDIRECTION:
|
||||
defer_left_direction(eax_call);
|
||||
break;
|
||||
|
||||
case EAXFREQUENCYSHIFTER_RIGHTDIRECTION:
|
||||
defer_right_direction(eax_call);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw EaxFrequencyShifterEffectException{"Unsupported property id."};
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
EaxEffectUPtr eax_create_eax_frequency_shifter_effect()
|
||||
{
|
||||
return std::make_unique<EaxFrequencyShifterEffect>();
|
||||
}
|
||||
|
||||
#endif // ALSOFT_EAX
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue