diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index e24ade47783..f59faa18d0a 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -311,7 +311,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest); ketsjiengine->SetPythonDictionary(dictionaryobject); initRasterizer(rasterizer, canvas); - initGameLogic(startscene); + PyObject *gameLogic = initGameLogic(startscene); initGameKeys(); initPythonConstraintBinding(); @@ -370,11 +370,11 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, exitstring = ketsjiengine->GetExitString(); // when exiting the mainloop + dictionaryClearByHand(gameLogic); exitGamePythonScripting(); ketsjiengine->StopEngine(); networkdevice->Disconnect(); } - if (sceneconverter) { delete sceneconverter; diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 48d24bef623..47723c60592 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -278,7 +278,7 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) Py_DECREF(excdict);*/ -#if 1 +#if 0 PyObject *excdict= PyDict_Copy(m_pythondictionary); PyObject* resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode, excdict, @@ -286,13 +286,13 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) ); PyDict_Clear(excdict); Py_DECREF(excdict); -#endif +#else -#if 0 PyObject* resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode, m_pythondictionary, m_pythondictionary ); + #endif if (resultobj) diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index c476cdb5894..d78ad955e1a 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -96,12 +96,14 @@ private: int m_activecam; bool m_bFixedTime; + bool m_firstframe; int m_currentFrame; double m_frameTime;//discrete timestamp of the 'game logic frame' double m_clockTime;//current time double m_previousClockTime;//previous clock time + double m_remainingTime; static double m_ticrate; diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index f86b984c789..65751a995d9 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -784,6 +784,15 @@ PyObject* initGameLogic(KX_Scene* scene) // quick hack to get gravity hook return d; } +void dictionaryClearByHand(PyObject *dict) +{ + // Clears the dictionary by hand: + // This prevents, extra references to global variables + // inside the GameLogic dictionary when the python interpreter is finalized. + // which allows the scene to safely delete them :) + // see: (space.c)->start_game + if(dict) PyDict_Clear(dict); +} // Python Sandbox code diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h index 85616e26b6c..a4c2d1453a6 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.h +++ b/source/gameengine/Ketsji/KX_PythonInit.h @@ -50,6 +50,8 @@ PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur void exitGamePlayerPythonScripting(); PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLevel level); void exitGamePythonScripting(); +void dictionaryClearByHand(PyObject *dict); + void PHY_SetActiveScene(class KX_Scene* scene); #include "MT_Vector3.h" diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index bdeffd79a60..1706937f8df 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -181,7 +181,7 @@ KX_Scene::~KX_Scene() if(m_objectlist) m_objectlist->Release(); - + if (m_parentlist) m_parentlist->Release(); @@ -210,6 +210,7 @@ KX_Scene::~KX_Scene() { delete m_bucketmanager; } + //Py_DECREF(m_attrlist); } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index cb4adc77d76..e24bc1653af 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -528,6 +528,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep) if (!SimdFuzzyZero(timeStep)) { + // define this in blender, the stepsize is 30 hertz, 60 hertz works much better //#define SPLIT_TIMESTEP 1