Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpTerritoryManager.cpp
/* Copyright (C) 2018 Wildfire Games. | /* Copyright (C) 2019 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 208 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) | ||||
Stan: Range loop ? | |||||
{ | |||||
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
Range loop ?