Tmx loader for SFML - an update!

It's been a while since I last updated my first and, apparently, most popular project but I've finally found some time to sit down and tackle the ever increasing list of issues. I've not fixed everything, but have made some significant improvements, so here they are in brief:

New debug levels. It was brought to my attention that the loader doesn't need to be so verbose all the time, so I've made debug output more flexible. Firstly the output of debug messages can be decided with three defines:

LOG_OUTPUT_CONSOLE
LOG_OUTPUT_FILE
LOG_OUTPUT_ALL

These allow messages to directed to either the console, a log file on disk, or both. Logging is skipped altogether if none of these are defined. This allows flexible logging between different builds, such as Debug and Release for example. The log class also has a function which allows setting a series of flags to define the level of logging, with Information, Warning and Error levels available. These are set via

Logger::SetLogLevel(Logger::Warning | Logger::Error);

and can be set at any point in code.

Texture fixes. There was a small but rather daft error which meant adding new textures to a loaded map would invalidate existing texture references. This has now been fixed.

Rendering optimisation. Large maps which contained a lot of TileQuad data would run abhorrently, due to the fact the renderer would check *every* TileQuad each frame for any updates. This was a silly mistake, and I've improved performance twenty-fold in some cases by listing dirty quads and only updating those. This means maps with a lot of moving tiles, such as map objects with attached textures, will suffer performance drops proportionally to the number of moving objects. In extreme cases it's probably better to handle such game entities outside of the map loader inside a scene graph or physics world for example (consider that all tiles will be updated, even when off screen. This would be much better optimised if handled elsewhere). Maps which are mostly static will draw much faster now, however. Vertex arrays which cover only a small portion of a map are also culled if not visible on screen. This gives a small performance boost, particularly to maps with a lot of layers or tile set textures.

The updates are all available via the source on Github, and the Readme contains more information on using the debugger output.

Popular Posts