diff options
Diffstat (limited to 'editor/draw.cpp')
| -rw-r--r-- | editor/draw.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/editor/draw.cpp b/editor/draw.cpp index ca926152..7ce5c7bf 100644 --- a/editor/draw.cpp +++ b/editor/draw.cpp @@ -7,8 +7,10 @@ #include "draw/anim.hpp" #include "src/camera-offset.hpp" #include "src/world.hpp" +#include "character.hpp" #include <Magnum/Math/Color.h> #include <Magnum/Math/Vector3.h> +#include <Magnum/GL/Renderer.h> #include "src/RTree.hpp" namespace floormat { @@ -140,8 +142,28 @@ void app::draw_collision_boxes() shader.set_tint({1, 1, 1, 1}); } +void app::draw_character() +{ + GL::Renderer::enable(GL::Renderer::Feature::DepthTest); + GL::Renderer::setDepthMask(false); + + auto& shader = M->shader(); + auto& mesh = M->meshes().anim; + const auto sz = M->window_size(); + auto& c = *_character; + const auto [minx, maxx, miny, maxy] = M->get_draw_bounds(); + + const with_shifted_camera_offset o{shader, c.pos.chunk(), {minx, miny}, {maxx, maxy}}; + if (floormat_main::check_chunk_visible(shader.camera_offset(), sz)) + mesh.draw(shader, *c.walk_anim, c.r, c.frame, c.pos.local(), Vector2b(c.offset), tile_shader::character_depth_offset); + + GL::Renderer::setDepthMask(true); + GL::Renderer::disable(GL::Renderer::Feature::DepthTest); +} + void app::draw() { + draw_character(); if (_render_bboxes) draw_collision_boxes(); if (_editor.current_tile_editor() || _editor.current_scenery_editor()) |
