diff options
author | Erwin Coumans <blender@erwincoumans.com> | 2006-04-01 07:30:15 +0400 |
---|---|---|
committer | Erwin Coumans <blender@erwincoumans.com> | 2006-04-01 07:30:15 +0400 |
commit | 36fd42ac85c40861b960b1f896dff972afc75691 (patch) | |
tree | f7c3e52ffa17a022829a4e22d6c67e25f4587f7b /source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp | |
parent | 63bc0b3847366bc21adc7bfcf5f03e223cf4d8f8 (diff) |
more Bullet physics improvements, mainly stability and performance related.
AddObjectActuator has new python method to immediately create objects (this allows to create multiple objects in 1 frame in different positions)
Diffstat (limited to 'source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index d9517a3a65b..322f41e11a3 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -85,28 +85,16 @@ bool KX_SCA_AddObjectActuator::Update() RemoveAllEvents(); if (bNegativeEvent) return false; // do nothing on negative events - if (m_OriginalObject) - { - // Add an identical object, with properties inherited from the original object - // Now it needs to be added to the current scene. - SCA_IObject* replica = m_scene->AddReplicaObject(m_OriginalObject,GetParent(),m_timeProp ); - KX_GameObject * game_obj = static_cast<KX_GameObject *>(replica); - game_obj->setLinearVelocity(m_linear_velocity,m_localFlag); - game_obj->ResolveCombinedVelocities(m_linear_velocity, MT_Vector3(0., 0., 0.), m_localFlag, false); - // keep a copy of the last object, to allow python scripters to change it - if (m_lastCreatedObject) - m_lastCreatedObject->Release(); - - m_lastCreatedObject = replica; - m_lastCreatedObject->AddRef(); - } + InstantAddObject(); + return false; } + SCA_IObject* KX_SCA_AddObjectActuator::GetLastCreatedObject() const { return m_lastCreatedObject; @@ -169,6 +157,8 @@ PyMethodDef KX_SCA_AddObjectActuator::Methods[] = { {"getLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLinearVelocity, METH_VARARGS, GetLinearVelocity_doc}, {"setLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPySetLinearVelocity, METH_VARARGS, SetLinearVelocity_doc}, {"getLastCreatedObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLastCreatedObject, METH_VARARGS,"getLastCreatedObject() : get the object handle to the last created object\n"}, + {"instantAddObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyInstantAddObject, METH_VARARGS,"instantAddObject() : immediately add object without delay\n"}, + {NULL,NULL} //Sentinel }; @@ -315,6 +305,35 @@ PyObject* KX_SCA_AddObjectActuator::PySetLinearVelocity(PyObject* self, Py_Return; } +void KX_SCA_AddObjectActuator::InstantAddObject() +{ + if (m_OriginalObject) + { + // Add an identical object, with properties inherited from the original object + // Now it needs to be added to the current scene. + SCA_IObject* replica = m_scene->AddReplicaObject(m_OriginalObject,GetParent(),m_timeProp ); + KX_GameObject * game_obj = static_cast<KX_GameObject *>(replica); + game_obj->setLinearVelocity(m_linear_velocity,m_localFlag); + game_obj->ResolveCombinedVelocities(m_linear_velocity, MT_Vector3(0., 0., 0.), m_localFlag, false); + + // keep a copy of the last object, to allow python scripters to change it + if (m_lastCreatedObject) + m_lastCreatedObject->Release(); + + m_lastCreatedObject = replica; + m_lastCreatedObject->AddRef(); + } +} + +PyObject* KX_SCA_AddObjectActuator::PyInstantAddObject(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + InstantAddObject(); + + Py_Return; +} + /* 7. GetLastCreatedObject */ |