Fix dirtlike lighting (ambient occlusion)

This commit is contained in:
blockmaster2000 2016-08-17 21:43:22 +00:00
parent f887e27b8a
commit 91baae320f
1 changed files with 7 additions and 8 deletions

View File

@ -385,7 +385,7 @@ TileSpec getMetaTile(MapNode mn, v3s16 p, v3s16 face_dir, SelectedNode &select)
return spec; return spec;
} }
v3s16 dirs8[8] = { static const v3s16 dirs8[8] = {
v3s16(0,0,0), v3s16(0,0,0),
v3s16(0,0,1), v3s16(0,0,1),
v3s16(0,1,0), v3s16(0,1,0),
@ -411,19 +411,18 @@ u8 getSmoothLight(v3s16 p, v3s16 corner, VoxelManipulator &vmanip)
if (corner.Z == 1) if (corner.Z == 1)
p.Z += 1; p.Z += 1;
for (u32 i=0; i<8; i++) { for (u8 i = 0; i < 8; i++) {
MapNode n = vmanip.getNodeRO(p - dirs8[i]); MapNode n = vmanip.getNodeRO(p - dirs8[i]);
if ( ContentFeatures &f = content_features(n);
content_features(n).param_type == CPT_LIGHT if (f.param_type == CPT_LIGHT) {
) {
dl += n.getLight(LIGHTBANK_DAY); dl += n.getLight(LIGHTBANK_DAY);
nl += n.getLight(LIGHTBANK_NIGHT); nl += n.getLight(LIGHTBANK_NIGHT);
light_count++; light_count++;
if (content_features(n).light_source > 0) if (f.light_source > 0)
ambient_occlusion -= 2.0; ambient_occlusion -= 2.0;
}else if (content_features(n).draw_type == CDT_CUBELIKE) { } else if (f.draw_type == CDT_CUBELIKE || f.draw_type == CDT_DIRTLIKE) {
ambient_occlusion += 1.0; ambient_occlusion += 1.0;
}else if (n.getContent() != CONTENT_IGNORE) { } else if (n.getContent() != CONTENT_IGNORE) {
ambient_occlusion += 0.5; ambient_occlusion += 0.5;
} }
} }