Cache generated building meshes per type #59
No reviewers
Labels
No labels
assets
bug
duplicate
enhancement
help wanted
invalid
question
testing
ui
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
liamjd/UntitledColonyBuilder!59
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "41-cache-building-meshes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #41
What
BuildingMeshes.build()now caches generated meshes in a staticDictionarykeyed on[type.id, tile_size, level_height], so every placed building of a type (and the placement ghost) shares oneMeshand oneMaterial.build()'s signature is unchanged; the old body moved into a private_generate().type.meshstill short-circuits before the cache and is never stored, in both directions: it is not cached, and it is not shadowed by a generated mesh already cached under the same id.tile_sizechange. The key carries the size, so a stale entry is only ever under a key nobody asks for again.Engine.is_editor_hint()), which handles the "editplaceholder_colorin a.tresand keep getting the old mesh" hazard. This was chosen over wiringclear_cache()into terrain regeneration, which the three-part key makes unnecessary.clear_cache()is public for the GUT suite, wired intobefore_each().build()doc comment now states the shared, read-only contract. That was already true on the authored path.Review note
Three existing tests built two types that both used the helper's fixed id
test_typewith identical sizes: the colour comparison and the two box-vs-cylinder height comparisons. With the cache, the second build is a hit on the first, so the colour test would fail and the height tests would pass vacuously. The helper now takes an optionalidand those tests pass distinct ones. The reason is documented in the file header.Verification
test_building_meshes.gd: 35 tests, 10 new, covering all four acceptance points from #41 plus the stale-until-cleared behaviour.material_override, and no caller writes to the returned mesh (checkedbuildings.gd,placement_controller.gd,tools/screenshot_buildings.gd).🤖 Generated with Claude Code
https://claude.ai/code/session_01MijPibgzE26Nkjti7k2Xyt