Skip to content

Commit 2da791b

Browse files
committed
Audio3DManager: fix regression with setSoundVelocityAuto()
1 parent 6e730a2 commit 2da791b

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

direct/src/showbase/Audio3DManager.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
__all__ = ['Audio3DManager']
44

5-
from panda3d.core import Vec3, VBase3, WeakNodePath
5+
from panda3d.core import Vec3, VBase3, WeakNodePath, ClockObject
66
from direct.task.TaskManagerGlobal import Task, taskMgr
77
#
88
class Audio3DManager:
@@ -141,14 +141,22 @@ def getSoundVelocity(self, sound):
141141
"""
142142
Get the velocity of the sound.
143143
"""
144-
if (sound in self.vel_dict):
144+
if sound in self.vel_dict:
145145
vel = self.vel_dict[sound]
146-
if (vel!=None):
146+
if vel is not None:
147147
return vel
148-
else:
149-
for known_object in list(self.sound_dict.keys()):
150-
if self.sound_dict[known_object].count(sound):
151-
return known_object.getPosDelta(self.root)/globalClock.getDt()
148+
149+
for known_object in list(self.sound_dict.keys()):
150+
if self.sound_dict[known_object].count(sound):
151+
node_path = known_object.getNodePath()
152+
if not node_path:
153+
# The node has been deleted.
154+
del self.sound_dict[known_object]
155+
continue
156+
157+
clock = ClockObject.getGlobalClock()
158+
return node_path.getPosDelta(self.root) / clock.getDt()
159+
152160
return VBase3(0, 0, 0)
153161

154162
def setListenerVelocity(self, velocity):
@@ -176,10 +184,11 @@ def getListenerVelocity(self):
176184
"""
177185
Get the velocity of the listener.
178186
"""
179-
if (self.listener_vel!=None):
187+
if self.listener_vel is not None:
180188
return self.listener_vel
181-
elif (self.listener_target!=None):
182-
return self.listener_target.getPosDelta(self.root)/globalClock.getDt()
189+
elif self.listener_target is not None:
190+
clock = ClockObject.getGlobalClock()
191+
return self.listener_target.getPosDelta(self.root) / clock.getDt()
183192
else:
184193
return VBase3(0, 0, 0)
185194

doc/ReleaseNotes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
------------------------ RELEASE 1.10.1 -----------------------
22

3+
* Fix regression with Audio3DManager.setSoundVelocityAuto()
34
* Audio3DManager accepts tuple in setSoundVelocity/setListenerVelocity
45

56
------------------------ RELEASE 1.10.0 -----------------------

0 commit comments

Comments
 (0)