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

make windows happy by avoiding storing the heightmap on the stack

parent edd10e5a
No related branches found
No related tags found
No related merge requests found
Pipeline #3298 failed
......@@ -15,7 +15,7 @@ namespace fggl::data {
const int gridOffset = sizeX * sizeY;
// calculate normals for each triangle
math::vec3 triNormals[sizeX * sizeY * 2];
math::vec3* triNormals = new math::vec3[sizeX * sizeY * 2];
for (int i = 0; i < sizeX - 1; i++) {
for (int j = 0; j < sizeY - 1; j++) {
// calculate vertex
......@@ -66,12 +66,15 @@ namespace fggl::data {
locations[idx(i, j, sizeY)].normal = glm::normalize(finalNormal) * -1.0f; //FIXME the normals seem wrong.
}
}
delete[] triNormals;
}
void generateHeightMesh(const data::HeightMap *heights, data::Mesh &mesh) {
// step 1: convert height data into vertex locations
data::Vertex locations[data::heightMaxZ * data::heightMaxZ];
const int numElms = data::heightMaxX * data::heightMaxZ;
data::Vertex* locations = new data::Vertex[numElms];
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);
......@@ -88,9 +91,10 @@ namespace fggl::data {
mesh.restartVertex = data::heightMaxZ * data::heightMaxX;
// populate mesh
for (auto & location : locations) {
mesh.pushVertex(location);
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