From 30b4e57828acc1e2304373f9c8e4caecc39a3803 Mon Sep 17 00:00:00 2001 From: Alexander Shalamov Date: Thu, 30 Apr 2020 12:39:55 +0300 Subject: [core] Fix rest of 'brace initialization' errors --- .../layers/render_location_indicator_layer.cpp | 2 +- src/mbgl/util/bounding_volumes.cpp | 92 +++++++++++----------- src/mbgl/util/mat3.hpp | 6 +- src/mbgl/util/tile_cover.cpp | 4 +- 4 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/mbgl/renderer/layers/render_location_indicator_layer.cpp b/src/mbgl/renderer/layers/render_location_indicator_layer.cpp index 1a1bdc1b4b..28228e60da 100644 --- a/src/mbgl/renderer/layers/render_location_indicator_layer.cpp +++ b/src/mbgl/renderer/layers/render_location_indicator_layer.cpp @@ -441,7 +441,7 @@ public: mapbox::geometry::point{oldParams.puckPosition.latitude(), oldParams.puckPosition.longitude()}; mapbox::geometry::linear_ring border; for (const auto& v : puckGeometry) { - vec4 p{v.x, v.y, 0, 1}; + vec4 p{{v.x, v.y, 0, 1}}; matrix::transformMat4(p, p, translation); border.push_back(Point{int64_t(p[0]), int64_t(p[1])}); } diff --git a/src/mbgl/util/bounding_volumes.cpp b/src/mbgl/util/bounding_volumes.cpp index ccad4d95af..fc3419342c 100644 --- a/src/mbgl/util/bounding_volumes.cpp +++ b/src/mbgl/util/bounding_volumes.cpp @@ -8,7 +8,7 @@ namespace mbgl { namespace { vec3 toVec3(const vec4& v) { - return vec3{v[0], v[1], v[2]}; + return vec3{{v[0], v[1], v[2]}}; } double vec4Dot(const vec4& a, const vec4& b) { @@ -33,14 +33,14 @@ static Point ProjectPointsToAxis(const std::array& points, cons namespace util { -AABB::AABB() : min({0, 0, 0}), max({0, 0, 0}) {} +AABB::AABB() : min({{0, 0, 0}}), max({{0, 0, 0}}) {} AABB::AABB(const vec3& min_, const vec3& max_) : min(min_), max(max_) {} vec3 AABB::closestPoint(const vec3& point) const { - return {std::max(std::min(max[0], point[0]), min[0]), - std::max(std::min(max[1], point[1]), min[1]), - std::max(std::min(max[2], point[2]), min[2])}; + return {{std::max(std::min(max[0], point[0]), min[0]), + std::max(std::min(max[1], point[1]), min[1]), + std::max(std::min(max[2], point[2]), min[2])}}; } vec3 AABB::distanceXYZ(const vec3& point) const { @@ -62,8 +62,8 @@ AABB AABB::quadrant(int idx) const { // This aabb is split into 4 quadrants. For each axis define in which side of the split "idx" is // The result for indices 0, 1, 2, 3 is: { 0, 0 }, { 1, 0 }, { 0, 1 }, { 1, 1 } - const std::array xSplit = {0, 1, 0, 1}; - const std::array ySplit = {0, 0, 1, 1}; + const std::array xSplit = {{0, 1, 0, 1}}; + const std::array ySplit = {{0, 0, 1, 1}}; quadrantMin[0] = xSplit[idx] ? xCenter : quadrantMin[0]; quadrantMax[0] = xSplit[idx] ? quadrantMax[0] : xCenter; @@ -103,26 +103,26 @@ enum { Frustum::Frustum(const std::array& points_, const std::array& planes_) : points(points_), planes(planes_) { - const Point xBounds = ProjectPointsToAxis(points, {0, 0, 0}, {1, 0, 0}); - const Point yBounds = ProjectPointsToAxis(points, {0, 0, 0}, {0, 1, 0}); - const Point zBounds = ProjectPointsToAxis(points, {0, 0, 0}, {0, 0, 1}); + const Point xBounds = ProjectPointsToAxis(points, {{0, 0, 0}}, {{1, 0, 0}}); + const Point yBounds = ProjectPointsToAxis(points, {{0, 0, 0}}, {{0, 1, 0}}); + const Point zBounds = ProjectPointsToAxis(points, {{0, 0, 0}}, {{0, 0, 1}}); - bounds = AABB({xBounds.x, yBounds.x, zBounds.x}, {xBounds.y, yBounds.y, zBounds.y}); + bounds = AABB({{xBounds.x, yBounds.x, zBounds.x}}, {{xBounds.y, yBounds.y, zBounds.y}}); // Precompute a set of separating axis candidates for precise intersection tests. // Remaining axes not covered in basic intersection tests are: axis[] = (edges of aabb) x (edges of frustum) - std::array frustumEdges = {vec3Sub(points[near_br], points[near_bl]), - vec3Sub(points[near_tl], points[near_bl]), - vec3Sub(points[far_tl], points[near_tl]), - vec3Sub(points[far_tr], points[near_tr]), - vec3Sub(points[far_br], points[near_br]), - vec3Sub(points[far_bl], points[near_bl])}; + std::array frustumEdges = {{vec3Sub(points[near_br], points[near_bl]), + vec3Sub(points[near_tl], points[near_bl]), + vec3Sub(points[far_tl], points[near_tl]), + vec3Sub(points[far_tr], points[near_tr]), + vec3Sub(points[far_br], points[near_br]), + vec3Sub(points[far_bl], points[near_bl])}}; for (size_t i = 0; i < frustumEdges.size(); i++) { // Cross product [1, 0, 0] x [a, b, c] == [0, -c, b] // Cross product [0, 1, 0] x [a, b, c] == [c, 0, -a] - const vec3 axis0 = {0.0, -frustumEdges[i][2], frustumEdges[i][1]}; - const vec3 axis1 = {frustumEdges[i][2], 0.0, -frustumEdges[i][0]}; + const vec3 axis0 = {{0.0, -frustumEdges[i][2], frustumEdges[i][1]}}; + const vec3 axis1 = {{frustumEdges[i][2], 0.0, -frustumEdges[i][0]}}; projections[i * 2] = {axis0, ProjectPointsToAxis(points, points[0], axis0)}; projections[i * 2 + 1] = {axis1, ProjectPointsToAxis(points, points[0], axis1)}; @@ -131,14 +131,14 @@ Frustum::Frustum(const std::array& points_, const std::array& Frustum Frustum::fromInvProjMatrix(const mat4& invProj, double worldSize, double zoom, bool flippedY) { // Define frustum corner points in normalized clip space - std::array cornerCoords = {vec4{-1.0, 1.0, -1.0, 1.0}, - vec4{1.0, 1.0, -1.0, 1.0}, - vec4{1.0, -1.0, -1.0, 1.0}, - vec4{-1.0, -1.0, -1.0, 1.0}, - vec4{-1.0, 1.0, 1.0, 1.0}, - vec4{1.0, 1.0, 1.0, 1.0}, - vec4{1.0, -1.0, 1.0, 1.0}, - vec4{-1.0, -1.0, 1.0, 1.0}}; + std::array cornerCoords = {{vec4{{-1.0, 1.0, -1.0, 1.0}}, + vec4{{1.0, 1.0, -1.0, 1.0}}, + vec4{{1.0, -1.0, -1.0, 1.0}}, + vec4{{-1.0, -1.0, -1.0, 1.0}}, + vec4{{-1.0, 1.0, 1.0, 1.0}}, + vec4{{1.0, 1.0, 1.0, 1.0}}, + vec4{{1.0, -1.0, 1.0, 1.0}}, + vec4{{-1.0, -1.0, 1.0, 1.0}}}}; const double scale = std::pow(2.0, zoom); @@ -148,14 +148,14 @@ Frustum Frustum::fromInvProjMatrix(const mat4& invProj, double worldSize, double for (auto& component : coord) component *= 1.0 / coord[3] / worldSize * scale; } - std::array frustumPlanePointIndices = { - vec3i{near_bl, near_br, far_br}, // bottom - vec3i{near_tl, near_bl, far_bl}, // left - vec3i{near_br, near_tr, far_tr}, // right - vec3i{near_tl, far_tl, far_tr}, // top - vec3i{near_tl, near_tr, near_br}, // near - vec3i{far_br, far_tr, far_tl} // far - }; + std::array frustumPlanePointIndices = {{ + vec3i{{near_bl, near_br, far_br}}, // bottom + vec3i{{near_tl, near_bl, far_bl}}, // left + vec3i{{near_br, near_tr, far_tr}}, // right + vec3i{{near_tl, far_tl, far_tr}}, // top + vec3i{{near_tl, near_tr, near_br}}, // near + vec3i{{far_br, far_tr, far_tl}} // far + }}; if (flippedY) { std::for_each(frustumPlanePointIndices.begin(), frustumPlanePointIndices.end(), [](vec3i& tri) { @@ -177,7 +177,7 @@ Frustum Frustum::fromInvProjMatrix(const mat4& invProj, double worldSize, double const vec3 b = vec3Sub(p2, p1); const vec3 n = vec3Normalize(vec3Cross(a, b)); - frustumPlanes[i] = {n[0], n[1], n[2], -vec3Dot(n, p1)}; + frustumPlanes[i] = {{n[0], n[1], n[2], -vec3Dot(n, p1)}}; } std::array frustumPoints; @@ -197,12 +197,12 @@ IntersectionResult Frustum::intersects(const AABB& aabb) const { if (!bounds.intersects(aabb)) return IntersectionResult::Separate; - const std::array aabbPoints = { - vec4{aabb.min[0], aabb.min[1], 0.0, 1.0}, - vec4{aabb.max[0], aabb.min[1], 0.0, 1.0}, - vec4{aabb.max[0], aabb.max[1], 0.0, 1.0}, - vec4{aabb.min[0], aabb.max[1], 0.0, 1.0}, - }; + const std::array aabbPoints = {{ + vec4{{aabb.min[0], aabb.min[1], 0.0, 1.0}}, + vec4{{aabb.max[0], aabb.min[1], 0.0, 1.0}}, + vec4{{aabb.max[0], aabb.max[1], 0.0, 1.0}}, + vec4{{aabb.min[0], aabb.max[1], 0.0, 1.0}}, + }}; bool fullyInside = true; @@ -232,10 +232,10 @@ IntersectionResult Frustum::intersectsPrecise(const AABB& aabb, bool edgeCasesOn if (result == IntersectionResult::Separate) return result; } - const std::array aabbPoints = {vec3{aabb.min[0], aabb.min[1], 0.0}, - vec3{aabb.max[0], aabb.min[1], 0.0}, - vec3{aabb.max[0], aabb.max[1], 0.0}, - vec3{aabb.min[0], aabb.max[1], 0.0}}; + const std::array aabbPoints = {{vec3{{aabb.min[0], aabb.min[1], 0.0}}, + vec3{{aabb.max[0], aabb.min[1], 0.0}}, + vec3{{aabb.max[0], aabb.max[1], 0.0}}, + vec3{{aabb.min[0], aabb.max[1], 0.0}}}}; // For a precise SAT-test all edge cases needs to be covered // Projections of the frustum on separating axis candidates have been precomputed already diff --git a/src/mbgl/util/mat3.hpp b/src/mbgl/util/mat3.hpp index 6b2e61a006..9690bab00a 100644 --- a/src/mbgl/util/mat3.hpp +++ b/src/mbgl/util/mat3.hpp @@ -33,7 +33,7 @@ using vec3i = std::array; using mat3 = std::array; inline vec3 vec3Cross(const vec3& a, const vec3& b) { - return vec3{a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]}; + return vec3{{a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]}}; } inline double vec3Dot(const vec3& a, const vec3& b) { @@ -49,7 +49,7 @@ inline double vec3Length(const vec3& a) { } inline vec3 vec3Scale(const vec3& a, double s) { - return vec3{a[0] * s, a[1] * s, a[2] * s}; + return vec3{{a[0] * s, a[1] * s, a[2] * s}}; } inline vec3 vec3Normalize(const vec3& a) { @@ -57,7 +57,7 @@ inline vec3 vec3Normalize(const vec3& a) { } inline vec3 vec3Sub(const vec3& a, const vec3& b) { - return vec3{a[0] - b[0], a[1] - b[1], a[2] - b[2]}; + return vec3{{a[0] - b[0], a[1] - b[1], a[2] - b[2]}}; } namespace matrix { diff --git a/src/mbgl/util/tile_cover.cpp b/src/mbgl/util/tile_cover.cpp index dffee9e841..fb4579b9ab 100644 --- a/src/mbgl/util/tile_cover.cpp +++ b/src/mbgl/util/tile_cover.cpp @@ -171,7 +171,7 @@ std::vector tileCover(const TransformState& state, uint8_t z, auto centerPoint = TileCoordinate::fromScreenCoordinate(state, z, {state.getSize().width / 2.0, state.getSize().height / 2.0}).p; - vec3 centerCoord = {centerPoint.x, centerPoint.y, 0.0}; + vec3 centerCoord = {{centerPoint.x, centerPoint.y, 0.0}}; const Frustum frustum = Frustum::fromInvProjMatrix(state.getInvProjectionMatrix(), worldSize, z, flippedY); @@ -179,7 +179,7 @@ std::vector tileCover(const TransformState& state, uint8_t z, const double radiusOfMaxLvlLodInTiles = 3; const auto newRootTile = [&](int16_t wrap) -> Node { - return {AABB({wrap * numTiles, 0.0, 0.0}, {(wrap + 1) * numTiles, numTiles, 0.0}), + return {AABB({{wrap * numTiles, 0.0, 0.0}}, {{(wrap + 1) * numTiles, numTiles, 0.0}}), uint8_t(0), uint16_t(0), uint16_t(0), -- cgit v1.2.1