diff --git a/fggl/data/heightmap.cpp b/fggl/data/heightmap.cpp index 0c7dcf665fa3c8053d84b8667d502677d3d6cd5e..72b9b7833c532679eaf893711b56eaf77295278a 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++) {