forked from mirrors/0ad
Refactors coordinates of SOverlayTexturedLine, replaces array of floats by array of CVector2D.
Tested By: Stan Differential Revision: https://code.wildfiregames.com/D3072 This was SVN commit r24144.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2019 Wildfire Games.
|
||||
/* Copyright (C) 2020 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -89,7 +89,7 @@ struct SOverlayTexturedLine
|
||||
/// Color to apply to the line texture, where indicated by the mask.
|
||||
CColor m_Color;
|
||||
/// (x, z) vertex coordinate pairs; y is computed automatically.
|
||||
std::vector<float> m_Coords;
|
||||
std::vector<CVector2D> m_Coords;
|
||||
/// Half-width of the line, in world-space units.
|
||||
float m_Thickness;
|
||||
/// Should this line be treated as a closed loop? If set, any end cap settings are ignored.
|
||||
@@ -128,12 +128,12 @@ struct SOverlayTexturedLine
|
||||
*/
|
||||
void CreateOverlayTexture(const SOverlayDescriptor* overlayDescriptor);
|
||||
|
||||
void PushCoords(const float x, const float z) { m_Coords.push_back(x); m_Coords.push_back(z); }
|
||||
void PushCoords(const CVector2D& v) { PushCoords(v.X, v.Y); }
|
||||
void PushCoords(const float x, const float z) { m_Coords.emplace_back(x, z); }
|
||||
void PushCoords(const CVector2D& v) { m_Coords.push_back(v); }
|
||||
void PushCoords(const std::vector<CVector2D>& points)
|
||||
{
|
||||
for (size_t i = 0; i < points.size(); ++i)
|
||||
PushCoords(points[i]);
|
||||
for (const CVector2D& point : points)
|
||||
PushCoords(point);
|
||||
}
|
||||
|
||||
bool IsVisibleInFrustum(const CFrustum& frustum) const;
|
||||
|
||||
@@ -219,8 +219,6 @@ void OverlayRenderer::Submit(SOverlayTexturedLine* line)
|
||||
if (line->m_Coords.empty())
|
||||
return;
|
||||
|
||||
ENSURE(line->m_Coords.size() % 2 == 0);
|
||||
|
||||
m->texlines.push_back(line);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2019 Wildfire Games.
|
||||
/* Copyright (C) 2020 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -90,7 +90,7 @@ void CTexturedLineRData::Update(const SOverlayTexturedLine& line)
|
||||
std::vector<SVertex> vertices;
|
||||
std::vector<u16> indices;
|
||||
|
||||
size_t n = line.m_Coords.size() / 2; // number of line points
|
||||
const size_t n = line.m_Coords.size(); // number of line points
|
||||
bool closed = line.m_Closed;
|
||||
|
||||
ENSURE(n >= 2); // minimum needed to avoid errors (also minimum value to make sense, can't draw a line between 1 point)
|
||||
@@ -100,12 +100,12 @@ void CTexturedLineRData::Update(const SOverlayTexturedLine& line)
|
||||
// recompute p2 at the end of each iteration.
|
||||
|
||||
CVector3D p0;
|
||||
CVector3D p1(line.m_Coords[0], 0, line.m_Coords[1]);
|
||||
CVector3D p2(line.m_Coords[2], 0, line.m_Coords[3]);
|
||||
CVector3D p1(line.m_Coords[0].X, 0, line.m_Coords[0].Y);
|
||||
CVector3D p2(line.m_Coords[1].X, 0, line.m_Coords[1].Y);
|
||||
|
||||
if (closed)
|
||||
// grab the ending point so as to close the loop
|
||||
p0 = CVector3D(line.m_Coords[(n-1)*2], 0, line.m_Coords[(n-1)*2+1]);
|
||||
p0 = CVector3D(line.m_Coords[n - 1].X, 0, line.m_Coords[n - 1].Y);
|
||||
else
|
||||
// we don't want to loop around and use the direction towards the other end of the line, so create an artificial p0 that
|
||||
// extends the p2 -> p1 direction, and use that point instead
|
||||
@@ -210,7 +210,7 @@ void CTexturedLineRData::Update(const SOverlayTexturedLine& line)
|
||||
// next iteration is the last point of the line, so create an artificial p2 that extends the p0 -> p1 direction
|
||||
p2 = p1 + (p1 - p0);
|
||||
else
|
||||
p2 = CVector3D(line.m_Coords[((i+2) % n)*2], 0, line.m_Coords[((i+2) % n)*2+1]);
|
||||
p2 = CVector3D(line.m_Coords[(i + 2) % n].X, 0, line.m_Coords[(i + 2) % n].Y);
|
||||
|
||||
p2.Y = terrain.GetExactGroundLevel(p2.X, p2.Z);
|
||||
if (p2.Y < w)
|
||||
|
||||
@@ -514,10 +514,7 @@ void CCmpRallyPointRenderer::ConstructOverlayLines(size_t index)
|
||||
ENSURE(segment.m_EndIndex > segment.m_StartIndex);
|
||||
// End index is inclusive here
|
||||
for (size_t j = segment.m_StartIndex; j <= segment.m_EndIndex; ++j)
|
||||
{
|
||||
overlayLine.m_Coords.push_back(m_Path[index][j].X);
|
||||
overlayLine.m_Coords.push_back(m_Path[index][j].Y);
|
||||
}
|
||||
overlayLine.m_Coords.push_back(m_Path[index][j]);
|
||||
|
||||
m_TexturedOverlayLines[index].push_back(overlayLine);
|
||||
}
|
||||
@@ -588,11 +585,8 @@ void CCmpRallyPointRenderer::ConstructOverlayLines(size_t index)
|
||||
size_t dashEndIndex = dashedLine.GetEndIndex(i);
|
||||
ENSURE(dashEndIndex > dashStartIndex);
|
||||
|
||||
for (size_t n = dashStartIndex; n < dashEndIndex; n++)
|
||||
{
|
||||
dashOverlay.m_Coords.push_back(dashedLine.m_Points[n].X);
|
||||
dashOverlay.m_Coords.push_back(dashedLine.m_Points[n].Y);
|
||||
}
|
||||
for (size_t j = dashStartIndex; j < dashEndIndex; ++j)
|
||||
dashOverlay.m_Coords.push_back(dashedLine.m_Points[j]);
|
||||
|
||||
m_TexturedOverlayLines[index].push_back(dashOverlay);
|
||||
}
|
||||
|
||||
@@ -645,11 +645,10 @@ void CCmpTerritoryManager::UpdateBoundaryLines()
|
||||
SimRender::SmoothPointsAverage(boundaries[i].points, m_BoundaryLines.back().overlay.m_Closed);
|
||||
SimRender::InterpolatePointsRNS(boundaries[i].points, m_BoundaryLines.back().overlay.m_Closed, m_BorderSeparation);
|
||||
|
||||
std::vector<float>& points = m_BoundaryLines.back().overlay.m_Coords;
|
||||
std::vector<CVector2D>& points = m_BoundaryLines.back().overlay.m_Coords;
|
||||
for (size_t j = 0; j < boundaries[i].points.size(); ++j)
|
||||
{
|
||||
points.push_back(boundaries[i].points[j].X);
|
||||
points.push_back(boundaries[i].points[j].Y);
|
||||
points.push_back(boundaries[i].points[j]);
|
||||
|
||||
if (m_EnableLineDebugOverlays)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user