BGE API cleanup, patch from Moguri: RaySensor, NetworkMessageActuator, NetworkMessage...
authorBenoit Bolsee <benoit.bolsee@online.be>
Tue, 31 Mar 2009 19:02:01 +0000 (19:02 +0000)
committerBenoit Bolsee <benoit.bolsee@online.be>
Tue, 31 Mar 2009 19:02:01 +0000 (19:02 +0000)
source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h
source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp
source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h
source/gameengine/Ketsji/KX_PythonInit.cpp
source/gameengine/Ketsji/KX_RaySensor.cpp
source/gameengine/Ketsji/KX_RaySensor.h
source/gameengine/PyDoc/GameLogic.py
source/gameengine/PyDoc/KX_NetworkMessageActuator.py
source/gameengine/PyDoc/KX_NetworkMessageSensor.py
source/gameengine/PyDoc/KX_RaySensor.py

index 4e5f27df2daac94ac69ca5bccc73a8e2221723d0..fa4fdaee972882c64b5db203114b71a453196a22 100644 (file)
@@ -47,7 +47,7 @@ KX_NetworkMessageActuator::KX_NetworkMessageActuator(
        m_networkscene(networkscene),
        m_toPropName(toPropName),
        m_subject(subject),
-       m_bodyType(bodyType),
+       m_bPropBody(bodyType),
        m_body(body)
 {
 }
@@ -69,7 +69,7 @@ bool KX_NetworkMessageActuator::Update()
        }
        //printf("messageactuator true event\n");
 
