Skip to content

Commit

Permalink
Separate EAXCONTEXT_DISTANCEFACTOR and AL_METERS_PER_UNIT
Browse files Browse the repository at this point in the history
  • Loading branch information
kcat committed Sep 11, 2024
1 parent ad32044 commit 7ac9a5c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
6 changes: 5 additions & 1 deletion al/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,11 @@ void UpdateContextProps(ALCcontext *context)
props->OrientAt = listener.OrientAt;
props->OrientUp = listener.OrientUp;
props->Gain = listener.Gain;
props->MetersPerUnit = listener.mMetersPerUnit;
props->MetersPerUnit = listener.mMetersPerUnit
#ifdef ALSOFT_EAX
* context->eaxGetDistanceFactor()
#endif
;

props->AirAbsorptionGainHF = context->mAirAbsorptionGainHF;
props->DopplerFactor = context->mDopplerFactor;
Expand Down
15 changes: 10 additions & 5 deletions alc/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,19 @@ void ALCcontext::init()
mExtensionsString = std::move(extensions);
}

#ifdef ALSOFT_EAX
eax_set_defaults();
#endif

mParams.Position = alu::Vector{0.0f, 0.0f, 0.0f, 1.0f};
mParams.Matrix = alu::Matrix::Identity();
mParams.Velocity = alu::Vector{};
mParams.Gain = mListener.Gain;
mParams.MetersPerUnit = mListener.mMetersPerUnit;
mParams.MetersPerUnit = mListener.mMetersPerUnit
#ifdef ALSOFT_EAX
* eaxGetDistanceFactor()
#endif
;
mParams.AirAbsorptionGainHF = mAirAbsorptionGainHF;
mParams.DopplerFactor = mDopplerFactor;
mParams.SpeedOfSound = mSpeedOfSound * mDopplerVelocity;
Expand Down Expand Up @@ -746,10 +754,7 @@ void ALCcontext::eax_context_commit_primary_fx_slot_id()

void ALCcontext::eax_context_commit_distance_factor()
{
if(mListener.mMetersPerUnit == mEax.flDistanceFactor)
return;

mListener.mMetersPerUnit = mEax.flDistanceFactor;
/* mEax.flDistanceFactor was changed, so the context props are dirty. */
mPropsDirty = true;
}

Expand Down
6 changes: 5 additions & 1 deletion alc/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,11 @@ struct ALCcontext : public al::intrusive_ref<ALCcontext>, ContextBase {

void eaxSetLastError() noexcept;

EaxFxSlotIndex eaxGetPrimaryFxSlotIndex() const noexcept
[[nodiscard]]
auto eaxGetDistanceFactor() const noexcept -> float { return mEax.flDistanceFactor; }

[[nodiscard]]
auto eaxGetPrimaryFxSlotIndex() const noexcept -> EaxFxSlotIndex
{ return mEaxPrimaryFxSlotIndex; }

const ALeffectslot& eaxGetFxSlot(EaxFxSlotIndexValue fx_slot_index) const
Expand Down

0 comments on commit 7ac9a5c

Please sign in to comment.