mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
support for manual or task-driven position broadcasts
This commit is contained in:
parent
ac8ca1fe1b
commit
334cf9f8e8
@ -4,6 +4,8 @@ from ClockDelta import *
|
|||||||
from direct.task import Task
|
from direct.task import Task
|
||||||
from direct.showbase.PythonUtil import randFloat, Enum
|
from direct.showbase.PythonUtil import randFloat, Enum
|
||||||
|
|
||||||
|
DummyTask = ScratchPad()
|
||||||
|
|
||||||
class DistributedSmoothNodeBase:
|
class DistributedSmoothNodeBase:
|
||||||
"""common base class for DistributedSmoothNode and DistributedSmoothNodeAI
|
"""common base class for DistributedSmoothNode and DistributedSmoothNodeAI
|
||||||
"""
|
"""
|
||||||
@ -46,6 +48,12 @@ class DistributedSmoothNodeBase:
|
|||||||
# Delete this callback because it maintains a reference to self
|
# Delete this callback because it maintains a reference to self
|
||||||
self.d_broadcastPosHpr = None
|
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):
|
def startPosHprBroadcast(self, period=.2, stagger=0, type=None):
|
||||||
if self.cnode == None:
|
if self.cnode == None:
|
||||||
self.initializeCnode()
|
self.initializeCnode()
|
||||||
@ -83,10 +91,11 @@ class DistributedSmoothNodeBase:
|
|||||||
delay = 0.
|
delay = 0.
|
||||||
if stagger:
|
if stagger:
|
||||||
delay = randFloat(period)
|
delay = randFloat(period)
|
||||||
taskMgr.doMethodLater(self.__broadcastPeriod + delay,
|
if self.wantSmoothPosBroadcastTask():
|
||||||
self._posHprBroadcast, taskName)
|
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
|
# TODO: we explicitly stagger the initial task timing in
|
||||||
# startPosHprBroadcast; we should at least make an effort to keep
|
# startPosHprBroadcast; we should at least make an effort to keep
|
||||||
# this task accurately aligned with its period and starting time.
|
# this task accurately aligned with its period and starting time.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user