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:
-rw-r--r--doc/python_api/rst/bge.types.rst2
-rw-r--r--source/gameengine/Ketsji/KX_RadarSensor.cpp12
-rw-r--r--source/gameengine/Ketsji/KX_RadarSensor.h1
3 files changed, 13 insertions, 2 deletions
diff --git a/doc/python_api/rst/bge.types.rst b/doc/python_api/rst/bge.types.rst
index bcef816dc9d..1d9f84fbcac 100644
--- a/doc/python_api/rst/bge.types.rst
+++ b/doc/python_api/rst/bge.types.rst
@@ -2692,7 +2692,7 @@ Game Types (bge.types)
The angle of the cone (in degrees) with which to test.
- :type: float from 0 to 360
+ :type: float
.. attribute:: axis
diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp
index 678794f2beb..978944c20e8 100644
--- a/source/gameengine/Ketsji/KX_RadarSensor.cpp
+++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp
@@ -212,9 +212,19 @@ PyAttributeDef KX_RadarSensor::Attributes[] = {
KX_PYATTRIBUTE_FLOAT_ARRAY_RO("coneOrigin", KX_RadarSensor, m_cone_origin, 3),
KX_PYATTRIBUTE_FLOAT_ARRAY_RO("coneTarget", KX_RadarSensor, m_cone_target, 3),
KX_PYATTRIBUTE_FLOAT_RO("distance", KX_RadarSensor, m_coneheight),
- KX_PYATTRIBUTE_FLOAT_RW("angle", 0, 360, KX_RadarSensor, m_coneradius),
+ KX_PYATTRIBUTE_RO_FUNCTION("angle", KX_RadarSensor, pyattr_get_angle),
KX_PYATTRIBUTE_INT_RW("axis", 0, 5, true, KX_RadarSensor, m_axis),
{NULL} //Sentinel
};
+PyObject* KX_RadarSensor::pyattr_get_angle(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_RadarSensor* self= static_cast<KX_RadarSensor*>(self_v);
+
+ // The original angle from the gui was converted, so we recalculate the value here to maintain
+ // consistency between Python and the gui
+ return PyFloat_FromDouble(MT_degrees(atan(self->m_coneradius / self->m_coneheight)) * 2);
+
+}
+
#endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_RadarSensor.h b/source/gameengine/Ketsji/KX_RadarSensor.h
index 903413ca89b..f1ed5b3c982 100644
--- a/source/gameengine/Ketsji/KX_RadarSensor.h
+++ b/source/gameengine/Ketsji/KX_RadarSensor.h
@@ -93,6 +93,7 @@ public:
/* python */
virtual sensortype GetSensorType() { return ST_RADAR; }
+ static PyObject* pyattr_get_angle(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
};
#endif //__KX_RADARSENSOR_H__