From d838c73a910dc75b63abcd9bc0d670a7f60be9e3 Mon Sep 17 00:00:00 2001 From: Darren Ranalli Date: Thu, 6 Sep 2007 04:12:33 +0000 Subject: [PATCH] re-create C++ objects on disable/generate --- .../src/distributed/DistributedSmoothNode.py | 26 ++++++++++++------- .../distributed/DistributedSmoothNodeAI.py | 9 ++++++- .../distributed/DistributedSmoothNodeBase.py | 9 ++++++- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/direct/src/distributed/DistributedSmoothNode.py b/direct/src/distributed/DistributedSmoothNode.py index 23b1ce11d2..c16ed16170 100644 --- a/direct/src/distributed/DistributedSmoothNode.py +++ b/direct/src/distributed/DistributedSmoothNode.py @@ -66,21 +66,29 @@ class DistributedSmoothNode(DistributedNode.DistributedNode, self.DistributedSmoothNode_initialized = 1 DistributedNode.DistributedNode.__init__(self, cr) DistributedSmoothNodeBase.DistributedSmoothNodeBase.__init__(self) - self.cnode.setRepository(cr, 0, 0) - - self.smoother = SmoothMover() self.smoothStarted = 0 - self.lastSuggestResync = 0 - self._smoothWrtReparents = False + + def generate(self): + self.smoother = SmoothMover() + self.smoothStarted = 0 + self.lastSuggestResync = 0 + self._smoothWrtReparents = False + + DistributedNode.DistributedNode.generate(self) + DistributedSmoothNodeBase.DistributedSmoothNodeBase.generate(self) + self.cnode.setRepository(self.cr, 0, 0) + + self.activateSmoothing(GlobalSmoothing, GlobalPrediction) + + def disable(self): + DistributedSmoothNodeBase.DistributedSmoothNodeBase.disable(self) + DistributedNode.DistributedNode.disable(self) + del self.smoother def delete(self): DistributedSmoothNodeBase.DistributedSmoothNodeBase.delete(self) DistributedNode.DistributedNode.delete(self) - def generate(self): - DistributedNode.DistributedNode.generate(self) - self.activateSmoothing(GlobalSmoothing, GlobalPrediction) - ### Methods to handle computing and updating of the smoothed ### position. diff --git a/direct/src/distributed/DistributedSmoothNodeAI.py b/direct/src/distributed/DistributedSmoothNodeAI.py index 2e9b96d57d..ce63b2c07a 100755 --- a/direct/src/distributed/DistributedSmoothNodeAI.py +++ b/direct/src/distributed/DistributedSmoothNodeAI.py @@ -9,7 +9,14 @@ class DistributedSmoothNodeAI(DistributedNodeAI.DistributedNodeAI, DistributedNodeAI.DistributedNodeAI.__init__(self, air, name) DistributedSmoothNodeBase.DistributedSmoothNodeBase.__init__(self) - self.cnode.setRepository(air, 1, air.ourChannel) + def generate(self): + DistributedNodeAI.DistributedNodeAI.generate(self) + DistributedSmoothNodeBase.DistributedSmoothNodeBase.generate(self) + self.cnode.setRepository(self.air, 1, self.air.ourChannel) + + def disable(self): + DistributedSmoothNodeBase.DistributedSmoothNodeBase.disable(self) + DistributedNodeAI.DistributedNodeAI.disable(self) def delete(self): DistributedSmoothNodeBase.DistributedSmoothNodeBase.delete(self) diff --git a/direct/src/distributed/DistributedSmoothNodeBase.py b/direct/src/distributed/DistributedSmoothNodeBase.py index 540a6a1f9a..0c55962a56 100755 --- a/direct/src/distributed/DistributedSmoothNodeBase.py +++ b/direct/src/distributed/DistributedSmoothNodeBase.py @@ -10,14 +10,21 @@ class DistributedSmoothNodeBase: BroadcastTypes = Enum('FULL, XYH, XY') def __init__(self): + pass + + def generate(self): self.cnode = CDistributedSmoothNodeBase() self.cnode.setClockDelta(globalClockDelta) self.d_broadcastPosHpr = None - def delete(self): + def disable(self): + del self.cnode # make sure our task is gone self.stopPosHprBroadcast() + def delete(self): + pass + def b_clearSmoothing(self): self.d_clearSmoothing() self.clearSmoothing()