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 authored and past-due committed Sep 8, 2023
1 parent 6527ff5 commit a9d7606
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/terrain.cpp
Expand Up @@ -427,9 +427,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 a9d7606

Please sign in to comment.