TrinityCore
Loading...
Searching...
No Matches
MapBuilder.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef _MAP_BUILDER_H
19#define _MAP_BUILDER_H
20
21#include "FlatSet.h"
22#include "Optional.h"
24#include "TerrainBuilder.h"
25#include "TileBuilder.h"
26#include <boost/filesystem/path.hpp>
27#include <DetourNavMesh.h>
28#include <atomic>
29#include <span>
30#include <thread>
31#include <vector>
32
33namespace MMAP
34{
35 typedef std::unordered_map<uint32, Trinity::Containers::FlatSet<uint32>> TileList;
36
46
47 // ToDo: move this to its own file. For now it will stay here to keep the changes to a minimum, especially in the cpp file
48 class MapBuilder;
49
51 {
52 public:
53 MapTileBuilder(MapBuilder* mapBuilder,
54 Optional<float> maxWalkableAngle,
55 Optional<float> maxWalkableAngleNotSteep,
56 bool skipLiquid,
57 bool bigBaseUnit,
58 bool debugOutput,
59 std::vector<OffMeshData> const* offMeshConnections);
61
62 void WorkerThread();
63 void WaitCompletion();
64
65 bool shouldSkipTile(uint32 mapID, uint32 tileX, uint32 tileY) const override;
66
67 std::string GetProgressText() const override;
68
69 void OnTileDone() override;
70
71 private:
73 std::thread m_workerThread;
74 };
75
77 {
78 friend class TileBuilder;
79 friend class MapTileBuilder;
80
81 public:
82 MapBuilder(boost::filesystem::path const& inputDirectory,
83 boost::filesystem::path const& outputDirectory,
84 Optional<float> maxWalkableAngle,
85 Optional<float> maxWalkableAngleNotSteep,
86 bool skipLiquid,
87 bool skipContinents,
88 bool skipJunkMaps,
89 bool skipBattlegrounds,
90 bool debugOutput,
91 bool bigBaseUnit,
92 int mapid,
93 char const* offMeshFilePath,
94 unsigned int threads);
95
97
98 void buildMeshFromFile(char const* name);
99
100 // builds an mmap tile for the specified map and its mesh
101 void buildSingleTile(uint32 mapID, uint32 tileX, uint32 tileY);
102
103 // builds list of maps, then builds all of mmap tiles (based on the skip settings)
104 void buildMaps(Optional<uint32> mapID);
105
106 private:
107 // builds all mmap tiles for the specified map id (ignores skip settings)
108 void buildMap(uint32 mapID);
109 // detect maps and tiles
110 void discoverTiles();
111 std::span<uint32 const> getTileList(uint32 mapID) const;
112
113 void buildNavMesh(uint32 mapID, dtNavMesh* &navMesh);
114
115 bool shouldSkipMap(uint32 mapID) const;
116 bool isTransportMap(uint32 mapID) const;
117 bool isDevMap(uint32 mapID) const;
118 bool isBattlegroundMap(uint32 mapID) const;
119 bool isContinentMap(uint32 mapID) const;
120
121 uint32 percentageDone(uint32 totalTiles, uint32 totalTilesDone) const;
123
124 void ParseOffMeshConnectionsFile(char const* offMeshFilePath);
125
127
128 boost::filesystem::path m_inputDirectory;
129 boost::filesystem::path m_outputDirectory;
131
132 std::vector<OffMeshData> m_offMeshConnections;
133 unsigned int m_threads;
138
142
144
146 std::atomic<uint32> m_totalTilesProcessed;
147
148 std::vector<std::unique_ptr<TileBuilder>> m_tileBuilders;
150 std::atomic<bool> _cancelationToken;
151 };
152}
153
154#endif
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:25
void buildMeshFromFile(char const *name)
std::vector< OffMeshData > m_offMeshConnections
Definition MapBuilder.h:132
void ParseOffMeshConnectionsFile(char const *offMeshFilePath)
void buildMaps(Optional< uint32 > mapID)
ProducerConsumerQueue< TileInfo > _queue
Definition MapBuilder.h:149
uint32 percentageDone(uint32 totalTiles, uint32 totalTilesDone) const
bool isDevMap(uint32 mapID) const
Optional< float > m_maxWalkableAngleNotSteep
Definition MapBuilder.h:140
uint32 currentPercentageDone() const
void buildNavMesh(uint32 mapID, dtNavMesh *&navMesh)
bool shouldSkipMap(uint32 mapID) const
boost::filesystem::path m_outputDirectory
Definition MapBuilder.h:129
bool isTransportMap(uint32 mapID) const
Optional< float > m_maxWalkableAngle
Definition MapBuilder.h:139
std::atomic< bool > _cancelationToken
Definition MapBuilder.h:150
bool isContinentMap(uint32 mapID) const
boost::filesystem::path m_inputDirectory
Definition MapBuilder.h:128
void buildMap(uint32 mapID)
std::atomic< uint32 > m_totalTilesProcessed
Definition MapBuilder.h:146
std::span< uint32 const > getTileList(uint32 mapID) const
bool isBattlegroundMap(uint32 mapID) const
void buildSingleTile(uint32 mapID, uint32 tileX, uint32 tileY)
unsigned int m_threads
Definition MapBuilder.h:133
std::vector< std::unique_ptr< TileBuilder > > m_tileBuilders
Definition MapBuilder.h:148
MapBuilder * m_mapBuilder
Definition MapBuilder.h:72
std::thread m_workerThread
Definition MapBuilder.h:73
std::string GetProgressText() const override
void OnTileDone() override
bool shouldSkipTile(uint32 mapID, uint32 tileX, uint32 tileY) const override
std::unordered_map< uint32, Trinity::Containers::FlatSet< uint32 > > TileList
Definition MapBuilder.h:35
dtNavMeshParams m_navMeshParams
Definition MapBuilder.h:44