Skip to content

Commit 5490ec3

Browse files
authored
Add option to build OBJs with PRIMs (#65)
1 parent 9b50503 commit 5490ec3

29 files changed

Lines changed: 2588 additions & 1174 deletions

.idea/NavKit.iml

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

.idea/misc.xml

Lines changed: 3 additions & 0 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.1.0
6+
VERSION 2.2.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)

bin/glacier2obj.exe

-25 KB
Binary file not shown.

include/NavKit/NavKitConfig.h

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

include/NavKit/Resource.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
#define IDM_SETTINGS_NAVKIT 1200
1818
#define IDM_SETTINGS_SCENE 1201
1919
#define IDM_SETTINGS_RECAST 1202
20-
#define IDM_SETTINGS_AIRG 1203
20+
#define IDM_SETTINGS_OBJ 1203
21+
#define IDM_SETTINGS_AIRG 1204
2122
#define IDM_VIEW_NAVP_SHOW_NAVP 1300
2223
#define IDM_VIEW_NAVP_SHOW_INDICES 1301
2324
#define IDM_VIEW_NAVP_SHOW_PF_EXCLUDE_BOXES 1302
@@ -127,3 +128,15 @@
127128
#define IDC_STATIC_TILING_INFO_MAX_TILES 30336
128129
#define IDC_STATIC_TILING_INFO_MAX_POLYS 30337
129130
#define IDC_BUTTON_RECAST_RESET 30338
131+
132+
#define IDD_OBJ_SETTINGS 30400
133+
#define IDC_RADIO_MESH_TYPE_ALOC 30401
134+
#define IDC_RADIO_MESH_TYPE_PRIM 30402
135+
#define IDC_CHECK_PRIM_LOD_1 30403
136+
#define IDC_CHECK_PRIM_LOD_2 30404
137+
#define IDC_CHECK_PRIM_LOD_3 30405
138+
#define IDC_CHECK_PRIM_LOD_4 30406
139+
#define IDC_CHECK_PRIM_LOD_5 30407
140+
#define IDC_CHECK_PRIM_LOD_6 30408
141+
#define IDC_CHECK_PRIM_LOD_7 30409
142+
#define IDC_CHECK_PRIM_LOD_8 30410

include/NavKit/model/ZPathfinding.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,23 @@ namespace ZPathfinding {
8282
void readJson(simdjson::ondemand::object json);
8383
};
8484

