svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r22717:22875
[blender.git] / source / gameengine / Ketsji / KX_GameObject.cpp
index 91213bee865ab2f875ca82a69f47e89d1fb860ce..eeff39ab9b10fbb20d7ee186abb9e63475620efd 100644 (file)
@@ -2520,12 +2520,10 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo,
                }
        }
        MT_Point3 fromPoint = NodeGetWorldPosition();
+       
        if (dist != 0.0f)
-       {
-               MT_Vector3 toDir = toPoint-fromPoint;
-               toDir.normalize();
-               toPoint = fromPoint + (dist) * toDir;
-       }
+               toPoint = fromPoint + dist * (toPoint-fromPoint).safe_normalized();
+       
        PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment();
        KX_IPhysicsController *spc = GetPhysicsController();
        KX_GameObject *parent = GetParent();