-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMassSpringSystem.h
More file actions
101 lines (72 loc) · 2.06 KB
/
MassSpringSystem.h
File metadata and controls
101 lines (72 loc) · 2.06 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#ifndef MASSSPRINGSYSTEM_H
#define MASSSPRINGSYSTEM_H
#include <map>
#include <vector>
#include <GL/glew.h>
#include "BasicTimer.h"
#include "HostDeviceCode.h"
#include "Particle.h"
#include "Spring.h"
class MassSpringSystem
{
public:
MassSpringSystem();
~MassSpringSystem();
void AddParticle(Particle p);
void AddSpring(Spring s);
void GenerateCube(uint NumX, uint NumY, uint NumZ, glm::vec3 Dimension);
void InitGL(GLint locVertex, GLint locColor);
void InitCuda();
void Draw();
/**
* @brief Advance the system by one timestep
* @param DeltaT Size of the timestep in seconds
*/
void UpdateSystem(float DeltaT);
void SetFixedTop(bool bFixedTop = true) { Param.bFixedTop = bFixedTop; }
void ToggleFixedTop() { Param.bFixedTop = !Param.bFixedTop; }
void TogglePrintTime() { bPrintTimers = !bPrintTimers; }
void ToggleVelocityDisplay() { bDisplayVelocities = !bDisplayVelocities; }
private:
std::vector<Particle> Particles; //!< The particles
std::vector<Spring> Springs;
uint3 GridSize;
MSSParameters Param;
GLuint Vao;
uint NumVBO;
GLuint* VBOs;
// GLuint VboVertex;
// GLuint VboColor;
// GLuint VboSpring;
#ifdef DEBUG_VELOCITY
GLuint VaoVel;
#endif
GLuint LocVertex, LocColor;
BasicTimer ForceComputationTime;
BasicTimer IntegrationTime;
BasicTimer BufferUpdateTime;
bool bPrintTimers;
bool bDisplayVelocities;
float TotalMass;
Arrays HostArrays;
Arrays DeviceArrays;
cudaGraphicsResource** VboCudaResources;
/**
* @brief Update the VBO with new particle positions
*/
void UpdateParticleBuffer();
/**
* @brief Compute new particle positions and velocities based on current forces
*/
void IntegrateSystem(float DeltaT);
void ApplyForces();
void AddSpringForces();
void AllocArrays();
void FillArrays();
void FreeArrays();
void** GetArrayAddress(uint ArrayId);
void MapBuffers();
void UnmapBuffers();
// void PrintStats();
};
#endif // MASSSPRINGSYSTEM_H