Skip to content

Commit 179edd8

Browse files
committed
UPBGE: Use mathfu types in KX_AddObjectActuator.
1 parent 432ec8f commit 179edd8

File tree

3 files changed

+16
-38
lines changed

3 files changed

+16
-38
lines changed

source/gameengine/Converter/BL_ConvertActuators.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,15 +447,14 @@ void BL_ConvertActuators(const char *maggiename,
447447
originalval = converter.FindGameObject(editobact->ob);
448448
}
449449
}
450-
451450
KX_AddObjectActuator *tmpaddact = new KX_AddObjectActuator(
452451
gameobj,
453452
originalval,
454453
editobact->time,
455454
scene,
456-
editobact->linVelocity,
455+
mt::vec3(editobact->linVelocity),
457456
(editobact->localflag & ACT_EDOB_LOCAL_LINV) != 0,
458-
editobact->angVelocity,
457+
mt::vec3(editobact->angVelocity),
459458
(editobact->localflag & ACT_EDOB_LOCAL_ANGV) != 0);
460459

461460
//editobact->ob to gameobj

source/gameengine/Ketsji/KX_AddObjectActuator.cpp

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,16 @@
4343
/* Native functions */
4444
/* ------------------------------------------------------------------------- */
4545

46-
KX_AddObjectActuator::KX_AddObjectActuator(KX_GameObject *gameobj,
47-
KX_GameObject *original,
48-
float time,
49-
KX_Scene *scene,
50-
const float *linvel,
51-
bool linv_local,
52-
const float *angvel,
53-
bool angv_local)
54-
:
55-
SCA_IActuator(gameobj, KX_ACT_ADD_OBJECT),
46+
KX_AddObjectActuator::KX_AddObjectActuator(KX_GameObject *gameobj, KX_GameObject *original, float time, KX_Scene* scene,
47+
const mt::vec3& linvel, bool linv_local, const mt::vec3& angvel, bool angv_local)
48+
:SCA_IActuator(gameobj, KX_ACT_ADD_OBJECT),
5649
m_OriginalObject(original),
5750
m_scene(scene),
58-
51+
m_linear_velocity(linvel),
5952
m_localLinvFlag(linv_local),
53+
m_angular_velocity(angvel),
6054
m_localAngvFlag(angv_local)
6155
{
62-
m_linear_velocity[0] = linvel[0];
63-
m_linear_velocity[1] = linvel[1];
64-
m_linear_velocity[2] = linvel[2];
65-
m_angular_velocity[0] = angvel[0];
66-
m_angular_velocity[1] = angvel[1];
67-
m_angular_velocity[2] = angvel[2];
68-
6956
if (m_OriginalObject) {
7057
m_OriginalObject->RegisterActuator(this);
7158
}
@@ -207,9 +194,9 @@ PyAttributeDef KX_AddObjectActuator::Attributes[] = {
207194
EXP_PYATTRIBUTE_RW_FUNCTION("object", KX_AddObjectActuator, pyattr_get_object, pyattr_set_object),
208195
EXP_PYATTRIBUTE_RO_FUNCTION("objectLastCreated", KX_AddObjectActuator, pyattr_get_objectLastCreated),
209196
EXP_PYATTRIBUTE_FLOAT_RW("time", 0.0f, FLT_MAX, KX_AddObjectActuator, m_timeProp),
210-
EXP_PYATTRIBUTE_FLOAT_ARRAY_RW("linearVelocity", -FLT_MAX, FLT_MAX, KX_AddObjectActuator, m_linear_velocity, 3),
211-
EXP_PYATTRIBUTE_FLOAT_ARRAY_RW("angularVelocity", -FLT_MAX, FLT_MAX, KX_AddObjectActuator, m_angular_velocity, 3),
212-
EXP_PYATTRIBUTE_NULL //Sentinel
197+
EXP_PYATTRIBUTE_VECTOR_RW("linearVelocity", -FLT_MAX, FLT_MAX, KX_AddObjectActuator, m_linear_velocity, 3),
198+
EXP_PYATTRIBUTE_VECTOR_RW("angularVelocity", -FLT_MAX, FLT_MAX, KX_AddObjectActuator, m_angular_velocity, 3),
199+
EXP_PYATTRIBUTE_NULL //Sentinel
213200
};
214201

215202
PyObject *KX_AddObjectActuator::pyattr_get_object(EXP_PyObjectPlus *self, const struct EXP_PYATTRIBUTE_DEF *attrdef)
@@ -271,8 +258,8 @@ void KX_AddObjectActuator::InstantAddObject()
271258
// Add an identical object, with properties inherited from the original object
272259
// Now it needs to be added to the current scene.
273260
KX_GameObject *replica = m_scene->AddReplicaObject(m_OriginalObject, static_cast<KX_GameObject *>(GetParent()), m_timeProp);
274-
replica->SetLinearVelocity(mt::vec3(m_linear_velocity), m_localLinvFlag);
275-
replica->SetAngularVelocity(mt::vec3(m_angular_velocity), m_localAngvFlag);
261+
replica->SetLinearVelocity(m_linear_velocity, m_localLinvFlag);
262+
replica->SetAngularVelocity(m_angular_velocity, m_localAngvFlag);
276263

277264
// keep a copy of the last object, to allow python scripters to change it
278265
if (m_lastCreatedObject) {

source/gameengine/Ketsji/KX_AddObjectActuator.h

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ class KX_AddObjectActuator : public SCA_IActuator
5555
KX_Scene *m_scene;
5656

5757
/// Linear velocity upon creation of the object.
58-
float m_linear_velocity[3];
58+
mt::vec3 m_linear_velocity;
5959
/// Apply the velocity locally
6060
bool m_localLinvFlag;
6161

6262
/// Angular velocity upon creation of the object.
63-
float m_angular_velocity[3];
63+
mt::vec3 m_angular_velocity;
6464
/// Apply the velocity locally
6565
bool m_localAngvFlag;
6666

@@ -73,16 +73,8 @@ class KX_AddObjectActuator : public SCA_IActuator
7373
* available. Use with care!
7474
*/
7575

76-
KX_AddObjectActuator(
77-
KX_GameObject *gameobj,
78-
KX_GameObject *original,
79-
float time,
80-
KX_Scene* scene,
81-
const float *linvel,
82-
bool linv_local,
83-
const float *angvel,
84-
bool angv_local
85-
);
76+
KX_AddObjectActuator(KX_GameObject *gameobj, KX_GameObject *original, float time, KX_Scene* scene,
77+
const mt::vec3& linvel, bool linv_local, const mt::vec3& angvel, bool angv_local);
8678

8779
~KX_AddObjectActuator(void);
8880

0 commit comments

Comments
 (0)