mirror of
https://github.com/moparisthebest/minetest
synced 2024-11-15 13:55:11 -05:00
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.
This commit is contained in:
parent
5d60a6c533
commit
25ba96fcac
19
src/mesh.cpp
19
src/mesh.cpp
@ -186,17 +186,14 @@ void shadeMeshFaces(scene::IMesh *mesh)
|
|||||||
for (u32 i = 0; i < vertex_count; i++) {
|
for (u32 i = 0; i < vertex_count; i++) {
|
||||||
video::S3DVertex *vertex = (video::S3DVertex *)(vertices + i * stride);
|
video::S3DVertex *vertex = (video::S3DVertex *)(vertices + i * stride);
|
||||||
video::SColor &vc = vertex->Color;
|
video::SColor &vc = vertex->Color;
|
||||||
if (vertex->Normal.Y < -0.5) {
|
// Many special drawtypes have normals set to 0,0,0 and this
|
||||||
applyFacesShading (vc, 0.447213);
|
// must result in maximum brightness (no face shadng).
|
||||||
} else if (vertex->Normal.Z > 0.5) {
|
if (vertex->Normal.Y < -0.5f)
|
||||||
applyFacesShading (vc, 0.670820);
|
applyFacesShading (vc, 0.447213f);
|
||||||
} else if (vertex->Normal.Z < -0.5) {
|
else if (vertex->Normal.X > 0.5f || vertex->Normal.X < -0.5f)
|
||||||
applyFacesShading (vc, 0.670820);
|
applyFacesShading (vc, 0.670820f);
|
||||||
} else if (vertex->Normal.X > 0.5) {
|
else if (vertex->Normal.Z > 0.5f || vertex->Normal.Z < -0.5f)
|
||||||
applyFacesShading (vc, 0.836660);
|
applyFacesShading (vc, 0.836660f);
|
||||||
} else if (vertex->Normal.X < -0.5) {
|
|
||||||
applyFacesShading (vc, 0.836660);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user