Skip to content

Commit 25ba96f

Browse files
committedJan 13, 2017
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.
1 parent 5d60a6c commit 25ba96f

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed
 

‎src/mesh.cpp

+8-11
Original file line numberDiff line numberDiff line change
@@ -186,17 +186,14 @@ void shadeMeshFaces(scene::IMesh *mesh)
186186
for (u32 i = 0; i < vertex_count; i++) {
187187
video::S3DVertex *vertex = (video::S3DVertex *)(vertices + i * stride);
188188
video::SColor &vc = vertex->Color;
189-
if (vertex->Normal.Y < -0.5) {
190-
applyFacesShading (vc, 0.447213);
191-
} else if (vertex->Normal.Z > 0.5) {
192-
applyFacesShading (vc, 0.670820);
193-
} else if (vertex->Normal.Z < -0.5) {
194-
applyFacesShading (vc, 0.670820);
195-
} else if (vertex->Normal.X > 0.5) {
196-
applyFacesShading (vc, 0.836660);
197-
} else if (vertex->Normal.X < -0.5) {
198-
applyFacesShading (vc, 0.836660);
199-
}
189+
// Many special drawtypes have normals set to 0,0,0 and this
190+
// must result in maximum brightness (no face shadng).
191+
if (vertex->Normal.Y < -0.5f)
192+
applyFacesShading (vc, 0.447213f);
193+
else if (vertex->Normal.X > 0.5f || vertex->Normal.X < -0.5f)
194+
applyFacesShading (vc, 0.670820f);
195+
else if (vertex->Normal.Z > 0.5f || vertex->Normal.Z < -0.5f)
196+
applyFacesShading (vc, 0.836660f);
200197
}
201198
}
202199
}

0 commit comments

Comments
 (0)
Please sign in to comment.