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:
authorBenoit Bolsee <benoit.bolsee@online.be>2017-04-01 01:57:38 +0300
committerBenoit Bolsee <benoit.bolsee@online.be>2017-04-01 01:57:38 +0300
commit9847537979b8a3ccf4ee5c7f6ca5b66ed9d7b80b (patch)
treefa2b5006133bea1f042880d7accb9a1a2cab6564 /source/gameengine/Ketsji
parente4ea5e5810928ed3da2119a9a4a646bb6991436d (diff)
BGE: new bge.logic.Render() to perform render w/o logic step.
This function works only if python has control: 1. add scene custom property, call it __main__ 2. give it string value as the name of a text block 3. code game loop in python in text block. Example: import bge bge.logic.setUseExternalClock(True) t = 0.0; scene = bge.logic.getCurrentScene() cam = scene.cameras["Camera"] cam.setViewport(120,120,370,370) while not bge.logic.NextFrame(): cam.useViewport = True # second render with viewport enable, clock time unchanged bge.logic.Render() # advance animation for next frame t += 0.02 bge.logic.setClockTime(t) cam.useViewport = False
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp10
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.h3
2 files changed, 13 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index a93294e93ee..8b9dd2df9b1 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -905,6 +905,15 @@ static PyObject *gPyNextFrame(PyObject *)
}
}
+static PyObject *gPyRender(PyObject *)
+{
+ if (pynextframestate.render == NULL) Py_RETURN_NONE;
+ if (pynextframestate.state == NULL) Py_RETURN_NONE; //should never happen; raise exception instead?
+
+ pynextframestate.render(pynextframestate.state);
+ Py_RETURN_NONE;
+}
+
static struct PyMethodDef game_methods[] = {
{"expandPath", (PyCFunction)gPyExpandPath, METH_VARARGS, (const char *)gPyExpandPath_doc},
@@ -953,6 +962,7 @@ static struct PyMethodDef game_methods[] = {
{"PrintGLInfo", (PyCFunction)pyPrintExt, METH_NOARGS, (const char *)"Prints GL Extension Info"},
{"PrintMemInfo", (PyCFunction)pyPrintStats, METH_NOARGS, (const char *)"Print engine statistics"},
{"NextFrame", (PyCFunction)gPyNextFrame, METH_NOARGS, (const char *)"Render next frame (if Python has control)"},
+ {"Render", (PyCFunction)gPyRender, METH_NOARGS, (const char *)"Do only render (skip logic), if Python has control"},
{"getProfileInfo", (PyCFunction)gPyGetProfileInfo, METH_NOARGS, gPyGetProfileInfo_doc},
/* library functions */
{"LibLoad", (PyCFunction)gLibLoad, METH_VARARGS|METH_KEYWORDS, (const char *)""},
diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h
index 6550934a916..3b754ea1e25 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.h
+++ b/source/gameengine/Ketsji/KX_PythonInit.h
@@ -78,12 +78,15 @@ KX_Scene *KX_GetActiveScene();
KX_KetsjiEngine *KX_GetActiveEngine();
typedef int (*PyNextFrameFunc)(void *);
+typedef void (*PyRenderFunc)(void *);
struct PyNextFrameState {
/** can be either a GPG_NextFrameState or a BL_KetsjiNextFrameState */
void *state;
/** can be either GPG_PyNextFrame or BL_KetsjiPyNextFrame */
PyNextFrameFunc func;
+ /** can be either GPG_PyRender or BL_KetsjiPyRender */
+ PyRenderFunc render;
};
extern struct PyNextFrameState pynextframestate;