entt icon indicating copy to clipboard operation
entt copied to clipboard

Handling large tilemap

Open pawelKapl opened this issue 1 year ago • 7 comments

Hey!

Currently i am working on tilemap based 2D/3D game, where world is made of voxels, something conceptually similiar to Core Keeper. The thing is that i want to be able to handle quite large maps. The obvious choice is to divide scene into smaller chunks, so i will render & calculate only the closest ones - pretty cliche.

Up until now i was using a single EnTT registry per scene, and it worked quite well. Now i need to implement this chunking mechanism, and i have no idea how to do it. The only ways i can see is to:

  • create multiple registers - one per chunk, and maybe main one - that will keep entities describing those chunks.
  • each chunk has its own entity type storage, identified for example by its coords.

What do you suggest? EnTT is awesome and its pretty easy to use in a simple scenarios, however each time i am trying to dig deeper into its guts and functionalities i am being pushed away...

pawelKapl avatar Apr 18 '24 15:04 pawelKapl

Do you plan to run all systems on all chunks no matter what or, for example, you want to run full power on central and surrounding chunks while you run less systems as you get far from the player position?

skypjack avatar Apr 18 '24 16:04 skypjack

Yeah so second option, chunk with player and surrounding chunks - most probably all the calculations like physics, ai, rendering etc. Other chunks - most probably no operations at all, or almost no operations. Thanks for such quick response!

pawelKapl avatar Apr 18 '24 19:04 pawelKapl

You can also have a local registry and a global one for things like the player, an inventory and so on. There isn't the right answer, just a bunch of approaches that work fine. Your use case should guide you then. 🙂

skypjack avatar Apr 19 '24 06:04 skypjack

Yeah, good point. I could create one global scene registry, for handling stuff like player, craft, inventory, this registry would also probably keep references to chunks being part of a particular scene. So in systems i would most probably do smth like:

for (auto chunk : globalRegistry.view<Chunk>())
       if (chunk.loaded) chunk.registry.get<Tile/Decoration/Item>().doStuff();

pawelKapl avatar Apr 19 '24 08:04 pawelKapl

Another possibility, yeah. I think your question was answered. 🙂

skypjack avatar Apr 19 '24 10:04 skypjack

Yeah, thanks a LOT, apparently needed someone to just confirm that my ideas are not out of this planet! ;)

pawelKapl avatar Apr 19 '24 10:04 pawelKapl

You're welcome. The discord server is another good place for that in case. 👍

skypjack avatar Apr 19 '24 10:04 skypjack