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:
authorBenoit Bolsee <benoit.bolsee@online.be>2009-04-01 12:59:36 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2009-04-01 12:59:36 +0400
commit48e4a4834092a8772141e6240e5e70d67110f126 (patch)
tree3def4fda774b7c9e4fac7320fbed3fd0165e589a
parent1e2f736d3a1813742e77373beb461a8b6645ac32 (diff)
BGE API cleanup: ReplaceMeshActuator mesh attributes now returns a KX_MeshProxy. Fix a bug in KX_MeshProxy where the Python type was not set right.
-rw-r--r--source/gameengine/Ketsji/KX_MeshProxy.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_MeshProxy.h1
-rw-r--r--source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp19
-rw-r--r--source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py4
4 files changed, 15 insertions, 11 deletions
diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp
index a0c0a496c06..f40c307315e 100644
--- a/source/gameengine/Ketsji/KX_MeshProxy.cpp
+++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp
@@ -124,7 +124,7 @@ KX_MeshProxy::_getattr(const char *attr)
KX_MeshProxy::KX_MeshProxy(RAS_MeshObject* mesh)
- : m_meshobj(mesh)
+ : SCA_IObject(&Type), m_meshobj(mesh)
{
}
diff --git a/source/gameengine/Ketsji/KX_MeshProxy.h b/source/gameengine/Ketsji/KX_MeshProxy.h
index 34f60a54a3a..9e08937de07 100644
--- a/source/gameengine/Ketsji/KX_MeshProxy.h
+++ b/source/gameengine/Ketsji/KX_MeshProxy.h
@@ -47,6 +47,7 @@ public:
virtual CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
virtual const STR_String & GetText();
virtual float GetNumber();
+ virtual RAS_MeshObject* GetMesh() { return m_meshobj; }
virtual STR_String GetName();
virtual void SetName(STR_String name); // Set the name of the value
virtual void ReplicaSetName(STR_String name);
diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp
index 2f971084a39..58d6f659135 100644
--- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp
@@ -36,6 +36,7 @@
// Please look here for revision history.
#include "KX_SCA_ReplaceMeshActuator.h"
+#include "KX_MeshProxy.h"
#include "PyObjectPlus.h"
@@ -115,7 +116,8 @@ PyObject* KX_SCA_ReplaceMeshActuator::pyattr_get_mesh(void *self, const struct K
KX_SCA_ReplaceMeshActuator* actuator = static_cast<KX_SCA_ReplaceMeshActuator*>(self);
if (!actuator->m_mesh)
Py_RETURN_NONE;
- return PyString_FromString(const_cast<char *>(actuator->m_mesh->GetName().ReadPtr()));
+ KX_MeshProxy* meshproxy = new KX_MeshProxy(actuator->m_mesh);
+ return meshproxy;
}
int KX_SCA_ReplaceMeshActuator::pyattr_set_mesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
@@ -123,18 +125,19 @@ int KX_SCA_ReplaceMeshActuator::pyattr_set_mesh(void *self, const struct KX_PYAT
KX_SCA_ReplaceMeshActuator* actuator = static_cast<KX_SCA_ReplaceMeshActuator*>(self);
if (value == Py_None) {
actuator->m_mesh = NULL;
- } else {
- char* meshname = PyString_AsString(value);
- if (!meshname) {
- PyErr_SetString(PyExc_ValueError, "Expected the name of a mesh or None");
- return 1;
- }
- void* mesh = SCA_ILogicBrick::m_sCurrentLogicManager->GetMeshByName(STR_String(meshname));
+ } else if (PyString_Check(value)) {
+ void* mesh = SCA_ILogicBrick::m_sCurrentLogicManager->GetMeshByName(STR_String(PyString_AsString(value)));
if (mesh==NULL) {
PyErr_SetString(PyExc_ValueError, "The mesh name given does not exist");
return 1;
}
actuator->m_mesh= (class RAS_MeshObject*)mesh;
+ } else if PyObject_TypeCheck(value, &KX_MeshProxy::Type) {
+ KX_MeshProxy* proxy = (KX_MeshProxy*)value;
+ actuator->m_mesh= proxy->GetMesh();
+ } else {
+ PyErr_SetString(PyExc_ValueError, "Expected the name of a mesh, a mesh proxy or None");
+ return 1;
}
return 0;
}
diff --git a/source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py b/source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py
index 1faf215ed56..1013dd53cb9 100644
--- a/source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py
+++ b/source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py
@@ -57,9 +57,9 @@ class KX_SCA_ReplaceMeshActuator(SCA_IActuator):
C{ERROR: GameObject I{OBName} ReplaceMeshActuator I{ActuatorName} without object}
Properties:
- @ivar mesh: the name of the mesh that will replace the current one
+ @ivar mesh: L{KX_MeshProxy} or the name of the mesh that will replace the current one
Set to None to disable actuator
- @type mesh: string or None if no mesh is set
+ @type mesh: L{KX_MeshProxy} or None if no mesh is set
"""
def setMesh(name):
"""