Skip to content

Commit 09f2353

Browse files
committed
Refactor: format
1 parent 94cc6b6 commit 09f2353

10 files changed

Lines changed: 58 additions & 41 deletions

File tree

modules/Engine/include/Engine/Camera.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ namespace cae
2323
class Camera
2424
{
2525
public:
26-
Camera(const glm::vec3 position, const glm::vec3 rotation, const glm::vec3 direction, const float moveSpeed = CAMERA::MOVE_SPEED,
27-
const float lookSpeed = CAMERA::LOOK_SPEED, const float fov = CAMERA::FOV, const float nearPlane = CAMERA::NEAR_PLANE,
28-
const float farPlane = CAMERA::FAR_PLANE)
26+
Camera(const glm::vec3 position, const glm::vec3 rotation, const glm::vec3 direction,
27+
const float moveSpeed = CAMERA::MOVE_SPEED, const float lookSpeed = CAMERA::LOOK_SPEED,
28+
const float fov = CAMERA::FOV, const float nearPlane = CAMERA::NEAR_PLANE,
29+
const float farPlane = CAMERA::FAR_PLANE)
2930
: m_position(position), m_rotation(rotation), m_direction(direction), m_moveSpeed(moveSpeed),
30-
m_lookSpeed(lookSpeed), m_fov(fov), m_near(nearPlane), m_far(farPlane)
31-
{
32-
}
31+
m_lookSpeed(lookSpeed), m_fov(fov), m_near(nearPlane), m_far(farPlane)
32+
{
33+
}
3334
~Camera() = default;
3435

3536
Camera(const Camera &) = delete;

modules/Engine/src/engine.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ void cae::Engine::render()
6464
constexpr auto model = glm::mat4(1.0F);
6565

6666
const glm::mat4 mvp = m_camera->getViewProjection(static_cast<float>(m_windowPlugin->getWindowSize().width) /
67-
m_windowPlugin->getWindowSize().height) *
68-
model;
67+
m_windowPlugin->getWindowSize().height) *
68+
model;
6969
m_rendererPlugin->draw(m_windowPlugin->getWindowSize(), "basic", mvp);
7070
}
7171

modules/Utils/include/Utils/Path.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ namespace utl
128128
/// @return Resolved path relative to the user cwd
129129
/// @brief
130130
///
131-
static fs::path resolveRelativeToCwd(const fs::path& relativePath) {
131+
static fs::path resolveRelativeToCwd(const fs::path &relativePath)
132+
{
132133
return normalize(fs::current_path() / relativePath);
133134
}
134135

modules/Utils/include/Utils/PluginLoader.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ namespace utl
143143
}
144144
catch (const std::exception &e)
145145
{
146-
throw std::runtime_error(std::string("Unknown exception: ") + e.what());
147146
return nullptr;
148147
}
149148
}

plugins/Renderer/OpenGL/src/context/WGLContext.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ void cae::WGLContext::initialize(const NativeWindowHandle &window)
6565
{
6666
m_hwnd = static_cast<HWND>(window.window);
6767
m_hdc = GetDC(m_hwnd);
68-
if (m_hdc == nullptr) {
68+
if (m_hdc == nullptr)
69+
{
6970
throw std::runtime_error("Failed to get HDC from HWND");
7071
}
7172

@@ -89,10 +90,12 @@ void cae::WGLContext::initialize(const NativeWindowHandle &window)
8990
}
9091

9192
const HGLRC tempContext = wglCreateContext(m_hdc);
92-
if (tempContext == nullptr) {
93+
if (tempContext == nullptr)
94+
{
9395
throw std::runtime_error("Failed to create temporary WGL context");
9496
}
95-
if (wglMakeCurrent(m_hdc, tempContext) == 0) {
97+
if (wglMakeCurrent(m_hdc, tempContext) == 0)
98+
{
9699
throw std::runtime_error("Failed to make temporary context current");
97100
}
98101

@@ -146,7 +149,8 @@ void cae::WGLContext::initialize(const NativeWindowHandle &window)
146149
#ifdef CAE_DEBUG
147150
gl.DebugMessageCallback([](GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
148151
const GLchar *message, const void *userParam)
149-
{ utl::Logger::log("[GL DEBUG] " + std::string(message), utl::LogLevel::WARNING); }, nullptr);
152+
{ utl::Logger::log("[GL DEBUG] " + std::string(message), utl::LogLevel::WARNING); },
153+
nullptr);
150154
#endif
151155
}
152156
}

plugins/Window/Cocoa/include/Cocoa/Cocoa.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,32 @@ namespace cae
2626
Cocoa() = default;
2727
~Cocoa() override;
2828

