Skip to content

Commit

Permalink
fix getGridNormal for center point
Browse files Browse the repository at this point in the history
  • Loading branch information
amelentev committed Jul 31, 2023
1 parent 8408aa2 commit 373b873
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/terrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,8 @@ static Vector3f getGridNormal(int x, int y, bool center = false)
return -glm::normalize(res);
};
if (center) {
return calcNormal(getGridPosf(x, y, true), {
getGridPosf(x,y), getGridPosf(x+1, y), getGridPosf(x+1, y+1), getGridPosf(x, y+1)
});
// avg nearest normals provide better results
return (getGridNormal(x, y) + getGridNormal(x+1, y) + getGridNormal(x+1, y+1) + getGridNormal(x, y+1)) / 4.f;
} else {
return calcNormal(getGridPosf(x, y), {
getGridPosf(x+1, y), getGridPosf(x, y, true), getGridPosf(x, y+1), getGridPosf(x-1, y, true),
Expand Down

0 comments on commit 373b873

Please sign in to comment.