Skip to content

Base terrain editing tools for Castle Engine Editor#612

Open
and3md wants to merge 120 commits intomasterfrom
terrain-edit
Open

Base terrain editing tools for Castle Engine Editor#612
and3md wants to merge 120 commits intomasterfrom
terrain-edit

Conversation

@and3md
Copy link
Contributor

@and3md and3md commented May 28, 2024

This PR add basic TCastleTerrain edit suport for our editor:

obraz

With it you can:

  • raise terrain
  • lower terrain
  • level terrain
  • change heightmap size
  • save height map
  • save height map with other name

Raise/lower/level terrain operations supports many brushes shapes like cone, pyramid, square, circle, ring etc.
You can set many parameters like strength, size, rotation etc.

See the video:

terrain_edit.webm

Most of the code is in TCastleTerrainEditMode class.

There are two way to modify terrain height. The faster one is not working in TCastleControl so it is comneted in AlterTerrain function.

It can be uncomented using this example code:
https://github.com/and3md/castle-engine-terrain-editor-example

and3md added 30 commits April 2, 2024 11:53
@and3md
Copy link
Contributor Author

and3md commented May 28, 2024

I don't know why, but the video doesn't work for me in Firefox. Works on Chrome-based browsers

@michaliskambi
Copy link
Member

  • Merged with latest CGE master.
  • Checked compilation.
  • Small editor UI adjustments ("level" -> "flatten", more anchors).
  • TODO: Looks like after merging, actual editing is broken. i.e. "Raise" operations don't do anything? Will investigate and fix.

@michaliskambi
Copy link
Member

michaliskambi commented Aug 6, 2025

TODO: Looks like after merging, actual editing is broken. i.e. "Raise" operations don't do anything? Will investigate and fix.

Fixed now (got broken because of changes in master how is CastleControlUpdate called; you cannot set FDesignerLayer.Exists:=false when editing terrains now).

Also:

  • Copied example from https://github.com/and3md/castle-engine-terrain-editor-example into the engine, into examples/terrain/terrain_editing_in_game. Because this is a valid official feature: to enable to terraform the terrain at runtime.
  • Moved LCL editor logic to a separate unit and frame, to keep things (UI and code) nicely contained in separate unit.
  • Small code adjustments to look simpler to my eyes :)

…nnot make arrays with such index)

Also rename shader terrain2 -> terrain_heights_in_texture

Also put brush shaders in separate files, terrain_edit_brush
…ing it for actions disabled too much (like 137 keys)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants