From cde8ef44953d8c3199ecb5e3cdc8170bdcf77e3d Mon Sep 17 00:00:00 2001 From: Andrey Stepanov Date: Sat, 9 Nov 2024 14:18:08 +0500 Subject: [PATCH] suppress shadows of invisible nodes --- mapblockrenderer/renderer.go | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/mapblockrenderer/renderer.go b/mapblockrenderer/renderer.go index cae4b72..1fafafb 100644 --- a/mapblockrenderer/renderer.go +++ b/mapblockrenderer/renderer.go @@ -36,7 +36,7 @@ const ( EXPECTED_BLOCKS_PER_FLAT_MAPBLOCK = 16 * 16 ) -func IsViewBlocking(nodeName string) bool { +func (r *MapBlockRenderer) IsViewBlocking(nodeName string, param2 int) bool { if nodeName == "" { return false } @@ -49,6 +49,12 @@ func IsViewBlocking(nodeName string) bool { return false } + c := r.colors.GetColor(nodeName, param2) + + if c == nil { + return false + } + return true } @@ -147,12 +153,14 @@ func (r *MapBlockRenderer) Render(pos1, pos2 *types.MapBlockCoords) (*image.NRGB if r.enableShadow { var left, leftAbove, top, topAbove string + var left_param2, leftAbove_param2, top_param2, topAbove_param2 int if x > 0 { //same mapblock left = mb.GetNodeName(x-1, y, z) if y < 15 { leftAbove = mb.GetNodeName(x-1, y+1, z) + leftAbove_param2 = mb.GetParam2(x-1, y+1, z) } } else { @@ -162,8 +170,10 @@ func (r *MapBlockRenderer) Render(pos1, pos2 *types.MapBlockCoords) (*image.NRGB if neighbourMapblock != nil && err == nil { left = neighbourMapblock.GetNodeName(15, y, z) + left_param2 = neighbourMapblock.GetParam2(15, y, z) if y < 15 { leftAbove = neighbourMapblock.GetNodeName(15, y+1, z) + leftAbove_param2 = neighbourMapblock.GetParam2(15, y+1, z) } } } @@ -173,6 +183,7 @@ func (r *MapBlockRenderer) Render(pos1, pos2 *types.MapBlockCoords) (*image.NRGB top = mb.GetNodeName(x, y, z+1) if y < 15 { topAbove = mb.GetNodeName(x, y+1, z+1) + topAbove_param2 = mb.GetParam2(x, y+1, z+1) } } else { @@ -182,28 +193,30 @@ func (r *MapBlockRenderer) Render(pos1, pos2 *types.MapBlockCoords) (*image.NRGB if neighbourMapblock != nil && err == nil { top = neighbourMapblock.GetNodeName(x, y, 0) + top_param2 = neighbourMapblock.GetParam2(x, y, 0) if y < 15 { topAbove = neighbourMapblock.GetNodeName(x, y+1, 0) + topAbove_param2 = neighbourMapblock.GetParam2(x, y+1, 0) } } } - if IsViewBlocking(leftAbove) { + if r.IsViewBlocking(leftAbove, leftAbove_param2) { //add shadow c = addColorComponent(c, -10) } - if IsViewBlocking(topAbove) { + if r.IsViewBlocking(topAbove, topAbove_param2) { //add shadow c = addColorComponent(c, -10) } - if !IsViewBlocking(left) { + if !r.IsViewBlocking(left, left_param2) { //add light c = addColorComponent(c, 10) } - if !IsViewBlocking(top) { + if !r.IsViewBlocking(top, top_param2) { //add light c = addColorComponent(c, 10) }