feat: Take sound elevation into account
This commit is contained in:
parent
430c6498f8
commit
93cc5d1f83
4 changed files with 17 additions and 2 deletions
|
@ -39,6 +39,7 @@ void SoundBlueprint::load(const GffStruct &uts) {
|
|||
_maxDistance = uts.getFloat("MaxDistance");
|
||||
_minDistance = uts.getFloat("MinDistance");
|
||||
_continuous = uts.getInt("Continuous") != 0;
|
||||
_elevation = uts.getFloat("Elevation");
|
||||
_looping = uts.getInt("Looping") != 0;
|
||||
_positional = uts.getInt("Positional") != 0;
|
||||
_interval = uts.getInt("Interval");
|
||||
|
@ -73,6 +74,10 @@ bool SoundBlueprint::continuous() const {
|
|||
return _continuous;
|
||||
}
|
||||
|
||||
float SoundBlueprint::elevation() const {
|
||||
return _elevation;
|
||||
}
|
||||
|
||||
bool SoundBlueprint::looping() const {
|
||||
return _looping;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ public:
|
|||
float maxDistance() const;
|
||||
float minDistance() const;
|
||||
bool continuous() const;
|
||||
float elevation() const;
|
||||
bool looping() const;
|
||||
bool positional() const;
|
||||
int interval() const;
|
||||
|
@ -52,6 +53,7 @@ private:
|
|||
float _maxDistance { 0.0f };
|
||||
float _minDistance { 0.0f };
|
||||
bool _continuous { false };
|
||||
float _elevation { 0.0f };
|
||||
bool _looping { false };
|
||||
bool _positional { false };
|
||||
int _interval { 0 };
|
||||
|
|
|
@ -61,7 +61,7 @@ void Sound::update(float dt) {
|
|||
|
||||
if (_sound) {
|
||||
if (_audible) {
|
||||
_sound->setPosition(glm::vec3(_transform[3]));
|
||||
_sound->setPosition(getPosition());
|
||||
} else {
|
||||
_sound->stop();
|
||||
_sound.reset();
|
||||
|
@ -93,7 +93,7 @@ void Sound::update(float dt) {
|
|||
}
|
||||
|
||||
void Sound::playSound(const string &resRef, bool loop) {
|
||||
_sound = AudioPlayer::instance().play(resRef, AudioType::Sound, loop, 1.0f, _blueprint->positional(), Vector3(_transform[3]));
|
||||
_sound = AudioPlayer::instance().play(resRef, AudioType::Sound, loop, 1.0f, _blueprint->positional(), getPosition());
|
||||
}
|
||||
|
||||
void Sound::play() {
|
||||
|
@ -122,6 +122,12 @@ bool Sound::isActive() const {
|
|||
return _active;
|
||||
}
|
||||
|
||||
Vector3 Sound::getPosition() const {
|
||||
Vector3 position(_transform[3]);
|
||||
position.z += _blueprint->elevation();
|
||||
return move(position);
|
||||
}
|
||||
|
||||
int Sound::priority() const {
|
||||
return _priority;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,8 @@ public:
|
|||
|
||||
bool isActive() const;
|
||||
|
||||
Vector3 getPosition() const;
|
||||
|
||||
std::shared_ptr<SoundBlueprint> blueprint() const;
|
||||
int priority() const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue