diff --git a/direct/src/distributed/ClientRepository.py b/direct/src/distributed/ClientRepository.py index a59a37002b..10c61cd1c7 100644 --- a/direct/src/distributed/ClientRepository.py +++ b/direct/src/distributed/ClientRepository.py @@ -152,6 +152,7 @@ class ClientRepository(DirectObject.DirectObject): # Assign it an Id distObj.doId = doId # Update the required fields + distObj.generateInit() # Only called when constructed distObj.generate() distObj.updateRequiredFields(cdc, di) # Put the new do in both dictionaries @@ -190,6 +191,7 @@ class ClientRepository(DirectObject.DirectObject): self.doId2do[doId] = distObj self.doId2cdc[doId] = cdc # Update the required fields + distObj.generateInit() # Only called when constructed distObj.generate() distObj.updateRequiredOtherFields(cdc, di) # Put the new do in both dictionaries diff --git a/direct/src/distributed/DistributedObject.py b/direct/src/distributed/DistributedObject.py index 6bd7d28678..52413304e7 100644 --- a/direct/src/distributed/DistributedObject.py +++ b/direct/src/distributed/DistributedObject.py @@ -49,6 +49,12 @@ class DistributedObject(PandaObject): Inheritors should redefine this to take appropriate action on generate """ pass + + def generateInit(self): + """generateInit(self) + This method is called when the DistributedObject is first introduced + to the world... Not when it is pulled from the cache. + """ def getDoId(self): """getDoId(self) diff --git a/direct/src/interval/FunctionInterval.py b/direct/src/interval/FunctionInterval.py index 5fc4d1ab79..1f79db081c 100644 --- a/direct/src/interval/FunctionInterval.py +++ b/direct/src/interval/FunctionInterval.py @@ -44,9 +44,33 @@ class EventInterval(FunctionInterval): # Create function interval FunctionInterval.__init__(self, sendFunc, name = event) +### FunctionInterval subclass for accepting hooks ### +class AcceptInterval(FunctionInterval): + # Initialization + def __init__(self, dirObj, event, function, name): + """__init__(dirObj, event, function, name) + """ + def acceptFunc(dirObj = dirObj, event = event, function = function): + print "accepting..." + dirObj.accept(event, function) + # Create function interval + FunctionInterval.__init__(self, acceptFunc, name = name) + +### FunctionInterval subclass for throwing events ### +class IgnoreInterval(FunctionInterval): + # Initialization + def __init__(self, dirObj, event, name): + """__init__(dirObj, event, name) + """ + def ignoreFunc(dirObj = dirObj, event = event): + print "ignoring..." + dirObj.ignore(event) + # Create function interval + FunctionInterval.__init__(self, ignoreFunc, name = name) + ### Function Interval subclass for adjusting scene graph hierarchy ### class ParentInterval(FunctionInterval): - # PosInterval counter + # ParentInterval counter parentIntervalNum = 1 # Initialization def __init__(self, nodePath, parent, name = None): @@ -61,6 +85,23 @@ class ParentInterval(FunctionInterval): # Create function interval FunctionInterval.__init__(self, reparentFunc, name = name) +### Function Interval subclass for adjusting scene graph hierarchy ### +class WrtParentInterval(FunctionInterval): + # WrtParentInterval counter + wrtParentIntervalNum = 1 + # Initialization + def __init__(self, nodePath, parent, name = None): + """__init__(nodePath, parent, name) + """ + def wrtReparentFunc(nodePath = nodePath, parent = parent): + nodePath.wrtReparentTo(parent) + # Determine name + if (name == None): + name = 'WrtParentInterval-%d' % WrtParentInterval.wrtParentIntervalNum + WrtParentInterval.wrtParentIntervalNum += 1 + # Create function interval + FunctionInterval.__init__(self, wrtReparentFunc, name = name) + ### Function Interval subclasses for instantaneous pose changes ### class PosInterval(FunctionInterval): # PosInterval counter