From 1578173ccce924e90798a92b92d515f5dc074f76 Mon Sep 17 00:00:00 2001 From: Josh Wilson Date: Mon, 21 May 2007 23:12:59 +0000 Subject: [PATCH] "handling dt=0 so as to prevent divide by zero errors" --- direct/src/controls/ShipPilot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/direct/src/controls/ShipPilot.py b/direct/src/controls/ShipPilot.py index 3460d1ed82..558f0ef857 100755 --- a/direct/src/controls/ShipPilot.py +++ b/direct/src/controls/ShipPilot.py @@ -361,7 +361,7 @@ class ShipPilot(PhysicsWalker): reverse = 0 # How far did we move based on the amount of time elapsed? - dt=ClockObject.getGlobalClock().getDt() + dt = ClockObject.getGlobalClock().getDt() # this was causing the boat to get stuck moving forward or back if 0: @@ -563,7 +563,8 @@ class ShipPilot(PhysicsWalker): oldPosDelta = self.shipNodePath.getPosDelta(render) oldDt = dt assert hasattr(self.ship, 'worldVelocity') - self.ship.worldVelocity = oldPosDelta*(1/oldDt) + if oldDt: + self.ship.worldVelocity = oldPosDelta*(1/oldDt) if self.wantDebugIndicator: onScreenDebug.add("w __oldPosDelta vec", oldPosDelta.pPrintValues())