Update audio_sound_positioning.c
Calculate `right` Vector3 for correct audio stereo positioning.
This commit is contained in:
parent
1ec281e86f
commit
696f225f29
1 changed files with 2 additions and 2 deletions
|
@ -108,7 +108,7 @@ static void SetSoundPosition(Camera listener, Sound sound, Vector3 position, flo
|
||||||
// Calculate normalized vectors for spatial positioning
|
// Calculate normalized vectors for spatial positioning
|
||||||
Vector3 normalizedDirection = Vector3Normalize(direction);
|
Vector3 normalizedDirection = Vector3Normalize(direction);
|
||||||
Vector3 forward = Vector3Normalize(Vector3Subtract(listener.target, listener.position));
|
Vector3 forward = Vector3Normalize(Vector3Subtract(listener.target, listener.position));
|
||||||
Vector3 right = Vector3Normalize(Vector3CrossProduct(forward, listener.up));
|
Vector3 right = Vector3Normalize(Vector3CrossProduct(listener.up, forward));
|
||||||
|
|
||||||
// Reduce volume for sounds behind the listener
|
// Reduce volume for sounds behind the listener
|
||||||
float dotProduct = Vector3DotProduct(forward, normalizedDirection);
|
float dotProduct = Vector3DotProduct(forward, normalizedDirection);
|
||||||
|
@ -120,4 +120,4 @@ static void SetSoundPosition(Camera listener, Sound sound, Vector3 position, flo
|
||||||
// Apply final sound properties
|
// Apply final sound properties
|
||||||
SetSoundVolume(sound, attenuation);
|
SetSoundVolume(sound, attenuation);
|
||||||
SetSoundPan(sound, pan);
|
SetSoundPan(sound, pan);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue