diff options
author | Chris Robinson <[email protected]> | 2020-03-23 15:04:26 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-03-23 15:04:26 -0700 |
commit | b53294e291c0e00b94639527ae84d03037029f1a (patch) | |
tree | 70e6851b61e771aa8cbb65b6d8b2f20daae920cf | |
parent | 5d0f90fed0bd9f6516d5b0ce94fa6d58057c2e48 (diff) |
Use inline initialization more for sources
-rw-r--r-- | al/source.cpp | 45 | ||||
-rw-r--r-- | al/source.h | 90 |
2 files changed, 46 insertions, 89 deletions
diff --git a/al/source.cpp b/al/source.cpp index 4099f9ea..63397ec8 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -3347,51 +3347,6 @@ END_API_FUNC ALsource::ALsource() { - InnerAngle = 360.0f; - OuterAngle = 360.0f; - Pitch = 1.0f; - Position[0] = 0.0f; - Position[1] = 0.0f; - Position[2] = 0.0f; - Velocity[0] = 0.0f; - Velocity[1] = 0.0f; - Velocity[2] = 0.0f; - Direction[0] = 0.0f; - Direction[1] = 0.0f; - Direction[2] = 0.0f; - OrientAt[0] = 0.0f; - OrientAt[1] = 0.0f; - OrientAt[2] = -1.0f; - OrientUp[0] = 0.0f; - OrientUp[1] = 1.0f; - OrientUp[2] = 0.0f; - RefDistance = 1.0f; - MaxDistance = std::numeric_limits<float>::max(); - RolloffFactor = 1.0f; - Gain = 1.0f; - MinGain = 0.0f; - MaxGain = 1.0f; - OuterGain = 0.0f; - OuterGainHF = 1.0f; - - DryGainHFAuto = AL_TRUE; - WetGainAuto = AL_TRUE; - WetGainHFAuto = AL_TRUE; - AirAbsorptionFactor = 0.0f; - RoomRolloffFactor = 0.0f; - DopplerFactor = 1.0f; - HeadRelative = AL_FALSE; - Looping = AL_FALSE; - mDistanceModel = DistanceModel::Default; - mResampler = ResamplerDefault; - DirectChannels = DirectMode::Off; - mSpatialize = SpatializeAuto; - - StereoPan[0] = Deg2Rad( 30.0f); - StereoPan[1] = Deg2Rad(-30.0f); - - Radius = 0.0f; - Direct.Gain = 1.0f; Direct.GainHF = 1.0f; Direct.HFReference = LOWPASSFREQREF; diff --git a/al/source.h b/al/source.h index 4a6a2531..a800f299 100644 --- a/al/source.h +++ b/al/source.h @@ -5,6 +5,7 @@ #include <atomic> #include <cstddef> #include <iterator> +#include <limits> #include "AL/al.h" #include "AL/alc.h" @@ -13,6 +14,7 @@ #include "almalloc.h" #include "alnumeric.h" #include "alu.h" +#include "math_defs.h" #include "vector.h" struct ALbuffer; @@ -34,59 +36,59 @@ struct ALbufferlistitem { struct ALsource { /** Source properties. */ - ALfloat Pitch; - ALfloat Gain; - ALfloat OuterGain; - ALfloat MinGain; - ALfloat MaxGain; - ALfloat InnerAngle; - ALfloat OuterAngle; - ALfloat RefDistance; - ALfloat MaxDistance; - ALfloat RolloffFactor; - std::array<ALfloat,3> Position; - std::array<ALfloat,3> Velocity; - std::array<ALfloat,3> Direction; - std::array<ALfloat,3> OrientAt; - std::array<ALfloat,3> OrientUp; - bool HeadRelative; - bool Looping; - DistanceModel mDistanceModel; - Resampler mResampler; - DirectMode DirectChannels; - SpatializeMode mSpatialize; - - bool DryGainHFAuto; - bool WetGainAuto; - bool WetGainHFAuto; - ALfloat OuterGainHF; - - ALfloat AirAbsorptionFactor; - ALfloat RoomRolloffFactor; - ALfloat DopplerFactor; + float Pitch{1.0f}; + float Gain{1.0f}; + float OuterGain{0.0f}; + float MinGain{0.0f}; + float MaxGain{1.0f}; + float InnerAngle{360.0f}; + float OuterAngle{360.0f}; + float RefDistance{1.0f}; + float MaxDistance{std::numeric_limits<float>::max()}; + float RolloffFactor{1.0f}; + std::array<float,3> Position{{0.0f, 0.0f, 0.0f}}; + std::array<float,3> Velocity{{0.0f, 0.0f, 0.0f}}; + std::array<float,3> Direction{{0.0f, 0.0f, 0.0f}}; + std::array<float,3> OrientAt{{0.0f, 0.0f, -1.0f}}; + std::array<float,3> OrientUp{{0.0f, 1.0f, 0.0f}}; + bool HeadRelative{false}; + bool Looping{false}; + DistanceModel mDistanceModel{DistanceModel::Default}; + Resampler mResampler{ResamplerDefault}; + DirectMode DirectChannels{DirectMode::Off}; + SpatializeMode mSpatialize{SpatializeAuto}; + + bool DryGainHFAuto{true}; + bool WetGainAuto{true}; + bool WetGainHFAuto{true}; + float OuterGainHF{1.0f}; + + float AirAbsorptionFactor{0.0f}; + float RoomRolloffFactor{0.0f}; + float DopplerFactor{1.0f}; /* NOTE: Stereo pan angles are specified in radians, counter-clockwise * rather than clockwise. */ - std::array<ALfloat,2> StereoPan; + std::array<float,2> StereoPan{{Deg2Rad( 30.0f), Deg2Rad(-30.0f)}}; - ALfloat Radius; + float Radius{0.0f}; /** Direct filter and auxiliary send info. */ struct { - ALfloat Gain; - ALfloat GainHF; - ALfloat HFReference; - ALfloat GainLF; - ALfloat LFReference; + float Gain; + float GainHF; + float HFReference; + float GainLF; + float LFReference; } Direct; struct SendData { ALeffectslot *Slot; - ALfloat Gain; - ALfloat GainHF; - ALfloat HFReference; - ALfloat GainLF; - ALfloat LFReference; + float Gain; + float GainHF; + float HFReference; + float GainLF; + float LFReference; }; std::array<SendData,MAX_SENDS> Send; @@ -94,8 +96,8 @@ struct ALsource { * Last user-specified offset, and the offset type (bytes, samples, or * seconds). */ - ALdouble Offset{0.0}; - ALenum OffsetType{AL_NONE}; + double Offset{0.0}; + ALenum OffsetType{AL_NONE}; /** Source type (static, streaming, or undetermined) */ ALenum SourceType{AL_UNDETERMINED}; |