#include #include #include #include #include "Pendulum.h" #include 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::binary_semaphore semaphore = std::binary_semaphore(1); FPS * ups; void updateEnergy(); signals: void layoutChanged(); void positionChanged(); public slots: void clearPendula(); void addPendula(const std::vector &add); private slots: void update(); private: QTimer * timer; int updateInterval = 16; };