diff options
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r-- | source/gameengine/Ketsji/KX_CameraActuator.cpp | 3 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 26 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_KetsjiEngine.h | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_NavMeshObject.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_ObjectActuator.cpp | 4 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_PythonInit.cpp | 10 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_Scene.cpp | 5 |
7 files changed, 42 insertions, 10 deletions
diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 792a0759b59..acf30b4866c 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -36,7 +36,6 @@ #include "BLI_math_vector.h" #include "KX_CameraActuator.h" -#include <iostream> #include <math.h> #include <float.h> #include "KX_GameObject.h" @@ -197,7 +196,7 @@ bool KX_CameraActuator::Update(double curtime, bool frame) MT_Point3 lookat = ((KX_GameObject*)m_ob)->NodeGetWorldPosition(); MT_Matrix3x3 actormat = ((KX_GameObject*)m_ob)->NodeGetWorldOrientation(); - float fp1[3], fp2[3], rc[3]; + float fp1[3]={0}, fp2[3]={0}, rc[3]; float inp, fac; //, factor = 0.0; /* some factor... */ float mindistsq, maxdistsq, distsq; float mat[3][3]; diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 23419f11cd5..fab19008b25 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -184,7 +184,10 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) for (int i = tc_first; i < tc_numCategories; i++) m_logger->AddCategory((KX_TimeCategory)i); - + +#ifdef WITH_PYTHON + m_pyprofiledict = PyDict_New(); +#endif } @@ -197,6 +200,10 @@ KX_KetsjiEngine::~KX_KetsjiEngine() delete m_logger; if (m_usedome) delete m_dome; + +#ifdef WITH_PYTHON + Py_CLEAR(m_pyprofiledict); +#endif } @@ -256,6 +263,12 @@ void KX_KetsjiEngine::SetPyNamespace(PyObject *pythondictionary) MT_assert(pythondictionary); m_pythondictionary = pythondictionary; } + +PyObject* KX_KetsjiEngine::GetPyProfileDict() +{ + Py_INCREF(m_pyprofiledict); + return m_pyprofiledict; +} #endif @@ -297,7 +310,7 @@ void KX_KetsjiEngine::RenderDome() return; KX_SceneList::iterator sceneit; - KX_Scene* scene; + KX_Scene* scene = NULL; int n_renders=m_dome->GetNumberRenders();// usually 4 or 6 for (int i=0;i<n_renders;i++) { @@ -1513,6 +1526,15 @@ void KX_KetsjiEngine::RenderDebugProperties() m_rendertools->RenderBox2D(xcoord + (int)(2.2 * profile_indent), ycoord, m_canvas->GetWidth(), m_canvas->GetHeight(), time/tottime); ycoord += const_ysize; + +#ifdef WITH_PYTHON + PyObject *val = PyTuple_New(2); + PyTuple_SetItem(val, 0, PyFloat_FromDouble(time*1000.f)); + PyTuple_SetItem(val, 1, PyFloat_FromDouble(time/tottime * 100.f)); + + PyDict_SetItemString(m_pyprofiledict, m_profileLabels[j], val); + Py_DECREF(val); +#endif } } // Add the ymargin for titles below the other section of debug info diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 92ffaf47aa4..fdfe0551d18 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -81,6 +81,7 @@ private: #ifdef WITH_PYTHON /* borrowed from sys.modules["__main__"], don't manage ref's */ PyObject* m_pythondictionary; + PyObject* m_pyprofiledict; #endif class SCA_IInputDevice* m_keyboarddevice; class SCA_IInputDevice* m_mousedevice; @@ -222,6 +223,7 @@ public: #ifdef WITH_PYTHON void SetPyNamespace(PyObject *pythondictionary); PyObject* GetPyNamespace() { return m_pythondictionary; } + PyObject* GetPyProfileDict(); #endif void SetSceneConverter(KX_ISceneConverter* sceneconverter); void SetAnimRecordMode(bool animation_record, int startFrame); diff --git a/source/gameengine/Ketsji/KX_NavMeshObject.cpp b/source/gameengine/Ketsji/KX_NavMeshObject.cpp index 33656e9fd52..24400398f03 100644 --- a/source/gameengine/Ketsji/KX_NavMeshObject.cpp +++ b/source/gameengine/Ketsji/KX_NavMeshObject.cpp @@ -96,7 +96,7 @@ CValue* KX_NavMeshObject::GetReplica() void KX_NavMeshObject::ProcessReplica() { KX_GameObject::ProcessReplica(); - + m_navMesh = NULL; /* without this, building frees the navmesh we copied from */ BuildNavMesh(); KX_Scene* scene = KX_GetActiveScene(); KX_ObstacleSimulation* obssimulation = scene->GetObstacleSimulation(); diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index b4ee339568c..d02554e185e 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -215,8 +215,8 @@ bool KX_ObjectActuator::Update() m_previous_error = e; m_error_accumulator = I; parent->ApplyForce(m_force,(m_bitLocalFlag.LinearVelocity) != 0); - } else if(m_bitLocalFlag.CharacterMotion) - { + } + else if (m_bitLocalFlag.CharacterMotion) { MT_Vector3 dir = m_dloc; if (m_bitLocalFlag.AddOrSetCharLoc) { diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 66333a061c5..06abc755a9a 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -371,6 +371,15 @@ static PyObject *gPyLoadGlobalDict(PyObject *) Py_RETURN_NONE; } +static char gPyGetProfileInfo_doc[] = +"getProfileInfo()\n" +"returns a dictionary with profiling information"; + +static PyObject *gPyGetProfileInfo(PyObject *) +{ + return gp_KetsjiEngine->GetPyProfileDict(); +} + static char gPySendMessage_doc[] = "sendMessage(subject, [body, to, from])\n\ sends a message in same manner as a message actuator\ @@ -858,6 +867,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)"}, + {"getProfileInfo", (PyCFunction)gPyGetProfileInfo, METH_NOARGS, gPyGetProfileInfo_doc}, /* library functions */ {"LibLoad", (PyCFunction)gLibLoad, METH_VARARGS|METH_KEYWORDS, (const char *)""}, {"LibNew", (PyCFunction)gLibNew, METH_VARARGS, (const char *)""}, diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index fec275322e9..3e1a81c2f4f 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -1172,9 +1172,8 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj, bool use_gfx, bool u ); } newobj->SetDeformer(modifierDeformer); - } - else if (bHasShapeKey) - { + } + else if (bHasShapeKey) { BL_ShapeDeformer* shapeDeformer; if (bHasArmature) { |