-       if (m_bodyType == 1) // ACT_MESG_PROP in DNA_actuator_types.h
+       if (m_bPropBody) // ACT_MESG_PROP in DNA_actuator_types.h
        {
                m_networkscene->SendMessage(
                        m_toPropName,
@@ -132,6 +132,7 @@ PyParentObject KX_NetworkMessageActuator::Parents[] = {
 };
 
 PyMethodDef KX_NetworkMessageActuator::Methods[] = {
+       // Deprecated ----->
        {"setToPropName", (PyCFunction)
                KX_NetworkMessageActuator::sPySetToPropName, METH_VARARGS},
        {"setSubject", (PyCFunction)
@@ -140,23 +141,40 @@ PyMethodDef KX_NetworkMessageActuator::Methods[] = {
                KX_NetworkMessageActuator::sPySetBodyType, METH_VARARGS},
        {"setBody", (PyCFunction)
                KX_NetworkMessageActuator::sPySetBody, METH_VARARGS},
+       // <-----
        {NULL,NULL} // Sentinel
 };
 
 PyAttributeDef KX_NetworkMessageActuator::Attributes[] = {
+       KX_PYATTRIBUTE_STRING_RW("propName", 0, 100, false, KX_NetworkMessageActuator, m_toPropName),
+       KX_PYATTRIBUTE_STRING_RW("subject", 0, 100, false, KX_NetworkMessageActuator, m_subject),
+       KX_PYATTRIBUTE_BOOL_RW("usePropBody", KX_NetworkMessageActuator, m_bPropBody),
+       KX_PYATTRIBUTE_STRING_RW("body", 0, 100, false, KX_NetworkMessageActuator, m_body),
        { NULL }        //Sentinel
 };
 
 PyObject* KX_NetworkMessageActuator::_getattr(const char *attr) {
+       PyObject* object = _getattr_self(Attributes, this, attr);
+       if (object != NULL)
+               return object;
        _getattr_up(SCA_IActuator);
 }
 
+int KX_NetworkMessageActuator::_setattr(const char *attr, PyObject *value) {
+       int ret = _setattr_self(Attributes, this, attr, value);
+       if (ret >= 0)
+               return ret;
+       return SCA_IActuator::_setattr(attr, value);
+}
+
+// Deprecated ----->
 // 1. SetToPropName
 PyObject* KX_NetworkMessageActuator::PySetToPropName(
        PyObject* self,
        PyObject* args,
        PyObject* kwds)
 {
+       ShowDeprecationWarning("setToProp()", "the propName property");
     char* ToPropName;
 
        if (PyArg_ParseTuple(args, "s", &ToPropName)) {
@@ -175,6 +193,7 @@ PyObject* KX_NetworkMessageActuator::PySetSubject(
        PyObject* args,
        PyObject* kwds)
 {
+       ShowDeprecationWarning("setSubject()", "the subject property");
     char* Subject;
 
        if (PyArg_ParseTuple(args, "s", &Subject)) {
@@ -193,10 +212,11 @@ PyObject* KX_NetworkMessageActuator::PySetBodyType(
        PyObject* args,
        PyObject* kwds)
 {
+       ShowDeprecationWarning("setBodyType()", "the usePropBody property");
     int BodyType;
 
        if (PyArg_ParseTuple(args, "i", &BodyType)) {
-            m_bodyType = BodyType;
+               m_bPropBody = (BodyType != 0);
        }
        else {
                return NULL;
@@ -211,6 +231,7 @@ PyObject* KX_NetworkMessageActuator::PySetBody(
        PyObject* args,
        PyObject* kwds)
 {
+       ShowDeprecationWarning("setBody()", "the body property");
     char* Body;
 
        if (PyArg_ParseTuple(args, "s", &Body)) {
@@ -223,3 +244,4 @@ PyObject* KX_NetworkMessageActuator::PySetBody(
        Py_RETURN_NONE;
 }
 
+// <----- Deprecated
\ No newline at end of file
index 96b55ef839bbf9b329e831dec7db0f80d61f56db..d9a7f78733337a38d09fbd32917ec89b3980f839 100644 (file)
@@ -41,7 +41,7 @@ class KX_NetworkMessageActuator : public SCA_IActuator
        class NG_NetworkScene* m_networkscene;  // needed for replication
        STR_String m_toPropName;
        STR_String m_subject;
-       int m_bodyType;
+       bool m_bPropBody;
        STR_String m_body;
 public:
        KX_NetworkMessageActuator(
@@ -62,11 +62,14 @@ public:
        /* ------------------------------------------------------------ */
 
        virtual PyObject* _getattr(const char *attr);
+       virtual int _setattr(const char *attr, PyObject *value);
 
+       // Deprecated ----->
        KX_PYMETHOD(KX_NetworkMessageActuator, SetToPropName);
        KX_PYMETHOD(KX_NetworkMessageActuator, SetSubject);
        KX_PYMETHOD(KX_NetworkMessageActuator, SetBodyType);
        KX_PYMETHOD(KX_NetworkMessageActuator, SetBody);
+       // <-----
 
 };
 
index ac89d8b0716901d1e7002fcaa62270e97f21b5fb..40ade4607927114e062d7bb7854c052b7f0eeda0 100644 (file)
@@ -195,6 +195,7 @@ PyParentObject KX_NetworkMessageSensor::Parents[] = {
 };
 
 PyMethodDef KX_NetworkMessageSensor::Methods[] = {
+       // Deprecated ----->
        {"setSubjectFilterText", (PyCFunction)
                KX_NetworkMessageSensor::sPySetSubjectFilterText, METH_O,
                (PY_METHODCHAR)SetSubjectFilterText_doc},
@@ -210,17 +211,53 @@ PyMethodDef KX_NetworkMessageSensor::Methods[] = {
        {"getSubjects", (PyCFunction)
                KX_NetworkMessageSensor::sPyGetSubjects, METH_NOARGS,
                (PY_METHODCHAR)GetSubjects_doc},
+       // <-----
        {NULL,NULL} //Sentinel
 };
 
 PyAttributeDef KX_NetworkMessageSensor::Attributes[] = {
+       KX_PYATTRIBUTE_STRING_RW("subject", 0, 100, false, KX_NetworkMessageSensor, m_subject),
+       KX_PYATTRIBUTE_INT_RO("frameMessageCount", KX_NetworkMessageSensor, m_frame_message_count),
+       KX_PYATTRIBUTE_RO_FUNCTION("bodies", KX_NetworkMessageSensor, pyattr_get_bodies),
+       KX_PYATTRIBUTE_RO_FUNCTION("subjects", KX_NetworkMessageSensor, pyattr_get_subjects),
        { NULL }        //Sentinel
 };
 
 PyObject* KX_NetworkMessageSensor::_getattr(const char *attr) {
-       _getattr_up(SCA_ISensor); // implicit return!
+       PyObject* object = _getattr_self(Attributes, this, attr);
+       if (object != NULL)
+               return object;
+       _getattr_up(SCA_ISensor);
 }
 
+int KX_NetworkMessageSensor::_setattr(const char *attr, PyObject *value) {
+       int ret = _setattr_self(Attributes, this, attr, value);
+       if (ret >= 0)
+               return ret;
+       return SCA_ISensor::_setattr(attr, value);
+}
+
+PyObject* KX_NetworkMessageSensor::pyattr_get_bodies(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+       KX_NetworkMessageSensor *self = static_cast<KX_NetworkMessageSensor*>(self_v);
+       if (self->m_BodyList) {
+               return ((PyObject*) self->m_BodyList->AddRef());
+       } else {
+               return ((PyObject*) new CListValue());
+       }
+}
+
+PyObject* KX_NetworkMessageSensor::pyattr_get_subjects(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+       KX_NetworkMessageSensor *self = static_cast<KX_NetworkMessageSensor*>(self_v);
+       if (self->m_SubjectList) {
+               return ((PyObject*) self->m_SubjectList->AddRef());
+       } else {
+               return ((PyObject*) new CListValue());
+       }
+}
+
+// Deprecated ----->
 // 1. Set the message subject that this sensor listens for
 const char KX_NetworkMessageSensor::SetSubjectFilterText_doc[] = 
 "\tsetSubjectFilterText(value)\n"
@@ -228,6 +265,7 @@ const char KX_NetworkMessageSensor::SetSubjectFilterText_doc[] =
 
 PyObject* KX_NetworkMessageSensor::PySetSubjectFilterText( PyObject* self, PyObject* value)
 {
+       ShowDeprecationWarning("setSubjectFilterText()", "subject");
        char* Subject = PyString_AsString(value);
        if (Subject==NULL) {
                PyErr_SetString(PyExc_TypeError, "expected a string message");
@@ -245,6 +283,7 @@ const char KX_NetworkMessageSensor::GetFrameMessageCount_doc[] =
 
 PyObject* KX_NetworkMessageSensor::PyGetFrameMessageCount( PyObject* )
 {
+       ShowDeprecationWarning("getFrameMessageCount()", "frameMessageCount");
        return PyInt_FromLong(long(m_frame_message_count));
 }
 
@@ -255,6 +294,7 @@ const char KX_NetworkMessageSensor::GetBodies_doc[] =
 
 PyObject* KX_NetworkMessageSensor::PyGetBodies( PyObject* )
 {
+       ShowDeprecationWarning("getBodies()", "bodies");
        if (m_BodyList) {
                return ((PyObject*) m_BodyList->AddRef());
        } else {
@@ -269,6 +309,7 @@ const char KX_NetworkMessageSensor::GetSubject_doc[] =
 
 PyObject* KX_NetworkMessageSensor::PyGetSubject( PyObject* )
 {
+       ShowDeprecationWarning("getSubject()", "subject");
        return PyString_FromString(m_subject ? m_subject : "");
 }
 
@@ -279,9 +320,11 @@ const char KX_NetworkMessageSensor::GetSubjects_doc[] =
 
 PyObject* KX_NetworkMessageSensor::PyGetSubjects( PyObject* )
 {
+       ShowDeprecationWarning("getSubjects()", "subjects");
        if (m_SubjectList) {
                return ((PyObject*) m_SubjectList->AddRef());
        } else {
                return ((PyObject*) new CListValue());
        }
 }
+// <----- Deprecated
\ No newline at end of file
index 26adbc9945a2badac14e7b7f5b8cbeff9353bfa3..79e8bc910d181f26c543dd61ffedce7711dc902b 100644 (file)
@@ -73,13 +73,19 @@ public:
        /* ------------------------------------------------------------- */
 
        virtual PyObject* _getattr(const char *attr);
+       virtual int _setattr(const char *attr, PyObject *value);
 
+       // Deprecated ----->
        KX_PYMETHOD_DOC_O(KX_NetworkMessageSensor, SetSubjectFilterText);
        KX_PYMETHOD_DOC_NOARGS(KX_NetworkMessageSensor, GetFrameMessageCount);
        KX_PYMETHOD_DOC_NOARGS(KX_NetworkMessageSensor, GetBodies);
        KX_PYMETHOD_DOC_NOARGS(KX_NetworkMessageSensor, GetSubject);
        KX_PYMETHOD_DOC_NOARGS(KX_NetworkMessageSensor, GetSubjects);
+       // <-----
 
+       /* attributes */
+       static PyObject*        pyattr_get_bodies(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);     
+       static PyObject*        pyattr_get_subjects(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
 
 };
 
index bc2111571ac82a9006728ce148df1c261128a803..bf41f3a555f4ef7a937e0bf7b65b45ac1eb4e4ab 100644 (file)
@@ -48,6 +48,7 @@
 
 #include "KX_KetsjiEngine.h"
 #include "KX_RadarSensor.h"
+#include "KX_RaySensor.h"
 
 #include "SCA_IInputDevice.h"
 #include "SCA_PropertySensor.h"
@@ -1070,6 +1071,14 @@ PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack
        KX_MACRO_addTypesToDict(d, KX_RADAR_AXIS_NEG_Y, KX_RadarSensor::KX_RADAR_AXIS_NEG_X);
        KX_MACRO_addTypesToDict(d, KX_RADAR_AXIS_NEG_Z, KX_RadarSensor::KX_RADAR_AXIS_NEG_Z);
 
+       /* Ray Sensor */
+       KX_MACRO_addTypesToDict(d, KX_RAY_AXIS_POS_X, KX_RaySensor::KX_RAY_AXIS_POS_X);
+       KX_MACRO_addTypesToDict(d, KX_RAY_AXIS_POS_Y, KX_RaySensor::KX_RAY_AXIS_POS_Y);
+       KX_MACRO_addTypesToDict(d, KX_RAY_AXIS_POS_Z, KX_RaySensor::KX_RAY_AXIS_POS_Z);
+       KX_MACRO_addTypesToDict(d, KX_RAY_AXIS_NEG_X, KX_RaySensor::KX_RAY_AXIS_NEG_Y);
+       KX_MACRO_addTypesToDict(d, KX_RAY_AXIS_NEG_Y, KX_RaySensor::KX_RAY_AXIS_NEG_X);
+       KX_MACRO_addTypesToDict(d, KX_RAY_AXIS_NEG_Z, KX_RaySensor::KX_RAY_AXIS_NEG_Z);
+
        // Check for errors
        if (PyErr_Occurred())
     {
index ce12b98314700d21cd2d05593779e50feb33d68f..253fe11fe0536b13260097a662931355f352ec0b 100644 (file)
@@ -136,8 +136,13 @@ bool KX_RaySensor::RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void
        {
                m_rayHit = true;
                m_hitObject = hitKXObj;
-               m_hitPosition = result->m_hitPoint;
-               m_hitNormal = result->m_hitNormal;
+               m_hitPosition[0] = result->m_hitPoint[0];
+               m_hitPosition[1] = result->m_hitPoint[1];
+               m_hitPosition[2] = result->m_hitPoint[2];
+
+               m_hitNormal[0] = result->m_hitNormal[0];
+               m_hitNormal[1] = result->m_hitNormal[1];
+               m_hitNormal[2] = result->m_hitNormal[2];
                        
        }
        // no multi-hit search yet
@@ -180,8 +185,13 @@ bool KX_RaySensor::Evaluate(CValue* event)
        bool reset = m_reset && m_level;
        m_rayHit = false; 
        m_hitObject = NULL;
-       m_hitPosition.setValue(0,0,0);
-       m_hitNormal.setValue(1,0,0);
+       m_hitPosition[0] = 0;
+       m_hitPosition[1] = 0;
+       m_hitPosition[2] = 0;
+
+       m_hitNormal[0] = 1;
+       m_hitNormal[1] = 0;
+       m_hitNormal[2] = 0;
        
        KX_GameObject* obj = (KX_GameObject*)GetParent();
        MT_Point3 frompoint = obj->NodeGetWorldPosition();
@@ -236,7 +246,9 @@ bool KX_RaySensor::Evaluate(CValue* event)
                }
        }
        todir.normalize();
-       m_rayDirection = todir;
+       m_rayDirection[0] = todir[0];
+       m_rayDirection[1] = todir[1];
+       m_rayDirection[2] = todir[2];
 
        MT_Point3 topoint = frompoint + (m_distance) * todir;
        PHY_IPhysicsEnvironment* pe = m_scene->GetPhysicsEnvironment();
@@ -336,22 +348,44 @@ PyParentObject KX_RaySensor::Parents[] = {
 };
 
 PyMethodDef KX_RaySensor::Methods[] = {
+       // Deprecated ----->
        {"getHitObject",(PyCFunction) KX_RaySensor::sPyGetHitObject,METH_NOARGS, (PY_METHODCHAR)GetHitObject_doc},
        {"getHitPosition",(PyCFunction) KX_RaySensor::sPyGetHitPosition,METH_NOARGS, (PY_METHODCHAR)GetHitPosition_doc},
        {"getHitNormal",(PyCFunction) KX_RaySensor::sPyGetHitNormal,METH_NOARGS, (PY_METHODCHAR)GetHitNormal_doc},
        {"getRayDirection",(PyCFunction) KX_RaySensor::sPyGetRayDirection,METH_NOARGS, (PY_METHODCHAR)GetRayDirection_doc},
+       // <-----
        {NULL,NULL} //Sentinel
 };
 
 PyAttributeDef KX_RaySensor::Attributes[] = {
+       KX_PYATTRIBUTE_BOOL_RW("useMaterial", KX_RaySensor, m_bFindMaterial),
+       KX_PYATTRIBUTE_BOOL_RW("useXRay", KX_RaySensor, m_bXRay),
+       KX_PYATTRIBUTE_FLOAT_RW("range", 0, 10000, KX_RaySensor, m_distance),
+       KX_PYATTRIBUTE_STRING_RW("property", 0, 100, false, KX_RaySensor, m_propertyname),
+       KX_PYATTRIBUTE_INT_RW("axis", 0, 5, true, KX_RaySensor, m_axis),
+       KX_PYATTRIBUTE_FLOAT_ARRAY_RO("hitPosition", KX_RaySensor, m_hitPosition, 3),
+       KX_PYATTRIBUTE_FLOAT_ARRAY_RO("rayDirection", KX_RaySensor, m_rayDirection, 3),
+       KX_PYATTRIBUTE_FLOAT_ARRAY_RO("hitNormal", KX_RaySensor, m_hitNormal, 3),
+       KX_PYATTRIBUTE_RO_FUNCTION("hitObject", KX_RaySensor, pyattr_get_hitobject),
        { NULL }        //Sentinel
 };
 
+PyObject* KX_RaySensor::pyattr_get_hitobject(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+       KX_RaySensor* self = static_cast<KX_RaySensor*>(self_v);
+       if (self->m_hitObject)
+               return self->m_hitObject->AddRef();
+
+       Py_RETURN_NONE;
+}
+
+// Deprecated ----->
 const char KX_RaySensor::GetHitObject_doc[] = 
 "getHitObject()\n"
 "\tReturns the name of the object that was hit by this ray.\n";
 PyObject* KX_RaySensor::PyGetHitObject(PyObject* self)
 {
+       ShowDeprecationWarning("getHitObject()", "the hitObject property");
        if (m_hitObject)
        {
                return m_hitObject->AddRef();
@@ -365,7 +399,15 @@ const char KX_RaySensor::GetHitPosition_doc[] =
 "\tReturns the position (in worldcoordinates) where the object was hit by this ray.\n";
 PyObject* KX_RaySensor::PyGetHitPosition(PyObject* self)
 {
-       return PyObjectFrom(m_hitPosition);
+       ShowDeprecationWarning("getHitPosition()", "the hitPosition property");
+
+       PyObject *retVal = PyList_New(3);
+
+       PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_hitPosition[0]));
+       PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_hitPosition[1]));
+       PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_hitPosition[2]));
+
+       return retVal;
 }
 
 const char KX_RaySensor::GetRayDirection_doc[] = 
@@ -373,7 +415,15 @@ const char KX_RaySensor::GetRayDirection_doc[] =
 "\tReturns the direction from the ray (in worldcoordinates) .\n";
 PyObject* KX_RaySensor::PyGetRayDirection(PyObject* self)
 {
-       return PyObjectFrom(m_rayDirection);
+       ShowDeprecationWarning("getRayDirection()", "the rayDirection property");
+
+       PyObject *retVal = PyList_New(3);
+       
+       PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_rayDirection[0]));
+       PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_rayDirection[1]));
+       PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_rayDirection[2]));
+
+       return retVal;
 }
 
 const char KX_RaySensor::GetHitNormal_doc[] = 
@@ -381,11 +431,31 @@ const char KX_RaySensor::GetHitNormal_doc[] =
 "\tReturns the normal (in worldcoordinates) of the object at the location where the object was hit by this ray.\n";
 PyObject* KX_RaySensor::PyGetHitNormal(PyObject* self)
 {
-       return PyObjectFrom(m_hitNormal);
+       ShowDeprecationWarning("getHitNormal()", "the hitNormal property");
+
+       PyObject *retVal = PyList_New(3);
+
+       PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_hitNormal[0]));
+       PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_hitNormal[1]));
+       PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_hitNormal[2]));
+
+       return retVal;
 }
 
 
 
 PyObject* KX_RaySensor::_getattr(const char *attr) {
+       PyObject* object = _getattr_self(Attributes, this, attr);
+       if (object != NULL)
+               return object;
        _getattr_up(SCA_ISensor);
 }
