Skip to content

Commit 005209c

Browse files
committed
Cleanup and refactor
1 parent b93cc55 commit 005209c

37 files changed

Lines changed: 10299 additions & 10403 deletions

MP-APS/.vs/MP-APS/v15/.suo

4 KB
Binary file not shown.

MP-APS/.vs/MP-APS/v15/Browse.VC.db

14.9 MB
Binary file not shown.

MP-APS/3rdParty/nuklear/include/nuklear/nuklear.h

Lines changed: 10014 additions & 9647 deletions
Large diffs are not rendered by default.

MP-APS/3rdParty/nuklear/include/nuklear/nuklear_glfw_gl3.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,15 +339,15 @@ nk_glfw3_mouse_button_callback(GLFWwindow* window, int button, int action, int m
339339
}
340340

341341
NK_INTERN void
342-
nk_glfw3_clipbard_paste(nk_handle usr, struct nk_text_edit *edit)
342+
nk_glfw3_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
343343
{
344344
const char *text = glfwGetClipboardString(glfw.win);
345345
if (text) nk_textedit_paste(edit, text, nk_strlen(text));
346346
(void)usr;
347347
}
348348

349349
NK_INTERN void
350-
nk_glfw3_clipbard_copy(nk_handle usr, const char *text, int len)
350+
nk_glfw3_clipboard_copy(nk_handle usr, const char *text, int len)
351351
{
352352
char *str = 0;
353353
(void)usr;
@@ -370,8 +370,8 @@ nk_glfw3_init(GLFWwindow *win, enum nk_glfw_init_state init_state)
370370
glfwSetMouseButtonCallback(win, nk_glfw3_mouse_button_callback);
371371
}
372372
nk_init_default(&glfw.ctx, 0);
373-
glfw.ctx.clip.copy = nk_glfw3_clipbard_copy;
374-
glfw.ctx.clip.paste = nk_glfw3_clipbard_paste;
373+
glfw.ctx.clip.copy = nk_glfw3_clipboard_copy;
374+
glfw.ctx.clip.paste = nk_glfw3_clipboard_paste;
375375
glfw.ctx.clip.userdata = nk_handle_ptr(0);
376376
glfw.last_button_click = 0;
377377
nk_glfw3_device_create();

MP-APS/AI/AISystem.cpp

Lines changed: 0 additions & 2 deletions
This file was deleted.

MP-APS/AI/AISystem.h

Lines changed: 0 additions & 20 deletions
This file was deleted.

MP-APS/Camera.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,7 @@
44
#include <GLFW/glfw3.h>
55

