Browse Source

added bow sphere

Dave Schuyler 21 years ago
parent
commit
3cf0b32484
1 changed files with 28 additions and 6 deletions
  1. 28 6
      direct/src/controls/ShipPilot.py

+ 28 - 6
direct/src/controls/ShipPilot.py

@@ -162,12 +162,20 @@ class ShipPilot(PhysicsWalker.PhysicsWalker):
         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.avatarRadius = avatarRadius
-        self.cSphere = CollisionSphere(0.0, 0.0, 0.0, avatarRadius)
-        cSphereNode = CollisionNode('SP.cSphereNode')
-        cSphereNode.addSolid(self.cSphere)
-        self.cSphereNodePath = self.avatarNodePath.attachNewNode(cSphereNode)
-        self.cSphereBitMask = bitmask
+        if 0:
+            self.avatarRadius = avatarRadius
+            self.cSphere = CollisionTube(Point3(0.0, 0.0, 0.0), Point3(0.0, 40.0, 0.0), avatarRadius)
+            cSphereNode = CollisionNode('SP.cSphereNode')
+            cSphereNode.addSolid(self.cSphere)
+            self.cSphereNodePath = self.avatarNodePath.attachNewNode(cSphereNode)
+            self.cSphereBitMask = bitmask
+        else:
+            self.avatarRadius = avatarRadius
+            self.cSphere = CollisionSphere(0.0, -5.0, 0.0, avatarRadius)
+            cSphereNode = CollisionNode('SP.cSphereNode')
+            cSphereNode.addSolid(self.cSphere)
+            self.cSphereNodePath = self.avatarNodePath.attachNewNode(cSphereNode)
+            self.cSphereBitMask = bitmask
 
 
         cSphereNode.setFromCollideMask(self.cSphereBitMask)
         cSphereNode.setFromCollideMask(self.cSphereBitMask)
         cSphereNode.setIntoCollideMask(BitMask32.allOff())
         cSphereNode.setIntoCollideMask(BitMask32.allOff())
@@ -179,6 +187,18 @@ class ShipPilot(PhysicsWalker.PhysicsWalker):
 
 
         self.pusher.addCollider(self.cSphereNodePath, self.avatarNodePath)
         self.pusher.addCollider(self.cSphereNodePath, self.avatarNodePath)
 
 
+        if 1:
+            self.cBowSphere = CollisionSphere(0.0, 20.0, 0.0, avatarRadius)
+            cBowSphereNode = CollisionNode('SP.cBowSphereNode')
+            cBowSphereNode.addSolid(self.cBowSphere)
+            self.cBowSphereNodePath = self.avatarNodePath.attachNewNode(cBowSphereNode)
+            self.cBowSphereBitMask = bitmask
+
+            cBowSphereNode.setFromCollideMask(self.cSphereBitMask)
+            cBowSphereNode.setIntoCollideMask(BitMask32.allOff())
+
+            self.pusher.addCollider(self.cBowSphereNodePath, self.avatarNodePath)
+
     def takedownPhysics(self):
     def takedownPhysics(self):
         assert(self.debugPrint("takedownPhysics()"))
         assert(self.debugPrint("takedownPhysics()"))
         if hasattr(self, "phys"):
         if hasattr(self, "phys"):
@@ -391,6 +411,7 @@ class ShipPilot(PhysicsWalker.PhysicsWalker):
             self.collisionsActive = active
             self.collisionsActive = active
             if active:
             if active:
                 self.cTrav.addCollider(self.cSphereNodePath, self.pusher)
                 self.cTrav.addCollider(self.cSphereNodePath, self.pusher)
+                self.cTrav.addCollider(self.cBowSphereNodePath, self.pusher)
                 if self.useHeightRay:
                 if self.useHeightRay:
                     if self.useLifter:
                     if self.useLifter:
                         self.cTrav.addCollider(self.cRayNodePath, self.lifter)
                         self.cTrav.addCollider(self.cRayNodePath, self.lifter)
@@ -398,6 +419,7 @@ class ShipPilot(PhysicsWalker.PhysicsWalker):
                         self.cTrav.addCollider(self.cRayNodePath, self.cRayQueue)
                         self.cTrav.addCollider(self.cRayNodePath, self.cRayQueue)
             else:
             else:
                 self.cTrav.removeCollider(self.cSphereNodePath)
                 self.cTrav.removeCollider(self.cSphereNodePath)
+                self.cTrav.removeCollider(self.cBowSphereNodePath)
                 if self.useHeightRay:
                 if self.useHeightRay:
                     self.cTrav.removeCollider(self.cRayNodePath)
                     self.cTrav.removeCollider(self.cRayNodePath)
                 # Now that we have disabled collisions, make one more pass
                 # Now that we have disabled collisions, make one more pass