A5: World art for points of interest, build pieces, vessels and terrain

- PoiMesher dresses every point of interest from its parts: lapped tarred
  weatherboards, plank boards, stone in a running bond with lichen, tiled
  roofs with a ridge cap, salt-white trim on paint, crusted salt pans, and a
  tarred frame round the lighthouse's glowing glass. One mesh per POI.
- Huts get a shuttered window in each side wall (non-solid parts, no rng).
- Build pieces show their state: building in quarter steps, worn (a third of
  health gone) and battered (two thirds gone, strips knocked out).
  StructureView rebuilds a piece's mesh only when its state changes.
- VesselModels builds the barge (lofted hull, curved rails, mooring lines,
  gored envelope) and the sea chests in code; the primitive stand-ins are gone.
- Terrain: tussocks, wind-dried patches, shingle on sand, lichen on rock.
- test_world_art (9) fails on any primitive stand-in mesh or placeholder
  resource under src/ or assets/, and covers POI bounds and determinism,
  windows, the lamp surface, wear and build stages, view rebuilds and the
  vessel models.
- make poi-captures and make build-captures (state card, vessels).

Closes #45

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-13 20:39:24 -05:00
co-authored by Claude Opus 5.5
parent fdd4c992c3
commit 923876ed1f
22 changed files with 976 additions and 131 deletions
+173
View File
@@ -0,0 +1,173 @@
extends TestCase
## Issue A5: world art. Points of interest, build piece states, the barge and chests,
## and no placeholder meshes left in the game.
## Primitive meshes that would be stand-ins for real models. PlaneMesh (the sea's
## shader surface) and QuadMesh (screen passes and rain) are surfaces, not models.
const PLACEHOLDER_CLASSES: Array[String] = ["BoxMesh", "SphereMesh", "CylinderMesh", "CapsuleMesh", "PrismMesh", "TorusMesh", "TextMesh", "PlaceholderMesh", "PlaceholderMaterial", "PlaceholderTexture"]
const PLACEHOLDER_WORDS: Array[String] = ["stand-in shape", "placeholder mesh", "blockout", "art pass replaces"]
static var _island: Island
static var _pois: PoiSet
func _placed() -> PoiSet:
if _pois == null:
_island = Island.generate(2)
_pois = PoiSet.generate(_island)
return _pois
func test_no_placeholder_meshes_or_resources_remain() -> void:
var files: PackedStringArray = PackedStringArray()
_collect("res://src", files)
_collect("res://assets", files)
assert_true(files.size() > 100, "found the game's files (%d)" % files.size())
for path: String in files:
assert_false(path.get_file().to_lower().contains("placeholder"), "%s is named as a placeholder" % path)
if not (path.ends_with(".gd") or path.ends_with(".tscn") or path.ends_with(".tres") or path.ends_with(".gdshader")):
continue
var text: String = FileAccess.get_file_as_string(path)
for name: String in PLACEHOLDER_CLASSES:
assert_false(text.contains(name), "%s uses %s" % [path, name])
var lower: String = text.to_lower()
for word: String in PLACEHOLDER_WORDS:
assert_false(lower.contains(word), "%s says '%s'" % [path, word])
func test_every_poi_is_dressed_within_its_parts() -> void:
var placed: PoiSet = _placed()
var kinds: Dictionary = {}
var known: Array[String] = [Poi.LOOK_TARRED_WOOD, Poi.LOOK_PLANK, Poi.LOOK_STONE, Poi.LOOK_ROOF, Poi.LOOK_PAINT, Poi.LOOK_SALT, Poi.LOOK_LAMP, Poi.LOOK_WINDOW]
for poi: Poi in placed.pois:
kinds[poi.kind] = true
var bounds: AABB = poi.parts[0]["box"]
var parts: int = 0
for part: Dictionary in poi.parts:
assert_true(known.has(String(part["look"])), "%s: unknown look %s" % [poi.kind, part["look"]])
bounds = bounds.merge(part["box"])
parts += 1
var mesh: ArrayMesh = PoiMesher.build(poi.parts)
var vertices: int = mesh.surface_get_array_len(PoiMesher.SURFACE_SOLID)
# Dressed, not one box per part: boards, courses and tiles add many.
assert_true(vertices > parts * 36 * 2, "%s: %d vertices for %d parts" % [poi.kind, vertices, parts])
assert_true(bounds.grow(0.06).encloses(mesh.get_aabb()), "%s: mesh %s strays outside its parts %s" % [poi.kind, mesh.get_aabb(), bounds])
for kind: String in PoiSet.ORDER:
assert_true(kinds.has(kind), "seed 2 has a %s to check" % kind)
func test_poi_meshes_are_the_same_every_time() -> void:
var poi: Poi = _placed().pois[0]
var first: PackedVector3Array = PoiMesher.build(poi.parts).surface_get_arrays(0)[Mesh.ARRAY_VERTEX]
var second: PackedVector3Array = PoiMesher.build(poi.parts).surface_get_arrays(0)[Mesh.ARRAY_VERTEX]
var first_colours: PackedColorArray = PoiMesher.build(poi.parts).surface_get_arrays(0)[Mesh.ARRAY_COLOR]
var second_colours: PackedColorArray = PoiMesher.build(poi.parts).surface_get_arrays(0)[Mesh.ARRAY_COLOR]
assert_eq(first, second)
assert_eq(first_colours, second_colours)
func test_huts_have_windows_that_do_not_block() -> void:
var placed: PoiSet = _placed()
var windows: int = 0
for poi: Poi in placed.pois:
for part: Dictionary in poi.parts:
if part["look"] == Poi.LOOK_WINDOW:
windows += 1
assert_false(poi.solids.has(part["box"]), "%s: a window is solid" % poi.kind)
assert_true(windows >= 4, "the island's huts have windows (%d)" % windows)
func test_the_light_glows_on_its_own_surface() -> void:
for poi: Poi in _placed().pois:
if poi.kind != "lighthouse":
continue
var mesh: ArrayMesh = PoiMesher.build(poi.parts)
assert_eq(mesh.get_surface_count(), 2)
var lit: StandardMaterial3D = mesh.surface_get_material(PoiMesher.SURFACE_LAMP)
assert_true(lit.emission_enabled)
return
assert_true(false, "seed 2 has a lighthouse")
func test_wear_and_building_stages() -> void:
assert_eq(PieceMesher.wear_of(0, 300), PieceMesher.INTACT)
assert_eq(PieceMesher.wear_of(101, 300), PieceMesher.INTACT)
assert_eq(PieceMesher.wear_of(102, 300), PieceMesher.WORN)
assert_eq(PieceMesher.wear_of(201, 300), PieceMesher.BATTERED)
assert_eq(PieceMesher.wear_of(299, 300), PieceMesher.BATTERED)
assert_eq(PieceMesher.built_of(0, 60), 1.0)
assert_eq(PieceMesher.built_of(60, 60), 0.25, "just placed still shows its first step")
assert_eq(PieceMesher.built_of(30, 60), 0.5)
assert_eq(PieceMesher.built_of(1, 60), 1.0)
assert_eq(PieceMesher.built_of(5, 0), 1.0)
func test_piece_meshes_show_wear_and_building_inside_their_box() -> void:
var slot: Vector4i = Vector4i(0, 0, 0, StructureSet.SLOT_WALL_X)
var boxes: Array[AABB] = StructureSet.boxes_for(StructureSet.WALL, slot, 0)
for material: int in 3:
var counts: Dictionary = {}
for wear: int in [PieceMesher.INTACT, PieceMesher.WORN, PieceMesher.BATTERED]:
var mesh: ArrayMesh = PieceMesher.build(boxes, material, 7, wear)
assert_true(boxes[0].grow(0.001).encloses(mesh.get_aabb()), "material %d wear %d stays in the wall" % [material, wear])
counts[wear] = mesh.surface_get_array_len(0)
assert_true(counts[PieceMesher.BATTERED] < counts[PieceMesher.INTACT], "material %d: battered strips are knocked out" % material)
var intact_colours: PackedColorArray = PieceMesher.build(boxes, material, 7).surface_get_arrays(0)[Mesh.ARRAY_COLOR]
var worn_colours: PackedColorArray = PieceMesher.build(boxes, material, 7, PieceMesher.WORN).surface_get_arrays(0)[Mesh.ARRAY_COLOR]
assert_ne(intact_colours, worn_colours, "material %d: wear shows" % material)
var half: ArrayMesh = PieceMesher.build(boxes, material, 7, PieceMesher.INTACT, 0.5)
var whole: ArrayMesh = PieceMesher.build(boxes, material, 7)
assert_true(half.surface_get_array_len(0) < whole.surface_get_array_len(0), "material %d: half built shows less" % material)
assert_true(boxes[0].grow(0.001).encloses(half.get_aabb()))
var ramp: AABB = PieceMesher.build_ramp(Vector4i(0, 0, 0, StructureSet.SLOT_VOLUME), 0, 0, 3).get_aabb()
var ramp_half: AABB = PieceMesher.build_ramp(Vector4i(0, 0, 0, StructureSet.SLOT_VOLUME), 0, 0, 3, PieceMesher.BATTERED, 0.5).get_aabb()
assert_true(ramp.grow(0.001).encloses(ramp_half))
func test_structure_view_redraws_a_piece_when_its_state_changes() -> void:
var sim: Simulation = Simulation.new(3, SimGround.flat())
var piece: StructureSet.Piece = sim.structures.add(StructureSet.WALL, Materials.STONE, Vector4i(2, 0, 2, StructureSet.SLOT_WALL_X), 0, 0, 0, sim.ground)
var view: StructureView = StructureView.new()
view.setup(sim.structures)
assert_eq(view.meshes_built, 1)
assert_eq(view.shown_state(piece.id), [PieceMesher.INTACT, 0.25])
view.sync()
assert_eq(view.meshes_built, 1, "nothing changed, nothing rebuilt")
sim.structures.set_progress(piece.id, piece.build_ticks, 0)
view.sync()
assert_eq(view.meshes_built, 2)
assert_eq(view.shown_state(piece.id), [PieceMesher.INTACT, 1.0])
var events: Array[Dictionary] = []
sim.structures.damage(piece.id, roundi(piece.max_health * 0.5), "test", sim.ground, events)
view.sync()
assert_eq(view.shown_state(piece.id), [PieceMesher.WORN, 1.0])
sim.structures.damage(piece.id, roundi(piece.max_health * 0.3), "test", sim.ground, events)
view.sync()
assert_eq(view.shown_state(piece.id), [PieceMesher.BATTERED, 1.0])
assert_eq(view.meshes_built, 4)
assert_eq(view.drawn_count(), 1)
view.free()
func test_barge_and_chest_models() -> void:
var barge: AABB = VesselModels.barge().get_aabb()
assert_near(barge.position.y, -VesselModels.HULL_DEPTH, 0.05, "hull bottom")
assert_near(barge.end.y, VesselModels.ENVELOPE_HEIGHT + VesselModels.ENVELOPE_AXES.y, 0.05, "envelope top")
assert_near(barge.size.x, 2.0 * VesselModels.ENVELOPE_AXES.x, 0.05, "the envelope is the widest part")
assert_true(barge.size.z >= 2.0 * VesselModels.HULL_HALF_LENGTH, "hull length")
var chest: AABB = VesselModels.chest().get_aabb()
assert_near(chest.position.y, 0.0, 0.001, "chests stand on the ground")
assert_near(chest.size.y, VesselModels.CHEST_SIZE.y + 0.01, 0.02)
assert_true(chest.size.x < VesselModels.CHEST_SIZE.x + 0.1)
func _collect(dir_path: String, into: PackedStringArray) -> void:
var dir: DirAccess = DirAccess.open(dir_path)
if dir == null:
return
for name: String in dir.get_files():
into.append(dir_path.path_join(name))
for name: String in dir.get_directories():
if not name.begins_with("."):
_collect(dir_path.path_join(name), into)
+1
View File
@@ -0,0 +1 @@
uid://c3ipydy117bkm