diff --git a/direct/src/showbase/SfxPlayer.py b/direct/src/showbase/SfxPlayer.py index d03d10136b..01d87ca717 100644 --- a/direct/src/showbase/SfxPlayer.py +++ b/direct/src/showbase/SfxPlayer.py @@ -10,24 +10,28 @@ class SfxPlayer: UseInverseSquare = 0 def __init__(self): - # Distance at which sounds can no longer be heard - # This was determined experimentally - self.cutoffDistance = 120.0 - - # cutoff for inverse square attenuation - if SfxPlayer.UseInverseSquare: - self.cutoffDistance = 300.0 # volume attenuates according to the inverse square of the # distance from the source. volume = 1/(distance^2) # this is the volume at which a sound is nearly inaudible self.cutoffVolume = .02 + + # cutoff for inverse square attenuation + if SfxPlayer.UseInverseSquare: + self.setCutoffDistance(300.0) + else: + # Distance at which sounds can no longer be heard + # This was determined experimentally + self.setCutoffDistance(120.0) + + def setCutoffDistance(self, d): + self.cutoffDistance = d # this is the 'raw' distance at which the volume of a sound will # be equal to the cutoff volume rawCutoffDistance = math.sqrt(1./self.cutoffVolume) # this is a scale factor to convert distances so that a sound # located at self.cutoffDistance will have a volume # of self.cutoffVolume - self.distanceScale = rawCutoffDistance / self.cutoffDistance + self.distanceScale = rawCutoffDistance / self.cutoffDistance def getLocalizedVolume(self, node): """