mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
*** empty log message ***
This commit is contained in:
parent
af94f8f4e9
commit
149ee25973
@ -27,6 +27,9 @@ class ShipPilot(PhysicsWalker):
|
||||
wantDebugIndicator = base.config.GetBool(
|
||||
'want-avatar-physics-indicator', 0)
|
||||
|
||||
MAX_STRAIGHT_SAIL_BONUS = 1.0
|
||||
STRAIGHT_SAIL_BONUS_TIME = 10.0
|
||||
|
||||
# special methods
|
||||
def __init__(self,
|
||||
gravity = -32.1740,
|
||||
@ -47,6 +50,11 @@ class ShipPilot(PhysicsWalker):
|
||||
self.ship = None
|
||||
self.pusher = None
|
||||
|
||||
# Keeps track of the ship sailing in a straight heading
|
||||
# for long periods of time. We slowly up the ship's max
|
||||
# acceleration as this increases.
|
||||
self.straightHeading = 0
|
||||
|
||||
def setWalkSpeed(self, forward, jump, reverse, rotate):
|
||||
assert self.debugPrint("setWalkSpeed()")
|
||||
PhysicsWalker.setWalkSpeed(self, forward, 0, reverse, rotate)
|
||||
@ -94,7 +102,6 @@ class ShipPilot(PhysicsWalker):
|
||||
self.starboardPos = starboard.getPos(cRootNodePath)
|
||||
self.portPos = port.getPos(cRootNodePath)
|
||||
|
||||
|
||||
def setupCollisions(self):
|
||||
if self.pusher:
|
||||
return
|
||||
@ -358,6 +365,22 @@ class ShipPilot(PhysicsWalker):
|
||||
# How far did we move based on the amount of time elapsed?
|
||||
dt = ClockObject.getGlobalClock().getDt()
|
||||
|
||||
if reverse or turnLeft or turnRight or not forward:
|
||||
# Reset Straight Sailing Bonus
|
||||
self.straightHeading = 0
|
||||
else:
|
||||
# Add in the Straight Sailing Time
|
||||
self.straightHeading += dt
|
||||
|
||||
# Straight Sailing Acceleration Bonus
|
||||
straightSailBonus = 0.0
|
||||
#if self.straightHeading > self.STRAIGHT_SAIL_BONUS_TIME * 0.333:
|
||||
# straightSailBonus = (self.straightHeading - (self.STRAIGHT_SAIL_BONUS_TIME * 0.333)) / self.STRAIGHT_SAIL_BONUS_TIME * 0.666
|
||||
if self.straightHeading > (self.STRAIGHT_SAIL_BONUS_TIME * 0.5):
|
||||
straightSailBonus = (self.straightHeading - (self.STRAIGHT_SAIL_BONUS_TIME * 0.5)) / self.STRAIGHT_SAIL_BONUS_TIME * 0.5
|
||||
straightSailBonus = min(self.MAX_STRAIGHT_SAIL_BONUS, straightSailBonus * self.MAX_STRAIGHT_SAIL_BONUS)
|
||||
straightSailBonus += 1.0
|
||||
|
||||
# this was causing the boat to get stuck moving forward or back
|
||||
if 0:
|
||||
if not hasattr(self, "sailsDeployed"):
|
||||
@ -374,14 +397,14 @@ class ShipPilot(PhysicsWalker):
|
||||
self.sailsDeployed -= 0.25
|
||||
if self.sailsDeployed < -1.0:
|
||||
self.sailsDeployed = -1.0
|
||||
self.__speed = self.ship.acceleration * self.sailsDeployed
|
||||
self.__speed = self.ship.acceleration * straightSailBonus
|
||||
else:
|
||||
self.__speed=(forward and self.ship.acceleration) or \
|
||||
self.__speed=(forward and self.ship.acceleration * straightSailBonus) or \
|
||||
(reverse and -self.ship.reverseAcceleration)
|
||||
#self.__speed=(forward and min(dt*(self.__speed + self.ship.acceleration), self.ship.maxSpeed) or
|
||||
# reverse and min(dt*(self.__speed - self.ship.reverseAcceleration), self.ship.maxReverseSpeed))
|
||||
|
||||
avatarSlideSpeed=self.ship.acceleration*0.5
|
||||
avatarSlideSpeed=self.ship.acceleration *0.5 * straightSailBonus
|
||||
#self.__slideSpeed=slide and (
|
||||
# (turnLeft and -avatarSlideSpeed) or
|
||||
# (turnRight and avatarSlideSpeed))
|
||||
@ -392,8 +415,12 @@ class ShipPilot(PhysicsWalker):
|
||||
(turnLeft and self.ship.turnRate) or
|
||||
(turnRight and -self.ship.turnRate))
|
||||
|
||||
# Enable debug turbo mode
|
||||
maxSpeed = self.ship.maxSpeed
|
||||
# Add in Straight Sailing Multiplier
|
||||
self.__speed *= straightSailBonus
|
||||
self.__slideSpeed *= straightSailBonus
|
||||
maxSpeed = self.ship.maxSpeed * straightSailBonus
|
||||
|
||||
# Enable debug turbo modec
|
||||
debugRunning = inputState.isSet("debugRunning")
|
||||
if debugRunning or base.localAvatar.getTurbo():
|
||||
self.__speed*=4.0
|
||||
@ -469,7 +496,7 @@ class ShipPilot(PhysicsWalker):
|
||||
#newVector=Vec3(rotMat.xform(newVector))
|
||||
#maxLen = maxSpeed
|
||||
if (goForward):
|
||||
maxLen = self.ship.acceleration
|
||||
maxLen = self.ship.acceleration * straightSailBonus
|
||||
else:
|
||||
maxLen = self.ship.reverseAcceleration
|
||||
if newVector.length() > maxLen and \
|
||||
@ -477,7 +504,6 @@ class ShipPilot(PhysicsWalker):
|
||||
newVector.normalize()
|
||||
newVector *= maxLen
|
||||
|
||||
|
||||
if __debug__:
|
||||
onScreenDebug.add(
|
||||
"newVector", newVector)
|
||||
|
@ -35,6 +35,9 @@ class ShipPilot2(PhysicsWalker):
|
||||
useLifter = 0
|
||||
useHeightRay = 0
|
||||
|
||||
MAX_STRAIGHT_SAIL_BONUS = 4.0
|
||||
STRAIGHT_SAIL_BONUS_TIME = 10.0
|
||||
|
||||
# special methods
|
||||
def __init__(self, gravity = -32.1740, standableGround=0.707,
|
||||
hardLandingForce=16.0):
|
||||
@ -69,6 +72,11 @@ class ShipPilot2(PhysicsWalker):
|
||||
self.highMark = 0
|
||||
self.ship = None
|
||||
|
||||
# Keeps track of the ship sailing in a straight heading
|
||||
# for long periods of time. We slowly up the ship's max
|
||||
# acceleration as this increases.
|
||||
self.straightHeading = 0
|
||||
|
||||
def setWalkSpeed(self, forward, jump, reverse, rotate):
|
||||
assert self.debugPrint("setWalkSpeed()")
|
||||
self.avatarControlForwardSpeed=forward
|
||||
@ -604,6 +612,21 @@ class ShipPilot2(PhysicsWalker):
|
||||
# How far did we move based on the amount of time elapsed?
|
||||
dt=ClockObject.getGlobalClock().getDt()
|
||||
|
||||
if reverse or turnLeft or turnRight:
|
||||
# Reset Straight Sailing Bonus
|
||||
self.straightHeading = 0
|
||||
|
||||
# Straight Sailing Acceleration Bonus
|
||||
straightSailDt += dt
|
||||
straightSailBonus = 0.0
|
||||
if straightSailDt > self.STRAIGHT_SAIL_BONUS_TIME / 2.0:
|
||||
straightSailBonus = (straightSailDt - (self.STRAIGHT_SAIL_BONUS_TIME / 2.0)) / self.STRAIGHT_SAIL_BONUS_TIME / 2.0
|
||||
straightSailBonus *= self.MAX_STRAIGHT_SAIL_BONUS
|
||||
straightSailBonus += 1.0
|
||||
|
||||
print "##################"
|
||||
print straightSailBonus
|
||||
|
||||
# this was causing the boat to get stuck moving forward or back
|
||||
if 0:
|
||||
if not hasattr(self, "sailsDeployed"):
|
||||
@ -638,8 +661,11 @@ class ShipPilot2(PhysicsWalker):
|
||||
(turnLeft and self.ship.turnRate) or
|
||||
(turnRight and -self.ship.turnRate))
|
||||
|
||||
# Add in Straight Sailing Multiplier
|
||||
self.__speed *= straightSailBonus
|
||||
|
||||
# Enable debug turbo mode
|
||||
maxSpeed = self.ship.maxSpeed
|
||||
maxSpeed = self.ship.maxSpeed * straightSailBonus
|
||||
if __debug__:
|
||||
debugRunning = inputState.isSet("debugRunning")
|
||||
if debugRunning or base.localAvatar.getTurbo():
|
||||
|
Loading…
x
Reference in New Issue
Block a user