martedì 30 novembre 2010

Rewriting LayerMap and MapChunk

Overnight i came to the conclusion that LayerMap and MapChunk needs to be rewritten.

- all image cache stuff must be inside LayerMap, so that precaching on loading can be achieved simply.
- the chunk layout must be defined starting from the center of the visible_area, identifiyng the center chunk
- MapChunk class is probably useless, just a complication, can be removed (the only two informations it holds are chunk position and chunk data, the first is needed also by LayerMap)
- The triple double-for currently in use to remap all the chunks is overcomplicated. I can simply by using a simple mapped list (QMap) where the key is a mix of x,y and zoom. This way with simply one iteration (plus a second minor only for chunks that needs reloading) (best case: 9-iteration loop, worst case: 18-iteration loop, better than current 27-iterations fixed + up to 9! worst case inner loop)

Update: it took a while, but the new LayerMap code works very well! I am waiting to do some real-world timings on my 5800, just to see if i need to cache also the other zoom-levels or if its fine caching only one zoom level from the image,,,

Now i am a bit lost fixing a bug in the LayerTrack draw code...

Stay tuned!

Nessun commento:

Posta un commento