Applied patch #5247 by scabootssca. This adds an instant replace mesh feature.
authorCharlie Carley <snailrose@gmail.com>
Mon, 26 Mar 2007 03:35:01 +0000 (03:35 +0000)
committerCharlie Carley <snailrose@gmail.com>
Mon, 26 Mar 2007 03:35:01 +0000 (03:35 +0000)
source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp
source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h

index 452c92a77eca2d94821e7f5290ab44ed566e5ab8..221d531a1c265870d05acae1e9e3167f10709cb9 100644 (file)
@@ -83,9 +83,11 @@ PyParentObject KX_SCA_ReplaceMeshActuator::Parents[] = {
 
 
 PyMethodDef KX_SCA_ReplaceMeshActuator::Methods[] = {
-  {"setMesh", (PyCFunction) KX_SCA_ReplaceMeshActuator::sPySetMesh, METH_VARARGS, SetMesh_doc},
-  KX_PYMETHODTABLE(KX_SCA_ReplaceMeshActuator, getMesh),
-  {NULL,NULL} //Sentinel
+       {"setMesh", (PyCFunction) KX_SCA_ReplaceMeshActuator::sPySetMesh, METH_VARARGS, SetMesh_doc},
+       
+       KX_PYMETHODTABLE(KX_SCA_ReplaceMeshActuator, instantReplaceMesh),
+       KX_PYMETHODTABLE(KX_SCA_ReplaceMeshActuator, getMesh),
+       {NULL,NULL} //Sentinel
 };
 
 
@@ -135,6 +137,14 @@ KX_PYMETHODDEF_DOC(KX_SCA_ReplaceMeshActuator, getMesh,
        return PyString_FromString(const_cast<char *>(m_mesh->GetName().ReadPtr()));
 }
 
+
+KX_PYMETHODDEF_DOC(KX_SCA_ReplaceMeshActuator, instantReplaceMesh,
+"instantReplaceMesh() : immediately replace mesh without delay\n")
+{
+       InstantReplaceMesh();
+       Py_Return;
+}
+
 /* ------------------------------------------------------------------------- */
 /* Native functions                                                          */
 /* ------------------------------------------------------------------------- */
@@ -191,4 +201,9 @@ CValue* KX_SCA_ReplaceMeshActuator::GetReplica()
        return replica;
 };
 
+void KX_SCA_ReplaceMeshActuator::InstantReplaceMesh()
+{
+       if (m_mesh) m_scene->ReplaceMesh(GetParent(),m_mesh);
+}
+
 /* eof */
index c1b1fd6735db928eab5b5b686379a1296a5aa3bc..339fce54c494638f006ca7898b5ce23644ad5d63 100644 (file)
@@ -76,10 +76,12 @@ class KX_SCA_ReplaceMeshActuator : public SCA_IActuator
        _getattr(
                const STR_String& attr
        );
+       void    InstantReplaceMesh();
 
        /* 1. setMesh */
        KX_PYMETHOD_DOC(KX_SCA_ReplaceMeshActuator,SetMesh);
        KX_PYMETHOD_DOC(KX_SCA_ReplaceMeshActuator,getMesh);
+       KX_PYMETHOD_DOC(KX_SCA_ReplaceMeshActuator,instantReplaceMesh);
 
 };