Skip to content

Commit 9b50503

Browse files
authored
Add a menu bar and extract and build all feature (#64)
1 parent 27f7e6f commit 9b50503

51 files changed

Lines changed: 2652 additions & 1378 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.idea/dictionaries/project.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/editor.xml

Lines changed: 50 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cmake_policy(SET CMP0141 NEW)
33
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<CONFIG:Debug>,EditAndContinue,ProgramDatabase>" CACHE STRING "MSVC debug information format")
44
project(
55
NavKit
6-
VERSION 2.0.1
6+
VERSION 2.1.0
77
DESCRIPTION "An app to create NAVP and AIRG files for use with Hitman: World of Assassination"
88
LANGUAGES CXX)
99
set(CMAKE_CXX_STANDARD 20)

include/NavKit/NavKitConfig.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#define NavKit_VERSION_MAJOR "2"
2-
#define NavKit_VERSION_MINOR "0"
3-
#define NavKit_VERSION_PATCH "1"
2+
#define NavKit_VERSION_MINOR "1"
3+
#define NavKit_VERSION_PATCH "0"

include/NavKit/Resource.h

Lines changed: 128 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,129 @@
11
#pragma once
2-
#define IDD_ERROR_DIALOG 101
3-
#define IDC_ERROR_TEXT 1001
4-
#define IDC_COPY_BUTTON 1003
5-
#define IDD_UPDATE_DIALOG 201
6-
#define IDC_UPDATE_TEXT 2001
2+
3+
#define IDC_STATIC (-1)
4+
5+
#define IDR_NAVKITMENU 10000
6+
#define IDM_FILE_OPEN_SCENE 1000
7+
#define IDM_FILE_OPEN_OBJ 1001
8+
#define IDM_FILE_OPEN_NAVP 1002
9+
#define IDM_FILE_OPEN_AIRG 1003
10+
#define IDM_FILE_SAVE_SCENE 1010
11+
#define IDM_FILE_SAVE_OBJ 1011
12+
#define IDM_FILE_SAVE_NAVP 1012
13+
#define IDM_FILE_SAVE_AIRG 1013
14+
#define IDM_FILE_EXIT 1020
15+
#define IDM_EDIT_NAVP_STAIRS 1100
16+
#define IDM_EDIT_AIRG_CONNECT_WAYPOINT 1101
17+
#define IDM_SETTINGS_NAVKIT 1200
18+
#define IDM_SETTINGS_SCENE 1201
19+
#define IDM_SETTINGS_RECAST 1202
20+
#define IDM_SETTINGS_AIRG 1203
21+
#define IDM_VIEW_NAVP_SHOW_NAVP 1300
22+
#define IDM_VIEW_NAVP_SHOW_INDICES 1301
23+
#define IDM_VIEW_NAVP_SHOW_PF_EXCLUDE_BOXES 1302
24+
#define IDM_VIEW_NAVP_SHOW_PF_SEED_POINTS 1303
25+
#define IDM_VIEW_NAVP_SHOW_RECAST_DEBUG_INFO 1304
26+
#define IDM_VIEW_OBJ_SHOW_OBJ 1310
27+
#define IDM_VIEW_AIRG_SHOW_AIRG 1320
28+
#define IDM_VIEW_AIRG_SHOW_INDICES 1321
29+
#define IDM_VIEW_AIRG_SHOW_GRID 1322
30+
#define IDM_VIEW_AIRG_SHOW_RECAST_DEBUG_INFO 1323
31+
#define IDM_VIEW_AIRG_CELL_COLOR_OFF 1324
32+
#define IDM_VIEW_AIRG_CELL_COLOR_BITMAP 1325
33+
#define IDM_VIEW_AIRG_CELL_COLOR_VISION_DATA 1326
34+
#define IDM_VIEW_AIRG_CELL_COLOR_LAYER 1327
35+
#define IDM_VIEW_LOG_SHOW_LOG 1330
36+
#define IDM_EXTRACT_SCENE 1400
37+
#define IDM_EXTRACT_SCENE_AND_BUILD_OBJ 1401
38+
#define IDM_EXTRACT_SCENE_AND_BUILD_ALL 1402
39+
#define IDM_BUILD_OBJ_FROM_SCENE 1500
40+
#define IDM_BUILD_OBJ_FROM_NAVP 1501
41+
#define IDM_BUILD_NAVP 1510
42+
#define IDM_BUILD_AIRG 1520
43+
#define IDM_HELP_ABOUT 1600
44+
45+
#define IDD_ERROR_DIALOG 20000
46+
#define IDC_ERROR_TEXT 20001
47+
#define IDC_COPY_BUTTON 20002
48+
#define IDI_APPICON 20003
49+
#define IDD_UPDATE_DIALOG 20010
50+
#define IDD_UPDATE_DIALOG 20010
51+
#define IDC_UPDATE_TEXT 20011
52+
53+
#define IDD_NAVKIT_SETTINGS 30000
54+
#define IDC_SLIDER_BG_COLOR 30001
55+
#define IDC_BUTTON_BROWSE_HITMAN 30002
56+
#define IDC_BUTTON_BROWSE_OUTPUT 30003
57+
#define IDC_BUTTON_BROWSE_BLENDER 30004
58+
#define IDC_APPLY 30005
59+
#define IDC_EDIT_HITMAN_PATH 30006
60+
#define IDC_EDIT_OUTPUT_PATH 30007
61+
#define IDC_EDIT_BLENDER_PATH 30008
62+
#define IDC_BG_COLOR_TEXT 30010
63+
#define IDC_HITMAN_DIR_TEXT 30011
64+
#define IDC_OUTPUT_DIR_TEXT 30012
65+
#define IDC_BLENDER_PATH_TEXT 30013
66+
#define IDC_BUTTON_RESET_DEFAULTS 30014
67+
68+
#define IDD_AIRG_MENU 30100
69+
#define IDC_SLIDER_SPACING 30101
70+
#define IDC_SLIDER_XOFFSET 30102
71+
#define IDC_SLIDER_ZOFFSET 30103
72+
#define IDC_STATIC_SPACING_VAL 30104
73+
#define IDC_STATIC_XOFFSET_VAL 30105
74+
#define IDC_STATIC_ZOFFSET_VAL 30106
75+
76+
#define IDD_SCENE_MENU 30200
77+
#define IDC_SLIDER_BBOX_POS_X 30201
78+
#define IDC_SLIDER_BBOX_POS_Y 30202
79+
#define IDC_SLIDER_BBOX_POS_Z 30203
80+
#define IDC_SLIDER_BBOX_SCALE_X 30204
81+
#define IDC_SLIDER_BBOX_SCALE_Y 30205
82+
#define IDC_SLIDER_BBOX_SCALE_Z 30206
83+
#define IDC_BUTTON_BBOX_RESET 30207
84+
#define IDC_STATIC_BBOX_POS_X_VAL 30208
85+
#define IDC_STATIC_BBOX_POS_Y_VAL 30209
86+
#define IDC_STATIC_BBOX_POS_Z_VAL 30210
87+
#define IDC_STATIC_BBOX_SCALE_X_VAL 30211
88+
#define IDC_STATIC_BBOX_SCALE_Y_VAL 30212
89+
#define IDC_STATIC_BBOX_SCALE_Z_VAL 30213
90+
91+
#define IDD_RECAST_MENU 30300
92+
#define IDC_SLIDER_CELL_SIZE 30301
93+
#define IDC_SLIDER_CELL_HEIGHT 30302
94+
#define IDC_STATIC_CELL_SIZE_VAL 30303
95+
#define IDC_STATIC_CELL_HEIGHT_VAL 30304
96+
#define IDC_SLIDER_AGENT_HEIGHT 30305
97+
#define IDC_SLIDER_AGENT_RADIUS 30306
98+
#define IDC_SLIDER_AGENT_MAX_CLIMB 30307
99+
#define IDC_SLIDER_AGENT_MAX_SLOPE 30308
100+
#define IDC_STATIC_AGENT_HEIGHT_VAL 30309
101+
#define IDC_STATIC_AGENT_RADIUS_VAL 30310
102+
#define IDC_STATIC_AGENT_MAX_CLIMB_VAL 30311
103+
#define IDC_STATIC_AGENT_MAX_SLOPE_VAL 30312
104+
#define IDC_SLIDER_REGION_MIN_SIZE 30313
105+
#define IDC_SLIDER_REGION_MERGE_SIZE 30314
106+
#define IDC_STATIC_REGION_MIN_SIZE_VAL 30315
107+
#define IDC_STATIC_REGION_MERGE_SIZE_VAL 30316
108+
#define IDC_RADIO_PARTITION_WATERSHED 30317
109+
#define IDC_RADIO_PARTITION_MONOTONE 30318
110+
#define IDC_RADIO_PARTITION_LAYERS 30319
111+
#define IDC_CHECK_FILTER_LOW_HANGING 30320
112+
#define IDC_CHECK_FILTER_LEDGE_SPANS 30321
113+
#define IDC_CHECK_FILTER_WALKABLE_LOW 30322
114+
#define IDC_SLIDER_POLY_MAX_EDGE_LEN 30323
115+
#define IDC_SLIDER_POLY_MAX_EDGE_ERR 30324
116+
#define IDC_SLIDER_POLY_VERTS_PER_POLY 30325
117+
#define IDC_STATIC_POLY_MAX_EDGE_LEN_VAL 30326
118+
#define IDC_STATIC_POLY_MAX_EDGE_ERR_VAL 30327
119+
#define IDC_STATIC_POLY_VERTS_PER_POLY_VAL 30328
120+
#define IDC_SLIDER_DETAIL_SAMPLE_DIST 30329
121+
#define IDC_SLIDER_DETAIL_SAMPLE_MAX_ERR 30330
122+
#define IDC_STATIC_DETAIL_SAMPLE_DIST_VAL 30331
123+
#define IDC_STATIC_DETAIL_SAMPLE_MAX_ERR_VAL 30332
124+
#define IDC_SLIDER_TILING_TILE_SIZE 30333
125+
#define IDC_STATIC_TILING_TILE_SIZE_VAL 30334
126+
#define IDC_STATIC_TILING_INFO_TILES 30335
127+
#define IDC_STATIC_TILING_INFO_MAX_TILES 30336
128+
#define IDC_STATIC_TILING_INFO_MAX_POLYS 30337
129+
#define IDC_BUTTON_RECAST_RESET 30338

include/NavKit/adapter/RecastAdapter.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <mutex>
66
#include <string>
77
#include <vector>
8+
#define WIN32_LEAN_AND_MEAN
9+
#include <windows.h>
810

911
#include "../../RecastDemo/Sample_TileMesh.h"
1012

@@ -38,10 +40,14 @@ class RecastAdapter {
3840

3941
void log(int category, const std::string &message) const;
4042

43+
void showRecastDialog();
44+
4145
void drawInputGeom() const;
4246

4347
[[nodiscard]] bool loadInputGeom(const std::string &fileName) const;
4448

49+
void setTileSettings(const float *bBoxMin, const float *bBoxMax) const;
50+
4551
void setMeshBBox(const float *bBoxMin, const float *bBoxMax) const;
4652

4753
[[nodiscard]] const float *getBBoxMin() const;
@@ -50,6 +56,8 @@ class RecastAdapter {
5056

5157
[[nodiscard]] std::pair<int, int> getGridSize() const;
5258

59+
void setSceneBBoxToMesh() const;
60+
5361
void handleMeshChanged() const;
5462

5563
[[nodiscard]] bool handleBuild() const;
@@ -62,7 +70,7 @@ class RecastAdapter {
6270

6371
void resetCommonSettings() const;
6472

65-
void renderRecastNavmesh(bool isAirgInstance);
73+
void renderRecastNavmesh(bool isAirgInstance) const;
6674

6775
dtPolyRef getPoly(int tileIndex, int polyIndex) const;
6876

@@ -133,6 +141,8 @@ class RecastAdapter {
133141
float markerPosition[3]{};
134142
std::string selectedObject;
135143

144+
static HWND hRecastDialog;
136145
private:
137146
std::vector<dtPolyRef> pfSeedPointAreas;
147+
static INT_PTR CALLBACK RecastDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
138148
};

include/NavKit/model/ZPathfinding.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace ZPathfinding {
2020

2121
void readJson(simdjson::ondemand::object json);
2222

23-
void writeJson(std::ofstream &f) const;
23+
void writeJson(std::ostream &f) const;
2424
};
2525

2626
class Rotation {
@@ -37,7 +37,7 @@ namespace ZPathfinding {
3737

3838
void readJson(simdjson::ondemand::object json);
3939

40-
void writeJson(std::ofstream &f) const;
40+
void writeJson(std::ostream &f) const;
4141
};
4242

4343
class PfBoxType {
@@ -49,7 +49,7 @@ namespace ZPathfinding {
4949

5050
void readJson(simdjson::ondemand::object json);
5151

52-
void writeJson(std::ofstream &f) const;
52+
void writeJson(std::ostream &f) const;
5353
};
5454

5555
class Scale {
@@ -64,7 +64,7 @@ namespace ZPathfinding {
6464

6565
void readJson(simdjson::ondemand::object json);
6666

67-
void writeJson(std::ofstream &f) const;
67+
void writeJson(std::ostream &f) const;
6868
};
6969

7070
class Entity {
@@ -104,7 +104,7 @@ namespace ZPathfinding {
104104
Scale scale{};
105105
Rotation rotation{};
106106

107-
void writeJson(std::ofstream &f) const;
107+
void writeJson(std::ostream &f) const;
108108
};
109109

110110
class Alocs {
@@ -136,7 +136,7 @@ namespace ZPathfinding {
136136
Rotation rotation{};
137137
PfBoxType type{};
138138

139-
void writeJson(std::ofstream &f) const;
139+
void writeJson(std::ostream &f) const;
140140
};
141141

142142
class PfBoxes {
@@ -147,6 +147,8 @@ namespace ZPathfinding {
147147
static inline const std::string INCLUDE_TYPE = "PFBT_INCLUDE_MESH_COLLISION";
148148
static inline const std::string EXCLUDE_TYPE = "PFBT_EXCLUDE_MESH_COLLISION";
149149

150+
static inline const std::string NO_EXCLUDE_BOX_FOUND = "NO_EXCLUDE_BOX_FOUND";
151+
150152
PfBoxes(std::string fileName);
151153

152154
void readPathfindingBBoxes();
@@ -170,7 +172,7 @@ namespace ZPathfinding {
170172
Vec3 pos{};
171173
Rotation rotation{};
172174

173-
void writeJson(std::ofstream &f);
175+
void writeJson(std::ostream &f) const;
174176
};
175177

176178
class PfSeedPoints {

include/NavKit/module/Airg.h

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
#pragma once
2+
#include <optional>
23
#include <string>
4+
#include <thread>
35
#include <vector>
6+
#define WIN32_LEAN_AND_MEAN
7+
#include <windows.h>
48

59
struct Vec3;
610
struct ResourceConverter;
711
struct ResourceGenerator;
812
class ReasoningGrid;
913

14+
enum CellColorDataSource {
15+
OFF, AIRG_BITMAP, VISION_DATA, LAYER
16+
};
17+
1018
class Airg {
1119
public:
1220
explicit Airg();
@@ -30,48 +38,71 @@ class Airg {
3038
bool showAirg;
3139
bool showAirgIndices;
3240
bool showRecastDebugInfo;
33-
float cellColorSource;
41+
CellColorDataSource cellColorSource;
3442
ResourceConverter *airgResourceConverter;
3543
ResourceGenerator *airgResourceGenerator;
3644
ReasoningGrid *reasoningGrid;
3745
int airgScroll;
3846
int selectedWaypointIndex;
3947
bool doAirgHitTest;
4048
bool buildingVisionAndDeadEndData;
41-
static const int AIRG_MENU_HEIGHT;
4249

4350
static void resetDefaults();
4451

45-
void drawMenu();
46-
4752
void finalizeSave();
4853

4954
void build();
5055

51-
void renderLayerIndices(int waypointIndex, bool selected);
56+
void renderLayerIndices(int waypointIndex) const;
5257

5358
void renderCellBitmaps(int waypointIndex, bool selected);
5459

55-
void renderVisionData(int waypointIndex, bool selected);
60+
void renderVisionData(int waypointIndex, bool selected) const;
5661

5762
void renderAirg();
5863

59-
void renderAirgForHitTest();
64+
void renderAirgForHitTest() const;
6065

6166
void setSelectedAirgWaypointIndex(int index);
6267

63-
void connectWaypoints(int startWaypointIndex, int endWaypointIndex) const;
68+
void connectWaypoints(int startWaypointIndex, int endWaypointIndex);
6469

6570
void setLastLoadFileName(const char *fileName);
6671

6772
void setLastSaveFileName(const char *fileName);
6873

74+
void handleOpenAirgClicked();
75+
76+
void handleSaveAirgClicked();
77+
78+
[[nodiscard]] bool canLoad() const;
79+
80+
[[nodiscard]] bool canSave() const;
81+
82+
[[nodiscard]] bool canBuildAirg() const;
83+
84+
void handleBuildAirgClicked();
85+
86+
[[nodiscard]] bool canEnterConnectWaypointMode() const;
87+
88+
void handleConnectWaypointClicked();
89+
90+
std::optional<std::jthread> backgroundWorker;
91+
92+
void showAirgDialog();
93+
94+
static void UpdateDialogControls(HWND hDlg);
95+
96+
static HWND hAirgDialog;
97+
6998
private:
99+
static INT_PTR CALLBACK AirgDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
100+
70101
static char *openSaveAirgFileDialog(char *lastAirgFolder);
71102

72103
static char *openAirgFileDialog(const char *lastAirgFolder);
73104

74105
static void saveAirg(Airg *airg, std::string fileName, bool isJson);
75106

76-
static void loadAirg(Airg *airg, char *fileName, bool isFromJson);
107+
static void loadAirg(Airg *airg, const std::string& fileName, bool isFromJson);
77108
};

include/NavKit/module/GameConnection.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ class GameConnection {
2727

2828
~GameConnection();
2929

30-
void sendNavp(NavPower::NavMesh *navMesh) const;
31-
3230
void sendChunk(const std::vector<NavPower::Area> &areas, int chunkIndex, int chunkCount) const;
3331

3432
int connectToGame();

include/NavKit/module/Gui.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ class Gui {
1515
bool showMenu;
1616
bool showLog;
1717
int logScroll;
18-
int collapsedLogScroll;
1918
int lastLogCount;
2019
};

0 commit comments

Comments
 (0)