Refactored Math::Vector in sound implementation

dev
Tomasz Kapuściński 2022-01-03 23:53:22 +01:00
parent 55f5d25c95
commit da2471567d
6 changed files with 21 additions and 21 deletions

View File

@ -316,15 +316,15 @@ bool CALSound::SearchFreeBuffer(SoundType sound, int &channel, bool &alreadyLoad
int CALSound::Play(SoundType sound, float amplitude, float frequency, bool loop) int CALSound::Play(SoundType sound, float amplitude, float frequency, bool loop)
{ {
return Play(sound, Math::Vector{}, true, amplitude, frequency, loop); return Play(sound, glm::vec3{0, 0, 0}, true, amplitude, frequency, loop);
} }
int CALSound::Play(SoundType sound, const Math::Vector &pos, float amplitude, float frequency, bool loop) int CALSound::Play(SoundType sound, const glm::vec3 &pos, float amplitude, float frequency, bool loop)
{ {
return Play(sound, pos, false, amplitude, frequency, loop); return Play(sound, pos, false, amplitude, frequency, loop);
} }
int CALSound::Play(SoundType sound, const Math::Vector &pos, bool relativeToListener, float amplitude, float frequency, bool loop) int CALSound::Play(SoundType sound, const glm::vec3 &pos, bool relativeToListener, float amplitude, float frequency, bool loop)
{ {
if (!m_enabled) if (!m_enabled)
{ {
@ -408,7 +408,7 @@ bool CALSound::AddEnvelope(int channel, float amplitude, float frequency, float
return true; return true;
} }
bool CALSound::Position(int channel, const Math::Vector &pos) bool CALSound::Position(int channel, const glm::vec3 &pos)
{ {
if (!CheckChannel(channel)) if (!CheckChannel(channel))
{ {
@ -570,11 +570,11 @@ void CALSound::FrameMove(float rTime)
} }
} }
void CALSound::SetListener(const Math::Vector &eye, const Math::Vector &lookat) void CALSound::SetListener(const glm::vec3 &eye, const glm::vec3 &lookat)
{ {
m_eye = eye; m_eye = eye;
m_lookat = lookat; m_lookat = lookat;
Math::Vector forward = glm::normalize(lookat - eye); glm::vec3 forward = glm::normalize(lookat - eye);
float orientation[] = {forward.x, forward.y, forward.z, 0.f, -1.0f, 0.0f}; float orientation[] = {forward.x, forward.y, forward.z, 0.f, -1.0f, 0.0f};
alListener3f(AL_POSITION, eye.x, eye.y, eye.z); alListener3f(AL_POSITION, eye.x, eye.y, eye.z);

View File

@ -96,14 +96,14 @@ public:
void SetMusicVolume(int volume) override; void SetMusicVolume(int volume) override;
int GetMusicVolume() override; int GetMusicVolume() override;
void SetListener(const Math::Vector &eye, const Math::Vector &lookat) override; void SetListener(const glm::vec3 &eye, const glm::vec3 &lookat) override;
void FrameMove(float rTime) override; void FrameMove(float rTime) override;
int Play(SoundType sound, float amplitude=1.0f, float frequency=1.0f, bool loop = false) override; int Play(SoundType sound, float amplitude=1.0f, float frequency=1.0f, bool loop = false) override;
int Play(SoundType sound, const Math::Vector &pos, float amplitude=1.0f, float frequency=1.0f, bool loop = false) override; int Play(SoundType sound, const glm::vec3 &pos, float amplitude=1.0f, float frequency=1.0f, bool loop = false) override;
bool FlushEnvelope(int channel) override; bool FlushEnvelope(int channel) override;
bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper) override; bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper) override;
bool Position(int channel, const Math::Vector &pos) override; bool Position(int channel, const glm::vec3 &pos) override;
bool Frequency(int channel, float frequency) override; bool Frequency(int channel, float frequency) override;
bool Stop(int channel) override; bool Stop(int channel) override;
bool StopAll() override; bool StopAll() override;
@ -117,7 +117,7 @@ public:
private: private:
void CleanUp(); void CleanUp();
int Play(SoundType sound, const Math::Vector &pos, bool relativeToListener, float amplitude, float frequency, bool loop); int Play(SoundType sound, const glm::vec3 &pos, bool relativeToListener, float amplitude, float frequency, bool loop);
int GetPriority(SoundType); int GetPriority(SoundType);
bool SearchFreeBuffer(SoundType sound, int &channel, bool &alreadyLoaded); bool SearchFreeBuffer(SoundType sound, int &channel, bool &alreadyLoaded);
bool CheckChannel(int &channel); bool CheckChannel(int &channel);
@ -134,7 +134,7 @@ private:
std::unique_ptr<CChannel> m_currentMusic; std::unique_ptr<CChannel> m_currentMusic;
std::list<OldMusic> m_oldMusic; std::list<OldMusic> m_oldMusic;
OldMusic m_previousMusic; OldMusic m_previousMusic;
Math::Vector m_eye; glm::vec3 m_eye;
Math::Vector m_lookat; glm::vec3 m_lookat;
CWorkerThread m_thread; CWorkerThread m_thread;
}; };

View File

@ -94,7 +94,7 @@ bool CChannel::Pause()
return true; return true;
} }
bool CChannel::SetPosition(const Math::Vector &pos, bool relativeToListener) bool CChannel::SetPosition(const glm::vec3 &pos, bool relativeToListener)
{ {
if (!m_ready || m_buffer == nullptr) if (!m_ready || m_buffer == nullptr)
{ {

View File

@ -59,7 +59,7 @@ public:
bool Pause(); bool Pause();
bool Stop(); bool Stop();
bool SetPosition(const Math::Vector &pos, bool relativeToListener = false); bool SetPosition(const glm::vec3 &pos, bool relativeToListener = false);
bool SetFrequency(float freq); bool SetFrequency(float freq);
float GetFrequency(); float GetFrequency();
@ -120,6 +120,6 @@ private:
bool m_ready; bool m_ready;
bool m_loop; bool m_loop;
bool m_mute; bool m_mute;
Math::Vector m_position; glm::vec3 m_position;
}; };

View File

@ -98,7 +98,7 @@ int CSoundInterface::GetMusicVolume()
return 0; return 0;
} }
void CSoundInterface::SetListener(const Math::Vector &eye, const Math::Vector &lookat) void CSoundInterface::SetListener(const glm::vec3 &eye, const glm::vec3 &lookat)
{ {
} }
@ -111,7 +111,7 @@ int CSoundInterface::Play(SoundType sound, float amplitude, float frequency, boo
return 0; return 0;
} }
int CSoundInterface::Play(SoundType sound, const Math::Vector &pos, float amplitude, float frequency, bool loop) int CSoundInterface::Play(SoundType sound, const glm::vec3 &pos, float amplitude, float frequency, bool loop)
{ {
return 0; return 0;
} }
@ -126,7 +126,7 @@ bool CSoundInterface::AddEnvelope(int channel, float amplitude, float frequency,
return true; return true;
} }
bool CSoundInterface::Position(int channel, const Math::Vector &pos) bool CSoundInterface::Position(int channel, const glm::vec3 &pos)
{ {
return true; return true;
} }

