#include #include #include #include #include #include "Pendulum.h" using namespace std::chrono; class QTimer; class FPS; class Simulation : public QObject { Q_OBJECT public: explicit Simulation(); double sizeMeters = 50; double gravity {}; double timescale {}; int substeps {}; double potentialEnergy = 0, kineticEnergy = 0; bool isPlaying = false; std::vector pendula; std::mutex pendulaMutex; FPS * ups; signals: void layoutChanged(); void positionChanged(); public slots: void clearPendula(); void addPendula(const std::vector &add); private slots: void update(); private: void updateEnergy(); QTimer * timer; int updateInterval = 16; };