Render the procedural terrain in the editor with @tool #20

Merged
liamjd merged 1 commit from 19-render-map-in-editor into main 2026-08-18 05:56:20 +01:00
Owner

Closes #19.

Adds @tool to game.gd and terrain_grid.gd so the procedurally
generated map renders live in the Godot 3D editor view, not just at
runtime.

What changed

  • game.gd: seed falls back to a hardcoded value in-editor (GameState
    isn't reliably available there), and the runtime-only camera
    positioning is skipped under Engine.is_editor_hint().
  • terrain_grid.gd: generation now also runs under @tool. Without
    further changes, this bakes the generated MeshLibrary and GridMap
    cell data into game.tscn on every editor save (confirmed via a
    281-line all-additions diff during development). Fixed by clearing
    mesh_library/data on NOTIFICATION_EDITOR_PRE_SAVE and
    regenerating on NOTIFICATION_EDITOR_POST_SAVE, so the scene file
    stays clean while the editor preview stays live.

Verified

  • Saving game.tscn in the editor after these changes produces no diff
    (confirmed the pre/post-save clear-and-regenerate cycle works).
  • A stray baked CameraRig transform left over from an earlier,
    unguarded save was stripped from game.tscn before committing.

Not covered

  • No automated test coverage for the editor-only notification hook
    (GUT runs headless; this is inherently an editor-interaction path).
Closes #19. Adds `@tool` to `game.gd` and `terrain_grid.gd` so the procedurally generated map renders live in the Godot 3D editor view, not just at runtime. ## What changed - `game.gd`: seed falls back to a hardcoded value in-editor (`GameState` isn't reliably available there), and the runtime-only camera positioning is skipped under `Engine.is_editor_hint()`. - `terrain_grid.gd`: generation now also runs under `@tool`. Without further changes, this bakes the generated `MeshLibrary` and `GridMap` cell data into `game.tscn` on every editor save (confirmed via a 281-line all-additions diff during development). Fixed by clearing `mesh_library`/`data` on `NOTIFICATION_EDITOR_PRE_SAVE` and regenerating on `NOTIFICATION_EDITOR_POST_SAVE`, so the scene file stays clean while the editor preview stays live. ## Verified - Saving `game.tscn` in the editor after these changes produces no diff (confirmed the pre/post-save clear-and-regenerate cycle works). - A stray baked `CameraRig` transform left over from an earlier, unguarded save was stripped from `game.tscn` before committing. ## Not covered - No automated test coverage for the editor-only notification hook (GUT runs headless; this is inherently an editor-interaction path).
Adding @tool to game.gd and terrain_grid.gd lets the generated map show
in the 3D editor view. GameState isn't reliably available in-editor, so
the seed falls back to a hardcoded value and runtime-only camera
positioning is skipped under Engine.is_editor_hint().

The generated MeshLibrary and GridMap cell data would otherwise get
baked into game.tscn on every editor save. TerrainGrid now clears them
in NOTIFICATION_EDITOR_PRE_SAVE and regenerates in
NOTIFICATION_EDITOR_POST_SAVE so the scene file stays clean.
liamjd merged commit 0099912e7f into main 2026-08-18 05:56:20 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
liamjd/UntitledColonyBuilder!20
No description provided.