From 5907a8902e6f01774cebbb515349a66c86a47fb3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 9 Nov 2022 18:27:32 +0100 Subject: allow drawing walls in random order --- shaders/tile.cpp | 4 ++-- shaders/tile.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'shaders') diff --git a/shaders/tile.cpp b/shaders/tile.cpp index c8261acd..22a91497 100644 --- a/shaders/tile.cpp +++ b/shaders/tile.cpp @@ -66,11 +66,11 @@ void tile_shader::_draw() } } -float tile_shader::depth_value(const local_coords& xy) noexcept +float tile_shader::depth_value(const local_coords& xy, float offset) noexcept { constexpr float max = (TILE_MAX_DIM+1)*(TILE_MAX_DIM+1) * .5f; constexpr float min = -1 + 1.f/256; - float value = min + xy.to_index()/max; + float value = min + (xy.to_index() + offset)/max; fm_assert(value > -1 && value < 1); return value; } diff --git a/shaders/tile.hpp b/shaders/tile.hpp index 8a45e1e7..4acc556b 100644 --- a/shaders/tile.hpp +++ b/shaders/tile.hpp @@ -27,7 +27,7 @@ struct tile_shader : GL::AbstractShaderProgram tile_shader& set_camera_offset(Vector2d camera_offset); Vector4 tint() const { return _tint; } tile_shader& set_tint(const Vector4& tint); - static float depth_value(const local_coords& xy) noexcept; + static float depth_value(const local_coords& xy, float offset = 0) noexcept; template static constexpr Math::Vector2 project(const Math::Vector3& pt); template static constexpr Math::Vector2 unproject(const Math::Vector2& px); -- cgit v1.2.3