Skip to content

Commit

Permalink
Moved out AudioManager listener type.
Browse files Browse the repository at this point in the history
  • Loading branch information
afritz1 committed Nov 16, 2024
1 parent 5024e2f commit d036791
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 29 deletions.
18 changes: 4 additions & 14 deletions OpenTESArena/src/Audio/AudioManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,19 +313,9 @@ class OpenALStream
}
};

AudioManager::ListenerData::ListenerData(const Double3 &position, const Double3 &direction)
AudioListenerData::AudioListenerData(const Double3 &position, const Double3 &direction)
: position(position), direction(direction) { }

const Double3 &AudioManager::ListenerData::getPosition() const
{
return this->position;
}

const Double3 &AudioManager::ListenerData::getDirection() const
{
return this->direction;
}

AudioManager::AudioManager()
{
mMusicVolume = 0.0f;
Expand Down Expand Up @@ -821,8 +811,8 @@ void AudioManager::updateSources()
}
}

void AudioManager::updateListener(const ListenerData &listenerData)
void AudioManager::updateListener(const AudioListenerData &listenerData)
{
this->setListenerPosition(listenerData.getPosition());
this->setListenerOrientation(listenerData.getDirection());
this->setListenerPosition(listenerData.position);
this->setListenerOrientation(listenerData.direction);
}
24 changes: 10 additions & 14 deletions OpenTESArena/src/Audio/AudioManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,18 @@ class Options;

struct MusicDefinition;

// Contains data for defining the state of an audio listener.
struct AudioListenerData
{
Double3 position;
Double3 direction;

AudioListenerData(const Double3 &position, const Double3 &direction);
};

// Manages what sounds and music are played by OpenAL Soft.
class AudioManager
{
public:
// Contains data for defining the state of an audio listener.
class ListenerData
{
private:
Double3 position;
Double3 direction;
public:
ListenerData(const Double3 &position, const Double3 &direction);

const Double3 &getPosition() const;
const Double3 &getDirection() const;
};
private:
static constexpr ALint UNSUPPORTED_EXTENSION = -1;

Expand Down Expand Up @@ -139,7 +135,7 @@ class AudioManager
void updateSources();

// Updates the position of the 3D listener.
void updateListener(const ListenerData &listenerData);
void updateListener(const AudioListenerData &listenerData);
};

#endif
2 changes: 1 addition & 1 deletion OpenTESArena/src/Game/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ void Game::loop()

// Update audio listener orientation.
const WorldDouble3 newPlayerWorldPos = VoxelUtils::coordToWorldPoint(newPlayerCoord);
const AudioManager::ListenerData listenerData(newPlayerWorldPos, newPlayerDirection);
const AudioListenerData listenerData(newPlayerWorldPos, newPlayerDirection);
this->audioManager.updateListener(listenerData);
}

Expand Down

0 comments on commit d036791

Please sign in to comment.