66
/***********************************************************************************/
7-
Camera::Camera(const glm::vec3& position, const glm::vec3& up, const float yaw, const float pitch, const float FOV) noexcept :
8-
m_position(position),
9-
m_front(glm::vec3(0.0f, 0.0f, -1.0f)),
10-
m_up(up),
11-
m_yaw(yaw),
12-
m_pitch(pitch),
13-
m_FOV(FOV),
14-
m_firstMouse(true),
15-
m_prevX(0.0),
16-
m_prevY(0.0)
17-
{
7+
Camera::Camera() noexcept {
188
updateVectors();
199
}
2010

@@ -29,18 +19,18 @@ void Camera::SetFar(const float far) {
2919
}
3020

3121
/***********************************************************************************/
32-
void Camera::SetSpeed(const double speed) {
22+
void Camera::SetSpeed(const float speed) {
3323
m_speed = speed;
3424
}
3525

3626
/***********************************************************************************/
3727
void Camera::Update(const double deltaTime) {
3828

3929
if (Input::GetInstance().IsKeyPressed(GLFW_KEY_TAB)) {
40-
m_shouldUpdate = !m_shouldUpdate;
30+
m_dirty = !m_dirty;
4131
}
4232

43-
if (m_shouldUpdate) {
33+
if (m_dirty) {
4434
// Update view from mouse movement
4535
updateView();
4636

MP-APS/Camera.h

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
class Camera {
66

77
public:
8-
Camera(const glm::vec3& position = { 0.0f, 0.0f, 0.0f }, const glm::vec3& up = { 0.0f, 1.0f, 0.0f }, const float yaw = -90.0f, const float pitch = 0.0f, const float FOV = 70.0f) noexcept;
8+
Camera() noexcept;
99

1010
void SetNear(const float near);
1111
void SetFar(const float far);
12-
void SetSpeed(const double speed);
12+
void SetSpeed(const float speed);
1313

1414
void Update(const double deltaTime);
1515

1616
auto GetViewMatrix() const { return lookAt(m_position, m_position + m_front, m_up); }
17+
// TODO: optimize projection matrix calculation
1718
auto GetProjMatrix(const float width, const float height) const { return glm::perspective(m_FOV, width / height, m_near, m_far); }
1819
auto GetPosition() const noexcept { return m_position; }
1920

@@ -37,24 +38,26 @@ class Camera {
3738
void updateVectors();
3839

3940
// Camera Attributes
40-
glm::vec3 m_position;
41-
glm::vec3 m_front;
42-
glm::vec3 m_up;
41+
glm::vec3 m_position{ 0.0f, 0.0f, 0.0f };
42+
glm::vec3 m_front{ 0.0f, 0.0f, -1.0f };
43+
glm::vec3 m_up{ 0.0f, 1.0f, 0.0f };
4344
glm::vec3 m_right;
44-
const glm::vec3 m_worldUp = glm::vec3(0.0f, 1.0f, 0.0f);
45+
const glm::vec3 m_worldUp{ 0.0f, 1.0f, 0.0f };
4546

4647
float m_near = 1.0f, m_far = 100.0f;
4748

4849
// Eular Angles
49-
double m_yaw, m_pitch;
50+
float m_yaw{ -90.0f };
51+
float m_pitch{ 0.0f };
5052

51-
double m_speed = 5.0;
52-
const double m_sensitivity = 0.3;
53-
const float m_FOV;
53+
float m_speed{ 5.0f };
54+
const float m_sensitivity{ 0.3f };
55+
const float m_FOV{ 70.0f };
5456

5557
// Mouse positions
56-
bool m_firstMouse;
57-
double m_prevX, m_prevY;
58+
bool m_firstMouse{ true };
59+
double m_prevX{ 0.0 }, m_prevY{0.0};
5860

59-
bool m_shouldUpdate = true;
61+
// Should we update the camera attributes?
62+
bool m_dirty{ true };
6063
};

MP-APS/Core/GUISystem.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "GUISystem.h"
22

3+
#include <cstddef>
4+
35
#include <glad/glad.h>
46

57
#define NK_INCLUDE_FIXED_TYPES
@@ -16,6 +18,9 @@
1618

1719
//https://github.com/vurtun/nuklear/blob/master/demo/glfw_opengl3/main.c
1820

21+
const constexpr std::size_t MaxVertexBuffer{ 512 * 1024 };
22+
const constexpr std::size_t MaxElementBuffer{ 128 * 1024 };
23+
1924
/***********************************************************************************/
2025
void GUISystem::Init(GLFWwindow* windowPtr) {
2126
m_nuklearContext = nk_glfw3_init(windowPtr, NK_GLFW3_INSTALL_CALLBACKS);
@@ -78,7 +83,7 @@ void GUISystem::Render() {
7883
nk_end(m_nuklearContext);
7984

8085

81-
nk_glfw3_render(NK_ANTI_ALIASING_ON, m_maxVertexBuffer, m_maxElementBuffer);
86+
nk_glfw3_render(NK_ANTI_ALIASING_ON, MaxVertexBuffer, MaxElementBuffer);
8287
}
8388

8489
/***********************************************************************************/

MP-APS/Core/GUISystem.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#pragma once
22

3-
#include <cstddef>
4-
53
/***********************************************************************************/
64
// Forward Declarations
75
struct nk_context;
@@ -23,8 +21,5 @@ class GUISystem {
2321
void Shutdown() const;
2422

2523
private:
26-
nk_context* m_nuklearContext;
27-
28-
std::size_t m_maxVertexBuffer = 512 * 1024;
29-
std::size_t m_maxElementBuffer = 128 * 1024;
24+
nk_context* m_nuklearContext{ nullptr };
3025
};

0 commit comments

Comments
 (0)