Index: ps/trunk/source/graphics/Overlay.h =================================================================== --- ps/trunk/source/graphics/Overlay.h +++ ps/trunk/source/graphics/Overlay.h @@ -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 @@ /// 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 m_Coords; + std::vector 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 @@ */ 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& 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; Index: ps/trunk/source/renderer/OverlayRenderer.cpp =================================================================== --- ps/trunk/source/renderer/OverlayRenderer.cpp +++ ps/trunk/source/renderer/OverlayRenderer.cpp @@ -219,8 +219,6 @@ if (line->m_Coords.empty()) return; - ENSURE(line->m_Coords.size() % 2 == 0); - m->texlines.push_back(line); } Index: ps/trunk/source/renderer/TexturedLineRData.cpp =================================================================== --- ps/trunk/source/renderer/TexturedLineRData.cpp +++ ps/trunk/source/renderer/TexturedLineRData.cpp @@ -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 @@ std::vector vertices; std::vector 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 @@ // 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 @@ // 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) Index: ps/trunk/source/simulation2/components/CCmpRallyPointRenderer.cpp =================================================================== --- ps/trunk/source/simulation2/components/CCmpRallyPointRenderer.cpp +++ ps/trunk/source/simulation2/components/CCmpRallyPointRenderer.cpp @@ -514,10 +514,7 @@ 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 @@ 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); } Index: ps/trunk/source/simulation2/components/CCmpTerritoryManager.cpp =================================================================== --- ps/trunk/source/simulation2/components/CCmpTerritoryManager.cpp +++ ps/trunk/source/simulation2/components/CCmpTerritoryManager.cpp @@ -645,11 +645,10 @@ 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& points = m_BoundaryLines.back().overlay.m_Coords; + std::vector& 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) {