From 6c46e70e3576ae9d27c3ad5c8c95c3198c9be501 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Sun, 1 Apr 2018 12:38:43 +0200 Subject: Bring back render layers (WIP). --- src/render.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'src') 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++) { -- cgit