diff options
-rw-r--r-- | source/blender/python/SConscript | 2 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Blender.c | 49 | ||||
-rw-r--r-- | source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp | 4 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/ghost/GPG_Application.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/BL_BlenderShader.cpp | 14 | ||||
-rw-r--r-- | source/gameengine/Ketsji/BL_BlenderShader.h | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_PythonInit.cpp | 83 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_PythonInit.h | 2 | ||||
-rw-r--r-- | source/gameengine/PyDoc/Rasterizer.py | 17 |
9 files changed, 107 insertions, 68 deletions
diff --git a/source/blender/python/SConscript b/source/blender/python/SConscript index 27dd510f944..dfd7dc8cfdc 100644 --- a/source/blender/python/SConscript +++ b/source/blender/python/SConscript @@ -6,7 +6,7 @@ sources = Split('BPY_interface.c BPY_menus.c') + env.Glob('api2_2x/*.c') incs = 'api2_2x ../blenkernel ../nodes ../blenlib ../blenloader' incs += ' ../render/extern/include ../radiosity/extern/include' incs += ' ../makesdna #intern/guardedalloc #intern/bmfont ../imbuf ../include' -incs += ' #extern/glew/include ../gpu' +incs += ' #extern/glew/include' incs += ' ' + env['BF_PYTHON_INC'] incs += ' ' + env['BF_OPENGL_INC'] diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c index 4fcb779b7dd..b00823dad8c 100644 --- a/source/blender/python/api2_2x/Blender.c +++ b/source/blender/python/api2_2x/Blender.c @@ -56,7 +56,6 @@ struct ID; /*keep me up here */ #include "DNA_screen_types.h" /* for SPACE_VIEW3D */ #include "DNA_userdef_types.h" #include "DNA_packedFile_types.h" -#include "GPU_material.h" #include "EXPP_interface.h" /* for bpy_gethome() */ #include "gen_utils.h" #include "modules.h" @@ -316,41 +315,7 @@ static PyObject *Blender_Set( PyObject * self, PyObject * args ) U.gameflags |= USER_DISABLE_MIPMAP; set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP)); - } - else if(StringEqual( name, "glsl_lights" ) || - StringEqual( name, "glsl_shaders" ) || - StringEqual( name, "glsl_shadows" ) || - StringEqual( name, "glsl_ramps" ) || - StringEqual( name, "glsl_nodes" ) || - StringEqual( name, "glsl_extra_textures" )) { - - int value = PyObject_IsTrue( arg ); - int flag = 0; - - if (value==-1) - return EXPP_ReturnPyObjError( PyExc_ValueError, - "expected an integer" ); - - if(StringEqual( name, "glsl_lights" )) - flag = G_FILE_GLSL_NO_LIGHTS; - else if(StringEqual( name, "glsl_shaders" )) - flag = G_FILE_GLSL_NO_SHADERS; - else if(StringEqual( name, "glsl_shadows" )) - flag = G_FILE_GLSL_NO_SHADOWS; - else if(StringEqual( name, "glsl_ramps" )) - flag = G_FILE_GLSL_NO_RAMPS; - else if(StringEqual( name, "glsl_nodes" )) - flag = G_FILE_GLSL_NO_NODES; - else if(StringEqual( name, "glsl_extra_textures" )) - flag = G_FILE_GLSL_NO_EXTRA_TEX; - - if (value) - G.fileflags &= ~flag; - else - G.fileflags |= flag; - - GPU_materials_free(); - }else + } else return ( EXPP_ReturnPyObjError( PyExc_AttributeError, "value given is not a blender setting" ) ); Py_RETURN_NONE; @@ -597,18 +562,6 @@ static PyObject *Blender_Get( PyObject * self, PyObject * value ) ret = PyInt_FromLong( (U.flag & USER_FILECOMPRESS) >> 15 ); else if(StringEqual( str, "mipmap" )) ret = PyInt_FromLong( (U.gameflags & USER_DISABLE_MIPMAP)!=0 ); - else if(StringEqual( str, "glsl_lights" )) - ret = PyInt_FromLong( (G.fileflags & G_FILE_GLSL_NO_LIGHTS)==0 ); - else if(StringEqual( str, "glsl_shaders" )) - ret = PyInt_FromLong( (G.fileflags & G_FILE_GLSL_NO_SHADERS)==0 ); - else if(StringEqual( str, "glsl_shadows" )) - ret = PyInt_FromLong( (G.fileflags & G_FILE_GLSL_NO_SHADOWS)==0 ); - else if(StringEqual( str, "glsl_ramps" )) - ret = PyInt_FromLong( (G.fileflags & G_FILE_GLSL_NO_RAMPS)==0 ); - else if(StringEqual( str, "glsl_nodes" )) - ret = PyInt_FromLong( (G.fileflags & G_FILE_GLSL_NO_NODES)==0 ); - else if(StringEqual( str, "glsl_extra_textures" )) - ret = PyInt_FromLong( (G.fileflags & G_FILE_GLSL_NO_EXTRA_TEX)==0 ); else if(StringEqual( str, "add_view_align" )) ret = PyInt_FromLong( ((U.flag & USER_ADD_VIEWALIGNED)!=0) ); else if(StringEqual( str, "add_editmode" )) diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 4bba77e3e4b..27c8a44a3e6 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -336,7 +336,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest); ketsjiengine->SetPythonDictionary(dictionaryobject); initRasterizer(rasterizer, canvas); - PyObject *gameLogic = initGameLogic(startscene); + PyObject *gameLogic = initGameLogic(ketsjiengine, startscene); PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module. initGameKeys(); initPythonConstraintBinding(); @@ -603,7 +603,7 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest); ketsjiengine->SetPythonDictionary(dictionaryobject); initRasterizer(rasterizer, canvas); - PyObject *gameLogic = initGameLogic(startscene); + PyObject *gameLogic = initGameLogic(ketsjiengine, startscene); PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module initGameKeys(); initPythonConstraintBinding(); diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 972d6d06b13..f53d8e9c3f6 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -651,7 +651,7 @@ bool GPG_Application::startEngine(void) PyObject* dictionaryobject = initGamePlayerPythonScripting("Ketsji", psl_Lowest); m_ketsjiengine->SetPythonDictionary(dictionaryobject); initRasterizer(m_rasterizer, m_canvas); - PyDict_SetItemString(dictionaryobject, "GameLogic", initGameLogic(startscene)); // Same as importing the module + PyDict_SetItemString(dictionaryobject, "GameLogic", initGameLogic(m_ketsjiengine, startscene)); // Same as importing the module initGameKeys(); initPythonConstraintBinding(); diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp index fc1cd1824ab..e4368173482 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.cpp +++ b/source/gameengine/Ketsji/BL_BlenderShader.cpp @@ -29,8 +29,10 @@ static struct Scene *GetSceneForName(const STR_String& scenename) return (Scene*)G.main->scene.first; } -const bool BL_BlenderShader::Ok()const +bool BL_BlenderShader::Ok() { + VerifyShader(); + return (mMat && mMat->gpumaterial); } @@ -61,15 +63,7 @@ bool BL_BlenderShader::VerifyShader() if(mMat && !mMat->gpumaterial) GPU_material_from_blender(mBlenderScene, mMat); - if(mMat && mMat->gpumaterial != mGPUMat) { - mGPUMat = mMat->gpumaterial; - - /* this is shaky - display lists are wrong now after the - * material changed, so we set all meshes as modified to - * rebuild their display lists */ - if(mScene->GetBucketManager()) - mScene->GetBucketManager()->ReleaseDisplayLists(); - } + mGPUMat = mMat->gpumaterial; return (mMat && mGPUMat); } diff --git a/source/gameengine/Ketsji/BL_BlenderShader.h b/source/gameengine/Ketsji/BL_BlenderShader.h index 2729bc9b048..63801195ecf 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.h +++ b/source/gameengine/Ketsji/BL_BlenderShader.h @@ -40,7 +40,7 @@ public: BL_BlenderShader(KX_Scene *scene, struct Material *ma, int lightlayer); virtual ~BL_BlenderShader(); - const bool Ok()const; + bool Ok(); void SetProg(bool enable); int GetAttribNum(); diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 0e214641065..4f2532c79b2 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -51,13 +51,13 @@ #include "BL_ActionActuator.h" #include "RAS_IRasterizer.h" #include "RAS_ICanvas.h" +#include "RAS_BucketManager.h" #include "MT_Vector3.h" #include "MT_Point3.h" #include "ListValue.h" #include "KX_Scene.h" #include "SND_DeviceManager.h" -#include "RAS_OpenGLRasterizer/RAS_GLExtensionManager.h" #include "BL_Shader.h" #include "KX_PyMath.h" @@ -73,6 +73,7 @@ #include "BKE_utildefines.h" #include "BKE_global.h" #include "BLI_blenlib.h" +#include "GPU_material.h" static void setSandbox(TPythonSecurityLevel level); @@ -80,6 +81,7 @@ static void setSandbox(TPythonSecurityLevel level); // 'local' copy of canvas ptr, for window height/width python scripts static RAS_ICanvas* gp_Canvas = NULL; static KX_Scene* gp_KetsjiScene = NULL; +static KX_KetsjiEngine* gp_KetsjiEngine = NULL; static RAS_IRasterizer* gp_Rasterizer = NULL; void KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color) @@ -671,6 +673,76 @@ static PyObject* gPyDisableMotionBlur(PyObject*, Py_Return; } +int getGLSLSettingFlag(char *setting) +{ + if(strcmp(setting, "lights") == 0) + return G_FILE_GLSL_NO_LIGHTS; + else if(strcmp(setting, "shaders") == 0) + return G_FILE_GLSL_NO_SHADERS; + else if(strcmp(setting, "shadows") == 0) + return G_FILE_GLSL_NO_SHADOWS; + else if(strcmp(setting, "ramps") == 0) + return G_FILE_GLSL_NO_RAMPS; + else if(strcmp(setting, "nodes") == 0) + return G_FILE_GLSL_NO_NODES; + else if(strcmp(setting, "extra_textures") == 0) + return G_FILE_GLSL_NO_EXTRA_TEX; + else + return -1; +} + +static PyObject* gPySetGLSLMaterialSetting(PyObject*, + PyObject* args, + PyObject*) +{ + char *setting; + int enable, flag; + + if (PyArg_ParseTuple(args,"si",&setting,&enable)) + { + flag = getGLSLSettingFlag(setting); + + if(flag != -1) { + if (enable) + G.fileflags &= ~flag; + else + G.fileflags |= flag; + + /* display lists and GLSL materials need to be remade */ + if(gp_KetsjiEngine) { + KX_SceneList *scenes = gp_KetsjiEngine->CurrentScenes(); + KX_SceneList::iterator it; + + for(it=scenes->begin(); it!=scenes->end(); it++) + if((*it)->GetBucketManager()) + (*it)->GetBucketManager()->ReleaseDisplayLists(); + } + + GPU_materials_free(); + } + } + + Py_Return; +} + +static PyObject* gPyGetGLSLMaterialSetting(PyObject*, + PyObject* args, + PyObject*) +{ + char *setting; + int enabled = 0, flag; + + if (PyArg_ParseTuple(args,"s",&setting)) + { + flag = getGLSLSettingFlag(setting); + + if(flag != -1) + enabled = ((G.fileflags & flag) != 0); + } + + return PyInt_FromLong(enabled); +} + STR_String gPyGetWindowHeight__doc__="getWindowHeight doc"; STR_String gPyGetWindowWidth__doc__="getWindowWidth doc"; STR_String gPyEnableVisibility__doc__="enableVisibility doc"; @@ -704,11 +776,13 @@ static struct PyMethodDef rasterizer_methods[] = { {"getEyeSeparation", (PyCFunction) gPyGetEyeSeparation, METH_VARARGS, "get the eye separation for stereo mode"}, {"setFocalLength", (PyCFunction) gPySetFocalLength, METH_VARARGS, "set the focal length for stereo mode"}, {"getFocalLength", (PyCFunction) gPyGetFocalLength, METH_VARARGS, "get the focal length for stereo mode"}, + {"setGLSLMaterialSetting",(PyCFunction) gPySetGLSLMaterialSetting, + METH_VARARGS, "set the state of a GLSL material setting"}, + {"getGLSLMaterialSetting",(PyCFunction) gPyGetGLSLMaterialSetting, + METH_VARARGS, "get the state of a GLSL material setting"}, { NULL, (PyCFunction) NULL, 0, NULL } }; - - // Initialization function for the module (*must* be called initGameLogic) static char GameLogic_module_documentation[] = @@ -721,11 +795,12 @@ static char Rasterizer_module_documentation[] = -PyObject* initGameLogic(KX_Scene* scene) // quick hack to get gravity hook +PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack to get gravity hook { PyObject* m; PyObject* d; + gp_KetsjiEngine = engine; gp_KetsjiScene = scene; gUseVisibilityTemp=false; diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h index 41cf7fd67b3..6851a7798ce 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.h +++ b/source/gameengine/Ketsji/KX_PythonInit.h @@ -40,7 +40,7 @@ typedef enum { extern bool gUseVisibilityTemp; -PyObject* initGameLogic(class KX_Scene* ketsjiscene); +PyObject* initGameLogic(class KX_KetsjiEngine *engine, class KX_Scene* ketsjiscene); PyObject* initGameKeys(); PyObject* initRasterizer(class RAS_IRasterizer* rasty,class RAS_ICanvas* canvas); PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecurityLevel level); diff --git a/source/gameengine/PyDoc/Rasterizer.py b/source/gameengine/PyDoc/Rasterizer.py index f0e48b6ed43..a21173b71b0 100644 --- a/source/gameengine/PyDoc/Rasterizer.py +++ b/source/gameengine/PyDoc/Rasterizer.py @@ -145,3 +145,20 @@ def getFocalLength(): @rtype: float """ + +def setGLSLMaterialSetting(setting, enable): + """ + Enables or disables a GLSL material setting. + + @type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures) + @type enable: boolean + """ + +def getGLSLMaterialSetting(setting, enable): + """ + Get the state of a GLSL material setting. + + @type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures) + @rtype: boolean + """ + |