Changeset View
Changeset View
Standalone View
Standalone View
source/renderer/TexturedLineRData.cpp
/* Copyright (C) 2017 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, | ||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
* GNU General Public License for more details. | * GNU General Public License for more details. | ||||
* | * | ||||
* You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | ||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
#include "precompiled.h" | #include "precompiled.h" | ||||
#include "TexturedLineRData.h" | #include "TexturedLineRData.h" | ||||
#include "graphics/Frustum.h" | |||||
#include "graphics/Terrain.h" | #include "graphics/Terrain.h" | ||||
#include "maths/MathUtil.h" | #include "maths/MathUtil.h" | ||||
#include "maths/Quaternion.h" | #include "maths/Quaternion.h" | ||||
#include "renderer/OverlayRenderer.h" | #include "renderer/OverlayRenderer.h" | ||||
#include "renderer/Renderer.h" | #include "renderer/Renderer.h" | ||||
#include "simulation2/Simulation2.h" | #include "simulation2/Simulation2.h" | ||||
#include "simulation2/system/SimContext.h" | #include "simulation2/system/SimContext.h" | ||||
#include "simulation2/components/ICmpWaterManager.h" | #include "simulation2/components/ICmpWaterManager.h" | ||||
▲ Show 20 Lines • Show All 268 Lines • ▼ Show 20 Lines | for (unsigned i = 0; i < capIndices.size(); i++) | ||||
capIndices[i] += vertices.size(); | capIndices[i] += vertices.size(); | ||||
vertices.insert(vertices.end(), capVertices.begin(), capVertices.end()); | vertices.insert(vertices.end(), capVertices.begin(), capVertices.end()); | ||||
indices.insert(indices.end(), capIndices.begin(), capIndices.end()); | indices.insert(indices.end(), capIndices.begin(), capIndices.end()); | ||||
} | } | ||||
ENSURE(indices.size() % 3 == 0); // GL_TRIANGLES indices, so must be multiple of 3 | ENSURE(indices.size() % 3 == 0); // GL_TRIANGLES indices, so must be multiple of 3 | ||||
m_BoundingBox = CBoundingBoxAligned(); | |||||
Stan: Maybe that function should be called GetCBoundingBoxAligned(). | |||||
for (const SVertex& vertex : vertices) | |||||
m_BoundingBox += vertex.m_Position; | |||||
m_VB = g_VBMan.Allocate(sizeof(SVertex), vertices.size(), GL_STATIC_DRAW, GL_ARRAY_BUFFER); | m_VB = g_VBMan.Allocate(sizeof(SVertex), vertices.size(), GL_STATIC_DRAW, GL_ARRAY_BUFFER); | ||||
if (m_VB) // allocation might fail (e.g. due to too many vertices) | if (m_VB) // allocation might fail (e.g. due to too many vertices) | ||||
{ | { | ||||
m_VB->m_Owner->UpdateChunkVertices(m_VB, &vertices[0]); // copy data into VBO | m_VB->m_Owner->UpdateChunkVertices(m_VB, &vertices[0]); // copy data into VBO | ||||
for (size_t k = 0; k < indices.size(); ++k) | for (size_t k = 0; k < indices.size(); ++k) | ||||
indices[k] += m_VB->m_Index; | indices[k] += m_VB->m_Index; | ||||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | case SOverlayTexturedLine::LINECAP_SQUARE: | ||||
} | } | ||||
break; | break; | ||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
bool CTexturedLineRData::IsVisibleInFrustum(const CFrustum& frustum) const | |||||
{ | |||||
return frustum.IsBoxVisible(m_BoundingBox); | |||||
} |
Wildfire Games · Phabricator
Maybe that function should be called GetCBoundingBoxAligned().