/
Particle.h
105 lines (79 loc) · 1.9 KB
/
Particle.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
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
102
103
104
#pragma once
#include "glm/glm.hpp"
#include <cstdlib>
#include <stdint.h>
#include <vector>
using namespace glm;
typedef union {
// for some reason unsigned long int doesn't work
// unsigned long int value;
uint64_t value;
struct {
short int x;
short int y;
short int z;
unsigned short int level;
} data;
unsigned char c[8];
} hash_t;
struct Particle
{
vec3 m_InitPosition;
vec3 m_Position;
vec3 m_Velocity;
// vec3 m_RotVelocity;
vec4 m_Color;
float m_fRotate;
float m_fRadius;
// float m_fSize;
float m_fAge;
float m_fLifeTime;
Particle()
: m_InitPosition(0,0,0)
, m_Position(0,0,0) // Center point of particle
, m_Velocity(0,0,0)
, m_Color(0)
, m_fRadius(1)
, m_fRotate(0)
, m_fAge(0)
, m_fLifeTime(0)
{}
};
typedef std::vector<Particle> ParticleBuffer;
/// specifically designed for hgrid implementation
struct h_Particle
{
h_Particle *pPrevParticle;
h_Particle *pNextParticle; // embedded link to next hgrid particle
vec3 m_Position;
vec3 m_Pre_Velocity;
vec3 m_Velocity;
// vec3 m_RotVelocity;
vec4 m_Color;
float m_fRotate;
float m_fRadius;
float m_fmass;
int m_id;
// uint64_t m_hash; // hash bucket
hash_t m_hash;
// float m_fSize;
float m_fAge;
float m_fLifeTime;
int state;
h_Particle()
: m_Position(0,0,0) // Center point of particle
, m_Pre_Velocity(0,1000,0)
, m_Velocity(0,0,0)
, m_Color(0)
, m_fRadius(1)
, m_fRotate(0)
, m_fAge(0)
, m_fLifeTime(0)
, m_fmass(1)
, m_id(0)
{
pPrevParticle = NULL;
pNextParticle = NULL;
}
};
typedef std::vector<h_Particle> h_ParticleBuffer;