diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2008-07-30 21:41:47 +0400 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2008-07-30 21:41:47 +0400 |
commit | 8a8a12ed846dc86b2f9b21582fd34d941beed7ed (patch) | |
tree | 3d080dee853afcfdb5fd43ea48b441b3128c0583 /source/gameengine/Physics/Sumo/Fuzzics | |
parent | d05363627bee12bd9e5af8b1114b68f73eeb3e5f (diff) |
BGE patch: logic optimization part 2: remove inactive sensors from logic manager.
With this patch, only sensors that are connected to
active states are actually registered in the logic
manager. Inactive sensors won't take any CPU,
especially the Radar and Near sensors that use a
physical object for the detection: these objects
are removed from the physics engine.
To take advantage of this optimization patch, you
need to define very light idle state when the
objects are inactive: make them transparent, suspend
the physics, keep few sensors active (e,g a message
sensor to wake up), etc.
Diffstat (limited to 'source/gameengine/Physics/Sumo/Fuzzics')
-rw-r--r-- | source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp index b5bf67b14ea..f0791bbf89f 100644 --- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp +++ b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp @@ -98,12 +98,17 @@ void SM_Scene::addTouchCallback(int response_class, DT_ResponseCallback callback void SM_Scene::addSensor(SM_Object& object) { - object.calcXform(); - m_objectList.push_back(&object); - DT_AddObject(m_scene, object.getObjectHandle()); - DT_SetResponseClass(m_respTable, object.getObjectHandle(), m_ResponseClass[SENSOR_RESPONSE]); - DT_SetResponseClass(m_secondaryRespTable, object.getObjectHandle(), m_secondaryResponseClass[SENSOR_RESPONSE]); - DT_SetResponseClass(m_fixRespTable, object.getObjectHandle(), m_fixResponseClass[SENSOR_RESPONSE]); + T_ObjectList::iterator i = + std::find(m_objectList.begin(), m_objectList.end(), &object); + if (i == m_objectList.end()) + { + object.calcXform(); + m_objectList.push_back(&object); + DT_AddObject(m_scene, object.getObjectHandle()); + DT_SetResponseClass(m_respTable, object.getObjectHandle(), m_ResponseClass[SENSOR_RESPONSE]); + DT_SetResponseClass(m_secondaryRespTable, object.getObjectHandle(), m_secondaryResponseClass [SENSOR_RESPONSE]); + DT_SetResponseClass(m_fixRespTable, object.getObjectHandle(), m_fixResponseClass[SENSOR_RESPONSE]); + } } void SM_Scene::add(SM_Object& object) { |