build 181128. coupler sounds enhancement, minor ai logic tweaks, minor bug fixes

This commit is contained in:
tmj-fstate
2018-11-28 23:29:35 +01:00
parent 1d6f75322b
commit 3fbf5bf894
17 changed files with 199 additions and 63 deletions

View File

@@ -81,7 +81,13 @@ openal_source::update( double const Deltatime, glm::vec3 const &Listenervelocity
if( sound_range < 0.0 ) {
sound_velocity = Listenervelocity; // cached for doppler shift calculation
}
/*
// HACK: if the application gets stuck for long time loading assets the audio can gone awry.
// terminate all sources when it happens to stay on the safe side
if( Deltatime > 1.0 ) {
stop();
}
*/
if( id != audio::null_resource ) {
sound_change = false;
@@ -314,7 +320,6 @@ openal_renderer::erase( sound_source const *Controller ) {
// updates state of all active emitters
void
openal_renderer::update( double const Deltatime ) {
// update listener
// gain
::alListenerf( AL_GAIN, clamp( Global.AudioVolume, 0.f, 2.f ) * ( Global.iPause == 0 ? 1.f : 0.15f ) );
@@ -411,6 +416,14 @@ openal_renderer::fetch_source() {
}
}
if( newsource.id == audio::null_resource ) {
// for sources with functional emitter reset emitter parameters from potential last use
::alSourcef( newsource.id, AL_PITCH, 1.f );
::alSourcef( newsource.id, AL_GAIN, 1.f );
::alSourcefv( newsource.id, AL_POSITION, glm::value_ptr( glm::vec3{ 0.f } ) );
::alSourcefv( newsource.id, AL_VELOCITY, glm::value_ptr( glm::vec3{ 0.f } ) );
}
return newsource;
}