Skip to content
Snippets Groups Projects
Commit 71cd957e authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers
Browse files

make use of std::array for heightmap data

parent 4ef4a829
No related branches found
No related tags found
No related merge requests found
......@@ -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++) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment