forked from retroplasma/earth-reverse-engineering
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrocktree_types.h
109 lines (88 loc) · 2.14 KB
/
rocktree_types.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
105
106
107
108
109
#include <SDL_opengl.h>
enum dl_state : int {
dl_state_stub = 1,
dl_state_downloading = 2,
dl_state_downloaded = 4,
};
struct rocktree_t {
enum texture_format : int {
texture_format_rgb = 1,
texture_format_dxt1 = 2,
};
struct bulk_t;
struct node_t {
NodeDataRequest request;
bool can_have_data;
std::atomic<dl_state> dl_state;
bulk_t* parent;
void setNotDownloadedYet() {
dl_state = dl_state_stub;
}
void setStartedDownloading() {
if (parent) parent->busy_ctr++;
dl_state = dl_state_downloading;
}
void setFinishedDownloading() {
dl_state = dl_state_downloaded;
}
void setFailedDownloading() {
dl_state = dl_state_stub;
if (parent) parent->busy_ctr--;
}
void setDeleted() {
dl_state = dl_state_stub;
if (parent) parent->busy_ctr--;
}
float meters_per_texel;
OrientedBoundingBox obb;
std::unique_ptr<NodeData> _data;
Matrix4d matrix_globe_from_mesh;
struct mesh_t {
std::vector<uint8_t> vertices;
std::vector<uint16_t> indices;
Vector2f uv_offset;
Vector2f uv_scale;
std::vector<uint8_t> texture;
texture_format texture_format;
int texture_width;
int texture_height;
GLuint vertex_buffer;
GLuint index_buffer;
GLuint texture_buffer;
bool buffered;
};
std::vector<mesh_t> meshes;
};
struct bulk_t {
BulkMetadataRequest request;
std::atomic<dl_state> dl_state;
bulk_t* parent;
void setNotDownloadedYet() {
dl_state = dl_state_stub;
}
void setStartedDownloading() {
if (parent) parent->busy_ctr++;
dl_state = dl_state_downloading;
}
void setFinishedDownloading() {
dl_state = dl_state_downloaded;
}
void setFailedDownloading() {
dl_state = dl_state_stub;
if (parent) parent->busy_ctr--;
}
void setDeleted() {
dl_state = dl_state_stub;
if (parent) parent->busy_ctr--;
}
Vector3f head_node_center;
std::unique_ptr<BulkMetadata> _metadata;
std::atomic<int> busy_ctr;
std::map<std::string, std::unique_ptr<node_t>> nodes;
std::map<std::string, std::unique_ptr<bulk_t>> bulks;
};
float radius;
bulk_t *root_bulk;
std::unique_ptr<PlanetoidMetadata> _metadata;
std::atomic<bool> downloaded;
};