Skip to content

Commit 864c4aa

Browse files
committed
spatialization: Fixed scalar source-relative calculation.
Reference PR #37.
1 parent 8bcdfce commit 864c4aa

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

mojoal.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,13 +1761,15 @@ static void calculate_channel_gains(const ALCcontext *ctx, const ALsource *src,
17611761

17621762
{
17631763
#if NEED_SCALAR_FALLBACK
1764-
/* if values aren't source-relative, then convert it to be so. */
1765-
if (!src->source_relative) {
1766-
SDL_memcpy(position, src->position, sizeof (position));
1767-
} else {
1764+
/* If !source_relative, position is in world space, otherwise, it's in relation to the Listener's position.
1765+
So a source-relative source that's at ( 0, 0, 0 ) will be treated as being on top of the listener,
1766+
no matter where the listener moves. If not source relative, it'll get quieter as the listener moves away. */
1767+
if (!src->source_relative) {
17681768
position[0] = src->position[0] - ctx->listener.position[0];
17691769
position[1] = src->position[1] - ctx->listener.position[1];
17701770
position[2] = src->position[2] - ctx->listener.position[2];
1771+
} else {
1772+
SDL_memcpy(position, src->position, sizeof (position));
17711773
}
17721774
distance = magnitude(position);
17731775
#endif

0 commit comments

Comments
 (0)