+
+int KX_RaySensor::_setattr(const char *attr, PyObject *value) {
+       int ret = _setattr_self(Attributes, this, attr, value);
+       if (ret >= 0)
+               return ret;
+       return SCA_ISensor::_setattr(attr, value);
+}
+
+// <----- Deprecated
\ No newline at end of file
index 09d8bc1369a2d505c0c69e67a545dd8dcfcd0f2e..e7901a0d10db245a41524881d6e530301f83b73a 100644 (file)
@@ -44,15 +44,15 @@ class KX_RaySensor : public SCA_ISensor
        STR_String              m_propertyname;
        bool                    m_bFindMaterial;
        bool                    m_bXRay;
-       double                  m_distance;
+       float                   m_distance;
        class KX_Scene* m_scene;
        bool                    m_bTriggered;
        int                             m_axis;
        bool                    m_rayHit;
-       MT_Point3               m_hitPosition;
+       float                   m_hitPosition[3];
        SCA_IObject*    m_hitObject;
-       MT_Vector3              m_hitNormal;
-       MT_Vector3              m_rayDirection;
+       float                   m_hitNormal[3];
+       float                   m_rayDirection[3];
 
 public:
        KX_RaySensor(class SCA_EventManager* eventmgr,
@@ -73,13 +73,31 @@ public:
 
        bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data);
        bool NeedRayCast(KX_ClientObjectInfo* client);
