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:
authorKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-10-16 15:41:50 +0400
committerKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-10-16 15:41:50 +0400
commit7b2567924b9b86961cd4c07b76653f49939cab1c (patch)
treeadcf1091db6f3f78c05c6b02c567a9b77fc10092 /source/gameengine/Ketsji/KX_PythonInit.cpp
parent063982914038ecd578bab7849a1e94cccbb8d8b9 (diff)
Switch fixed time system. Logic updates should now happen at 30Hz, physics at 60Hz. (By default, use Python to set.) Some actuators still run at framerate (IPO, Action) for nice smooth animation, and an excuse to buy high end hardware.
Keyboard sensors can now hook escape key. Ctrl-Break can be used from within blender if you've forgotten an end game actuator. Fixed a stupid bug preventing some actuators working (like TrackTo).
Diffstat (limited to 'source/gameengine/Ketsji/KX_PythonInit.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index 3d6995ab4e0..ba466f20f64 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -41,6 +41,8 @@
#include "KX_PythonInit.h"
+#include "KX_KetsjiEngine.h"
+
#include "SCA_IInputDevice.h"
#include "SCA_PropertySensor.h"
#include "SCA_RandomActuator.h"
@@ -58,6 +60,7 @@
#include "KX_PyMath.h"
+#include "SumoPhysicsEnvironment.h"
// FIXME: Enable for access to blender python modules. This is disabled because
// python has dependencies on a lot of other modules and is a pain to link.
//#define USE_BLENDER_PYTHON
@@ -182,6 +185,43 @@ static PyObject* gPyStopDSP(PyObject*,
return NULL;
}
+static PyObject* gPySetLogicTicRate(PyObject*,
+ PyObject* args,
+ PyObject*)
+{
+ float ticrate;
+ if (PyArg_ParseTuple(args, "f", &ticrate))
+ {
+ KX_KetsjiEngine::SetTicRate(ticrate);
+ Py_Return;
+ }
+
+ return NULL;
+}
+
+static PyObject* gPyGetLogicTicRate(PyObject*, PyObject*, PyObject*)
+{
+ return PyFloat_FromDouble(KX_KetsjiEngine::GetTicRate());
+}
+
+static PyObject* gPySetPhysicsTicRate(PyObject*,
+ PyObject* args,
+ PyObject*)
+{
+ float ticrate;
+ if (PyArg_ParseTuple(args, "f", &ticrate))
+ {
+ SumoPhysicsEnvironment::setTicRate(ticrate);
+ Py_Return;
+ }
+
+ return NULL;
+}
+
+static PyObject* gPyGetPhysicsTicRate(PyObject*, PyObject*, PyObject*)
+{
+ return PyFloat_FromDouble(SumoPhysicsEnvironment::getTicRate());
+}
static STR_String gPyGetCurrentScene_doc =
"getCurrentScene()\n"
@@ -209,6 +249,10 @@ static struct PyMethodDef game_methods[] = {
{"setGravity",(PyCFunction) gPySetGravity, METH_VARARGS,"set Gravitation"},
{"getSpectrum",(PyCFunction) gPyGetSpectrum, METH_VARARGS,"get audio spectrum"},
{"stopDSP",(PyCFunction) gPyStopDSP, METH_VARARGS,"stop using the audio dsp (for performance reasons)"},
+ {"getLogicTicRate", (PyCFunction) gPyGetLogicTicRate, METH_VARARGS, "Gets the logic tic rate"},
+ {"setLogicTicRate", (PyCFunction) gPySetLogicTicRate, METH_VARARGS, "Sets the logic tic rate"},
+ {"getPhysicsTicRate", (PyCFunction) gPyGetPhysicsTicRate, METH_VARARGS, "Gets the physics tic rate"},
+ {"setPhysicsTicRate", (PyCFunction) gPySetPhysicsTicRate, METH_VARARGS, "Sets the physics tic rate"},
{NULL, (PyCFunction) NULL, 0, NULL }
};