summaryrefslogtreecommitdiffhomepage
path: root/src/camera-offset.cpp
blob: b132cdab48e74b6601e1a7122926ef754de48a3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "camera-offset.hpp"
#include "tile-defs.hpp"
#include "shaders/tile.hpp"

namespace floormat {

static_assert(sizeof(short) == 2);

with_shifted_camera_offset::with_shifted_camera_offset(tile_shader& shader, short x, short y) :
    _shader{shader},
    _offset{shader.camera_offset()}
{
    constexpr auto chunk_size = TILE_MAX_DIM20d*dTILE_SIZE;
    const auto offset = _offset +  tile_shader::project(Vector3d(x, y, 0) * chunk_size);
    _shader.set_camera_offset(offset);
}

with_shifted_camera_offset::~with_shifted_camera_offset()
{
    _shader.set_camera_offset(_offset);
}

} // namespace floormat