Added the docs & use Python booleans for physics reinstance.
authorKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>
Sat, 23 Apr 2005 12:25:21 +0000 (12:25 +0000)
committerKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>
Sat, 23 Apr 2005 12:25:21 +0000 (12:25 +0000)
source/gameengine/Expressions/PyObjectPlus.h
source/gameengine/Ketsji/KX_MeshProxy.cpp
source/gameengine/PyDoc/KX_MeshProxy.py

index 8784d28d502d409ae7b6fda09530787f136fb76e..c261012a3bccd3c0f5d3c02d0e44b127e5651cef 100644 (file)
                                                                // some basic python macros
 #define Py_NEWARGS 1                   
 #define Py_Return { Py_INCREF(Py_None); return Py_None;}
+static inline PyObject* Py_Success(bool truth)
+{
+       if (truth)
+       {
+               Py_INCREF(Py_True);
+               return Py_True;
+       }
+       Py_INCREF(Py_False);
+       return Py_False;
+}
 
 #define Py_Error(E, M)   {PyErr_SetString(E, M); return NULL;}
 #define Py_Try(F) {if (!(F)) return NULL;}
 #define Py_Assert(A,E,M) {if (!(A)) {PyErr_SetString(E, M); return NULL;}}
 
-inline void Py_Fatal(char *M) {
+static inline void Py_Fatal(char *M) {
        //cout << M << endl; 
        exit(-1);
 };
index b8176c05ec370f71cf89770be2e0810a07be2ddd..37d8581631453ad8cda331f21658e0a460c9656e 100644 (file)
@@ -213,5 +213,5 @@ PyObject* KX_MeshProxy::PyGetVertex(PyObject* self,
 KX_PYMETHODDEF_DOC(KX_MeshProxy, reinstancePhysicsMesh,
 "Reinstance the physics mesh.")
 {
-       return PyInt_FromLong(KX_ReInstanceShapeFromMesh(m_meshobj));
+       return Py_Success(KX_ReInstanceShapeFromMesh(m_meshobj));
 }
index f93cd5c1f7ba63e3a2d27c4c4c2a05809d5201ad..e43fa3598f07e0f424e8ba7239d534ef158fc9cc 100644 (file)
@@ -95,4 +95,16 @@ class KX_MeshProxy:
                @rtype: L{KX_VertexProxy}
                @return: a vertex object.
                """
+       def reinstancePhysicsMesh():
+               """
+               Updates the physics system with the changed mesh.
+               
+               A mesh must have only one material with collision flags, 
+               and have all collision primitives in one vertex array (ie. < 65535 verts) and
+               be either a polytope or polyheder mesh.  If you don't get a warning in the
+               console when the collision type is polytope, the mesh is suitable for reinstance.
+               
+               @rtype: boolean
+               @return: True if reinstance succeeded, False if it failed.
+               """