From 71cd957e7245db3984aa86b114a0c8b1a22c3d2d Mon Sep 17 00:00:00 2001 From: Joseph Walton-Rivers <joseph@walton-rivers.uk> Date: Sun, 24 Apr 2022 15:51:31 +0100 Subject: [PATCH] make use of std::array for heightmap data --- fggl/data/heightmap.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fggl/data/heightmap.cpp b/fggl/data/heightmap.cpp index 0c7dcf6..72b9b78 100644 --- a/fggl/data/heightmap.cpp +++ b/fggl/data/heightmap.cpp @@ -73,8 +73,9 @@ namespace fggl::data { // step 1: convert height data into vertex locations const int numElms = data::heightMaxX * data::heightMaxZ; - data::Vertex* locations = new data::Vertex[numElms]; + std::array<data::Vertex, numElms> locations{}; + // iterate the for (std::size_t x = 0; x < data::heightMaxX; x++) { for (std::size_t z = 0; z < data::heightMaxZ; z++) { float level = heights->getValue(x, z); @@ -86,7 +87,7 @@ namespace fggl::data { locations[idx1].posititon = math::vec3(-0.5f + xPos, level, -0.5f - zPos); } } - gridVertexNormals(locations); + gridVertexNormals(locations.data()); mesh.restartVertex = data::heightMaxZ * data::heightMaxX; @@ -94,7 +95,6 @@ namespace fggl::data { for (auto i = 0; i < numElms; i++) { mesh.pushVertex(locations[i]); } - delete[] locations; for (std::size_t x = 0; x < data::heightMaxX - 1; x++) { for (std::size_t z = 0; z < data::heightMaxZ; z++) { -- GitLab