Reduce positional effect on sounds

This commit is contained in:
2025-06-02 11:13:19 +01:00
parent b442001246
commit 6706ac494a
4 changed files with 163 additions and 153 deletions
+9 -1
View File
@@ -157,15 +157,23 @@ Within 10 units considers the sound to be directly in front.
soundAngle :: Point2 -> World -> Int16
{-# INLINE soundAngle #-}
soundAngle p w
| dist p earPos < 10 = 0
| d < 10 = 0
| otherwise =
round
. radToDeg
. f
. normalizeAngle
. (+ pi)
$ argV (vNormal (p -.- earPos)) - (w ^. wCam . camRot)
where
earPos = w ^. wCam . camViewFrom
d = dist p earPos
-- the following should soften the positional effect
-- when you are close to the sound source
f x | x < pi / 2 = x * dfact
| x < 3 * pi / 2 = pi + (dfact * (x - pi))
| otherwise = 2*pi + (dfact * (x - 2*pi))
dfact = min ((d - 10) / 100) 1
{- | Uses the first free origin from a list.
Does nothing if all origins are already creating sounds.