ソースを参照

fixed sticky velocity

Darren Ranalli 20 年 前
コミット
ea3279d087
1 ファイル変更8 行追加5 行削除
  1. 8 5
      direct/src/controls/ShipPilot.py

+ 8 - 5
direct/src/controls/ShipPilot.py

@@ -805,7 +805,9 @@ class ShipPilot(PhysicsWalker.PhysicsWalker):
         assert self.avatarNodePath.getPos().almostEqual(physObject.getPosition(), 0.0001)
         assert self.avatarNodePath.getPos().almostEqual(physObject.getPosition(), 0.0001)
 
 
         # Check to see if we're moving at all:
         # Check to see if we're moving at all:
-        if self.__speed or self.__slideSpeed or self.__rotationSpeed or moveToGround!=Vec3.zero():
+        physVel = physObject.getVelocity()
+        physVelLen = physVel.length()
+        if (physVelLen!=0. or self.__speed or self.__slideSpeed or self.__rotationSpeed or moveToGround!=Vec3.zero()):
             distance = dt * self.__speed
             distance = dt * self.__speed
             goForward = True
             goForward = True
             if (distance < 0):
             if (distance < 0):
@@ -867,19 +869,20 @@ class ShipPilot(PhysicsWalker.PhysicsWalker):
             #assert self.avatarNodePath.getH()==debugTempH-rotation
             #assert self.avatarNodePath.getH()==debugTempH-rotation
             messenger.send("avatarMoving")
             messenger.send("avatarMoving")
         else:
         else:
+            # even if there are no active inputs, we still might be moving
+            assert physObject.getVelocity().length() == 0.
             self.__vel.set(0.0, 0.0, 0.0)
             self.__vel.set(0.0, 0.0, 0.0)
             goForward = True
             goForward = True
 
 
         
         
         #*#
         #*#
-        speed = physObject.getVelocity()
-        speedLen = speed.length()
+        speed = physVel
         if (goForward):
         if (goForward):
-            if speedLen > maxSpeed:
+            if physVelLen > maxSpeed:
                 speed.normalize()
                 speed.normalize()
                 speed *= maxSpeed
                 speed *= maxSpeed
         else:
         else:
-            if speedLen > self.ship.maxReverseSpeed:
+            if physVelLen > self.ship.maxReverseSpeed:
                 speed.normalize()
                 speed.normalize()
                 speed *= self.ship.maxReverseSpeed
                 speed *= self.ship.maxReverseSpeed