From 334cf9f8e8c9b60feb772c81bad39e74f63c1b37 Mon Sep 17 00:00:00 2001 From: Darren Ranalli Date: Wed, 28 Nov 2007 19:33:00 +0000 Subject: [PATCH] support for manual or task-driven position broadcasts --- .../distributed/DistributedSmoothNodeBase.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/direct/src/distributed/DistributedSmoothNodeBase.py b/direct/src/distributed/DistributedSmoothNodeBase.py index a727835c57..403302171d 100755 --- a/direct/src/distributed/DistributedSmoothNodeBase.py +++ b/direct/src/distributed/DistributedSmoothNodeBase.py @@ -4,11 +4,13 @@ from ClockDelta import * from direct.task import Task from direct.showbase.PythonUtil import randFloat, Enum +DummyTask = ScratchPad() + class DistributedSmoothNodeBase: """common base class for DistributedSmoothNode and DistributedSmoothNodeAI """ BroadcastTypes = Enum('FULL, XYH, XY') - + def __init__(self): pass @@ -46,6 +48,12 @@ class DistributedSmoothNodeBase: # Delete this callback because it maintains a reference to self self.d_broadcastPosHpr = None + def posHprBroadcastStarted(self): + return self.d_broadcastPosHpr != None + + def wantSmoothPosBroadcastTask(self): + return True + def startPosHprBroadcast(self, period=.2, stagger=0, type=None): if self.cnode == None: self.initializeCnode() @@ -83,10 +91,11 @@ class DistributedSmoothNodeBase: delay = 0. if stagger: delay = randFloat(period) - taskMgr.doMethodLater(self.__broadcastPeriod + delay, - self._posHprBroadcast, taskName) + if self.wantSmoothPosBroadcastTask(): + taskMgr.doMethodLater(self.__broadcastPeriod + delay, + self._posHprBroadcast, taskName) - def _posHprBroadcast(self, task): + def _posHprBroadcast(self, task=DummyTask): # TODO: we explicitly stagger the initial task timing in # startPosHprBroadcast; we should at least make an effort to keep # this task accurately aligned with its period and starting time.