Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
bozbalci committed Jan 8, 2020
1 parent 8988fef commit 57d2e6d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,4 @@ friends/
# Python
virtualenv/
__pycache__/
*.pyc
*.pyc
1 change: 1 addition & 0 deletions assignments/hw3/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ hw3_flat: flat.cpp
.PHONY += codegen
codegen:
cd code_generation; python3 ./generate.py flat.cpp > ../flat.cpp
clang-format -i flat.cpp
# cd code_generation; python3 ./generate.py sphere.cpp > ../sphere.cpp

codegen-build: codegen hw3_flat
Expand Down
49 changes: 23 additions & 26 deletions assignments/hw3/src/flat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,38 +665,35 @@ struct HW3Utility {
// MESH GENERATION
void GenerateTerrainVertices()
{

for (auto z = 0; z < TextureHeight; ++z) {
for (auto x = 0; x < TextureWidth; ++x) {
Vertices.push_back({
.Position = glm::vec3((float) x, 0.0f, (float) z),
.TextureCoordinates = glm::vec2((float) -x / TextureWidth,
(float) -z / TextureHeight)
});
}
}

for (auto z = 0; z < TextureHeight; ++z) {
for (auto x = 0; x < TextureWidth; ++x) {
Vertices.push_back(
{.Position = glm::vec3((float)x, 0.0f, (float)z),
.TextureCoordinates = glm::vec2(
(float)-x / TextureWidth, (float)-z / TextureHeight)});
}
}
}

void GenerateTerrainIndices()
{

for (auto i = 0; i < TextureHeight - 1; ++i) {
for (auto j = 0; j < TextureWidth - 1; ++j) {
auto Current = i * TextureWidth + j;
auto Right = Current + 1;
auto Bottom = Current + TextureWidth;
auto BottomRight = Bottom + 1;

Indices.push_back(Current);
Indices.push_back(Right);
Indices.push_back(Bottom);
Indices.push_back(Right);
Indices.push_back(BottomRight);
Indices.push_back(Bottom);
}
}

for (auto i = 0; i < TextureHeight - 1; ++i) {
for (auto j = 0; j < TextureWidth - 1; ++j) {
auto Current = i * TextureWidth + j;
auto Right = Current + 1;
auto Bottom = Current + TextureWidth;
auto BottomRight = Bottom + 1;

Indices.push_back(Current);
Indices.push_back(Right);
Indices.push_back(Bottom);
Indices.push_back(Right);
Indices.push_back(BottomRight);
Indices.push_back(Bottom);
}
}
}

// LIFETIME METHODS
Expand Down

0 comments on commit 57d2e6d

Please sign in to comment.