Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/simulation2/components/CCmpTerritoryManager.cpp
Show First 20 Lines • Show All 217 Lines • ▼ Show 20 Lines | virtual void HandleMessage(const CMessage& msg, bool UNUSED(global)) | ||||
{ | { | ||||
const CMessageInterpolate& msgData = static_cast<const CMessageInterpolate&> (msg); | const CMessageInterpolate& msgData = static_cast<const CMessageInterpolate&> (msg); | ||||
Interpolate(msgData.deltaSimTime, msgData.offset); | Interpolate(msgData.deltaSimTime, msgData.offset); | ||||
break; | break; | ||||
} | } | ||||
case MT_RenderSubmit: | case MT_RenderSubmit: | ||||
{ | { | ||||
const CMessageRenderSubmit& msgData = static_cast<const CMessageRenderSubmit&> (msg); | const CMessageRenderSubmit& msgData = static_cast<const CMessageRenderSubmit&> (msg); | ||||
RenderSubmit(msgData.collector); | RenderSubmit(msgData.collector, msgData.frustum, msgData.culling); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// Check whether the entity is either a settlement or territory influence; | // Check whether the entity is either a settlement or territory influence; | ||||
// ignore any others | // ignore any others | ||||
void MakeDirtyIfRelevantEntity(entity_id_t ent) | void MakeDirtyIfRelevantEntity(entity_id_t ent) | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | // m_DebugOverlay = new TerritoryOverlay(*this); | ||||
u8 GetTerritoryPercentage(player_id_t player); | u8 GetTerritoryPercentage(player_id_t player); | ||||
std::vector<STerritoryBoundary> ComputeBoundaries(); | std::vector<STerritoryBoundary> ComputeBoundaries(); | ||||
void UpdateBoundaryLines(); | void UpdateBoundaryLines(); | ||||
void Interpolate(float frameTime, float frameOffset); | void Interpolate(float frameTime, float frameOffset); | ||||
void RenderSubmit(SceneCollector& collector); | void RenderSubmit(SceneCollector& collector, const CFrustum& frustum, bool culling); | ||||
void SetVisibility(bool visible) | void SetVisibility(bool visible) | ||||
{ | { | ||||
m_Visible = visible; | m_Visible = visible; | ||||
} | } | ||||
void UpdateColors(); | void UpdateColors(); | ||||
▲ Show 20 Lines • Show All 372 Lines • ▼ Show 20 Lines | for (size_t i = 0; i < m_BoundaryLines.size(); ++i) | ||||
{ | { | ||||
CColor c = m_BoundaryLines[i].color; | CColor c = m_BoundaryLines[i].color; | ||||
c.a *= 0.2f + 0.8f * fabsf((float)cos(m_AnimTime * M_PI)); // TODO: should let artists tweak this | c.a *= 0.2f + 0.8f * fabsf((float)cos(m_AnimTime * M_PI)); // TODO: should let artists tweak this | ||||
m_BoundaryLines[i].overlay.m_Color = c; | m_BoundaryLines[i].overlay.m_Color = c; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
void CCmpTerritoryManager::RenderSubmit(SceneCollector& collector) | void CCmpTerritoryManager::RenderSubmit(SceneCollector& collector, const CFrustum& frustum, bool culling) | ||||
{ | { | ||||
if (!m_Visible) | if (!m_Visible) | ||||
return; | return; | ||||
for (size_t i = 0; i < m_BoundaryLines.size(); ++i) | for (size_t i = 0; i < m_BoundaryLines.size(); ++i) | ||||
{ | |||||
if (culling && !m_BoundaryLines[i].overlay.IsVisibleInFrustum(frustum)) | |||||
continue; | |||||
collector.Submit(&m_BoundaryLines[i].overlay); | collector.Submit(&m_BoundaryLines[i].overlay); | ||||
} | |||||
for (size_t i = 0; i < m_DebugBoundaryLineNodes.size(); ++i) | for (size_t i = 0; i < m_DebugBoundaryLineNodes.size(); ++i) | ||||
collector.Submit(&m_DebugBoundaryLineNodes[i]); | collector.Submit(&m_DebugBoundaryLineNodes[i]); | ||||
} | } | ||||
player_id_t CCmpTerritoryManager::GetOwner(entity_pos_t x, entity_pos_t z) | player_id_t CCmpTerritoryManager::GetOwner(entity_pos_t x, entity_pos_t z) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 147 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator