diff options
author | Porteries Tristan <republicthunderbolt9@gmail.com> | 2015-11-26 21:54:27 +0300 |
---|---|---|
committer | Porteries Tristan <republicthunderbolt9@gmail.com> | 2015-11-26 21:54:27 +0300 |
commit | b3808a4e065bf5007da3c74e27500fbbda809a01 (patch) | |
tree | 5b966933104f6acdcc1912df2d26c1af3e010b7b /source/gameengine/Ketsji/KX_GameObject.cpp | |
parent | d00a3316e7f6bbcb52793efe28271da77b81ce4c (diff) |
BGE: Fix ray cast with unfound property.
To return a valid ray cast result the object must not be NULL and KX_RayCast::RayTest must return true.
Diffstat (limited to 'source/gameengine/Ketsji/KX_GameObject.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 5e66250bd80..412a112df6b 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -3736,8 +3736,9 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, RayCastData rayData(propName, false, (1 << OB_MAX_COL_MASKS) - 1); KX_RayCast::Callback<KX_GameObject, RayCastData> callback(this, spc, &rayData); - if (KX_RayCast::RayTest(pe, fromPoint, toPoint, callback)) + if (KX_RayCast::RayTest(pe, fromPoint, toPoint, callback) && rayData.m_hitObject) { return rayData.m_hitObject->GetProxy(); + } Py_RETURN_NONE; } @@ -3883,8 +3884,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, RayCastData rayData(propName, xray, mask); KX_RayCast::Callback<KX_GameObject, RayCastData> callback(this, spc, &rayData, face, (poly == 2)); - if (KX_RayCast::RayTest(pe, fromPoint, toPoint, callback)) - { + if (KX_RayCast::RayTest(pe, fromPoint, toPoint, callback) && rayData.m_hitObject) { PyObject *returnValue = (poly == 2) ? PyTuple_New(5) : (poly) ? PyTuple_New(4) : PyTuple_New(3); if (returnValue) { // unlikely this would ever fail, if it does python sets an error PyTuple_SET_ITEM(returnValue, 0, rayData.m_hitObject->GetProxy()); |