Simulate thousands of n-Pendula (up to 32) with Position Based Dynamics
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
736 B

1 year ago
#include <vector>
#include <cstdint>
1 year ago
#include <QObject>
#include <chrono>
#include <mutex>
#include "Pendulum.h"
using namespace std::chrono;
1 year ago
class QPainter;
1 year ago
class QTimer;
1 year ago
1 year ago
class Simulation : public QObject {
Q_OBJECT
1 year ago
public:
explicit Simulation();
double size = 50;
double gravity {};
double timescale {};
int substeps {};
1 year ago
bool isPlaying = false;
void draw(QPainter*, int);
signals:
void pendulaChanged(const std::vector<Pendulum *> &newPendula);
public slots:
void clearPendula();
void addPendula(const std::vector<Pendulum *> &add);
1 year ago
private slots:
void update();
private:
std::mutex pendulaMutex;
QTimer * timer;
int updateInterval = 17;
std::vector<Pendulum *> pendula;
time_point<system_clock> lastUpdate;
1 year ago
};