Dave Schuyler 21 years ago
parent
commit
d88fec148a

+ 7 - 0
direct/src/controls/GravityWalker.py

@@ -455,6 +455,13 @@ class GravityWalker(DirectObject.DirectObject):
         self.rotationSpeed=not slide and (
                 (turnLeft and self.avatarControlRotateSpeed) or
                 (turnRight and -self.avatarControlRotateSpeed))
+        
+        if __debug__:
+            debugRunning = inputState.isSet("debugRunning")
+            if debugRunning:
+                self.speed*=4.0
+                self.slideSpeed*=4.0
+                self.rotationSpeed*=1.25
 
         if self.needToDeltaPos:
             self.setPriorParentVector()

+ 1 - 1
direct/src/controls/InputState.py

@@ -73,7 +73,7 @@ class InputState(DirectObject.DirectObject):
     def set(self, name, isSet):
         assert(self.debugPrint("set(name=%s, isSet=%s)"%(name, isSet)))
         self.state[name] = isSet
-        # We change the name befor sending it because this may
+        # We change the name before sending it because this may
         # be the same name that messenger used to call InputState.set()
         # this avoids running in circles:
         messenger.send("InputState-%s"%(name,), [isSet])

+ 8 - 1
direct/src/controls/NonPhysicsWalker.py

@@ -198,7 +198,14 @@ class NonPhysicsWalker(DirectObject.DirectObject):
         self.rotationSpeed=not slide and (
                 (turnLeft and self.avatarControlRotateSpeed) or
                 (turnRight and -self.avatarControlRotateSpeed))
-           
+         
+        if __debug__:
+            debugRunning = inputState.isSet("debugRunning")
+            if debugRunning:
+                self.speed*=4.0
+                self.slideSpeed*=4.0
+                self.rotationSpeed*=1.25
+
         if self.wantDebugIndicator:
             self.displayDebugInfo()
         # How far did we move based on the amount of time elapsed?

+ 24 - 7
direct/src/controls/ShipPilot.py

@@ -245,6 +245,16 @@ class ShipPilot(PhysicsWalker.PhysicsWalker):
         self.phys.addLinearForce(gravity)
         self.gravity = gravity
         
+        fn=ForceNode("ship buoyancy")
+        fnp=NodePath(fn)
+        #fnp.reparentTo(physicsActor)
+        fnp.reparentTo(render)
+        self.nodes.append(fnp)
+        buoyancy=LinearVectorForce(0.0, 0.0, 0.0)
+        fn.addForce(buoyancy)
+        self.phys.addLinearForce(buoyancy)
+        self.buoyancy = buoyancy
+        
         fn=ForceNode("ship keel")
         fnp=NodePath(fn)
         #fnp.reparentTo(physicsActor)
@@ -548,12 +558,13 @@ class ShipPilot(PhysicsWalker.PhysicsWalker):
         #rotPhysToAvatar=Mat3.rotateMatNormaxis(self.avatarNodePath.getH(), Vec3.up())
         contact=self.actorNode.getContactVector()
         
-        # hack fix for falling through the floor:
-        if contact==Vec3.zero() and self.avatarNodePath.getZ()<-50.0:
-            # DCR: don't reset X and Y; allow player to move
-            self.reset()
-            self.avatarNodePath.setZ(50.0)
-            messenger.send("walkerIsOutOfWorld", [self.avatarNodePath])
+        depth=physObject.getPosition().getZ()
+        if depth < 0.0:
+            self.buoyancy.setVector(Vec3.zero())
+        else:
+            self.buoyancy.setVector(Vec3.zero())
+            physObject.setPosition(Point3(physObject.getPosition().getX(), physObject.getPosition().getY(), 0.0))
+            #self.buoyancy.setVector(Vec3(0, 0, -depth))
 
         # get the button states:
         forward = inputState.isSet("forward")
@@ -566,7 +577,6 @@ class ShipPilot(PhysicsWalker.PhysicsWalker):
         jump = inputState.isSet("jump")
         # Determine what the speeds are based on the buttons:
         
-        
         if 0:
             if not hasattr(self, "sailsDeployed"):
                 self.sailsDeployed = 0.0
@@ -597,6 +607,13 @@ class ShipPilot(PhysicsWalker.PhysicsWalker):
                 (turnLeft and self.ship.turnRate) or
                 (turnRight and -self.ship.turnRate))
 
+        if __debug__:
+            debugRunning = inputState.isSet("debugRunning")
+            if debugRunning:
+                self.__speed*=4.0
+                self.__slideSpeed*=4.0
+                self.__rotationSpeed*=1.25
+
 
         #*#
         if not hasattr(self, "currentTurning"):