diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-07-09 19:30:15 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-07-09 19:30:15 +0400 |
commit | 732d886e0a8853ad8029e3e68cc826b69a28cf87 (patch) | |
tree | 7b8019e5ba637ce7139dab4a751e6e3996aaa1e3 /source/gameengine | |
parent | d0d179dce604a529381425a6c53f6cf4ea756b1d (diff) |
bugfix, vector was not checked for zero length before normalizing, closing blender instantly with an assert.
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index e29ca72500a..db13d30e2f1 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1608,14 +1608,18 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, other = static_cast<KX_GameObject*>(pyfrom); fromPoint = other->NodeGetWorldPosition(); } - - if (dist != 0.0f) - { + + if (dist != 0.0f) { MT_Vector3 toDir = toPoint-fromPoint; + if (MT_fuzzyZero(toDir.length2())) { + return Py_BuildValue("OOO", Py_None, Py_None, Py_None); + } toDir.normalize(); toPoint = fromPoint + (dist) * toDir; + } else if (MT_fuzzyZero((toPoint-fromPoint).length2())) { + return Py_BuildValue("OOO", Py_None, Py_None, Py_None); } - + MT_Point3 resultPoint; MT_Vector3 resultNormal; PHY_IPhysicsEnvironment* pe = GetPhysicsEnvironment(); |