+
+
+       //Python Interface
+       enum RayAxis {
+               KX_RAY_AXIS_POS_Y = 0,
+               KX_RAY_AXIS_POS_X,
+               KX_RAY_AXIS_POS_Z,
+               KX_RAY_AXIS_NEG_X,
+               KX_RAY_AXIS_NEG_Y,
+               KX_RAY_AXIS_NEG_Z
+       };
+
+
+       virtual PyObject* _getattr(const char *attr);
+       virtual int _setattr(const char *attr, PyObject *value);
        
+       // Deprecated ----->
        KX_PYMETHOD_DOC_NOARGS(KX_RaySensor,GetHitObject);
        KX_PYMETHOD_DOC_NOARGS(KX_RaySensor,GetHitPosition);
        KX_PYMETHOD_DOC_NOARGS(KX_RaySensor,GetHitNormal);
        KX_PYMETHOD_DOC_NOARGS(KX_RaySensor,GetRayDirection);
+       // <-----
 
-       virtual PyObject* _getattr(const char *attr);
+       /* Attributes */
+       static PyObject* pyattr_get_hitobject(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
        
 };
 
index 0524a9df355cb460f4189b0c767d06e71cfcea25..833d896ba6b21353b011b81f07c9d4199c5523c5 100644 (file)
@@ -148,6 +148,14 @@ Documentation for the GameLogic Module.
 @var KX_RADAR_AXIS_NEG_X:                  See L{KX_RadarSensor}
 @var KX_RADAR_AXIS_NEG_Y:                  See L{KX_RadarSensor}
 @var KX_RADAR_AXIS_NEG_Z:                  See L{KX_RadarSensor}
