diff --git a/include/Application.hpp b/include/Application.hpp index b92e249..b4cb0c0 100644 --- a/include/Application.hpp +++ b/include/Application.hpp @@ -1,16 +1,14 @@ #pragma once -#include "ApplicationSettings.hpp" #include "SoftBody.hpp" class Application { public: - explicit Application(ApplicationSettings applicationSettings); - void fixedUpdate(float fixedDeltaTime); + Application(); + void FixedUpdate(float fixedDeltaTime); void Run(); private: - ApplicationSettings mApplicationSettings; glm::vec2 mGravitationalAcceleration{0.0f, 10.0f}; std::vector mSoftBodies; }; diff --git a/include/ApplicationSettings.hpp b/include/ApplicationSettings.hpp deleted file mode 100644 index 1ea1fc2..0000000 --- a/include/ApplicationSettings.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include - -struct ApplicationSettings { - unsigned int width{0U}; - unsigned int height{0U}; - std::string title; - float fixedDeltaTime{1.0f / 64.0f}; - float timeScale{1.0f}; -}; diff --git a/src/Application.cpp b/src/Application.cpp index 0aa54e9..27df560 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -22,7 +22,7 @@ #include -Application::Application(ApplicationSettings applicationSettings) : mApplicationSettings(std::move(applicationSettings)) { +Application::Application() { mSoftBodies.emplace_back(DoubleSpringPendulum(glm::vec2(200.0f, 0.0f), 50.0f, 2.0f, 4.0f)); mSoftBodies.emplace_back(SoftBody1(glm::vec2(100.0f, 100.0f), 50.0f, 2.0f, 4.0f)); mSoftBodies.emplace_back(SoftBody2(glm::vec2(300.0f, 200.0f), 50.0f, 2.0f, 4.0f)); @@ -30,7 +30,7 @@ Application::Application(ApplicationSettings applicationSettings) : mApplication mSoftBodies.emplace_back(SpringPendulum(glm::vec2(400.0f, 0.0f), 100.0f, 2.0f, 4.0f)); } -void Application::fixedUpdate(float fixedDeltaTime) { +void Application::FixedUpdate(float fixedDeltaTime) { for (SoftBody &softBody: mSoftBodies) { for (Spring &spring: softBody.springs) { const glm::vec2 dPosition = spring.mParticle2.position - spring.mParticle1.position; @@ -56,8 +56,6 @@ void Application::fixedUpdate(float fixedDeltaTime) { } void Application::Run() { - sf::VideoMode mode(mApplicationSettings.width, mApplicationSettings.height); - sf::ContextSettings settings; settings.depthBits = 24u; settings.stencilBits = 8u; @@ -65,7 +63,7 @@ void Application::Run() { settings.majorVersion = 3u; settings.minorVersion = 0u; - sf::RenderWindow window(mode, mApplicationSettings.title, sf::Style::Default, settings); + sf::RenderWindow window({600u, 600u}, "ParticlePhysics", sf::Style::Default, settings); window.setFramerateLimit(120u); sf::View view = window.getDefaultView(); @@ -74,8 +72,8 @@ void Application::Run() { ImPlot::CreateContext(); - const sf::Time fixedDeltaTime = sf::seconds(mApplicationSettings.fixedDeltaTime); - const float timeScale = mApplicationSettings.timeScale; + const sf::Time fixedDeltaTime = sf::seconds(1.0f / 128.0f); + const float timeScale = 4.0f; sf::Time accumulator = sf::Time::Zero; sf::Clock deltaClock; while (window.isOpen()) { @@ -98,7 +96,7 @@ void Application::Run() { const sf::Time deltaTime = deltaClock.restart(); accumulator += timeScale * deltaTime; while (accumulator > fixedDeltaTime) { - fixedUpdate(fixedDeltaTime.asSeconds()); + FixedUpdate(fixedDeltaTime.asSeconds()); accumulator -= fixedDeltaTime; } diff --git a/src/Main.cpp b/src/Main.cpp index 6f2db2c..69b479b 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -6,14 +6,7 @@ int main() { Logging::Init(); - ApplicationSettings applicationSettings; - applicationSettings.width = 600u; - applicationSettings.height = 600u; - applicationSettings.title = "ParticlePhysics"; - applicationSettings.fixedDeltaTime = 1.0f / 128.0f; - applicationSettings.timeScale = 4.0f; - - Application application(applicationSettings); + Application application; application.Run(); return EXIT_SUCCESS;