svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r20855:20928
Sequencer changes from source/blender/src coming next
This commit is contained in:
@@ -70,6 +70,7 @@
|
||||
#include "MT_Vector3.h"
|
||||
#include "MT_Point3.h"
|
||||
#include "ListValue.h"
|
||||
#include "InputParser.h"
|
||||
#include "KX_Scene.h"
|
||||
#include "SND_DeviceManager.h"
|
||||
|
||||
@@ -501,6 +502,32 @@ static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *)
|
||||
}
|
||||
|
||||
|
||||
static PyObject *gEvalExpression(PyObject*, PyObject* value)
|
||||
{
|
||||
char* txt= PyString_AsString(value);
|
||||
|
||||
if (txt==NULL) {
|
||||
PyErr_SetString(PyExc_TypeError, "Expression.calc(text): expects a single string argument");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CParser parser;
|
||||
CExpression* expr = parser.ProcessText(txt);
|
||||
CValue* val = expr->Calculate();
|
||||
expr->Release();
|
||||
|
||||
if (val) {
|
||||
PyObject* pyobj = val->ConvertValueToPython();
|
||||
if (pyobj)
|
||||
return pyobj;
|
||||
else
|
||||
return val->GetProxy();
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
static struct PyMethodDef game_methods[] = {
|
||||
{"expandPath", (PyCFunction)gPyExpandPath, METH_VARARGS, (PY_METHODCHAR)gPyExpandPath_doc},
|
||||
{"sendMessage", (PyCFunction)gPySendMessage, METH_VARARGS, (PY_METHODCHAR)gPySendMessage_doc},
|
||||
@@ -529,6 +556,7 @@ static struct PyMethodDef game_methods[] = {
|
||||
{"getAverageFrameRate", (PyCFunction) gPyGetAverageFrameRate, METH_NOARGS, (PY_METHODCHAR)"Gets the estimated average frame rate"},
|
||||
{"getBlendFileList", (PyCFunction)gPyGetBlendFileList, METH_VARARGS, (PY_METHODCHAR)"Gets a list of blend files in the same directory as the current blend file"},
|
||||
{"PrintGLInfo", (PyCFunction)pyPrintExt, METH_NOARGS, (PY_METHODCHAR)"Prints GL Extension Info"},
|
||||
{"EvalExpression", (PyCFunction)gEvalExpression, METH_O, (PY_METHODCHAR)"Evaluate a string as a game logic expression"},
|
||||
{NULL, (PyCFunction) NULL, 0, NULL }
|
||||
};
|
||||
|
||||
@@ -1035,6 +1063,7 @@ PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack
|
||||
// Create the module and add the functions
|
||||
#if (PY_VERSION_HEX >= 0x03000000)
|
||||
m = PyModule_Create(&GameLogic_module_def);
|
||||
PyDict_SetItemString(PySys_GetObject("modules"), GameLogic_module_def.m_name, m);
|
||||
#else
|
||||
m = Py_InitModule4("GameLogic", game_methods,
|
||||
GameLogic_module_documentation,
|
||||
@@ -1701,6 +1730,7 @@ PyObject* initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas)
|
||||
// Create the module and add the functions
|
||||
#if (PY_VERSION_HEX >= 0x03000000)
|
||||
m = PyModule_Create(&Rasterizer_module_def);
|
||||
PyDict_SetItemString(PySys_GetObject("modules"), Rasterizer_module_def.m_name, m);
|
||||
#else
|
||||
m = Py_InitModule4("Rasterizer", rasterizer_methods,
|
||||
Rasterizer_module_documentation,
|
||||
@@ -1835,6 +1865,7 @@ PyObject* initGameKeys()
|
||||
// Create the module and add the functions
|
||||
#if (PY_VERSION_HEX >= 0x03000000)
|
||||
m = PyModule_Create(&GameKeys_module_def);
|
||||
PyDict_SetItemString(PySys_GetObject("modules"), GameKeys_module_def.m_name, m);
|
||||
#else
|
||||
m = Py_InitModule4("GameKeys", gamekeys_methods,
|
||||
GameKeys_module_documentation,
|
||||
@@ -1990,6 +2021,8 @@ PyObject* initGeometry() {Py_INCREF(Py_None);return Py_None;}
|
||||
PyObject* initBGL() {Py_INCREF(Py_None);return Py_None;}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void KX_SetActiveScene(class KX_Scene* scene)
|
||||
{
|
||||
gp_KetsjiScene = scene;
|
||||
@@ -2021,11 +2054,17 @@ int saveGamePythonConfig( char **marshal_buffer)
|
||||
if (pyGlobalDictMarshal) {
|
||||
// for testing only
|
||||
// PyObject_Print(pyGlobalDictMarshal, stderr, 0);
|
||||
|
||||
char *marshal_cstring;
|
||||
|
||||
#if PY_VERSION_HEX < 0x03000000
|
||||
marshal_cstring = PyString_AsString(pyGlobalDictMarshal);
|
||||
marshal_length= PyString_Size(pyGlobalDictMarshal);
|
||||
#else // py3 uses byte arrays
|
||||
marshal_cstring = PyBytes_AsString(pyGlobalDictMarshal);
|
||||
marshal_length= PyBytes_Size(pyGlobalDictMarshal);
|
||||
#endif
|
||||
*marshal_buffer = new char[marshal_length + 1];
|
||||
memcpy(*marshal_buffer, PyString_AsString(pyGlobalDictMarshal), marshal_length);
|
||||
|
||||
memcpy(*marshal_buffer, marshal_cstring, marshal_length);
|
||||
Py_DECREF(pyGlobalDictMarshal);
|
||||
} else {
|
||||
printf("Error, GameLogic.globalDict could not be marshal'd\n");
|
||||
@@ -2102,5 +2141,5 @@ void setGamePythonPath(char *path)
|
||||
// engine but loading blend files within the BGE wont overwrite gp_GamePythonPathOrig
|
||||
void resetGamePythonPath()
|
||||
{
|
||||
gp_GamePythonPathOrig[0] == '\0';
|
||||
gp_GamePythonPathOrig[0] = '\0';
|
||||
}
|
||||
|
Reference in New Issue
Block a user