mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-10-14 07:17:44 +00:00
Dynamic message subscriptions.
Allow components to individually subscribe/unsubscribe to messages, instead of statically subscribing the entire component type. Use this for most Interpolate/RenderSubmit messages, to avoid the performance cost of passing those messages to a large number of components that will just ignore them anyway. On Azure Coast this reduces total time per frame by about 30% on a CPU-bound system. This was SVN commit r15400.
This commit is contained in:
@@ -116,7 +116,6 @@ public:
|
||||
{
|
||||
componentManager.SubscribeToMessageType(MT_Update_MotionFormation);
|
||||
componentManager.SubscribeToMessageType(MT_Update_MotionUnit);
|
||||
componentManager.SubscribeToMessageType(MT_RenderSubmit); // for debug overlays
|
||||
componentManager.SubscribeToMessageType(MT_PathResult);
|
||||
componentManager.SubscribeToMessageType(MT_ValueModification);
|
||||
}
|
||||
@@ -403,6 +402,7 @@ public:
|
||||
}
|
||||
case MT_RenderSubmit:
|
||||
{
|
||||
PROFILE3("UnitMotion::RenderSubmit");
|
||||
const CMessageRenderSubmit& msgData = static_cast<const CMessageRenderSubmit&> (msg);
|
||||
RenderSubmit(msgData.collector);
|
||||
break;
|
||||
@@ -436,6 +436,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateMessageSubscriptions()
|
||||
{
|
||||
bool needRender = m_DebugOverlayEnabled;
|
||||
GetSimContext().GetComponentManager().DynamicSubscriptionNonsync(MT_RenderSubmit, this, needRender);
|
||||
}
|
||||
|
||||
virtual bool IsMoving()
|
||||
{
|
||||
return m_Moving;
|
||||
@@ -487,6 +493,7 @@ public:
|
||||
virtual void SetDebugOverlay(bool enabled)
|
||||
{
|
||||
m_DebugOverlayEnabled = enabled;
|
||||
UpdateMessageSubscriptions();
|
||||
}
|
||||
|
||||
virtual bool MoveToPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange);
|
||||
|
||||
Reference in New Issue
Block a user