+
+@group Ray Sensor: KX_RAY_AXIS_POS_X, KX_RAY_AXIS_POS_Y, KX_RAY_AXIS_POS_Z, KX_RAY_AXIS_NEG_X, KX_RAY_AXIS_NEG_Y, KX_RAY_AXIS_NEG_Z
+@var KX_RAY_AXIS_POS_X:                    See L{KX_RaySensor}
+@var KX_RAY_AXIS_POS_Y:                    See L{KX_RaySensor}
+@var KX_RAY_AXIS_POS_Z:                    See L{KX_RaySensor}
+@var KX_RAY_AXIS_NEG_X:                    See L{KX_RaySensor}
+@var KX_RAY_AXIS_NEG_Y:                    See L{KX_RaySensor}
+@var KX_RAY_AXIS_NEG_Z:                    See L{KX_RaySensor}
 """
 
 
index aecd28977434d93eeea79c00820e498c06b0eb35..c9f48d47eb80d56159c8ce9f6715fd3f6fa38584 100644 (file)
@@ -5,21 +5,33 @@ from SCA_IActuator import *
 class KX_NetworkMessageActuator(SCA_IActuator):
        """
        Message Actuator
+       
+       @ivar propName: Messages will only be sent to objects with the given property name.
+       @type propName: string
+       @ivar subject: The subject field of the message.
+       @type subject: string
+       @ivar body: The body of the message.
+       @type body: string
+       @ivar usePropBody: Send a property instead of a regular body message.
+       @type usePropBody: boolean
        """
        def setToPropName(name):
                """
