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.
This commit is contained in:
@@ -48,19 +48,10 @@ SCA_ActuatorEventManager::~SCA_ActuatorEventManager()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SCA_ActuatorEventManager::RegisterSensor(SCA_ISensor* sensor)
|
||||
{
|
||||
m_sensors.push_back(sensor);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SCA_ActuatorEventManager::NextFrame()
|
||||
{
|
||||
// check for changed actuator
|
||||
for (vector<SCA_ISensor*>::const_iterator it = m_sensors.begin();!(it==m_sensors.end());it++)
|
||||
for (set<SCA_ISensor*>::const_iterator it = m_sensors.begin();!(it==m_sensors.end());it++)
|
||||
{
|
||||
(*it)->Activate(m_logicmgr,NULL);
|
||||
}
|
||||
@@ -69,7 +60,7 @@ void SCA_ActuatorEventManager::NextFrame()
|
||||
void SCA_ActuatorEventManager::UpdateFrame()
|
||||
{
|
||||
// update the state of actuator before executing them
|
||||
for (vector<SCA_ISensor*>::const_iterator it = m_sensors.begin();!(it==m_sensors.end());it++)
|
||||
for (set<SCA_ISensor*>::const_iterator it = m_sensors.begin();!(it==m_sensors.end());it++)
|
||||
{
|
||||
((SCA_ActuatorSensor*)(*it))->Update();
|
||||
}
|
||||
|
Reference in New Issue
Block a user