Browse Source

re-create C++ objects on disable/generate

Darren Ranalli 18 years ago
parent
commit
d838c73a91

+ 17 - 9
direct/src/distributed/DistributedSmoothNode.py

@@ -66,21 +66,29 @@ class DistributedSmoothNode(DistributedNode.DistributedNode,
             self.DistributedSmoothNode_initialized = 1
             self.DistributedSmoothNode_initialized = 1
             DistributedNode.DistributedNode.__init__(self, cr)
             DistributedNode.DistributedNode.__init__(self, cr)
             DistributedSmoothNodeBase.DistributedSmoothNodeBase.__init__(self)
             DistributedSmoothNodeBase.DistributedSmoothNodeBase.__init__(self)
-            self.cnode.setRepository(cr, 0, 0)
-
-            self.smoother = SmoothMover()
             self.smoothStarted = 0
             self.smoothStarted = 0
-            self.lastSuggestResync = 0
-            self._smoothWrtReparents = False
-
-    def delete(self):
-        DistributedSmoothNodeBase.DistributedSmoothNodeBase.delete(self)
-        DistributedNode.DistributedNode.delete(self)
 
 
     def generate(self):
     def generate(self):
+        self.smoother = SmoothMover()
+        self.smoothStarted = 0
+        self.lastSuggestResync = 0
+        self._smoothWrtReparents = False
+
         DistributedNode.DistributedNode.generate(self)
         DistributedNode.DistributedNode.generate(self)
+        DistributedSmoothNodeBase.DistributedSmoothNodeBase.generate(self)
+        self.cnode.setRepository(self.cr, 0, 0)
+
         self.activateSmoothing(GlobalSmoothing, GlobalPrediction)
         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)
+
     ### Methods to handle computing and updating of the smoothed
     ### Methods to handle computing and updating of the smoothed
     ### position.
     ### position.
 
 

+ 8 - 1
direct/src/distributed/DistributedSmoothNodeAI.py

@@ -9,7 +9,14 @@ class DistributedSmoothNodeAI(DistributedNodeAI.DistributedNodeAI,
         DistributedNodeAI.DistributedNodeAI.__init__(self, air, name)
         DistributedNodeAI.DistributedNodeAI.__init__(self, air, name)
         DistributedSmoothNodeBase.DistributedSmoothNodeBase.__init__(self)
         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):
     def delete(self):
         DistributedSmoothNodeBase.DistributedSmoothNodeBase.delete(self)
         DistributedSmoothNodeBase.DistributedSmoothNodeBase.delete(self)

+ 8 - 1
direct/src/distributed/DistributedSmoothNodeBase.py

@@ -10,14 +10,21 @@ class DistributedSmoothNodeBase:
     BroadcastTypes = Enum('FULL, XYH, XY')
     BroadcastTypes = Enum('FULL, XYH, XY')
     
     
     def __init__(self):
     def __init__(self):
+        pass
+
+    def generate(self):
         self.cnode = CDistributedSmoothNodeBase()
         self.cnode = CDistributedSmoothNodeBase()
         self.cnode.setClockDelta(globalClockDelta)
         self.cnode.setClockDelta(globalClockDelta)
         self.d_broadcastPosHpr = None
         self.d_broadcastPosHpr = None
 
 
-    def delete(self):
+    def disable(self):
+        del self.cnode
         # make sure our task is gone
         # make sure our task is gone
         self.stopPosHprBroadcast()
         self.stopPosHprBroadcast()
 
 
+    def delete(self):
+        pass
+
     def b_clearSmoothing(self):
     def b_clearSmoothing(self):
         self.d_clearSmoothing()
         self.d_clearSmoothing()
         self.clearSmoothing()
         self.clearSmoothing()