-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathParticle.cpp
More file actions
33 lines (25 loc) · 753 Bytes
/
Copy pathParticle.cpp
File metadata and controls
33 lines (25 loc) · 753 Bytes
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
#include "Particle.h"
Particle::Particle(glm::vec3 pos, glm::vec3 v, float m) : mass(m), fixed(false),
normal(glm::vec3(0)), position(pos), velocity(v), acceleration(glm::vec3(0)) {}
Particle::~Particle() {}
void Particle::move(float step) {
if (!fixed) {
velocity = velocity + step * acceleration;
position = position + step * velocity;
}
}
void Particle::clearAcceleration() {
acceleration = glm::vec3(0);
}
void Particle::applyForce(glm::vec3 force) {
acceleration += force / mass;
}
void Particle::applyAcceleration(glm::vec3 a) {
acceleration += a;
}
void Particle::setFix() {
fixed = true;
}
void Particle::setFree() {
fixed = false;
}