Merge of itasc branch. Project files, scons and cmake should be working. Makefile...
[blender.git] / source / gameengine / Ketsji / KX_SCA_ReplaceMeshActuator.cpp
index 00842d7..e118972 100644 (file)
 
 /* Integration hooks ------------------------------------------------------- */
 
-       PyTypeObject 
-
-KX_SCA_ReplaceMeshActuator::Type = {
-#if (PY_VERSION_HEX >= 0x02060000)
+PyTypeObject KX_SCA_ReplaceMeshActuator::Type = {
        PyVarObject_HEAD_INIT(NULL, 0)
-#else
-       /* python 2.5 and below */
-       PyObject_HEAD_INIT( NULL )  /* required py macro */
-       0,                          /* ob_size */
-#endif
        "KX_SCA_ReplaceMeshActuator",
        sizeof(PyObjectPlus_Proxy),
        0,
@@ -69,50 +61,29 @@ KX_SCA_ReplaceMeshActuator::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       py_base_getattro,
-       py_base_setattro,
        0,0,0,0,0,0,0,0,0,
-       Methods
-};
-
-PyParentObject KX_SCA_ReplaceMeshActuator::Parents[] = {
-       &KX_SCA_ReplaceMeshActuator::Type,
+       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+       0,0,0,0,0,0,0,
+       Methods,
+       0,
+       0,
        &SCA_IActuator::Type,
-       &SCA_ILogicBrick::Type,
-       &CValue::Type,
-       NULL
+       0,0,0,0,0,0,
+       py_base_new
 };
 
-
-
 PyMethodDef KX_SCA_ReplaceMeshActuator::Methods[] = {
        KX_PYMETHODTABLE(KX_SCA_ReplaceMeshActuator, instantReplaceMesh),
-       // Deprecated ----->
-       {"setMesh", (PyCFunction) KX_SCA_ReplaceMeshActuator::sPySetMesh, METH_O, (PY_METHODCHAR)SetMesh_doc},
-       KX_PYMETHODTABLE(KX_SCA_ReplaceMeshActuator, getMesh),
        {NULL,NULL} //Sentinel
 };
 
 PyAttributeDef KX_SCA_ReplaceMeshActuator::Attributes[] = {
        KX_PYATTRIBUTE_RW_FUNCTION("mesh", KX_SCA_ReplaceMeshActuator, pyattr_get_mesh, pyattr_set_mesh),
+       KX_PYATTRIBUTE_BOOL_RW    ("useDisplayMesh", KX_SCA_ReplaceMeshActuator, m_use_gfx),
+       KX_PYATTRIBUTE_BOOL_RW    ("usePhysicsMesh", KX_SCA_ReplaceMeshActuator, m_use_phys),
        { NULL }        //Sentinel
 };
 
-PyObject* KX_SCA_ReplaceMeshActuator::py_getattro(PyObject *attr)
-{
-       py_getattro_up(SCA_IActuator);
-}
-
-PyObject* KX_SCA_ReplaceMeshActuator::py_getattro_dict() {
-       py_getattro_dict_up(SCA_IActuator);
-}
-
-int KX_SCA_ReplaceMeshActuator::py_setattro(PyObject *attr, PyObject* value) 
-{
-       py_setattro_up(SCA_IActuator);
-}
-
 PyObject* KX_SCA_ReplaceMeshActuator::pyattr_get_mesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
 {
        KX_SCA_ReplaceMeshActuator* actuator = static_cast<KX_SCA_ReplaceMeshActuator*>(self);
@@ -134,37 +105,6 @@ int KX_SCA_ReplaceMeshActuator::pyattr_set_mesh(void *self, const struct KX_PYAT
        return PY_SET_ATTR_SUCCESS;
 }
 
-/* 1. setMesh */
-const char KX_SCA_ReplaceMeshActuator::SetMesh_doc[] = 
-       "setMesh(name)\n"
-       "\t- name: string or None\n"
-       "\tSet the mesh that will be substituted for the current one.\n";
-
-PyObject* KX_SCA_ReplaceMeshActuator::PySetMesh(PyObject* value)
-{
-       ShowDeprecationWarning("setMesh()", "the mesh property");
-       RAS_MeshObject* new_mesh;
-       
-       if (!ConvertPythonToMesh(value, &new_mesh, true, "actuator.mesh = value: KX_SCA_ReplaceMeshActuator"))
-               return NULL;
-       
-       m_mesh = new_mesh;
-       Py_RETURN_NONE;
-}
-
-KX_PYMETHODDEF_DOC(KX_SCA_ReplaceMeshActuator, getMesh,
-"getMesh() -> string\n"
-"Returns the name of the mesh to be substituted.\n"
-)
-{
-       ShowDeprecationWarning("getMesh()", "the mesh property");
-       if (!m_mesh)
-               Py_RETURN_NONE;
-
-       return PyString_FromString(const_cast<char *>(m_mesh->GetName().ReadPtr()));
-}
-
-
 KX_PYMETHODDEF_DOC(KX_SCA_ReplaceMeshActuator, instantReplaceMesh,
 "instantReplaceMesh() : immediately replace mesh without delay\n")
 {
@@ -179,11 +119,14 @@ KX_PYMETHODDEF_DOC(KX_SCA_ReplaceMeshActuator, instantReplaceMesh,
 KX_SCA_ReplaceMeshActuator::KX_SCA_ReplaceMeshActuator(SCA_IObject *gameobj,
                                                                                                           class RAS_MeshObject *mesh,
                                                                                                           SCA_IScene* scene,
-                                                                                                          PyTypeObject* T) : 
+                                                                                                          bool use_gfx,
+                                                                                                          bool use_phys) :
 
-       SCA_IActuator(gameobj, T),
+       SCA_IActuator(gameobj, KX_ACT_REPLACE_MESH),
        m_mesh(mesh),
-       m_scene(scene)
+       m_scene(scene),
+       m_use_gfx(use_gfx),
+       m_use_phys(use_phys)
 {
 } /* End of constructor */
 
@@ -205,7 +148,8 @@ bool KX_SCA_ReplaceMeshActuator::Update()
        if (bNegativeEvent)
                return false; // do nothing on negative events
 
-       if (m_mesh) m_scene->ReplaceMesh(GetParent(),m_mesh);
+       if (m_mesh || m_use_phys) /* NULL mesh is ok if were updating physics */
+               m_scene->ReplaceMesh(GetParent(),m_mesh, m_use_gfx, m_use_phys);
 
        return false;
 }
@@ -227,7 +171,7 @@ CValue* KX_SCA_ReplaceMeshActuator::GetReplica()
 
 void KX_SCA_ReplaceMeshActuator::InstantReplaceMesh()
 {
-       if (m_mesh) m_scene->ReplaceMesh(GetParent(),m_mesh);
+       if (m_mesh) m_scene->ReplaceMesh(GetParent(),m_mesh, m_use_gfx, m_use_phys);
 }
 
 /* eof */