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:
Diffstat (limited to 'source/gameengine/Ketsji/KX_TouchSensor.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_TouchSensor.cpp83
1 files changed, 43 insertions, 40 deletions
diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp
index 705b54edd37..5a6e8e6f501 100644
--- a/source/gameengine/Ketsji/KX_TouchSensor.cpp
+++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp
@@ -242,22 +242,22 @@ bool KX_TouchSensor::NewHandleCollision(void*object1,void*object2,const PHY_Coll
/* ------------------------------------------------------------------------- */
/* Integration hooks ------------------------------------------------------- */
PyTypeObject KX_TouchSensor::Type = {
- PyObject_HEAD_INIT(&PyType_Type)
+ PyObject_HEAD_INIT(NULL)
0,
"KX_TouchSensor",
- sizeof(KX_TouchSensor),
+ sizeof(PyObjectPlus_Proxy),
0,
- PyDestructor,
+ py_base_dealloc,
0,
- __getattr,
- __setattr,
- 0, //&MyPyCompare,
- __repr,
- 0, //&cvalue_as_number,
0,
0,
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_TouchSensor::Parents[] = {
@@ -286,34 +286,19 @@ PyAttributeDef KX_TouchSensor::Attributes[] = {
KX_PYATTRIBUTE_STRING_RW("property",0,100,false,KX_TouchSensor,m_touchedpropname),
KX_PYATTRIBUTE_BOOL_RW("useMaterial",KX_TouchSensor,m_bFindMaterial),
KX_PYATTRIBUTE_BOOL_RW("pulseCollisions",KX_TouchSensor,m_bTouchPulse),
- KX_PYATTRIBUTE_DUMMY("objectHit"),
- KX_PYATTRIBUTE_DUMMY("objectHitList"),
+ KX_PYATTRIBUTE_RO_FUNCTION("objectHit", KX_TouchSensor, pyattr_get_object_hit),
+ KX_PYATTRIBUTE_RO_FUNCTION("objectHitList", KX_TouchSensor, pyattr_get_object_hit_list),
{ NULL } //Sentinel
};
-PyObject* KX_TouchSensor::_getattr(const char *attr)
-{
- if (!strcmp(attr, "objectHit")) {
- if (m_hitObject) return m_hitObject->AddRef();
- else Py_RETURN_NONE;
- }
- if (!strcmp(attr, "objectHitList")) {
- return m_colliders->AddRef();
- }
-
- PyObject* object= _getattr_self(Attributes, this, attr);
- if (object != NULL)
- return object;
- _getattr_up(SCA_ISensor);
+PyObject* KX_TouchSensor::py_getattro(PyObject *attr)
+{
+ py_getattro_up(SCA_ISensor);
}
-int KX_TouchSensor::_setattr(const char *attr, PyObject *value)
+int KX_TouchSensor::py_setattro(PyObject *attr, PyObject *value)
{
- int ret = _setattr_self(Attributes, this, attr, value);
- if (ret >= 0)
- return ret;
-
- return SCA_ISensor::_setattr(attr, value);
+ py_setattro_up(SCA_ISensor);
}
/* Python API */
@@ -325,7 +310,7 @@ const char KX_TouchSensor::SetProperty_doc[] =
"\tSet the property or material to collide with. Use\n"
"\tsetTouchMaterial() to switch between properties and\n"
"\tmaterials.";
-PyObject* KX_TouchSensor::PySetProperty(PyObject* self, PyObject* value)
+PyObject* KX_TouchSensor::PySetProperty(PyObject* value)
{
ShowDeprecationWarning("setProperty()", "the propertyName property");
char *nameArg= PyString_AsString(value);
@@ -343,21 +328,21 @@ const char KX_TouchSensor::GetProperty_doc[] =
"\tReturns the property or material to collide with. Use\n"
"\tgetTouchMaterial() to find out whether this sensor\n"
"\tlooks for properties or materials.";
-PyObject* KX_TouchSensor::PyGetProperty(PyObject* self) {
+PyObject* KX_TouchSensor::PyGetProperty() {
return PyString_FromString(m_touchedpropname);
}
const char KX_TouchSensor::GetHitObject_doc[] =
"getHitObject()\n"
;
-PyObject* KX_TouchSensor::PyGetHitObject(PyObject* self)
+PyObject* KX_TouchSensor::PyGetHitObject()
{
ShowDeprecationWarning("getHitObject()", "the objectHit property");
/* to do: do Py_IncRef if the object is already known in Python */
/* otherwise, this leaks memory */
if (m_hitObject)
{
- return m_hitObject->AddRef();
+ return m_hitObject->GetProxy();
}
Py_RETURN_NONE;
}
@@ -366,12 +351,12 @@ const char KX_TouchSensor::GetHitObjectList_doc[] =
"getHitObjectList()\n"
"\tReturn a list of the objects this object collided with,\n"
"\tbut only those matching the property/material condition.\n";
-PyObject* KX_TouchSensor::PyGetHitObjectList(PyObject* self)
+PyObject* KX_TouchSensor::PyGetHitObjectList()
{
ShowDeprecationWarning("getHitObjectList()", "the objectHitList property");
/* to do: do Py_IncRef if the object is already known in Python */
/* otherwise, this leaks memory */ /* Edit, this seems ok and not to leak memory - Campbell */
- return m_colliders->AddRef();
+ return m_colliders->GetProxy();
}
/*getTouchMaterial and setTouchMaterial were never added to the api,
@@ -382,9 +367,9 @@ const char KX_TouchSensor::GetTouchMaterial_doc[] =
"getTouchMaterial()\n"
"\tReturns KX_TRUE if this sensor looks for a specific material,\n"
"\tKX_FALSE if it looks for a specific property.\n" ;
-PyObject* KX_TouchSensor::PyGetTouchMaterial(PyObject* self)
+PyObject* KX_TouchSensor::PyGetTouchMaterial()
{
- ShowDeprecationWarning("getTouchMaterial()", "the materialCheck property");
+ ShowDeprecationWarning("getTouchMaterial()", "the useMaterial property");
return PyInt_FromLong(m_bFindMaterial);
}
@@ -395,8 +380,9 @@ const char KX_TouchSensor::SetTouchMaterial_doc[] =
"\t- flag: KX_TRUE or KX_FALSE.\n"
"\tSet flag to KX_TRUE to switch on positive pulse mode,\n"
"\tKX_FALSE to switch off positive pulse mode.\n" ;
-PyObject* KX_TouchSensor::PySetTouchMaterial(PyObject* self, PyObject *value)
+PyObject* KX_TouchSensor::PySetTouchMaterial(PyObject *value)
{
+ ShowDeprecationWarning("setTouchMaterial()", "the useMaterial property");
int pulseArg = PyInt_AsLong(value);
if(pulseArg ==-1 && PyErr_Occurred()) {
@@ -410,4 +396,21 @@ PyObject* KX_TouchSensor::PySetTouchMaterial(PyObject* self, PyObject *value)
}
#endif
+PyObject* KX_TouchSensor::pyattr_get_object_hit(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_TouchSensor* self= static_cast<KX_TouchSensor*>(self_v);
+
+ if (self->m_hitObject)
+ return self->m_hitObject->GetProxy();
+ else
+ Py_RETURN_NONE;
+}
+
+PyObject* KX_TouchSensor::pyattr_get_object_hit_list(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_TouchSensor* self= static_cast<KX_TouchSensor*>(self_v);
+ return self->m_colliders->GetProxy();
+}
+
+
/* eof */