fallahn / sfml-tmxloader

SFML 2.x based tmx tilemap parser for files created with Tiled tile map editor
106 stars 35 forks source link

Give more control over quadtree elements #46

Open fluffynukeit opened 8 years ago

fluffynukeit commented 8 years ago

Hi. Thanks for this awesome library. Having a map loader with a built-in quad tree is really convenient. It would be nice to have more control over the quad's elements, though.

For instance, I'd like to be able to only add objects from a particular layer instead of all layers (or arbitrary combinations of layers/objects). I suppose I can do this now by using QuadTreeRoot directly, but I'd be ignoring the UpdateQuadTree and QueryQuadTree methods, which aren't strictly necessary.

Also nice would be using the quad tree class for anything providing a GetAABB method, not just Map Objects. For instance, I'd love to double dip and use it for tracking projectiles, for instance.

I think both of these can be resolved by breaking out the quad tree implementation into a template. It's arguable whether or not the MapLoader member functions should remain or be removed in favor of using the QuadTree directly.

What do you think?

fallahn commented 8 years ago

I think this is a very fair point. When I implemeneted this it was my first attempt at a quad tree so there is a lot of room for improvement. The rest of the map loader library has apparently evolved, leaving the quad tree behind. I have since implemented a more flexible quad tree in another project, which I'll give some serious consideration to adapting, should I get the time.