diff --git a/Aquaria/DSQ.cpp b/Aquaria/DSQ.cpp index a9a8bd2..036b234 100644 --- a/Aquaria/DSQ.cpp +++ b/Aquaria/DSQ.cpp @@ -2208,6 +2208,16 @@ void DSQ::playPositionalSfx(const std::string &name, const Vector &position, flo { PlaySfx sfx = calcPositionalSfx(position); + // FIXME: Right now, positional sound effects never update their relative position to the + // listener, which means that if they are spawned too far away to be audible, it is not possible + // that they ever get audible at all. Additionally, the current scripting API only provides + // functions to fade sounds OUT, not to set their volume arbitrarily. + // Because audio thread creation is costly, drop sounds that can not be heard. + // This needs to be removed once proper audio source/listener positioning is implemented, + // or the scripting interface gets additional functions to mess with sound. -- FG + if (sfx.vol <= 0) + return; + sfx.freq = f; sfx.name = name; diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index 228da1d..f59140e 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -2346,6 +2346,11 @@ luaFunc(entity_playSfx) float fadeOut = lua_tonumber(L, 6); if(vol > 0) sfx.vol *= vol; + + // FIXME: See comment in DSQ::playPositionalSfx() -- FG + if (sfx.vol <= 0) + luaReturnPtr(NULL); + h = core->sound->playSfx(sfx); if (fadeOut != 0) { @@ -5136,6 +5141,10 @@ luaFunc(playSfx) sfx.vol = vol; } + // FIXME: See comment in DSQ::playPositionalSfx() -- FG + if (sfx.vol <= 0) + luaReturnPtr(NULL); + sfx.name = getString(L, 1); sfx.freq = freq; sfx.loops = loops;