OpenTTD Source: src/town_kdtree.h Source File

OpenTTD Source 15.3

town_kdtree.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef TOWN_KDTREE_H
11#define TOWN_KDTREE_H
12
13#include "core/kdtree.hpp"
14#include "town.h"
15
16 struct Kdtree_TownXYFunc {
17 inline uint16_t operator()(TownID tid, int dim)
18 {
19 return (dim == 0) ? TileX(Town::Get(tid)->xy) : TileY(Town::Get(tid)->xy);
20 }
21};
22
23using TownKdtree = Kdtree<TownID, Kdtree_TownXYFunc, uint16_t, int>;
24extern TownKdtree _town_kdtree;
25extern TownKdtree _town_local_authority_kdtree;
26
27#endif
Kdtree
K-dimensional tree, specialised for 2-dimensional space.
Definition kdtree.hpp:33
kdtree.hpp
K-d tree template specialised for 2-dimensional Manhattan geometry.
TileY
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition map_func.h:438
TileX
static uint TileX(TileIndex tile)
Get the X component of a tile.
Definition map_func.h:428
Kdtree_TownXYFunc
Definition town_kdtree.h:16
PoolID< uint16_t, struct TownIDTag, 64000, 0xFFFF >
Pool::PoolItem<&_town_pool >::Get
static Titem * Get(auto index)
Returns Titem with given index.
Definition pool_type.hpp:387
town.h
Base of the town class.