Skip to content

Commit 44186f7

Browse files
committed
UPBGE: Use mathfu types in KX_RadarSensor.
1 parent 11e3f98 commit 44186f7

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

source/gameengine/Ketsji/KX_RadarSensor.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,8 @@ void KX_RadarSensor::SynchronizeTransform()
136136

137137
mt::mat3x4 trans(rot, pos + rot * mt::vec3(0, -m_coneheight / 2.0f, 0));
138138

139-
//Using a temp variable to translate mt::vec3 to float[3].
140-
//float[3] works better for the Python interface.
141-
mt::vec3 temp = trans.TranslationVector3D();
142-
m_cone_origin[0] = temp[0];
143-
m_cone_origin[1] = temp[1];
144-
m_cone_origin[2] = temp[2];
145-
146-
temp = trans * mt::vec3(0, -m_coneheight / 2.0f, 0);
147-
m_cone_target[0] = temp[0];
148-
m_cone_target[1] = temp[1];
149-
m_cone_target[2] = temp[2];
150-
139+
m_cone_origin = trans.TranslationVector3D();
140+
m_cone_target = trans * mt::vec3(0, -m_coneheight/2.0f, 0);
151141

152142
if (m_physCtrl) {
153143
PHY_IMotionState *motionState = m_physCtrl->GetMotionState();
@@ -194,8 +184,8 @@ PyMethodDef KX_RadarSensor::Methods[] = {
194184
};
195185

196186
PyAttributeDef KX_RadarSensor::Attributes[] = {
197-
EXP_PYATTRIBUTE_FLOAT_ARRAY_RO("coneOrigin", KX_RadarSensor, m_cone_origin, 3),
198-
EXP_PYATTRIBUTE_FLOAT_ARRAY_RO("coneTarget", KX_RadarSensor, m_cone_target, 3),
187+
EXP_PYATTRIBUTE_VECTOR_RO("coneOrigin", KX_RadarSensor, m_cone_origin, 3),
188+
EXP_PYATTRIBUTE_VECTOR_RO("coneTarget", KX_RadarSensor, m_cone_target, 3),
199189
EXP_PYATTRIBUTE_FLOAT_RO("distance", KX_RadarSensor, m_coneheight),
200190
EXP_PYATTRIBUTE_RO_FUNCTION("angle", KX_RadarSensor, pyattr_get_angle),
201191
EXP_PYATTRIBUTE_INT_RW("axis", 0, 5, true, KX_RadarSensor, m_axis),

source/gameengine/Ketsji/KX_RadarSensor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ class KX_RadarSensor : public KX_NearSensor
5353
/**
5454
* The previous position of the origin of the cone.
5555
*/
56-
float m_cone_origin[3];
56+
mt::vec3 m_cone_origin;
5757

5858
/**
5959
* The previous direction of the cone (origin to bottom plane).
6060
*/
61-
float m_cone_target[3];
61+
mt::vec3 m_cone_target;
6262

6363
public:
6464

0 commit comments

Comments
 (0)