HighMap library (C++)
Loading...
Searching...
No Matches
tile_region.hpp
Go to the documentation of this file.
1/* Copyright (c) 2025 Otto Link. Distributed under the terms of the GNU General
2 Public License. The full license is in the file LICENSE, distributed with
3 this software. */
4
10#pragma once
11#include <string>
12
13#include <glm/vec2.hpp>
14#include <glm/vec4.hpp>
15
16#include "highmap/algebra.hpp"
17
18namespace hmap
19{
20
21struct TileKey
22{
23 int tx;
24 int ty;
25
26 bool operator==(const TileKey &other) const
27 {
28 return tx == other.tx && ty == other.ty;
29 }
30
31 unsigned int hash() const
32 {
33 return (static_cast<uint64_t>(tx) << 32) | (static_cast<uint32_t>(ty));
34 }
35};
36
38{
39 TileKey key; // ID
40 glm::vec4 bbox; // (x1, x2, y1, y2) in arbitrary coordinates
41 glm::ivec2 shape; // number of cells in tile (incl. halo)
42 glm::ivec4 halo; // number of extra cells around overlapping with other
43 // tiles
44
45 TileRegion(const TileKey &key,
46 const glm::vec4 &bbox,
47 const glm::ivec2 &shape,
48 const glm::vec4 &halo = {0, 0, 0, 0});
49
50 glm::vec2 cell_center(int i, int j) const;
51 glm::vec2 cell_corner(int i, int j) const;
52 std::string key_as_string() const;
53};
54
55} // namespace hmap
Header file defining basic vector and matrix manipulation classes.
Definition algebra.hpp:22
Definition tile_region.hpp:22
int ty
Definition tile_region.hpp:24
bool operator==(const TileKey &other) const
Definition tile_region.hpp:26
unsigned int hash() const
Definition tile_region.hpp:31
int tx
Definition tile_region.hpp:23
Definition tile_region.hpp:38
glm::vec4 bbox
Definition tile_region.hpp:40
glm::vec2 cell_center(int i, int j) const
Definition tile_region.cpp:21
glm::ivec4 halo
Definition tile_region.hpp:42
glm::ivec2 shape
Definition tile_region.hpp:41
glm::vec2 cell_corner(int i, int j) const
Definition tile_region.cpp:37
std::string key_as_string() const
Definition tile_region.cpp:44
TileKey key
Definition tile_region.hpp:39