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:
@@ -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)
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user