-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jelly.h
69 lines (47 loc) · 1.36 KB
/
Jelly.h
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
#ifndef _JELLY_H_
#define _JELLY_H_
#include <vector>
#include "Mesh.h"
#include "Particle.h"
#include "Constraints.h"
// forward declaration
struct Spring;
class Jelly;
using Jelly_Ptr = std::shared_ptr<Jelly>;
/**
* A jelly is represented by mass-spring system.
*/
class Jelly
{
public:
Jelly();
~Jelly();
void Update();
void Initialize(std::vector<std::vector<std::vector<Particle_Ptr>>>& particles, std::vector<unsigned int> indices);
// setter
void setParticles(std::vector<std::vector<std::vector<Particle_Ptr>>>& particles);
//void setSprings(std::vector<)
//getters
std::shared_ptr<Mesh> getJellyMesh() { return m_jelly_mesh; };
private:
// Refresh GPU vertex buffer data (positions)
void UpdateVBO();
/*Particles*/
void UpdateParticlePositions();
/*Basic properties*/
std::vector<glm::vec3> m_positions;
std::vector<std::vector<std::vector<Particle_Ptr>>> m_particles;
size_t m_num_of_particles;
// Buffer in Jelly class for faster update
// TODO: Change to SOA (Structure of Array)
// Or find a way using pointer to manage these
/*Springs*/
std::vector<DistanceConstraint*> m_shear_springs;
std::vector<DistanceConstraint*> m_structural_springs;
std::vector<DistanceConstraint*> m_bend_springs;
/*Mesh of jelly*/
std::shared_ptr<Mesh> m_jelly_mesh;
/*Mesh of Particles*/
std::shared_ptr<Mesh> m_particle_mesh;
};
#endif