B2 Grid building and placement preview #16

Closed
opened 2026-11-09 05:26:54 +00:00 by claude · 1 comment
Owner

Depends on: B1

A server-authoritative snap grid with wall, floor, ramp and breakwater pieces in three materials, plus a client placement ghost. A breakwater is Tidewall's own piece: it holds back rising water for a short time.

Acceptance

  • The server rejects out-of-range, overlapping or unaffordable placements, with tests.
  • The client ghost shows valid and invalid states.
  • A rapid-placement test at 10 pieces per second stays within the tick budget.
**Depends on:** B1 A server-authoritative snap grid with wall, floor, ramp and breakwater pieces in three materials, plus a client placement ghost. A breakwater is Tidewall's own piece: it holds back rising water for a short time. **Acceptance** - The server rejects out-of-range, overlapping or unaffordable placements, with tests. - The client ghost shows valid and invalid states. - A rapid-placement test at 10 pieces per second stays within the tick budget.
claude added this to the v0.3 Building and Combat milestone 2026-11-09 05:26:54 +00:00
claude added the priority/hightype/feature labels 2026-11-09 05:26:54 +00:00
claude added this to the Tidewall v1.0 project 2026-11-09 15:00:06 +00:00
eric closed this issue 2026-11-11 19:23:37 +00:00
Author
Owner

Done in f35ebf7.

What changed

  • StructureSet (src/sim/structure_set.gd) holds pieces in grid slots: a cell's floor, the two wall edges, or the cell's volume for ramps and roofs. Each piece's boxes go into SimGround, so movement and line of sight already respect them. It keeps touching-neighbour links for B3. Ramps are stairs of 0.4 m steps, so they climb with the existing step-up. Walls and breakwaters over lower ground get a skirt down to the terrain, which leaves no gap for water or players. Breakwaters are 0.6 m thick and share the wall slot.
  • Building (src/sim/building.gd): target() snaps the player's look and position to a slot. check() validates any slot as if a hostile client had chosen it: state, kind and material, world bounds, BUILD_RANGE, occupancy, trapping a player, cost, and touching the terrain or another piece. Fire in build mode (selection = piece, material = material) places at most 10 pieces a second. A player standing in the low step of a new floor is lifted onto it.
  • Design decision: pieces are a whole 4 m cell tall, but levels snap every 2 m (BUILD_LEVEL_METRES). With a 4 m vertical grid, the first capture showed ground-level forts half buried on gentle slopes. With half levels, a ground piece is never more than a metre from the builder's feet. A slot also counts as taken when the same slot half a cell up or down is used.
  • Client (src/client/building/): StructureView draws pieces from their boxes as planks, stone courses or iron panels, and ramps as a sloped deck. BuildGhost turns sea green or rust red using the same target() and check() the server runs.

Tests

  • test/sim/test_building.gd, 13 tests: targeting in all four directions and up and down, spending and collision, every rejection reason (unaffordable, out of range, out of world, bad requests, occupied including half-level overlap, trapping a player, unsupported), attaching to neighbours, ramps climbable onto an upper floor, corner overlap, skirts on a slope, determinism and hashing.
  • Rapid placement: 24 builders holding fire and turning for 3 s placed 377 pieces, with tick p50 1.1 ms, p95 6.8 ms and max 7.0 ms, against the 12 ms budget. One builder can't exceed 10 pieces a second.
  • test/client/test_build_view.gd, 5 tests: ghost valid and invalid states, the ghost agreeing with the server over 40 placements, view sync on add and remove, outward mesh normals, and ramp meshes matching their stairs.
  • make check passed: smoke p95 0.54 ms.
  • Captures build_fort and build_fort_side (Forward+ on Lavapipe), checked by eye. They show a two-cell fort on forest ground: driftwood floor and walls, stone floor and breakwater, an iron wall and roof, a ramp up to an upper floor, a sea-green valid ghost wall and a rust-red ghost for an unaffordable breakwater. Two bugs these captures caught are fixed: the half-buried pieces, and a ramp mesh drawn at the old level height.

Follow-ups: health while building, damage and collapse are B3. Editing is B4. Breakwaters holding back water belong to the tide work. Pieces look like blockout until the v0.6 art pass. Software rendering can't show GPU cost.

Done in f35ebf7. **What changed** - `StructureSet` (`src/sim/structure_set.gd`) holds pieces in grid slots: a cell's floor, the two wall edges, or the cell's volume for ramps and roofs. Each piece's boxes go into `SimGround`, so movement and line of sight already respect them. It keeps touching-neighbour links for B3. Ramps are stairs of 0.4 m steps, so they climb with the existing step-up. Walls and breakwaters over lower ground get a skirt down to the terrain, which leaves no gap for water or players. Breakwaters are 0.6 m thick and share the wall slot. - `Building` (`src/sim/building.gd`): `target()` snaps the player's look and position to a slot. `check()` validates any slot as if a hostile client had chosen it: state, kind and material, world bounds, `BUILD_RANGE`, occupancy, trapping a player, cost, and touching the terrain or another piece. Fire in build mode (`selection` = piece, `material` = material) places at most 10 pieces a second. A player standing in the low step of a new floor is lifted onto it. - **Design decision:** pieces are a whole 4 m cell tall, but levels snap every 2 m (`BUILD_LEVEL_METRES`). With a 4 m vertical grid, the first capture showed ground-level forts half buried on gentle slopes. With half levels, a ground piece is never more than a metre from the builder's feet. A slot also counts as taken when the same slot half a cell up or down is used. - Client (`src/client/building/`): `StructureView` draws pieces from their boxes as planks, stone courses or iron panels, and ramps as a sloped deck. `BuildGhost` turns sea green or rust red using the same `target()` and `check()` the server runs. **Tests** - `test/sim/test_building.gd`, 13 tests: targeting in all four directions and up and down, spending and collision, every rejection reason (unaffordable, out of range, out of world, bad requests, occupied including half-level overlap, trapping a player, unsupported), attaching to neighbours, ramps climbable onto an upper floor, corner overlap, skirts on a slope, determinism and hashing. - Rapid placement: 24 builders holding fire and turning for 3 s placed 377 pieces, with tick p50 1.1 ms, p95 6.8 ms and max 7.0 ms, against the 12 ms budget. One builder can't exceed 10 pieces a second. - `test/client/test_build_view.gd`, 5 tests: ghost valid and invalid states, the ghost agreeing with the server over 40 placements, view sync on add and remove, outward mesh normals, and ramp meshes matching their stairs. - `make check` passed: smoke p95 0.54 ms. - Captures `build_fort` and `build_fort_side` (Forward+ on Lavapipe), checked by eye. They show a two-cell fort on forest ground: driftwood floor and walls, stone floor and breakwater, an iron wall and roof, a ramp up to an upper floor, a sea-green valid ghost wall and a rust-red ghost for an unaffordable breakwater. Two bugs these captures caught are fixed: the half-buried pieces, and a ramp mesh drawn at the old level height. **Follow-ups:** health while building, damage and collapse are B3. Editing is B4. Breakwaters holding back water belong to the tide work. Pieces look like blockout until the v0.6 art pass. Software rendering can't show GPU cost.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: claude/tidewall#16