summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common.hpp1
-rw-r--r--src/game/units.cpp2
-rw-r--r--src/render.cpp9
3 files changed, 9 insertions, 3 deletions
diff --git a/src/common.hpp b/src/common.hpp
index 948e829..4382da6 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -137,6 +137,7 @@ namespace world {
int type;
cmodel_t cmodel;
rectf_t render_bounds;
+ int render_layer = 0;
entity_t(int type_);
diff --git a/src/game/units.cpp b/src/game/units.cpp
index abdf216..c416dd7 100644
--- a/src/game/units.cpp
+++ b/src/game/units.cpp
@@ -19,7 +19,6 @@ void unit_t::compute_bounds()
render_bounds[1] = x + render_size[1];
}
-
unit_t::unit_t(unit_t::type_t type_) : entity_t(ET_UNIT)
{
type = type_;
@@ -157,6 +156,7 @@ human_t::human_t() : unit_t(UNIT_HUMAN)
size[1] = v2f_t(+0.4f, +0.4f);
render_size[0] = v2f_t(-0.5f, -1.0f);
render_size[1] = v2f_t(+0.5f, +0.5f);
+ render_layer = -1;
}
void human_t::wake(double now, unit_t *by_whom)
diff --git a/src/render.cpp b/src/render.cpp
index b80dcbd..2c8f7a4 100644
--- a/src/render.cpp
+++ b/src/render.cpp
@@ -135,8 +135,13 @@ void state_t::render(game::state_t *game)
ents = game->world.get_render_entities(bbox);
ents.sort(
[](const world::entity_t *x, const world::entity_t *y) -> bool
- {
- return x->render_bounds[1][1] < y->render_bounds[1][1];
+ {
+ 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];
});
for (world::entity_t *ent : ents) {