+               DEPRECATED: Use the propName property instead.
                Messages will only be sent to objects with the given property name.
                
                @type name: string
                """
        def setSubject(subject):
                """
+               DEPRECATED: Use the subject property instead.
                Sets the subject field of the message.
                
                @type subject: string
                """
        def setBodyType(bodytype):
                """
+               DEPRECATED: Use the usePropBody property instead.
                Sets the type of body to send.
                
                @type bodytype: boolean
@@ -27,6 +39,7 @@ class KX_NetworkMessageActuator(SCA_IActuator):
                """
        def setBody(body):
                """
+               DEPRECATED: Use the body property instead.
                Sets the message body.
                
                @type body: string
index 8f5f3609df753fb66371d95400d7ef97b27c98b9..0fecad58437598e3e17f1181a29596d56eab3d0c 100644 (file)
@@ -7,9 +7,22 @@ class KX_NetworkMessageSensor(SCA_ISensor):
        The Message Sensor logic brick.
        
        Currently only loopback (local) networks are supported.
+       
+       @ivar subject: The subject the sensor is looking for.
+       @type subject: string
+       @ivar frameMessageCount: The number of messages received since the last frame.
+                                                               (Read-only)
+       @type framemessageCount: int
+       @ivar subjects: The list of message subjects received. (Read-only)
+       @type subjects: list of strings
+       @ivar bodies: The list of message bodies received. (Read-only)
+       @type bodies: list of strings
        """
+       
+       
        def setSubjectFilterText(subject):
                """
