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:
authorSybren A. Stüvel <sybren@stuvel.eu>2015-08-25 14:42:09 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2015-08-25 14:42:09 +0300
commitba5807c2710939cf8171fb19830f82cece48759f (patch)
tree77c7c9eddca6c63ff84850cd0db9f6bf485e660a /source/gameengine/Ketsji/KX_PythonInit.cpp
parent6f7eb623d3beaf7e49b5bb0d7686c2b2c714d867 (diff)
BGE: added bge.logic.{get,set}AnimRecordFrame functions
By using getAnimRecordFrame(), game developers have access to the frame number used by the "Record animation" feature. This enables them to record additional information in Blender's F-Curves and ensuring perfect synchronization with the information already recorded by Blender. The setAnimRecordFrame() can be used to change the frame number at which animations are recorded, for example to introduce delays the recording that do not require delays in the actual game/simulation run. The getter/setter functions in KX_KetsjiEngine are not directly named after property they access (m_currentFrame). I found "current frame" to be too vague for a public interface, hence chose a more descriptive name. Reviewers: moguri, hg1, campbellbarton, panzergame, aligorith Reviewed By: panzergame, aligorith Differential Revision: https://developer.blender.org/D1449
Diffstat (limited to 'source/gameengine/Ketsji/KX_PythonInit.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index 4cb632ed739..2fef74ca33d 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -526,6 +526,27 @@ static PyObject *gPyGetPhysicsTicRate(PyObject *)
return PyFloat_FromDouble(PHY_GetActiveEnvironment()->GetFixedTimeStep());
}
+static PyObject *gPySetAnimRecordFrame(PyObject *, PyObject *args)
+{
+ int anim_record_frame;
+
+ if (!PyArg_ParseTuple(args, "i:setAnimRecordFrame", &anim_record_frame))
+ return NULL;
+
+ if (anim_record_frame < 0 && (U.flag & USER_NONEGFRAMES)) {
+ PyErr_Format(PyExc_ValueError, "Frame number must be non-negative (was %i).", anim_record_frame);
+ return NULL;
+ }
+
+ gp_KetsjiEngine->setAnimRecordFrame(anim_record_frame);
+ Py_RETURN_NONE;
+}
+
+static PyObject *gPyGetAnimRecordFrame(PyObject *)
+{
+ return PyLong_FromLong(gp_KetsjiEngine->getAnimRecordFrame());
+}
+
static PyObject *gPyGetAverageFrameRate(PyObject *)
{
return PyFloat_FromDouble(KX_KetsjiEngine::GetAverageFrameRate());
@@ -887,6 +908,8 @@ static struct PyMethodDef game_methods[] = {
{"setLogicTicRate", (PyCFunction) gPySetLogicTicRate, METH_VARARGS, (const char *)"Sets the logic tic rate"},
{"getPhysicsTicRate", (PyCFunction) gPyGetPhysicsTicRate, METH_NOARGS, (const char *)"Gets the physics tic rate"},
{"setPhysicsTicRate", (PyCFunction) gPySetPhysicsTicRate, METH_VARARGS, (const char *)"Sets the physics tic rate"},
+ {"getAnimRecordFrame", (PyCFunction) gPyGetAnimRecordFrame, METH_NOARGS, (const char *)"Gets the current frame number used for animation recording"},
+ {"setAnimRecordFrame", (PyCFunction) gPySetAnimRecordFrame, METH_VARARGS, (const char *)"Sets the current frame number used for animation recording"},
{"getExitKey", (PyCFunction) gPyGetExitKey, METH_NOARGS, (const char *)"Gets the key used to exit the game engine"},
{"setExitKey", (PyCFunction) gPySetExitKey, METH_VARARGS, (const char *)"Sets the key used to exit the game engine"},
{"getAverageFrameRate", (PyCFunction) gPyGetAverageFrameRate, METH_NOARGS, (const char *)"Gets the estimated average frame rate"},