29-
Cocoa(const Cocoa&) = delete;
30-
Cocoa& operator=(const Cocoa&) = delete;
29+
Cocoa(const Cocoa &) = delete;
30+
Cocoa &operator=(const Cocoa &) = delete;
3131

3232
[[nodiscard]] std::string getName() const override { return "Cocoa"; }
3333
[[nodiscard]] utl::PluginType getType() const override { return utl::PluginType::WINDOW; }
3434
[[nodiscard]] utl::PluginPlatform getPlatform() const override { return utl::PluginPlatform::MACOSX; }
3535

36-
bool create(const std::string& name, WindowSize size) override;
36+
bool create(const std::string &name, WindowSize size) override;
3737
void close() override;
3838

3939
[[nodiscard]] NativeWindowHandle getNativeHandle() const override;
4040
[[nodiscard]] WindowSize getWindowSize() const override;
4141

42-
void setIcon(const std::string &path) const override {}
42+
void setIcon(const std::string &path) const override {}
4343

4444
[[nodiscard]] bool shouldClose() const override;
4545
void pollEvents() override;
46-
bool pollEvent(WindowEvent& event) override;
46+
bool pollEvent(WindowEvent &event) override;
4747

4848
[[nodiscard]] bool wasResized() const override { return m_resized; }
4949
void resetResizedFlag() override { m_resized = false; }
5050

5151
private:
52-
void* m_window = nullptr; // NSWindow*
53-
void* m_view = nullptr; // NSView*
54-
void* m_app = nullptr; // NSApplication*
52+
void *m_window = nullptr; // NSWindow*
53+
void *m_view = nullptr; // NSView*
54+
void *m_app = nullptr; // NSApplication*
5555

5656
bool m_shouldClose = false;
5757
bool m_resized = false;

