Mercurial > games > semicongine
changeset 865:dc7b1312fc76
fix: grid-generation not correct
author | Sam <sam@basx.dev> |
---|---|
date | Mon, 01 Jan 2024 17:39:49 +0700 |
parents | db6f2ec42e27 |
children | 0ae619ecc4bf |
files | semicongine/mesh.nim |
diffstat | 1 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/semicongine/mesh.nim Sat Dec 30 00:17:04 2023 +0700 +++ b/semicongine/mesh.nim Mon Jan 01 17:39:49 2024 +0700 @@ -518,21 +518,26 @@ center_offset_x = -(float32(columns) * cellSize) / 2'f32 center_offset_y = -(float32(rows) * cellSize) / 2'f32 var - pos = @[newVec3f(center_offset_x, center_offset_y)] - col = @[color, color] + pos: seq[Vec3f] + col: seq[Vec4f] i = 0'u16 for h in 0'u16 .. rows: for w in 0'u16 .. columns: pos.add newVec3f(center_offset_x + float32(w) * cellSize, center_offset_y + float32(h) * cellSize) col.add color if w > 0 and h > 0: - result[].smallIndices.add [i, i - 1, i - w - 1] - result[].smallIndices.add [i, i - w - 1, i - w] + result[].smallIndices.add [i, i - 1, i - rows - 2] + result[].smallIndices.add [i, i - rows - 2, i - rows - 1] i.inc result[].initVertexAttribute(DEFAULT_POSITION_ATTRIBUTE, pos) result[].initVertexAttribute("color", col) + echo pos + echo result[].smallIndices + echo result + + # MESH TREES ============================================================================= type