View File

@ -129,7 +129,7 @@ public:
* \param eye - position of listener * \param eye - position of listener
* \param lookat - direction listener is looking at * \param lookat - direction listener is looking at
*/ */
virtual void SetListener(const Math::Vector &eye, const Math::Vector &lookat); virtual void SetListener(const glm::vec3 &eye, const glm::vec3 &lookat);
/** Update data each frame /** Update data each frame
* \param rTime - time since last update * \param rTime - time since last update
@ -153,7 +153,7 @@ public:
* \param loop - loop sound * \param loop - loop sound
* \return identifier of channel that sound will be played on * \return identifier of channel that sound will be played on
*/ */
virtual int Play(SoundType sound, const Math::Vector &pos, float amplitude=1.0f, float frequency=1.0f, bool loop = false); virtual int Play(SoundType sound, const glm::vec3 &pos, float amplitude=1.0f, float frequency=1.0f, bool loop = false);
/** Remove all operations that would be made on sound in channel. /** Remove all operations that would be made on sound in channel.
* \param channel - channel to work on * \param channel - channel to work on
@ -176,7 +176,7 @@ public:
* \param pos - new positino of a sound * \param pos - new positino of a sound
* \return return true on success * \return return true on success
*/ */
virtual bool Position(int channel, const Math::Vector &pos); virtual bool Position(int channel, const glm::vec3 &pos);
/** Set sound frequency /** Set sound frequency
* \param channel - channel to work on * \param channel - channel to work on