[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25766] trunk/blender/source/gameengine/ Ketsji/KX_GameObject.cpp: BGE: KX_GameObject.rayCast() to return 5-tuple in case of no hit when poly=2 option is used.
Benoit Bolsee
benoit.bolsee at online.be
Wed Jan 6 09:44:11 CET 2010
Revision: 25766
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25766
Author: ben2610
Date: 2010-01-06 09:44:10 +0100 (Wed, 06 Jan 2010)
Log Message:
-----------
BGE: KX_GameObject.rayCast() to return 5-tuple in case of no hit when poly=2 option is used.
Modified Paths:
--------------
trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
Modified: trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp 2010-01-06 06:51:04 UTC (rev 25765)
+++ trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp 2010-01-06 08:44:10 UTC (rev 25766)
@@ -2605,6 +2605,23 @@
return ret;
}
+static PyObject *none_tuple_5()
+{
+ PyObject *ret= PyTuple_New(5);
+ PyTuple_SET_ITEM(ret, 0, Py_None);
+ PyTuple_SET_ITEM(ret, 1, Py_None);
+ PyTuple_SET_ITEM(ret, 2, Py_None);
+ PyTuple_SET_ITEM(ret, 3, Py_None);
+ PyTuple_SET_ITEM(ret, 4, Py_None);
+
+ Py_INCREF(Py_None);
+ Py_INCREF(Py_None);
+ Py_INCREF(Py_None);
+ Py_INCREF(Py_None);
+ Py_INCREF(Py_None);
+ return ret;
+}
+
KX_PYMETHODDEF_DOC(KX_GameObject, rayCast,
"rayCast(to,from,dist,prop,face,xray,poly): cast a ray and return 3-tuple (object,hit,normal) or 4-tuple (object,hit,normal,polygon) or 4-tuple (object,hit,normal,polygon,hituv) of contact point with object within dist that matches prop.\n"
" If no hit, return (None,None,None) or (None,None,None,None) or (None,None,None,None,None).\n"
@@ -2742,11 +2759,11 @@
return returnValue;
}
// no hit
- if (poly)
- //return Py_BuildValue("OOOO", Py_None, Py_None, Py_None, Py_None);
+ if (poly == 2)
+ return none_tuple_5();
+ else if (poly)
return none_tuple_4();
else
- //return Py_BuildValue("OOO", Py_None, Py_None, Py_None);
return none_tuple_3();
}
More information about the Bf-blender-cvs
mailing list