11:19 PM
I have a design question. I'm working on optimizing pathfinding in 2D.
That's what I have so far. The map is split into sectors(n×n) and then analyzed.
Each sector has "blobs" which are connected areas.
These blobs are in local space, so the topleft tile is (0;0).
Now, I need to check the distance between two blobs in two sectors.
To do this, I need to transform the blobs coordinates based on the sector they're in.
This is where my problem is. I do this transform calculation constantly to do things.
This leads me to think I should try and store the blobs in world space instead of local space.
However, each sector doesn't know their location relative to other sectors.
They just know they're a sector and that they have blobs.
So storing the world-space blobs in the sector isn't possible.
So I figured I should store world-space blobs in the grid, the class that holds all the sectors.
But should I remove the local-space blobs then? Seems most straightforward that a sector handles the "analyze blobs" part of the problem.
But I don't want to store both local-space blobs and world-space blobs.
Hmm, perhaps a "GetBlobs" method on the Sector, and then store them on the Grid.
This way, the Sector is still responsible for doing it's part and the Grid, which knows the position of Sectors will be able to transform the blobs as they should before being stored.