Audio3DManager: fix regression with setSoundVelocityAuto()

This commit is contained in:
rdb 2019-01-06 09:27:35 +01:00
parent 6e730a2e95
commit 2da791b9fb
2 changed files with 20 additions and 10 deletions

View File

@ -2,7 +2,7 @@
__all__ = ['Audio3DManager']
from panda3d.core import Vec3, VBase3, WeakNodePath
from panda3d.core import Vec3, VBase3, WeakNodePath, ClockObject
from direct.task.TaskManagerGlobal import Task, taskMgr
#
class Audio3DManager:
@ -141,14 +141,22 @@ class Audio3DManager:
"""
Get the velocity of the sound.
"""
if (sound in self.vel_dict):
if sound in self.vel_dict:
vel = self.vel_dict[sound]
if (vel!=None):
if vel is not None:
return vel
else:
for known_object in list(self.sound_dict.keys()):
if self.sound_dict[known_object].count(sound):
return known_object.getPosDelta(self.root)/globalClock.getDt()
for known_object in list(self.sound_dict.keys()):
if self.sound_dict[known_object].count(sound):
node_path = known_object.getNodePath()
if not node_path:
# The node has been deleted.
del self.sound_dict[known_object]
continue
clock = ClockObject.getGlobalClock()
return node_path.getPosDelta(self.root) / clock.getDt()
return VBase3(0, 0, 0)
def setListenerVelocity(self, velocity):
@ -176,10 +184,11 @@ class Audio3DManager:
"""
Get the velocity of the listener.
"""
if (self.listener_vel!=None):
if self.listener_vel is not None:
return self.listener_vel
elif (self.listener_target!=None):
return self.listener_target.getPosDelta(self.root)/globalClock.getDt()
elif self.listener_target is not None:
clock = ClockObject.getGlobalClock()
return self.listener_target.getPosDelta(self.root) / clock.getDt()
else:
return VBase3(0, 0, 0)

View File

@ -1,5 +1,6 @@
------------------------ RELEASE 1.10.1 -----------------------
* Fix regression with Audio3DManager.setSoundVelocityAuto()
* Audio3DManager accepts tuple in setSoundVelocity/setListenerVelocity
------------------------ RELEASE 1.10.0 -----------------------