Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2008-07-09 19:30:15 +0400
committerCampbell Barton <ideasman42@gmail.com>2008-07-09 19:30:15 +0400
commit732d886e0a8853ad8029e3e68cc826b69a28cf87 (patch)
tree7b8019e5ba637ce7139dab4a751e6e3996aaa1e3
parentd0d179dce604a529381425a6c53f6cf4ea756b1d (diff)
bugfix, vector was not checked for zero length before normalizing, closing blender instantly with an assert.
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp12
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();