-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParticle.h
More file actions
35 lines (26 loc) · 783 Bytes
/
Particle.h
File metadata and controls
35 lines (26 loc) · 783 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
34
35
#pragma once
#include "Constraint.h"
class Particle
{
public:
float drag = 0.01f;
float elasticity = 10.0f;
float mass = 2.5f;
bool is_pinned = false;
sf::Vector2f position;
sf::Vector2f prev_position;
sf::Vector2f forces;
sf::Vector2f velocity;
// Constraints that are referencing this particle
std::vector<Constraint*> constraints;
Particle(float x, float y);
// Inline functions
const sf::Vector2f& get_position() const { return position; }
void add_force(sf::Vector2f force) { forces += force; }
void move(sf::Vector2f move_ammount) { if (not is_pinned) position += move_ammount; }
// Functions
void add_constraint(Constraint* c);
void update(float dt);
void update_velocity(float dt);
void break_constraints();
};