From 1b5a4bb5084c79a79da50affc5d9c8cd94fd47d7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 29 Nov 2022 23:22:00 +0100 Subject: camera-offset: disallow nesting --- src/camera-offset.cpp | 9 +++++---- src/camera-offset.hpp | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/camera-offset.cpp b/src/camera-offset.cpp index 7c5be7f3..1c77659c 100644 --- a/src/camera-offset.cpp +++ b/src/camera-offset.cpp @@ -8,20 +8,21 @@ static_assert(sizeof(short) == 2); with_shifted_camera_offset::with_shifted_camera_offset(tile_shader& shader, chunk_coords c, chunk_coords first, chunk_coords last) : _shader{shader}, - _camera{shader.camera_offset()}, - _depth{shader.depth_offset()} + _camera{shader.camera_offset()} { + fm_assert(shader.depth_offset() == 0.f); + constexpr auto chunk_size = TILE_MAX_DIM20d*dTILE_SIZE; const auto offset = _camera + tile_shader::project(Vector3d(c.x, c.y, 0) * chunk_size); const auto len_x = (float)(last.x - first.x), cx = (float)(c.x - first.x), cy = (float)(c.y - first.y); - const float depth_offset = _depth + shader.depth_tile_size*(cy*TILE_MAX_DIM*len_x*TILE_MAX_DIM + cx*TILE_MAX_DIM); + const float depth_offset = shader.depth_tile_size*(cy*TILE_MAX_DIM*len_x*TILE_MAX_DIM + cx*TILE_MAX_DIM); _shader.set_camera_offset(offset, depth_offset); } with_shifted_camera_offset::~with_shifted_camera_offset() { - _shader.set_camera_offset(_camera, _depth); + _shader.set_camera_offset(_camera, 0); } } // namespace floormat diff --git a/src/camera-offset.hpp b/src/camera-offset.hpp index ef098694..80fc004e 100644 --- a/src/camera-offset.hpp +++ b/src/camera-offset.hpp @@ -14,7 +14,6 @@ struct with_shifted_camera_offset final private: tile_shader& _shader; // NOLINT Vector2d _camera; - float _depth; }; } // namespace floormat -- cgit v1.2.3