85-
class HashAndEntity {
85+
class HashesAndEntity {
8686
public:
87-
HashAndEntity() = default;
87+
HashesAndEntity() = default;
8888

89-
std::string hash;
89+
std::string alocHash;
90+
std::string primHash;
9091
Entity entity;
9192

9293
void readJson(simdjson::ondemand::object json);
9394
};
9495

95-
class Aloc {
96+
class Mesh {
9697
public:
97-
Aloc() = default;
98+
Mesh() = default;
9899

99-
std::string hash;
100+
std::string alocHash;
101+
std::string primHash;
100102
std::string id;
101103
std::string name;
102104
std::string tblu;
@@ -107,16 +109,16 @@ namespace ZPathfinding {
107109
void writeJson(std::ostream &f) const;
108110
};
109111

110-
class Alocs {
112+
class Meshes {
111113
public:
112-
Alocs() {
114+
Meshes() {
113115
}
114116

115-
Alocs(std::string fileName);
117+
Meshes(simdjson::ondemand::array alocs);
116118

117-
std::vector<Aloc> readAlocs() const;
119+
std::vector<Mesh> readMeshes() const;
118120

119-
std::vector<HashAndEntity> hashesAndEntities{};
121+
std::vector<HashesAndEntity> hashesAndEntities{};
120122
};
121123

122124
class PfBox {
@@ -149,13 +151,11 @@ namespace ZPathfinding {
149151

150152
static inline const std::string NO_EXCLUDE_BOX_FOUND = "NO_EXCLUDE_BOX_FOUND";
151153

152-
PfBoxes(std::string fileName);
154+
PfBoxes(simdjson::ondemand::array);
153155

154156
void readPathfindingBBoxes();
155157

156-
std::vector<PfBox> readExclusionBoxes() const;
157-
158-
std::vector<HashAndEntity> hashesAndEntities{};
158+
std::vector<Entity> entities{};
159159
};
160160

161161
class PfSeedPoint {
@@ -180,10 +180,10 @@ namespace ZPathfinding {
180180
PfSeedPoints() {
181181
}
182182

183-
PfSeedPoints(std::string fileName);
183+
PfSeedPoints(simdjson::ondemand::array pfSeedPoints);
184184

185185
std::vector<PfSeedPoint> readPfSeedPoints() const;
186186

187-
std::vector<HashAndEntity> hashesAndEntities{};
187+
std::vector<Entity> entities{};
188188
};
189189
}

include/NavKit/module/Airg.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class Airg {
4242
ResourceConverter *airgResourceConverter;
4343
ResourceGenerator *airgResourceGenerator;
4444
ReasoningGrid *reasoningGrid;
45-
int airgScroll;
4645
int selectedWaypointIndex;
4746
bool doAirgHitTest;
4847
bool buildingVisionAndDeadEndData;

include/NavKit/module/Navp.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ class Navp {
7373
bool doNavpHitTest;
7474
bool doNavpExclusionBoxHitTest;
7575
bool doNavpPfSeedPointHitTest;
76-
int navpScroll;
7776
bool loading;
7877

7978
bool stairsCheckboxValue;

include/NavKit/module/Obj.h

Lines changed: 106 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,106 @@
1-
#pragma once
2-
#include <map>
3-
#include <optional>
4-
#include <string>
5-
#include <thread>
6-
#include <vector>
7-
8-
9-
class Obj {
10-
explicit Obj();
11-
12-
public:
13-
static Obj &getInstance() {
14-
static Obj instance;
15-
return instance;
16-
}
17-
18-
std::string loadObjName;
19-
std::string saveObjName;
20-
std::string lastObjFileName;
21-
std::string lastSaveObjFileName;
22-
std::string generatedObjName;
23-
bool objLoaded;
24-
bool showObj;
25-
bool loadObj;
26-
std::vector<std::string> files;
27-
const std::string meshesFolder = "Obj";
28-
std::string objToLoad;
29-
std::vector<bool> objLoadDone;
30-
int objScroll;
31-
bool startedObjGeneration;
32-
bool blenderObjStarted;
33-
bool blenderObjGenerationDone;
34-
bool glacier2ObjDebugLogsEnabled;
35-
bool blenderSet;
36-
bool errorBuilding;
37-
std::string blenderPath;
38-
std::map<std::string, std::pair<int, int> > objectTriangleRanges;
39-
bool doObjHitTest;
40-
41-
static char *openSetBlenderFileDialog(const char *lastBlenderFile);
42-
43-
void loadObjMesh();
44-
45-
static void copyObjFile(const std::string &from, const std::string &to);
46-
47-
void saveObjMesh(char *objToCopy, char *newFileName);
48-
49-
void setBlenderFile(const std::string &fileName);
50-
51-
void buildObjFromNavp(bool alsoLoadIntoUi);
52-
53-
void buildObj(const char *blenderPath, const char *sceneFilePath, const char *outputFolder);
54-
55-
void finalizeObjBuild();
56-
57-
static void renderObj();
58-
59-
static char *openLoadObjFileDialog(const char *lastObjFolder);
60-
61-
static char *openSaveObjFileDialog(char *lastObjFolder);
62-
63-
void setLastLoadFileName(const char *fileName);
64-
65-
void setLastSaveFileName(const char *fileName);
66-
67-
void handleOpenObjClicked();
68-
69-
void handleSaveObjClicked();
70-
71-
bool canLoad() const;
72-
73-
bool canBuildObjFromNavp() const;
74-
75-
bool canBuildObjFromScene() const;
76-
77-
void handleBuildObjFromSceneClicked();
78-
79-
void handleBuildObjFromNavpClicked();
80-
81-
void finalizeLoad();
82-
83-
std::optional<std::jthread> backgroundWorker;
84-
};
1+
#pragma once
2+
#include <map>
3+
#include <optional>
4+
#include <string>
5+
#include <thread>
6+
#include <vector>
7+
#define WIN32_LEAN_AND_MEAN
8+
#include <windows.h>
9+
10+
enum MeshType {
11+
ALOC,
12+
PRIM
13+
};
14+
15+
class Obj {
16+
explicit Obj();
17+
18+
static void updateObjDialogControls(HWND hDlg);
19+
20+
public:
21+
static Obj &getInstance() {
22+
static Obj instance;
23+
return instance;
24+
}
25+
26+
std::string loadObjName;
27+
std::string saveObjName;
28+
std::string lastObjFileName;
29+
std::string lastSaveObjFileName;
30+
std::string generatedObjName;
31+
bool objLoaded;
32+
bool showObj;
33+
bool loadObj;
34+
std::vector<std::string> files;
35+
const std::string meshesFolder = "Obj";
36+
std::string objToLoad;
37+
std::vector<bool> objLoadDone;
38+
bool startedObjGeneration;
39+
bool blenderObjStarted;
40+
bool blenderObjGenerationDone;
41+
bool glacier2ObjDebugLogsEnabled;
42+
bool errorBuilding;
43+
bool errorExtracting;
44+
bool extractingAlocsOrPrims;
45+
bool doneExtractingAlocsOrPrims;
46+
std::map<std::string, std::pair<int, int> > objectTriangleRanges;
47+
bool doObjHitTest;
48+
MeshType meshTypeForBuild;
49+
bool primLods[8];
50+
static HWND hObjDialog;
51+
52+
static char *openSetBlenderFileDialog(const char *lastBlenderFile);
53+
54+
void loadObjMesh();
55+
56+
static void copyObjFile(const std::string &from, const std::string &to);
57+
58+
void saveObjMesh(char *objToCopy, char *newFileName);
59+
60+
void buildObjFromNavp(bool alsoLoadIntoUi);
61+
62+
void buildObj();
63+
64+
void finalizeObjBuild();
65+
66+
static void renderObj();
67+
68+
static char *openLoadObjFileDialog(const char *lastObjFolder);
69+
70+
static char *openSaveObjFileDialog(char *lastObjFolder);
71+
72+
void setLastLoadFileName(const char *fileName);
73+
74+
void setLastSaveFileName(const char *fileName);
75+
76+
void handleOpenObjClicked();
77+
78+
void handleSaveObjClicked();
79+
80+
bool canLoad() const;
81+
82+
static bool canBuildObjFromNavp();
83+
84+
bool canBuildObjFromScene() const;
85+
86+
void handleBuildObjFromSceneClicked();
87+
88+
void handleBuildObjFromNavpClicked();
89+
90+
void finalizeLoad();
91+
92+
[[nodiscard]] std::string buildPrimLodsString() const;
93+
94+
void saveObjSettings() const;
95+
96+
static INT_PTR ObjSettingsDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
97+
98+
void showObjDialog();
99+
100+
std::optional<std::jthread> backgroundWorker;
101+
102+
void finalizeExtractAlocsOrPrims();
103+
104+
private:
105+
void extractAlocsOrPrims();
106+
};

0 commit comments

Comments
 (0)