plugins/Window/GLFW/src/glfw.cpp

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,22 @@ static cae::KeyCode translateKey(const int key)
6868
void cae::GLFW::keyCallback(GLFWwindow *window, const int key, int, const int action, int)
6969
{
7070
auto *self = static_cast<GLFW *>(glfwGetWindowUserPointer(window));
71-
if (self == nullptr) {
71+
if (self == nullptr)
72+
{
7273
return;
7374
}
7475

7576
WindowEvent e{};
76-
if (action == GLFW_PRESS) {
77+
if (action == GLFW_PRESS)
78+
{
7779
e.type = WindowEventType::KeyDown;
78-
} else if (action == GLFW_RELEASE) {
80+
}
81+
else if (action == GLFW_RELEASE)
82+
{
7983
e.type = WindowEventType::KeyUp;
80-
} else {
84+
}
85+
else
86+
{
8187
return;
8288
}
8389

@@ -88,7 +94,8 @@ void cae::GLFW::keyCallback(GLFWwindow *window, const int key, int, const int ac
8894
void cae::GLFW::mouseButtonCallback(GLFWwindow *window, int button, const int action, int)
8995
{
9096
auto *self = static_cast<GLFW *>(glfwGetWindowUserPointer(window));
91-
if (self == nullptr) {
97+
if (self == nullptr)
98+
{
9299
return;
93100
}
94101

@@ -102,7 +109,8 @@ void cae::GLFW::mouseButtonCallback(GLFWwindow *window, int button, const int ac
102109
void cae::GLFW::cursorPosCallback(GLFWwindow *window, const double x, const double y)
103110
{
104111
auto *self = static_cast<GLFW *>(glfwGetWindowUserPointer(window));
105-
if (self == nullptr) {
112+
if (self == nullptr)
113+
{
106114
return;
107115
}
108116

@@ -117,7 +125,8 @@ void cae::GLFW::cursorPosCallback(GLFWwindow *window, const double x, const doub
117125
void cae::GLFW::scrollCallback(GLFWwindow *window, const double xoffset, const double yoffset)
118126
{
119127
auto *self = static_cast<GLFW *>(glfwGetWindowUserPointer(window));
120-
if (self == nullptr) {
128+
if (self == nullptr)
129+
{
121130
return;
122131
}
123132

@@ -132,12 +141,13 @@ void cae::GLFW::scrollCallback(GLFWwindow *window, const double xoffset, const d
132141
void cae::GLFW::frameBufferResizeCallback(GLFWwindow *window, const int width, const int height)
133142
{
134143
auto *self = static_cast<GLFW *>(glfwGetWindowUserPointer(window));
135-
if (self == nullptr) {
144+
if (self == nullptr)
145+
{
136146
return;
137147
}
138148

139149
self->m_frameBufferResized = true;
140-
self->m_frameBufferSize = {.width=static_cast<uint16_t>(width), .height=static_cast<uint16_t>(height)};
150+
self->m_frameBufferSize = {.width = static_cast<uint16_t>(width), .height = static_cast<uint16_t>(height)};
141151

142152
WindowEvent e{};
143153
e.type = WindowEventType::Resize;
@@ -176,7 +186,7 @@ bool cae::GLFW::create(const std::string &name, const WindowSize size)
176186
glfwSetCursorPosCallback(m_window, cursorPosCallback);
177187
glfwSetScrollCallback(m_window, scrollCallback);
178188
#ifdef __APPLE__
179-
glfwMakeContextCurrent((GLFWwindow*)m_window);
189+
glfwMakeContextCurrent((GLFWwindow *)m_window);
180190
#endif
181191
return true;
182192
}
@@ -229,7 +239,8 @@ void cae::GLFW::setIcon(const std::string &path) const
229239

230240
bool cae::GLFW::pollEvent(WindowEvent &event)
231241
{
232-
if (m_eventQueue.empty()) {
242+
if (m_eventQueue.empty())
243+
{
233244
return false;
234245
}
235246

plugins/Window/Win32/src/win32.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ LRESULT CALLBACK cae::Win32::WindowProc(const HWND hwnd, const UINT msg, const W
8787
}
8888

8989
self = reinterpret_cast<Win32 *>(GetWindowLongPtrW(hwnd, GWLP_USERDATA));
90-
if (self == nullptr) {
90+
if (self == nullptr)
91+
{
9192
return DefWindowProcW(hwnd, msg, wParam, lParam);
92-
}
93+
}
9394

9495
WindowEvent e{};
9596
switch (msg)
@@ -98,7 +99,7 @@ LRESULT CALLBACK cae::Win32::WindowProc(const HWND hwnd, const UINT msg, const W
9899
self->m_frameBufferResized = true;
99100
self->m_frameBufferSize = {.width = LOWORD(lParam), .height = HIWORD(lParam)};
100101
e.type = WindowEventType::Resize;
101-
e.resize = {.w=LOWORD(lParam), .h=HIWORD(lParam)};
102+
e.resize = {.w = LOWORD(lParam), .h = HIWORD(lParam)};
102103
self->m_eventQueue.push(e);
103104
return 0;
104105

@@ -205,7 +206,7 @@ void cae::Win32::setIcon(const std::string &path) const
205206
{
206207
const utl::Image image(path);
207208

208-
for (size_t i = 0; std::cmp_less(i ,image.width * image.height); ++i)
209+
for (size_t i = 0; std::cmp_less(i, image.width * image.height); ++i)
209210
{
210211
std::swap(image.pixels[(i * 4) + 0], image.pixels[(i * 4) + 2]);
211212
}
@@ -255,7 +256,6 @@ void cae::Win32::setIcon(const std::string &path) const
255256

256257
SendMessageW(m_hwnd, WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(hIcon));
257258
SendMessageW(m_hwnd, WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(hIcon));
258-
259259
}
260260
catch (const std::exception &e)
261261
{

plugins/Window/X11/src/x11.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void cae::X11::setIcon(const std::string &path) const
118118
{
119119
const utl::Image image(path);
120120

121-
const auto pixelCount = static_cast<const size_t>(image.width * image.height);
121+
const auto pixelCount = image.width * image.height;
122122
std::vector<unsigned long> iconData;
123123
iconData.reserve(2 + pixelCount);
124124

src/application.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ void cae::Application::mainLoop()
211211
m_engine->getCamera()->rotate(lookDir.x, lookDir.y, 1.0F);
212212
}
213213

214-
glm::vec3 forward = glm::normalize(glm::vec3(m_engine->getCamera()->getDirection().x, 0.0F, m_engine->getCamera()->getDirection().z));
214+
glm::vec3 forward = glm::normalize(
215+
glm::vec3(m_engine->getCamera()->getDirection().x, 0.0F, m_engine->getCamera()->getDirection().z));
215216
glm::vec3 right = glm::normalize(glm::cross(forward, glm::vec3(0.0F, 1.0F, 0.0F)));
216217

217218
if (m_keyState[KeyCode::W])
@@ -246,6 +247,6 @@ void cae::Application::mainLoop()
246247
m_engine->getCamera()->move(glm::vec3(0.0F, 1.0F, 0.0F), m_engine->getClock()->getDeltaSeconds());
247248
}
248249

249-
m_engine->update(fpsBuffer, fpsIndex);
250+
m_engine->update(fpsBuffer, fpsIndex);
250251
}
251252
}

0 commit comments

Comments
 (0)