-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparticlesystem.hpp
48 lines (36 loc) · 1.18 KB
/
particlesystem.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef PARTICLESYSTEM_HPP
#define PARTICLESYSTEM_HPP
#include "objvertexsystem.hpp"
#include "particle.hpp"
#include "vec.hpp"
#include <QGLWidget>
#include <vector>
class ParticleSystem {
public:
ParticleSystem();
void initParticleSystem();
void computeForcesAndUpdateParticles();
std::vector<Vec3f> *mpVertices;
std::vector<std::vector<int>> *mpTets;
std::vector<Particle> mParticles;
std::vector<Vec3f> mInitialVertexPositions;
std::vector<GLfloat> *mpObjVertices;
ObjVertexSystem mObjVertexSystem;
void startSimulation() { mSimulate = true; }
void stopSimulation() { mSimulate = false; }
float mDeltaT;
float mGravity;
float mRestitution;
float mStiffness;
float mDamping;
float mMass;
float mGroundpos;
private:
void computeForcesOnSystem();
void computeForcesOnParticle(Particle &particle, unsigned particleIdx);
float currentLength(int nodeA, int nodeB);
float restLength(int nodeA, int nodeB);
Vec3f directionFromAtoB(int nodeA, int nodeB);
bool mSimulate;
};
#endif // PARTICLESYSTEM_HPP