TokisanGames / Terrain3D

A high performance, editable terrain system for Godot 4.
MIT License
2.22k stars 131 forks source link

Update debug collision on operations #106

Open TokisanGames opened 1 year ago

TokisanGames commented 1 year ago

When adding/removing regions, sculpting, undo/redo the debug collision shapes are not updated automatically. Currently the user must turn _show_debug_collision off and on.

Currently updating destroys and rebuilds and takes .5-1s to update, so it's not good to update on every painting. It could update during the undo/redo setup, but that's still a bit slow.

What would be faster to mark dirty regions and only update those. It also needs to add and remove CollisionShapes as regions are added or removed.

outobugi commented 1 year ago

Maybe, instead of using collision shapes, we could make a plane mesh with same structure as the collider would be and make a wireframe shader for it?

TokisanGames commented 1 year ago

That's an interesting idea. And that could work in game as well.

matthewhilton commented 8 months ago

Just some notes from my experimentation adding this (in my game the collision updates after edits in game, but it would be the same for updating in the editor)

Switched to generate 1 heightmap shape per region (instead of 1 big one covering every region). Then when edits happen, they only update the single region. (Code is here but its very very rough https://github.com/TokisanGames/Terrain3D/compare/main...matthewhilton:Terrain3D:collision-update-improvements-090)

My game only has max 8 regions so this is OK. Might not be suitable for larger terrains.

Performance optimisation:

TokisanGames commented 8 months ago

278 will address this.