+               DEPRECATED: Use the subject property instead.
                Change the message subject text that this sensor is listening to.
                
                @type subject: string
@@ -18,24 +31,28 @@ class KX_NetworkMessageSensor(SCA_ISensor):
        
        def getFrameMessageCount():
                """
+               DEPRECATED: Use the frameMessageCount property instead.
                Get the number of messages received since the last frame.
                
                @rtype: integer
                """
        def getBodies():
                """
+               DEPRECATED: Use the bodies property instead.
                Gets the list of message bodies.
                
                @rtype: list
                """
        def getSubject():
                """
+               DEPRECATED: Use the subject property instead.
                Gets the message subject this sensor is listening for from the Subject: field.
                
                @rtype: string
                """
        def getSubjects():
                """
+               DEPRECATED: Use the subjects property instead.
                Gets the list of message subjects received.
                
                @rtype: list
index e487edcb655113610bb203ec60493d8c1b29b338..b9de54e92a5e59be21be24648ad67b94f9dd6e19 100644 (file)
@@ -5,28 +5,53 @@ from SCA_ISensor import *
 class KX_RaySensor(SCA_ISensor):
        """
        A ray sensor detects the first object in a given direction.
+       
+       @ivar property: The property the ray is looking for.
+       @type property: string
+       @ivar range: The distance of the ray.
+       @type range: float
+       @ivar useMaterial: Whether or not to look for a material (false = property)
+       @type useMaterial: boolean
+       @ivar useXRay: Whether or not to use XRay.
+       @type useXRay: boolean
+       @ivar hitObject: The game object that was hit by the ray. (Read-only)
+       @type hitObject: KX_GameObject
+       @ivar hitPosition: The position (in worldcoordinates) where the object was hit by the ray. (Read-only)
+       @type hitPosition: list [x, y, z]
+       @ivar hitNormal: The normal (in worldcoordinates) of the object at the location where the object was hit by the ray. (Read-only)
+       @type hitNormal: list [x, y, z]
+       @ivar rayDirection: The direction from the ray (in worldcoordinates). (Read-only)
+       @type rayDirection: list [x, y, z]
+       @ivar axis: The axis the ray is pointing on.
+       @type axis: int from 0 to 5
+               KX_RAY_AXIS_POS_X, KX_RAY_AXIS_POS_Y, KX_RAY_AXIS_POS_Z,
+               KX_RAY_AXIS_NEG_X, KX_RAY_AXIS_NEG_Y, KX_RAY_AXIS_NEG_Z
        """
        
        def getHitObject():
                """
+               DEPRECATED: Use the hitObject property instead.
                Returns the game object that was hit by this ray.
                
                @rtype: KX_GameObject
                """
        def getHitPosition():
                """
+               DEPRECATED: Use the hitPosition property instead.
                Returns the position (in worldcoordinates) where the object was hit by this ray.
                
                @rtype: list [x, y, z]
                """
        def getHitNormal():
                """
+               DEPRECATED: Use the hitNormal property instead.
                Returns the normal (in worldcoordinates) of the object at the location where the object was hit by this ray.
                
                @rtype: list [nx, ny, nz]
                """
        def getRayDirection():
                """
+               DEPRECATED: Use the rayDirection property instead.
                Returns the direction from the ray (in worldcoordinates)
                
                @rtype: list [dx, dy, dz]