mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
support for manual or task-driven position broadcasts
This commit is contained in:
parent
ac8ca1fe1b
commit
334cf9f8e8
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user