BGE Python API
* fixed segfaults in CListValue.index(val) and CListValue.count(val) when the pyTypes could not be converted into a CValue. * added scene.objects to replace scene.getObjectList() * added function names to PyArg_ParseTuple() so errors will include the function names * removed cases of PyArg_ParseTuple(args,"O",&pyobj) where METH_O ensures a single argument. * Made PyObjectFrom use ugly python api rather then Py_BuildValue(), approx %40 speedup for functions that return Python vector and matrix types like ob.orientation.
This commit is contained in:
@@ -125,10 +125,10 @@ static PyObject* gPyGetRandomFloat(PyObject*)
|
||||
return PyFloat_FromDouble(MT_random());
|
||||
}
|
||||
|
||||
static PyObject* gPySetGravity(PyObject*, PyObject* args)
|
||||
static PyObject* gPySetGravity(PyObject*, PyObject* value)
|
||||
{
|
||||
MT_Vector3 vec = MT_Vector3(0., 0., 0.);
|
||||
if (!PyVecArgTo(args, vec))
|
||||
MT_Vector3 vec;
|
||||
if (!PyVecTo(value, vec))
|
||||
return NULL;
|
||||
|
||||
if (gp_KetsjiScene)
|
||||
@@ -412,7 +412,7 @@ static struct PyMethodDef game_methods[] = {
|
||||
METH_VARARGS, (PY_METHODCHAR)SCA_PythonController::sPyAddActiveActuator__doc__},
|
||||
{"getRandomFloat",(PyCFunction) gPyGetRandomFloat,
|
||||
METH_NOARGS, (PY_METHODCHAR)gPyGetRandomFloat_doc.Ptr()},
|
||||
{"setGravity",(PyCFunction) gPySetGravity, METH_VARARGS, (PY_METHODCHAR)"set Gravitation"},
|
||||
{"setGravity",(PyCFunction) gPySetGravity, METH_O, (PY_METHODCHAR)"set Gravitation"},
|
||||
{"getSpectrum",(PyCFunction) gPyGetSpectrum, METH_NOARGS, (PY_METHODCHAR)"get audio spectrum"},
|
||||
{"stopDSP",(PyCFunction) gPyStopDSP, METH_VARARGS, (PY_METHODCHAR)"stop using the audio dsp (for performance reasons)"},
|
||||
{"getLogicTicRate", (PyCFunction) gPyGetLogicTicRate, METH_NOARGS, (PY_METHODCHAR)"Gets the logic tic rate"},
|
||||
@@ -542,11 +542,11 @@ static PyObject* gPyGetFocalLength(PyObject*, PyObject*, PyObject*)
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* gPySetBackgroundColor(PyObject*, PyObject* args)
|
||||
static PyObject* gPySetBackgroundColor(PyObject*, PyObject* value)
|
||||
{
|
||||
|
||||
MT_Vector4 vec = MT_Vector4(0., 0., 0.3, 0.);
|
||||
if (!PyVecArgTo(args, vec))
|
||||
MT_Vector4 vec;
|
||||
if (!PyVecTo(value, vec))
|
||||
return NULL;
|
||||
|
||||
if (gp_Canvas)
|
||||
@@ -558,11 +558,11 @@ static PyObject* gPySetBackgroundColor(PyObject*, PyObject* args)
|
||||
|
||||
|
||||
|
||||
static PyObject* gPySetMistColor(PyObject*, PyObject* args)
|
||||
static PyObject* gPySetMistColor(PyObject*, PyObject* value)
|
||||
{
|
||||
|
||||
MT_Vector3 vec = MT_Vector3(0., 0., 0.);
|
||||
if (!PyVecArgTo(args, vec))
|
||||
MT_Vector3 vec;
|
||||
if (!PyVecTo(value, vec))
|
||||
return NULL;
|
||||
|
||||
if (!gp_Rasterizer) {
|
||||
@@ -613,11 +613,11 @@ static PyObject* gPySetMistEnd(PyObject*, PyObject* args)
|
||||
}
|
||||
|
||||
|
||||
static PyObject* gPySetAmbientColor(PyObject*, PyObject* args)
|
||||
static PyObject* gPySetAmbientColor(PyObject*, PyObject* value)
|
||||
{
|
||||
|
||||
MT_Vector3 vec = MT_Vector3(0., 0., 0.);
|
||||
if (!PyVecArgTo(args, vec))
|
||||
MT_Vector3 vec;
|
||||
if (!PyVecTo(value, vec))
|
||||
return NULL;
|
||||
|
||||
if (!gp_Rasterizer) {
|
||||
@@ -812,9 +812,9 @@ static PyObject* gPyDrawLine(PyObject*, PyObject* args)
|
||||
if (!PyArg_ParseTuple(args,"OOO",&ob_from,&ob_to,&ob_color))
|
||||
return NULL;
|
||||
|
||||
MT_Vector3 from(0., 0., 0.);
|
||||
MT_Vector3 to(0., 0., 0.);
|
||||
MT_Vector3 color(0., 0., 0.);
|
||||
MT_Vector3 from;
|
||||
MT_Vector3 to;
|
||||
MT_Vector3 color;
|
||||
if (!PyVecTo(ob_from, from))
|
||||
return NULL;
|
||||
if (!PyVecTo(ob_to, to))
|
||||
@@ -840,9 +840,9 @@ static struct PyMethodDef rasterizer_methods[] = {
|
||||
METH_VARARGS, "showMouse(bool visible)"},
|
||||
{"setMousePosition",(PyCFunction) gPySetMousePosition,
|
||||
METH_VARARGS, "setMousePosition(int x,int y)"},
|
||||
{"setBackgroundColor",(PyCFunction)gPySetBackgroundColor,METH_VARARGS,"set Background Color (rgb)"},
|
||||
{"setAmbientColor",(PyCFunction)gPySetAmbientColor,METH_VARARGS,"set Ambient Color (rgb)"},
|
||||
{"setMistColor",(PyCFunction)gPySetMistColor,METH_VARARGS,"set Mist Color (rgb)"},
|
||||
{"setBackgroundColor",(PyCFunction)gPySetBackgroundColor,METH_O,"set Background Color (rgb)"},
|
||||
{"setAmbientColor",(PyCFunction)gPySetAmbientColor,METH_O,"set Ambient Color (rgb)"},
|
||||
{"setMistColor",(PyCFunction)gPySetMistColor,METH_O,"set Mist Color (rgb)"},
|
||||
{"setMistStart",(PyCFunction)gPySetMistStart,METH_VARARGS,"set Mist Start(rgb)"},
|
||||
{"setMistEnd",(PyCFunction)gPySetMistEnd,METH_VARARGS,"set Mist End(rgb)"},
|
||||
{"enableMotionBlur",(PyCFunction)gPyEnableMotionBlur,METH_VARARGS,"enable motion blur"},
|
||||
|
||||
Reference in New Issue
Block a user