W5: Vegetation and harvestable props
PropSet places about 3,000 pines, scrub, boulders, wrecks and crates per island from the seed, by elevation band with grove noise, clear of points of interest. Each prop is one collision box in SimGround with health from Tuning.PROP_KINDS; destroying it removes the box at once (SimGround.remove_solid). Prop health is part of the state hash. PropView draws them as one MultiMesh per kind per 128 m square (about 150 instanced draws), with per-kind visibility ranges, procedural flat-shaded meshes fitted to the collision boxes, and cheap sync of felled props. Closes #12 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -112,3 +112,21 @@ func test_index_gives_the_same_answers_as_a_full_scan() -> void:
|
||||
if box.end.y <= 6.0 and x > box.position.x and x < box.end.x and z > box.position.z and z < box.end.z:
|
||||
expected = maxf(expected, box.end.y)
|
||||
assert_eq(ground.support_height(x, z, 6.0), expected)
|
||||
|
||||
|
||||
func test_removed_solids_vanish_from_every_query() -> void:
|
||||
var ground: SimGround = SimGround.flat()
|
||||
var keep: int = ground.add_solid(AABB(Vector3(0.0, 0.0, 0.0), Vector3(2.0, 1.0, 2.0)))
|
||||
var gone: int = ground.add_solid(AABB(Vector3(10.0, 0.0, 10.0), Vector3(20.0, 3.0, 2.0)))
|
||||
assert_eq(gone, keep + 1)
|
||||
assert_true(ground.body_blocked(Vector3(15.0, 0.0, 11.0), 0.4, 1.8, 0.0))
|
||||
assert_true(ground.remove_solid(gone))
|
||||
assert_false(ground.remove_solid(gone), "removing twice reports false")
|
||||
assert_false(ground.remove_solid(99), "unknown IDs report false")
|
||||
assert_false(ground.body_blocked(Vector3(15.0, 0.0, 11.0), 0.4, 1.8, 0.0))
|
||||
assert_eq(ground.support_height(25.0, 11.0, 10.0), 0.0)
|
||||
assert_eq(ground.raycast(Vector3(5.0, 1.0, 11.0), Vector3(35.0, 1.0, 11.0)), 1.0)
|
||||
assert_false(ground.point_inside(Vector3(15.0, 1.0, 11.0)))
|
||||
# The other solid keeps its ID and still collides, and new IDs never reuse old ones.
|
||||
assert_eq(ground.support_height(1.0, 1.0, 5.0), 1.0)
|
||||
assert_eq(ground.add_solid(AABB(Vector3(40.0, 0.0, 40.0), Vector3.ONE)), gone + 1)
|
||||
|
||||
Reference in New Issue
Block a user