From 8a8a12ed846dc86b2f9b21582fd34d941beed7ed Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 30 Jul 2008 17:41:47 +0000 Subject: 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. --- source/gameengine/GameLogic/SCA_MouseManager.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'source/gameengine/GameLogic/SCA_MouseManager.cpp') diff --git a/source/gameengine/GameLogic/SCA_MouseManager.cpp b/source/gameengine/GameLogic/SCA_MouseManager.cpp index b4251d8ab53..ca875dad07c 100644 --- a/source/gameengine/GameLogic/SCA_MouseManager.cpp +++ b/source/gameengine/GameLogic/SCA_MouseManager.cpp @@ -75,9 +75,10 @@ void SCA_MouseManager::NextFrame() { if (m_mousedevice) { - for (unsigned int i = 0; i < m_sensors.size(); i++) + set::iterator it; + for (it=m_sensors.begin(); it!=m_sensors.end(); it++) { - SCA_MouseSensor* mousesensor = (SCA_MouseSensor*) m_sensors[i]; + SCA_MouseSensor* mousesensor = (SCA_MouseSensor*)(*it); // (0,0) is the Upper Left corner in our local window // coordinates if (!mousesensor->IsSuspended()) @@ -98,15 +99,6 @@ void SCA_MouseManager::NextFrame() } } - - -void SCA_MouseManager::RegisterSensor(SCA_ISensor* keysensor) -{ - m_sensors.push_back(keysensor); -} - - - bool SCA_MouseManager::IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode) { /* We should guard for non-mouse events maybe? A rather silly side */ -- cgit v1.2.3