working with an ECS is pretty new to me but feels great so far!
So I’m working on a project that is very much dependent (gameplay-wise) on deformable height map terrain. A single level map should consist of one height map of at least 1024 x 1024 up to maybe 4096 x 4096 individual height points. These height points may be adjusted pretty randomly each frame at many locations on the map. The deformed height map should then allow to read actual ground height at a world location for basic collision testing.
I know all this stuff can be done using the JME TerrainQuad system, but I want to do it the ECS way now.
So would it make sense to have a Height Map Component that would store the terrain heights?
The data in it would consist of a single large array of floats representing the height points. Then I could have a Terrain System that would apply the heights of such a component to a TerrainQuad (with LOD) for visual display, a system for terrain modifications and one for collision (the latter two would only work on the component data, not on the quad scene graph object).
Sounds good so far with a clean separation between logic and rendering, but my main concern right now is memory usage and garbage collection. Since components by design should be pure read-only data objects, to modify the height map I would have to copy these large arrays (e.g. 4096 x 4096 x 4 byte float) every time changes are made, probably at many locations per frame!
What’s your opinion on this? Would this still be feasible?