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:
2026-11-11 12:17:42 -05:00
co-authored by Claude Opus 5.5
parent 283d0e966e
commit 5db53de4e8
20 changed files with 1116 additions and 1 deletions
+10
View File
@@ -0,0 +1,10 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://test/capture/terrain_scene.gd" id="1"]
[node name="CaptureProps" type="Node3D"]
script = ExtResource("1")
island_seed = 2
prop_kind = "wreck"
prop_crowd = 1
prop_view = Vector3(9, 4, 9)
+10
View File
@@ -0,0 +1,10 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://test/capture/terrain_scene.gd" id="1"]
[node name="CaptureProps" type="Node3D"]
script = ExtResource("1")
island_seed = 2
prop_kind = "crate"
prop_crowd = 2
prop_view = Vector3(5, 2.5, 6)
+11
View File
@@ -0,0 +1,11 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://test/capture/terrain_scene.gd" id="1"]
[node name="CaptureProps" type="Node3D"]
script = ExtResource("1")
island_seed = 2
prop_kind = "pine"
prop_crowd = 30
prop_view = Vector3(-20, 7, 28)
knock_out = 2
+10
View File
@@ -0,0 +1,10 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://test/capture/terrain_scene.gd" id="1"]
[node name="CaptureProps" type="Node3D"]
script = ExtResource("1")
island_seed = 2
prop_kind = "pine"
prop_crowd = 30
prop_view = Vector3(-20, 7, 28)
+10
View File
@@ -0,0 +1,10 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://test/capture/terrain_scene.gd" id="1"]
[node name="CaptureProps" type="Node3D"]
script = ExtResource("1")
island_seed = 2
prop_kind = "boulder"
prop_crowd = 6
prop_view = Vector3(4, 2.2, 5)
+8
View File
@@ -0,0 +1,8 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://test/capture/terrain_scene.gd" id="1"]
[node name="CaptureProps" type="Node3D"]
script = ExtResource("1")
island_seed = 2
show_props = true
+39
View File
@@ -19,6 +19,16 @@ const CRACK_COLOUR: Color = Color(1.0, 0.0, 1.0)
## the camera stands `poi_view` (x right, y up, z out of the front) from its origin.
@export var poi_kind: String = ""
@export var poi_view: Vector3 = Vector3(6.0, 7.0, 22.0)
## Draw the island's props too.
@export var show_props: bool = false
## When set, frame the first prop of this kind whose surroundings hold at least
## `prop_crowd` others within 25 m: the camera stands `prop_view` from it (x east, y up,
## z south) and looks at it.
@export var prop_kind: String = ""
@export var prop_crowd: int = 0
@export var prop_view: Vector3 = Vector3(10.0, 4.0, 14.0)
## Destroy every `knock_out`th prop near the framed one, to show felled props vanish.
@export var knock_out: int = 0
func _ready() -> void:
@@ -74,6 +84,35 @@ func _ready() -> void:
camera.position.y = maxf(camera.position.y, island.ground.terrain_height(camera.position.x, camera.position.z) + 2.0)
look_at_point = poi.origin + Vector3.UP * 2.5
break
if show_props or not prop_kind.is_empty():
var sim_props: PropSet = PropSet.generate(island, PoiSet.generate(island))
var prop_view_node: PropView = PropView.new()
prop_view_node.setup(sim_props)
add_child(prop_view_node)
if not prop_kind.is_empty():
for prop: int in sim_props.count():
if sim_props.kind_name(prop) != prop_kind:
continue
var at: Vector3 = sim_props.boxes[prop].get_center()
var crowd: PackedInt32Array = sim_props.near(at, 25.0)
if crowd.size() <= prop_crowd:
continue
var base: Vector3 = Vector3(at.x, island.ground.terrain_height(at.x, at.z), at.z)
# Back away along the view offset until no canopy is in the camera's face.
var offset: Vector3 = prop_view
for _try: int in 12:
camera.position = base + offset
camera.position.y = maxf(camera.position.y, island.ground.terrain_height(camera.position.x, camera.position.z) + 1.6)
if sim_props.near(Vector3(camera.position.x, island.ground.terrain_height(camera.position.x, camera.position.z), camera.position.z), 6.0).is_empty():
break
offset *= 1.15
look_at_point = base + Vector3.UP * minf(sim_props.boxes[prop].size.y * 0.5, 3.0)
if knock_out > 0:
for index: int in crowd.size():
if index % knock_out == 1:
sim_props.damage(crowd[index], 100000)
prop_view_node.sync()
break
add_child(camera)
camera.look_at(look_at_point)
camera.make_current()