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:
2008-07-30 17:41:47 +00:00
parent d05363627b
commit 8a8a12ed84
43 changed files with 158 additions and 242 deletions

View File

@@ -41,7 +41,8 @@
void SCA_ISensor::ReParent(SCA_IObject* parent)
{
SCA_ILogicBrick::ReParent(parent);
m_eventmgr->RegisterSensor(this);
// will be done when the sensor is activated
//m_eventmgr->RegisterSensor(this);
this->SetActive(false);
}
@@ -133,6 +134,7 @@ void SCA_ISensor::DecLink() {
{
// sensor is detached from all controllers, initialize it so that it
// is fresh as at startup when it is reattached again.
UnregisterToManager();
Init();
}
}
@@ -203,6 +205,11 @@ void SCA_ISensor::RegisterToManager()
m_eventmgr->RegisterSensor(this);
}
void SCA_ISensor::UnregisterToManager()
{
m_eventmgr->RemoveSensor(this);
}
void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr, CValue* event)
{