1 /* Copyright (C) 2020 Wildfire Games.
2 * This file is part of 0 A.D.
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
20 * Describes ground using heightmap mipmaps
21 * Used for camera movement
24 #ifndef INCLUDED_HEIGHTMIPMAP
25 #define INCLUDED_HEIGHTMIPMAP
34 SMipmap() : m_MapSize(0), m_Heightmap(0) { }
35 SMipmap(size_t MapSize
, u16
* Heightmap
) : m_MapSize(MapSize
), m_Heightmap(Heightmap
) { }
43 NONCOPYABLE(CHeightMipmap
);
49 void Initialize(size_t mapSize
, const u16
* ptr
);
52 // update the heightmap mipmaps
53 void Update(const u16
* ptr
);
55 // update a section of the heightmap mipmaps
56 // (coordinates are heightmap cells, inclusive of lower bounds,
57 // exclusive of upper bounds)
58 void Update(const u16
* ptr
, size_t left
, size_t bottom
, size_t right
, size_t top
);
60 float GetTrilinearGroundLevel(float x
, float z
, float radius
) const;
62 void DumpToDisk(const VfsPath
& path
) const;
66 // get bilinear filtered height from mipmap
67 float BilinearFilter(const SMipmap
&mipmap
, float x
, float z
) const;
69 // update rectangle of the output mipmap by bilinear interpolating an input mipmap of exactly twice its size
70 void HalfResizeUpdate(SMipmap
&out_mipmap
, size_t mapSize
, const u16
* ptr
, size_t left
, size_t bottom
, size_t right
, size_t top
);
72 // update rectangle of the output mipmap by bilinear interpolating the input mipmap
73 void BilinearUpdate(SMipmap
&out_mipmap
, size_t mapSize
, const u16
* ptr
, size_t left
, size_t bottom
, size_t right
, size_t top
);
75 // size of this map in each direction
79 std::vector
<SMipmap
> m_Mipmap
;