craftyjs/Crafty — pull request #429 by starwed (2013-03-06 02:54:20+00:00)
Title: Dirty develop

This is a rewrite of the general mechanism that Crafty uses to track dirty areas of the screen.

1. Only which entities have changed are tracked. The dirty regions are then calculated right before the scene is drawn. (The old method was to calculate dirty regions as entities changed, which was inefficient.)

2. The algorithm for merging rectangular regions together was corrected and simplified.

3. This patch also changes the order in which entities are drawn; everything within a particular dirty rectangle is now drawn in one go.

There's an alternative patch for 2 that got merged to master; I'm going to go ahead and submit this pull request anyway. If that one gets merged to develop, I'll do the work in making them compatible. However, I think change 3 would actually *also* fix the problem that patch was aiming for, so we'll want to measure how the two merge algorithms compare.