
One way to go at this is from the other direction. When a fire is placed, there's no way I can pre-fill every possible coordinate that the fire could heat. But maybe if I simplify it...
Look at the world as several layers of grids. The largest would have few cells (12x12?). The smallest would have a huge number, and get down to very local info. Have limited number of layers (5?10?)
When a fire is placed, is would be sized to the largest possible layer (maybe if it contains a % of that layer. If no %, then go the smallest). It would ONLY be placed on one grid at a time.
When a temperature calc is requested, the system would find which grid the user is on for each layer, and sum the temps in those grids (so 5 layers would return a max of 5 cells to calc - for example: world wide, regional, state, city, and local. If no value had been placed in the local cell, then it wouldn't get a value for that cell (or it would be zero).
So ANY fire placed, no matter how large or small, would have a calc on a small set of cells. In the DB, only those cells that had been effected would actually have a value (so in the above, layer 1 would have 12 cells populated, layer 2 would have 121, and layer 3 would have 63.
Fires would normally be placed rarely, while requests for temps would be done requested very often - so this might work. The down side is that there's not a easy way to decrease the temp of a single fire over time (which I was planning on doing). Might be able to force a periodic refresh, but that would be annoying.


Above is for a smaller fire - it's on a mid-level layer.

The last is on a small-level layer, with only a very local effect.
Didn't show it here, but I think as it goes down, it would effect more of the (smaller) cells.
No comments:
Post a Comment