فهرست منبع

maybe fixing AI crash with orphand doLater

Dave Schuyler 22 سال پیش
والد
کامیت
6a636ddc9e
3فایلهای تغییر یافته به همراه12 افزوده شده و 7 حذف شده
  1. 3 0
      direct/src/fsm/FourStateAI.py
  2. 7 5
      direct/src/showbase/NonPhysicsWalker.py
  3. 2 2
      direct/src/showbase/PhysicsWalker.py

+ 3 - 0
direct/src/fsm/FourStateAI.py

@@ -137,6 +137,9 @@ class FourStateAI:
 
 
     def delete(self):
     def delete(self):
         assert(self.debugPrint("delete()"))
         assert(self.debugPrint("delete()"))
+        if self.doLaterTask is not None:
+            self.doLaterTask.remove()
+            del self.doLaterTask
         del self.states
         del self.states
         del self.fsm
         del self.fsm
     
     

+ 7 - 5
direct/src/showbase/NonPhysicsWalker.py

@@ -57,7 +57,7 @@ class NonPhysicsWalker(DirectObject.DirectObject):
         # Set up the collision sphere
         # Set up the collision sphere
         # This is a sphere on the ground to detect barrier collisions
         # This is a sphere on the ground to detect barrier collisions
         self.cSphere = CollisionSphere(0.0, 0.0, 0.0, avatarRadius)
         self.cSphere = CollisionSphere(0.0, 0.0, 0.0, avatarRadius)
-        cSphereNode = CollisionNode('cSphereNode')
+        cSphereNode = CollisionNode('NPW.cSphereNode')
         cSphereNode.addSolid(self.cSphere)
         cSphereNode.addSolid(self.cSphere)
         self.cSphereNodePath = avatarNodePath.attachNewNode(cSphereNode)
         self.cSphereNodePath = avatarNodePath.attachNewNode(cSphereNode)
         self.cSphereBitMask = wallCollideMask
         self.cSphereBitMask = wallCollideMask
@@ -69,7 +69,7 @@ class NonPhysicsWalker(DirectObject.DirectObject):
         # This is a ray cast from your head down to detect floor polygons
         # This is a ray cast from your head down to detect floor polygons
         # A toon is about 4.0 feet high, so start it there
         # A toon is about 4.0 feet high, so start it there
         self.cRay = CollisionRay(0.0, 0.0, 4.0, 0.0, 0.0, -1.0)
         self.cRay = CollisionRay(0.0, 0.0, 4.0, 0.0, 0.0, -1.0)
-        cRayNode = CollisionNode('cRayNode')
+        cRayNode = CollisionNode('NPW.cRayNode')
         cRayNode.addSolid(self.cRay)
         cRayNode.addSolid(self.cRay)
         self.cRayNodePath = avatarNodePath.attachNewNode(cRayNode)
         self.cRayNodePath = avatarNodePath.attachNewNode(cRayNode)
         self.cRayBitMask = floorCollideMask
         self.cRayBitMask = floorCollideMask
@@ -92,13 +92,13 @@ class NonPhysicsWalker(DirectObject.DirectObject):
         # and float above them as we go down. I increased this
         # and float above them as we go down. I increased this
         # from 8.0 to 16.0 to prevent this
         # from 8.0 to 16.0 to prevent this
         self.lifter.setMaxVelocity(16.0)
         self.lifter.setMaxVelocity(16.0)
-
-        # activate the collider with the traverser and pusher
-        self.setCollisionsActive(1)
         
         
         self.pusher.addCollider(self.cSphereNodePath, avatarNodePath)
         self.pusher.addCollider(self.cSphereNodePath, avatarNodePath)
         self.lifter.addCollider(self.cRayNodePath, avatarNodePath)
         self.lifter.addCollider(self.cRayNodePath, avatarNodePath)
 
 
+        # activate the collider with the traverser and pusher
+        self.setCollisionsActive(1)
+
     def setAirborneHeightFunc(self, getAirborneHeight):
     def setAirborneHeightFunc(self, getAirborneHeight):
         self.getAirborneHeight = getAirborneHeight
         self.getAirborneHeight = getAirborneHeight
 
 
@@ -130,6 +130,8 @@ class NonPhysicsWalker(DirectObject.DirectObject):
                 # Now that we have disabled collisions, make one more pass
                 # Now that we have disabled collisions, make one more pass
                 # right now to ensure we aren't standing in a wall.
                 # right now to ensure we aren't standing in a wall.
                 self.oneTimeCollide()
                 self.oneTimeCollide()
+        print "  cTrav.ls()" #*#
+        print self.cTrav #*#
 
 
     def oneTimeCollide(self):
     def oneTimeCollide(self):
         """
         """

+ 2 - 2
direct/src/showbase/PhysicsWalker.py

@@ -119,7 +119,7 @@ class PhysicsWalker(DirectObject.DirectObject):
         # This is a ray cast from your head down to detect floor polygons
         # This is a ray cast from your head down to detect floor polygons
         # A toon is about 4.0 feet high, so start it there
         # A toon is about 4.0 feet high, so start it there
         self.cRay = CollisionRay(0.0, 0.0, 4.0, 0.0, 0.0, -1.0)
         self.cRay = CollisionRay(0.0, 0.0, 4.0, 0.0, 0.0, -1.0)
-        cRayNode = CollisionNode('cRayNode')
+        cRayNode = CollisionNode('PW.cRayNode')
         cRayNode.addSolid(self.cRay)
         cRayNode.addSolid(self.cRay)
         self.cRayNodePath = self.avatarNodePath.attachNewNode(cRayNode)
         self.cRayNodePath = self.avatarNodePath.attachNewNode(cRayNode)
         self.cRayBitMask = floorBitmask
         self.cRayBitMask = floorBitmask
@@ -189,7 +189,7 @@ class PhysicsWalker(DirectObject.DirectObject):
         if self.useHeightRay:
         if self.useHeightRay:
             centerHeight *= 2.0
             centerHeight *= 2.0
         self.cSphere = CollisionSphere(0.0, 0.0, centerHeight, avatarRadius)
         self.cSphere = CollisionSphere(0.0, 0.0, centerHeight, avatarRadius)
-        cSphereNode = CollisionNode('cSphereNode')
+        cSphereNode = CollisionNode('PW.cSphereNode')
         cSphereNode.addSolid(self.cSphere)
         cSphereNode.addSolid(self.cSphere)
         self.cSphereNodePath = self.avatarNodePath.attachNewNode(cSphereNode)
         self.cSphereNodePath = self.avatarNodePath.attachNewNode(cSphereNode)
         self.cSphereBitMask = bitmask
         self.cSphereBitMask = bitmask