From 4f51f073a02547d3d1a5cbdb48e3efa22824f60a Mon Sep 17 00:00:00 2001 From: greytower <> Date: Tue, 17 Apr 2007 01:17:27 +0000 Subject: [PATCH] deal with 0 duration projectile interval --- direct/src/interval/ProjectileInterval.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/direct/src/interval/ProjectileInterval.py b/direct/src/interval/ProjectileInterval.py index 9451681553..ed2cccf06d 100755 --- a/direct/src/interval/ProjectileInterval.py +++ b/direct/src/interval/ProjectileInterval.py @@ -111,10 +111,12 @@ class ProjectileInterval(Interval): def calcStartVel(startPos, endPos, duration, zAccel): # p(t) = p_0 + t*v_0 + .5*a*t^2 # v_0 = [p(t) - p_0 - .5*a*t^2] / t - t = duration - return Point3((endPos[0] - startPos[0]) / duration, + if (duration == 0): + return Point3(0, 0, 0) + else: + return Point3((endPos[0] - startPos[0]) / duration, (endPos[1] - startPos[1]) / duration, - (endPos[2] - startPos[2] - (.5*zAccel*t*t)) / t) + (endPos[2] - startPos[2] - (.5*zAccel*duration*duration)) / duration) def calcTimeOfImpactOnPlane(startHeight, endHeight, startVel, accel): return PythonUtil.solveQuadratic(accel * .5, startVel,