suppress shadows of invisible nodes
This commit is contained in:
parent
c45f002f82
commit
cde8ef4495
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user