From a2aea18d47d00e7b65b908cc15606e411ad8359d Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Sun, 30 Jun 2024 11:40:06 +0200 Subject: [PATCH] bottom right wip --- isotilerenderer.go | 14 ++++++++++++++ isotilerenderer_test.go | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/isotilerenderer.go b/isotilerenderer.go index ff217e8..a01a43d 100644 --- a/isotilerenderer.go +++ b/isotilerenderer.go @@ -26,6 +26,8 @@ func RenderIsometricTile(na types.NodeAccessor, cr types.ColorResolver, from, to min, max := types.SortPos(from, to) size := to.Subtract(from).Add(types.NewPos(1, 1, 1)) top_size := types.NewPos(size.X(), 1, size.Z()) + probe_bounds_min := types.NewPos(min.X()-size.Y(), min.Y(), min.Z()-size.Y()) + probe_bounds_max := types.NewPos(max.X()+size.Y(), max.Y(), max.Z()+size.Y()) width, height := GetIsometricImageSize(top_size, opts.CubeLen) center_x, center_y := GetIsoCenterCubeOffset(size, opts.CubeLen) @@ -46,6 +48,18 @@ func RenderIsometricTile(na types.NodeAccessor, cr types.ColorResolver, from, to } } + // bottom right corner + for zi := 0; zi <= size.Z(); zi++ { + for x := min.X() + zi; x <= max.X()-zi; x++ { + pos := types.NewPos(x, max.Y(), min.Z()-zi) + pnodes, err := Probe(probe_bounds_min, probe_bounds_max, pos, ipos, na, cr, true) + if err != nil { + return nil, fmt.Errorf("probe error, top layer: %v", err) + } + nodes = append(nodes, pnodes...) + } + } + slices.SortFunc(nodes, SortNodesWithColor) for _, n := range nodes { diff --git a/isotilerenderer_test.go b/isotilerenderer_test.go index 29adda4..0619ce1 100644 --- a/isotilerenderer_test.go +++ b/isotilerenderer_test.go @@ -23,8 +23,8 @@ func TestIsoTileRenderer(t *testing.T) { err = cm.LoadDefaults() assert.NoError(t, err) - from := types.NewPos(0, 0, 0) - to := types.NewPos(15, 30, 15) + from := types.NewPos(16, 16, 16) + to := types.NewPos(31, 30, 31) opts := &maprenderer.IsoTileRenderOpts{ CubeLen: 16, }