Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
xorz57 committed Jun 25, 2024
1 parent 9246624 commit b39b8cc
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 37 deletions.
30 changes: 15 additions & 15 deletions src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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:
Expand All @@ -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<float>(event.size.width), static_cast<float>(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);
}
Expand All @@ -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];
Expand All @@ -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) {
Expand Down
17 changes: 9 additions & 8 deletions src/Application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"};
Expand Down
2 changes: 1 addition & 1 deletion src/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
std::shared_ptr<spdlog::logger> Logging::sServerLogger;
std::shared_ptr<spdlog::logger> 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");
Expand Down
22 changes: 11 additions & 11 deletions src/Logging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@

class Logging {
public:
static void Init();
inline static std::shared_ptr<spdlog::logger> &GetServerLogger() { return sServerLogger; }
inline static std::shared_ptr<spdlog::logger> &GetClientLogger() { return sClientLogger; }
static void init();
inline static std::shared_ptr<spdlog::logger> &getServerLogger() { return sServerLogger; }
inline static std::shared_ptr<spdlog::logger> &getClientLogger() { return sClientLogger; }

private:
static std::shared_ptr<spdlog::logger> sServerLogger;
static std::shared_ptr<spdlog::logger> 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__)
4 changes: 2 additions & 2 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include <cstdlib>

int main() {
Logging::Init();
Logging::init();
Application application;
application.Run();
application.run();
return EXIT_SUCCESS;
}
1 change: 1 addition & 0 deletions src/Spring.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit b39b8cc

Please sign in to comment.