-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontext.h
More file actions
45 lines (35 loc) · 1.19 KB
/
Copy pathcontext.h
File metadata and controls
45 lines (35 loc) · 1.19 KB
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
#ifndef CONTEXT_H
#define CONTEXT_H
#include "object.h"
#include "collider.h"
#include "constraint.h"
#include <QMouseEvent>
class Context
{
public:
Context();
std::vector<Object> objects;
bool isGravityOn=false;
bool addPlanCollidersOn=false;
std::optional<Vec2> click;
bool addSphereColliderOn=false;
std::vector<std::unique_ptr<Collider>> colliders;
std::vector<std::unique_ptr<Constraint>> activeConstraints;
inline void addCollider(std::unique_ptr<Collider> collider) { colliders.push_back(std::move(collider)); }
inline void addConstraint(std::unique_ptr<Constraint> constraint) { activeConstraints.push_back(std::move(constraint)); }
void updatePhysicalSystem(float dt);
private:
void applyExternalForce(float dt);
void dampVelocities();
void updateExpectedPosition(float dt);
void updateNeighbors();
void addFluidConstraints();
void addDynamicContactConstraints();
void addStaticContactConstraints();
void enforceConstraint(const Constraint&, Particle&);
void projectConstraints();
void updateVelocityAndPosition(float dt);
void applyFriction(float dt);
void deleteContactConstraints();
};
#endif // CONTEXT_H