From b39b8cc8f18cf3042f49bcd663bd4496f96a89bc Mon Sep 17 00:00:00 2001 From: George Fotopoulos Date: Wed, 26 Jun 2024 01:59:54 +0300 Subject: [PATCH] Reformat --- src/Application.cpp | 30 +++++++++++++++--------------- src/Application.hpp | 17 +++++++++-------- src/Logging.cpp | 2 +- src/Logging.hpp | 22 +++++++++++----------- src/Main.cpp | 4 ++-- src/Spring.hpp | 1 + 6 files changed, 39 insertions(+), 37 deletions(-) diff --git a/src/Application.cpp b/src/Application.cpp index a29261a..d743c01 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -20,7 +20,7 @@ Application::Application() { mView = mWindow.getDefaultView(); } -void Application::Run() { +void Application::run() { const unsigned int rows = 16u; const unsigned int cols = 16u; const float padding = 8.0f; @@ -34,14 +34,14 @@ void Application::Run() { sf::Time accumulator = sf::Time::Zero; sf::Clock deltaClock; while (mWindow.isOpen()) { - ProcessEvents(); + processEvents(); const sf::Time deltaTime = deltaClock.restart(); const sf::Time scaledDeltaTime = timeScale * deltaTime; accumulator += scaledDeltaTime; while (accumulator > fixedDeltaTime) { - FixedUpdate(fixedDeltaTime); + fixedUpdate(fixedDeltaTime); accumulator -= fixedDeltaTime; } @@ -122,29 +122,29 @@ void Application::Run() { ImGui::SFML::Shutdown(); } -void Application::ProcessEvents() { +void Application::processEvents() { sf::Event event{}; while (mWindow.pollEvent(event)) { ImGui::SFML::ProcessEvent(mWindow, event); switch (event.type) { case sf::Event::Closed: - HandleEventClosed(event); + handleEventClosed(event); break; case sf::Event::Resized: - HandleEventResized(event); + handleEventResized(event); break; case sf::Event::MouseWheelScrolled: - HandleEventMouseWheelScrolled(event); + handleEventMouseWheelScrolled(event); break; case sf::Event::MouseButtonPressed: - HandleEventMouseButtonPressed(event); + handleEventMouseButtonPressed(event); break; case sf::Event::MouseButtonReleased: - HandleEventMouseButtonReleased(event); + handleEventMouseButtonReleased(event); break; default: @@ -153,16 +153,16 @@ void Application::ProcessEvents() { } } -void Application::HandleEventClosed(const sf::Event &event) { +void Application::handleEventClosed(const sf::Event &event) { mWindow.close(); } -void Application::HandleEventResized(const sf::Event &event) { +void Application::handleEventResized(const sf::Event &event) { mView.setSize(static_cast(event.size.width), static_cast(event.size.height)); mWindow.setView(mView); } -void Application::HandleEventMouseWheelScrolled(const sf::Event &event) { +void Application::handleEventMouseWheelScrolled(const sf::Event &event) { if (event.mouseWheelScroll.delta > 0.0f) { mView.zoom(1.0f / 1.05f); } @@ -172,7 +172,7 @@ void Application::HandleEventMouseWheelScrolled(const sf::Event &event) { mWindow.setView(mView); } -void Application::HandleEventMouseButtonPressed(const sf::Event &event) { +void Application::handleEventMouseButtonPressed(const sf::Event &event) { if (event.mouseButton.button == sf::Mouse::Left) { for (size_t softBodyIndex = 0; softBodyIndex < mSoftBodies.size(); ++softBodyIndex) { const SoftBody &softBody = mSoftBodies[softBodyIndex]; @@ -193,14 +193,14 @@ void Application::HandleEventMouseButtonPressed(const sf::Event &event) { } } -void Application::HandleEventMouseButtonReleased(const sf::Event &event) { +void Application::handleEventMouseButtonReleased(const sf::Event &event) { if (event.mouseButton.button == sf::Mouse::Left) { mIsSoftBodySelected = false; mIsParticleSelected = false; } } -void Application::FixedUpdate(const sf::Time &fixedDeltaTime) { +void Application::fixedUpdate(const sf::Time &fixedDeltaTime) { const float dt = fixedDeltaTime.asSeconds(); for (SoftBody &softBody: mSoftBodies) { for (Spring &spring: softBody.springs) { diff --git a/src/Application.hpp b/src/Application.hpp index 07ca39d..2038052 100644 --- a/src/Application.hpp +++ b/src/Application.hpp @@ -13,16 +13,17 @@ class Application { public: Application(); - void Run(); + + void run(); private: - void ProcessEvents(); - void HandleEventClosed(const sf::Event &event); - void HandleEventResized(const sf::Event &event); - void HandleEventMouseWheelScrolled(const sf::Event &event); - void HandleEventMouseButtonPressed(const sf::Event &event); - void HandleEventMouseButtonReleased(const sf::Event &event); - void FixedUpdate(const sf::Time &fixedDeltaTime); + void processEvents(); + void handleEventClosed(const sf::Event &event); + void handleEventResized(const sf::Event &event); + void handleEventMouseWheelScrolled(const sf::Event &event); + void handleEventMouseButtonPressed(const sf::Event &event); + void handleEventMouseButtonReleased(const sf::Event &event); + void fixedUpdate(const sf::Time &fixedDeltaTime); sf::VideoMode mMode{800u, 600u}; sf::String mTitle{"Particle Physics"}; diff --git a/src/Logging.cpp b/src/Logging.cpp index b894017..13d5d7e 100644 --- a/src/Logging.cpp +++ b/src/Logging.cpp @@ -5,7 +5,7 @@ std::shared_ptr Logging::sServerLogger; std::shared_ptr Logging::sClientLogger; -void Logging::Init() { +void Logging::init() { spdlog::set_pattern("[%H:%M:%S %z] [%n] [%^---%L---%$] [thread %t] %v"); sServerLogger = spdlog::stdout_color_mt("Engine"); sClientLogger = spdlog::stdout_color_mt("Client"); diff --git a/src/Logging.hpp b/src/Logging.hpp index 79c3263..e5339c3 100644 --- a/src/Logging.hpp +++ b/src/Logging.hpp @@ -6,21 +6,21 @@ class Logging { public: - static void Init(); - inline static std::shared_ptr &GetServerLogger() { return sServerLogger; } - inline static std::shared_ptr &GetClientLogger() { return sClientLogger; } + static void init(); + inline static std::shared_ptr &getServerLogger() { return sServerLogger; } + inline static std::shared_ptr &getClientLogger() { return sClientLogger; } private: static std::shared_ptr sServerLogger; static std::shared_ptr sClientLogger; }; -#define SERVER_TRACE(...) Logging::GetServerLogger()->trace(__VA_ARGS__) -#define SERVER_INFO(...) Logging::GetServerLogger()->info(__VA_ARGS__) -#define SERVER_WARN(...) Logging::GetServerLogger()->warn(__VA_ARGS__) -#define SERVER_ERROR(...) Logging::GetServerLogger()->error(__VA_ARGS__) +#define SERVER_TRACE(...) Logging::getServerLogger()->trace(__VA_ARGS__) +#define SERVER_INFO(...) Logging::getServerLogger()->info(__VA_ARGS__) +#define SERVER_WARN(...) Logging::getServerLogger()->warn(__VA_ARGS__) +#define SERVER_ERROR(...) Logging::getServerLogger()->error(__VA_ARGS__) -#define CLIENT_TRACE(...) Logging::GetClientLogger()->trace(__VA_ARGS__) -#define CLIENT_INFO(...) Logging::GetClientLogger()->info(__VA_ARGS__) -#define CLIENT_WARN(...) Logging::GetClientLogger()->warn(__VA_ARGS__) -#define CLIENT_ERROR(...) Logging::GetClientLogger()->error(__VA_ARGS__) +#define CLIENT_TRACE(...) Logging::getClientLogger()->trace(__VA_ARGS__) +#define CLIENT_INFO(...) Logging::getClientLogger()->info(__VA_ARGS__) +#define CLIENT_WARN(...) Logging::getClientLogger()->warn(__VA_ARGS__) +#define CLIENT_ERROR(...) Logging::getClientLogger()->error(__VA_ARGS__) diff --git a/src/Main.cpp b/src/Main.cpp index b399cb5..af68aa7 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -4,8 +4,8 @@ #include int main() { - Logging::Init(); + Logging::init(); Application application; - application.Run(); + application.run(); return EXIT_SUCCESS; } diff --git a/src/Spring.hpp b/src/Spring.hpp index 28cd5a1..5f786fd 100644 --- a/src/Spring.hpp +++ b/src/Spring.hpp @@ -4,6 +4,7 @@ struct Spring { Spring(Particle &particle1, Particle &particle2, float restLength, float springConstant, float dampingConstant); + Particle &mParticle1; Particle &mParticle2; float mRestLength{0.0f};