Skip to content

Commit

Permalink
bottom right wip
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Jun 30, 2024
1 parent 8a2544f commit a2aea18
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions isotilerenderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions isotilerenderer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down

0 comments on commit a2aea18

Please sign in to comment.