summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2018-04-01 12:38:43 +0200
committerPaweł Redman <pawel.redman@gmail.com>2018-04-01 12:38:43 +0200
commit6c46e70e3576ae9d27c3ad5c8c95c3198c9be501 (patch)
tree1c89733fcac387782a8b54ca077f702398d82728 /src
parente6f9705e91ab01a1ecdab9c4999fa29b3980a42a (diff)
Bring back render layers (WIP).
Diffstat (limited to 'src')
-rw-r--r--src/render.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/render.cpp b/src/render.cpp
index c3266ef..96153f9 100644
--- a/src/render.cpp
+++ b/src/render.cpp
@@ -200,6 +200,16 @@ rectf_t state_t::window_in_world_space(void)
return window_bounds(window);
}
+bool entity_order(const world::entity_t *x, const world::entity_t *y)
+{
+ if (x->render_layer < y->render_layer)
+ return true;
+ else if (x->render_layer > y->render_layer)
+ return false;
+ else
+ return x->render_bounds[1][1] < y->render_bounds[1][1];
+}
+
void state_t::render(game::state_t *game)
{
rectf_t bounds;
@@ -212,22 +222,9 @@ void state_t::render(game::state_t *game)
sectors[1] = world::sector_index_at(bounds[1]);
ents = game->world.get_render_entities(bounds);
- ents.sort(
- [](const world::entity_t *x, const world::entity_t *y) -> bool
- {
- return x->render_bounds[1][1] < y->render_bounds[1][1];
- // FIXME: bring render layers back
- /*
- if (x->render_layer < y->render_layer)
- return true;
- else if (x->render_layer > y->render_layer)
- return false;
- else
- return x->render_bounds[1][1] < y->render_bounds[1][1];*/
- });
+ ents.sort(entity_order);
ent = ents.begin();
-
for (world::coord_t sy = sectors[0][1]; sy <= sectors[1][1]; sy++)
for (world::coord_t ty = 0; ty < SECTOR_SIZE; ty++)
for (world::coord_t sx = sectors[0][0]; sx <= sectors[1][0]; sx++) {