Skip to content

Commit 08353b9

Browse files
committed
spatialization: Fix source-relative calculation in scalar code.
Totally had this backwards in my mind, my fault. Reference PR #37.
1 parent bd8172d commit 08353b9

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

mojoal.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -815,17 +815,18 @@ static void calculate_distance_attenuation_and_angle_scalar(const ALCcontext *ct
815815
const ALfloat *at = &ctx->listener.orientation[0];
816816
const ALfloat *up = &ctx->listener.orientation[4];
817817

818-
// If !source_relative, position is absolute, otherwise, it's in relation to the Listener's position.
819-
// Another way to say this is that if !source_relative, act like the listener is at (0,0,0).
818+
// If !source_relative, position is in world space, otherwise, it's in relation to the Listener's position.
819+
// So a source-relative source that's at ( 0, 0, 0 ) will be treated as being on top of the listener,
820+
// no matter where the listener moves. If not source relative, it'll get quieter as the listener moves away.
820821
ALfloat position[3];
821822
if (!src->source_relative) {
822-
position[0] = src->position[0];
823-
position[1] = src->position[1];
824-
position[2] = src->position[2];
825-
} else {
826823
position[0] = src->position[0] - ctx->listener.position[0];
827824
position[1] = src->position[1] - ctx->listener.position[1];
828825
position[2] = src->position[2] - ctx->listener.position[2];
826+
} else {
827+
position[0] = src->position[0];
828+
position[1] = src->position[1];
829+
position[2] = src->position[2];
829830
}
830831

831832
// Remove upwards component so it lies completely within the horizontal plane.

0 commit comments

Comments
 (0)