diff options
author | paramat <mat.gregory@virginmedia.com> | 2016-12-24 06:40:57 +0000 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2017-01-13 02:42:18 +0000 |
commit | 25ba96fcac9fce7bfa9dd6e9c2c3e96e2d5e147e (patch) | |
tree | 8f29173265a56e13d08f350d800ec801e7509e91 /src | |
parent | 5d60a6c533efb572a4004d110536da63bb62c58a (diff) | |
download | minetest-25ba96fcac9fce7bfa9dd6e9c2c3e96e2d5e147e.tar.gz minetest-25ba96fcac9fce7bfa9dd6e9c2c3e96e2d5e147e.tar.bz2 minetest-25ba96fcac9fce7bfa9dd6e9c2c3e96e2d5e147e.zip |
Meshes: Make object mesh face shading consistent
Previously, object meshes had their North and South faces darker than
East and West faces, the opposite of nodes and meshnodes. This commit
corrects this.
State constants as float-literals not double-literals.
Simplify code.
Add comment.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesh.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/mesh.cpp b/src/mesh.cpp index b68862d22..50465748c 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -186,17 +186,14 @@ void shadeMeshFaces(scene::IMesh *mesh) for (u32 i = 0; i < vertex_count; i++) { video::S3DVertex *vertex = (video::S3DVertex *)(vertices + i * stride); video::SColor &vc = vertex->Color; - if (vertex->Normal.Y < -0.5) { - applyFacesShading (vc, 0.447213); - } else if (vertex->Normal.Z > 0.5) { - applyFacesShading (vc, 0.670820); - } else if (vertex->Normal.Z < -0.5) { - applyFacesShading (vc, 0.670820); - } else if (vertex->Normal.X > 0.5) { - applyFacesShading (vc, 0.836660); - } else if (vertex->Normal.X < -0.5) { - applyFacesShading (vc, 0.836660); - } + // Many special drawtypes have normals set to 0,0,0 and this + // must result in maximum brightness (no face shadng). + if (vertex->Normal.Y < -0.5f) + applyFacesShading (vc, 0.447213f); + else if (vertex->Normal.X > 0.5f || vertex->Normal.X < -0.5f) + applyFacesShading (vc, 0.670820f); + else if (vertex->Normal.Z > 0.5f || vertex->Normal.Z < -0.5f) + applyFacesShading (vc, 0.836660f); } } } |