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:
authorMartin Poirier <theeth@yahoo.com>2008-10-28 21:47:01 +0300
committerMartin Poirier <theeth@yahoo.com>2008-10-28 21:47:01 +0300
commit025e4b046a527cdb58bccbccdec2f26d3973336c (patch)
treedbd3d6b68c75fa332a39f1eec628e044ece84d16 /source/gameengine
parentd1e90606c799d75fd3782a225b1f154918fc0fe7 (diff)
parent705a248c75467ef67eba1cda124fd5375eb4666f (diff)
merge 17122:17206
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/GameLogic/SCA_PythonController.cpp16
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp23
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h1
-rw-r--r--source/gameengine/PyDoc/KX_GameObject.py5
-rw-r--r--source/gameengine/PyDoc/SConscript28
5 files changed, 73 insertions, 0 deletions
diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp
index 4cb9bc8fe53..c354ab39747 100644
--- a/source/gameengine/GameLogic/SCA_PythonController.cpp
+++ b/source/gameengine/GameLogic/SCA_PythonController.cpp
@@ -262,6 +262,14 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
printf("Python compile error from controller \"%s\": \n", GetName().Ptr());
//PyRun_SimpleString(m_scriptText.Ptr());
PyErr_Print();
+
+ /* Added in 2.48a, the last_traceback can reference Objects for example, increasing
+ * their user count. Not to mention holding references to wrapped data.
+ * This is especially bad when the PyObject for the wrapped data is free'd, after blender
+ * has alredy dealocated the pointer */
+ PySys_SetObject( "last_traceback", Py_None);
+ PyErr_Clear(); /* just to be sure */
+
return;
}
m_bModified=false;
@@ -298,6 +306,14 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
// something is wrong, tell the user what went wrong
printf("Python script error from controller \"%s\": \n", GetName().Ptr());
PyErr_Print();
+
+ /* Added in 2.48a, the last_traceback can reference Objects for example, increasing
+ * their user count. Not to mention holding references to wrapped data.
+ * This is especially bad when the PyObject for the wrapped data is free'd, after blender
+ * has alredy dealocated the pointer */
+ PySys_SetObject( "last_traceback", Py_None);
+ PyErr_Clear(); /* just to be sure */
+
//PyRun_SimpleString(m_scriptText.Ptr());
}
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 8b2feca53a3..739c122a5ef 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -998,6 +998,7 @@ PyMethodDef KX_GameObject::Methods[] = {
{"getMesh", (PyCFunction)KX_GameObject::sPyGetMesh,METH_VARARGS},
{"getPhysicsId", (PyCFunction)KX_GameObject::sPyGetPhysicsId,METH_NOARGS},
{"getPropertyNames", (PyCFunction)KX_GameObject::sPyGetPropertyNames,METH_NOARGS},
+ {"replaceMesh",(PyCFunction) KX_GameObject::sPyReplaceMesh, METH_O},
{"endObject",(PyCFunction) KX_GameObject::sPyEndObject, METH_NOARGS},
KX_PYMETHODTABLE(KX_GameObject, rayCastTo),
KX_PYMETHODTABLE(KX_GameObject, rayCast),
@@ -1024,6 +1025,28 @@ bool KX_GameObject::ConvertPythonVectorArgs(PyObject* args,
}
*/
+PyObject* KX_GameObject::PyReplaceMesh(PyObject* self, PyObject* value)
+{
+ KX_Scene *scene = PHY_GetActiveScene();
+ char* meshname;
+ void* mesh_pt;
+
+ meshname = PyString_AsString(value);
+ if (meshname==NULL) {
+ PyErr_SetString(PyExc_ValueError, "Expected a mesh name");
+ return NULL;
+ }
+ mesh_pt = SCA_ILogicBrick::m_sCurrentLogicManager->GetMeshByName(STR_String(meshname));
+
+ if (mesh_pt==NULL) {
+ PyErr_SetString(PyExc_ValueError, "The mesh name given does not exist");
+ return NULL;
+ }
+ scene->ReplaceMesh(this, (class RAS_MeshObject*)mesh_pt);
+
+ Py_RETURN_NONE;
+}
+
PyObject* KX_GameObject::PyEndObject(PyObject* self)
{
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index 472d31362dd..20b15787d27 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -801,6 +801,7 @@ public:
KX_PYMETHOD_VARARGS(KX_GameObject,GetMesh);
KX_PYMETHOD_NOARGS(KX_GameObject,GetPhysicsId);
KX_PYMETHOD_NOARGS(KX_GameObject,GetPropertyNames);
+ KX_PYMETHOD_O(KX_GameObject,ReplaceMesh);
KX_PYMETHOD_NOARGS(KX_GameObject,EndObject);
KX_PYMETHOD_DOC(KX_GameObject,rayCastTo);
KX_PYMETHOD_DOC(KX_GameObject,rayCast);
diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py
index ff9b4ffc95b..505ce253dd1 100644
--- a/source/gameengine/PyDoc/KX_GameObject.py
+++ b/source/gameengine/PyDoc/KX_GameObject.py
@@ -30,6 +30,11 @@ class KX_GameObject:
Delete this object, can be used inpace of the EndObject Actuator.
The actual removal of the object from the scene is delayed.
"""
+ def replaceMesh(mesh_name):
+ """
+ Replace the mesh of this object with a new mesh. This works the same was as the actuator.
+ @type mesh_name: string
+ """
def getVisible():
"""
Gets the game object's visible flag.
diff --git a/source/gameengine/PyDoc/SConscript b/source/gameengine/PyDoc/SConscript
new file mode 100644
index 00000000000..3d1aa66bc69
--- /dev/null
+++ b/source/gameengine/PyDoc/SConscript
@@ -0,0 +1,28 @@
+#!/usr/bin/python
+Import ('env')
+
+
+from optparse import OptionParser
+try:
+ import epydoc
+except ImportError:
+ print "No epydoc install detected, Python API Docs will not be generated "
+if epydoc:
+ from epydoc.docbuilder import build_doc_index
+ from epydoc import cli
+ names = env.Glob("source/gameengine/PyDoc/*.py")
+ docindex = build_doc_index(names)
+ optvalues = cli.OPTION_DEFAULTS
+ optvalues["verbose"] = 1
+ optvalues["target"] = env["BF_DOCDIR"]+"/BGE_API/"
+ optvalues["url"] = "http://www.blender.org"
+ optvalues["top"] = "Game Engine API"
+ optvalues["name"] = "Blender"
+ optvalues["noprivate"] = 1
+ optvalues["noframes"] = 1
+ optvalues["names"] = names
+ optparser = OptionParser()
+ optparser.set_defaults(**optvalues)
+ (options, args) = optparser.parse_args()
+ cli.write_html(docindex, options)
+