-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBulletsControllerHelper.h
69 lines (61 loc) · 1.58 KB
/
BulletsControllerHelper.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
#pragma once
#include "Bullet.h"
#define default_standard_lifetime 10000
struct Differential {
glm::vec3 velocity;
glm::vec3 acceleration;
glm::vec3 jerk;
float speed;
std::function<vec3(float, vec3&, vec3&, vec3&, float&)> update;
Differential(vec3 velocity, vec3 acceleration, vec3 jerk, float speed, std::function<vec3(float, vec3&, vec3&, vec3&, float&)> func) {
this->velocity = velocity;
this->acceleration = acceleration;
this->jerk = jerk;
this->speed = speed;
this->update = func;
}
Differential() {}
};
struct Parametric {
float t = 0;
vec3 center = vec3(0);
vec3 rightVector = vec3(1, 0, 0);
vec3 upVector = vec3(0, 1, 0);
std::function<vec3(float&, vec3&, vec3&, vec3&)> update;
Parametric(float t, vec3 center, vec3 rightVector, vec3 upVector, std::function<vec3(float&, vec3&, vec3&, vec3&)> func) {
this->t = t;
this->center = center;
this->rightVector = rightVector;
this->upVector = upVector;
this->update = func;
}
Parametric() {}
};
enum FormationType {
DIFFERENTIAL, PARAMETRIC, EMPTY
};
struct BulletInfo {
~BulletInfo()
{
if (type != EMPTY && formationInfo != nullptr)
{
if (type == DIFFERENTIAL)
delete (Differential*)formationInfo;
else
delete (Parametric*)formationInfo;
}
}
Bullet* bullet;
FormationType type = EMPTY;
void* formationInfo = nullptr;
int maxLifeTime;
int lifeTime = default_standard_lifetime;
float initialSize;
float maximumSize;
};
struct BulletPattern
{
vec3* bulletPositions;
vector<BulletInfo*> liveBullets;
int numBullets;
};