Skip to content

Commit 37c24ff

Browse files
authored
Log output to file, Texture optimization, Json parsing fixes (#82)
1 parent f072517 commit 37c24ff

36 files changed

Lines changed: 678 additions & 668 deletions

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.11.1
6+
VERSION 2.12.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: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#pragma once
2-
3-
#define NavKit_VERSION_MAJOR "2"
4-
#define NavKit_VERSION_MINOR "11"
5-
#define NavKit_VERSION_PATCH "1"
1+
#define NavKit_VERSION_MAJOR "2"
2+
#define NavKit_VERSION_MINOR "12"
3+
#define NavKit_VERSION_PATCH "0"

include/NavKit/Resource.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#define IDM_SETTINGS_NAVKIT 1200
2121
#define IDM_SETTINGS_SCENE 1201
2222
#define IDM_SETTINGS_RECAST 1202
23-
#define IDM_SETTINGS_OBJ 1203
23+
#define IDM_SETTINGS_SCENE_MESH 1203
2424
#define IDM_SETTINGS_AIRG 1204
2525
#define IDM_VIEW_NAVP_SHOW_NAVP 1300
2626
#define IDM_VIEW_NAVP_SHOW_INDICES 1301
@@ -38,13 +38,14 @@
3838
#define IDM_VIEW_AIRG_CELL_COLOR_LAYER 1327
3939
#define IDM_VIEW_LOG_SHOW_LOG 1330
4040
#define IDM_VIEW_SCENE_SHOW_BBOX 1340
41+
#define IDM_VIEW_SCENE_SHOW_AXES 1341
4142
#define IDM_EXTRACT_SCENE 1400
4243
#define IDM_EXTRACT_SCENE_AND_BUILD_OBJ 1401
4344
#define IDM_EXTRACT_SCENE_AND_BUILD_ALL 1402
4445
#define IDM_BUILD_OBJ_FROM_SCENE 1500
4546
#define IDM_BUILD_OBJ_FROM_NAVP 1501
46-
#define IDM_BUILD_BLEND_FROM_SCENE 1502
47-
#define IDM_BUILD_BLEND_AND_OBJ_FROM_SCENE 1503
47+
#define IDM_BUILD_BLEND_FROM_SCENE 1502
48+
#define IDM_BUILD_BLEND_AND_OBJ_FROM_SCENE 1503
4849
#define IDM_BUILD_NAVP 1510
4950
#define IDM_BUILD_AIRG 1520
5051
#define IDM_HELP_ABOUT 1600
@@ -66,6 +67,7 @@
6667
#define IDC_EDIT_HITMAN_PATH 30006
6768
#define IDC_EDIT_OUTPUT_PATH 30007
6869
#define IDC_EDIT_BLENDER_PATH 30008
70+
#define IDC_CHECK_SHOW_DEBUG_LOGS 30009
6971
#define IDC_BG_COLOR_TEXT 30010
7072
#define IDC_HITMAN_DIR_TEXT 30011
7173
#define IDC_OUTPUT_DIR_TEXT 30012
@@ -148,9 +150,8 @@
148150
#define IDC_RADIO_BUILD_TYPE_INSTANCE 30412
149151
#define IDC_CHECK_FILTER_TO_INCLUDE_BOX 30413
150152
#define IDC_CHECK_SKIP_RPKG_EXTRACT 30414
151-
#define IDC_CHECK_SHOW_BLENDER_DEBUG_LOGS 30415
152-
#define IDC_CHECK_EXTRACT_TEXTURE_FILES 30416
153-
#define IDC_CHECK_APPLY_TEXTURES 30417
153+
#define IDC_CHECK_EXTRACT_TEXTURE_FILES 30415
154+
#define IDC_CHECK_APPLY_TEXTURES 30416
154155

155156
#define IDD_EXTRACT_NAVP_DIALOG 30500
156157
#define IDC_COMBOBOX_NAVP 30501

include/NavKit/adapter/RecastAdapter.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,10 @@ class RecastAdapter {
8383

8484
void save(const std::string& data) const;
8585

86-
[[nodiscard]] std::mutex& getLogMutex() const;
87-
8886
[[nodiscard]] int getVertCount() const;
8987

9088
[[nodiscard]] int getTriCount() const;
9189

92-
[[nodiscard]] int getLogCount() const;
93-
94-
std::deque<std::string>& getLogBuffer() const;
95-
9690
void addConvexVolume(Json::PfBox& pfBox) const;
9791

9892
[[nodiscard]] const ConvexVolume* getConvexVolumes() const;
@@ -139,7 +133,6 @@ class RecastAdapter {
139133
dtQueryFilter* filter;
140134
dtQueryFilter* filterWithExcluded;
141135
bool markerPositionSet;
142-
bool processHitTestShift;
143136
float markerPosition[3]{};
144137
std::string selectedObject;
145138

include/NavKit/model/Json.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,31 @@
11
#pragma once
22

33
#include <filesystem>
4-
#include <map>
54
#include <string>
65
#include <vector>
6+
#include <string_view>
77
#include "../../../extern/simdjson/simdjson.h"
88

99
namespace Json {
10+
template <typename t> struct SimdJsonTypeMap;
11+
12+
template <> struct SimdJsonTypeMap<float> { using type = double; };
13+
template <> struct SimdJsonTypeMap<double> { using type = double; };
14+
template <> struct SimdJsonTypeMap<int> { using type = int64_t; };
15+
template <> struct SimdJsonTypeMap<bool> { using type = bool; };
16+
template <> struct SimdJsonTypeMap<std::string> { using type = std::string_view; };
17+
std::string toString(double val);
18+
std::string toString(int64_t val);
19+
std::string toString(bool val);
20+
std::string toString(std::string_view val);
21+
struct JsonValueProxy {
22+
simdjson::ondemand::object json;
23+
std::string field;
24+
template <typename t, typename = typename SimdJsonTypeMap<t>::type>
25+
operator t();
26+
};
27+
JsonValueProxy getValue(simdjson::ondemand::object json, const std::string& field);
28+
1029
class Vec3 {
1130
public:
1231
Vec3(): x(0), y(0), z(0) {

include/NavKit/module/Logger.h

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22
#include <string>
33
#include "../../include/ConcurrentQueue/ConcurrentQueue.h"
4+
#include <fstream>
45

56
enum LogCategory {
67
NK_INFO = 1,
@@ -10,21 +11,34 @@ enum LogCategory {
1011
};
1112

1213
class Logger {
14+
static const int MAX_MESSAGES = 250;
15+
const char* messages[MAX_MESSAGES];
16+
std::mutex logMutex;
17+
std::ofstream logFile;
18+
std::deque<std::string> logBuffer;
19+
int messageCount;
20+
int textPoolSize;
21+
std::unique_ptr<rsj::ConcurrentQueue<std::pair<LogCategory, std::string>>> logQueue;
22+
23+
public:
1324
explicit Logger();
1425

15-
std::unique_ptr<rsj::ConcurrentQueue<std::pair<LogCategory, std::string>>> logQueue;
26+
int getLogCount() const;
1627

17-
bool debugLogsEnabled;
28+
std::deque<std::string>& getLogBuffer();
29+
30+
void doLog(const char* msg, int len);
1831

19-
public:
2032
static Logger& getInstance() {
2133
static Logger instance;
2234
return instance;
2335
}
2436

2537
static void log(LogCategory category, const char* format, ...);
2638

27-
static void logRunner();
39+
[[noreturn]] static void logRunner();
2840

2941
static void rustLogCallback(const char* message);
42+
43+
std::mutex& getLogMutex();
3044
};

include/NavKit/module/NavKitSettings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ struct DialogSettings {
66
std::string hitmanFolder;
77
std::string outputFolder;
88
std::string blenderPath;
9+
bool showDebugLogs;
910
};
1011

1112
class NavKitSettings {
@@ -30,6 +31,7 @@ class NavKitSettings {
3031
std::string hitmanFolder;
3132
std::string outputFolder;
3233
std::string blenderPath;
34+
bool showDebugLogs;
3335
static HWND hSettingsDialog;
3436

3537
void setHitmanFolder(const std::string& folderName);

include/NavKit/module/Renderer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ class Renderer {
4646

4747
void drawText(const std::string& text, Vec3 pos, Vec3 color = {0.0, 0.0, 0.0}, double size = 32.0) const;
4848

49-
static void drawBox(Vec3 pos, Vec3 size, Math::Quaternion rotation, bool filled, Vec3 fillColor, bool outlined,
50-
Vec3 outlineColor, float alpha);
49+
void drawBox(Vec3 pos, Vec3 size, Math::Quaternion rotation, bool filled, Vec3 fillColor, bool outlined,
50+
Vec3 outlineColor, float alpha) const;
5151

5252
bool initWindowAndRenderer();
5353

@@ -65,7 +65,7 @@ class Renderer {
6565

6666
void finalizeFrame() const;
6767

68-
static void drawBounds();
68+
void drawBounds();
6969

7070
void drawAxes();
7171

include/NavKit/module/Scene.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class Scene {
8282
float bBoxPos[3]{};
8383
float bBoxScale[3]{};
8484
bool showBBox;
85+
bool showAxes;
8586
int version;
8687
static HWND hSceneDialog;
8788

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ enum SceneMeshBuildType {
2323
COPY
2424
};
2525

26-
class Obj {
27-
explicit Obj();
26+
class SceneMesh {
27+
explicit SceneMesh();
2828

2929
static GLuint tileTextureId;
3030

@@ -33,8 +33,8 @@ class Obj {
3333
static void updateObjDialogControls(HWND hDlg);
3434

3535
public:
36-
static Obj& getInstance() {
37-
static Obj instance;
36+
static SceneMesh& getInstance() {
37+
static SceneMesh instance;
3838
return instance;
3939
}
4040

@@ -49,13 +49,12 @@ class Obj {
4949
std::vector<std::string> files;
5050
std::string objToLoad;
5151
std::vector<bool> objLoadDone;
52-
bool startedObjGeneration;
53-
bool blenderObjStarted;
54-
bool blenderObjGenerationDone;
52+
bool startedSceneMeshGeneration;
53+
bool blenderSceneMeshBuildStarted;
54+
bool blenderSceneMeshGenerationDone;
5555
bool blendFileOnlyBuild;
5656
bool blendFileAndObjBuild;
5757
bool filterToIncludeBox;
58-
bool glacier2ObjDebugLogsEnabled;
5958
bool errorBuilding;
6059
bool skipExtractingAlocsOrPrims;
6160
bool errorExtracting;
@@ -69,7 +68,7 @@ class Obj {
6968
bool blendFileBuilt;
7069
bool extractTextures;
7170
bool applyTextures;
72-
static HWND hObjDialog;
71+
static HWND hSceneMeshDialog;
7372
Model model;
7473

7574
static char* openSetBlenderFileDialog();
@@ -88,9 +87,9 @@ class Obj {
8887

8988
void buildObjFromNavp(bool alsoLoadIntoUi);
9089

91-
void buildObjFromScene();
90+
void buildSceneMeshFromScene();
9291

93-
void finalizeObjBuild();
92+
void finalizeSceneMeshBuild();
9493

9594
void renderObj() const;
9695

@@ -140,13 +139,13 @@ class Obj {
140139

141140
static INT_PTR ObjSettingsDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
142141

143-
void showObjDialog();
142+
void showSceneMeshDialog();
144143

145144
std::optional<std::jthread> backgroundWorker;
146145

147146
void finalizeExtractResources();
148147

149148
bool shouldExtractTextures() const;
150149

151-
void extractResourcesAndStartObjBuild();
150+
void extractResourcesAndStartSceneMeshBuild();
152151
};

0 commit comments

Comments
 (0)