… | |
… | |
10 | |
10 | |
11 | typedef int soffs; // 32 bit |
11 | typedef int soffs; // 32 bit |
12 | typedef unsigned int uoffs; |
12 | typedef unsigned int uoffs; |
13 | #define OFFS_BITS 31 |
13 | #define OFFS_BITS 31 |
14 | #define SOFFS_MIN (soffs)-(1 << (OFFS_BITS - 1)) |
14 | #define SOFFS_MIN (soffs)-(1 << (OFFS_BITS - 1)) |
|
|
15 | #define SOFFS_MAX (soffs)+(1 << (OFFS_BITS - 1)) |
15 | #define MAXEXTENT ((1UL << OFFS_BITS) - 1) |
16 | #define MAXEXTENT ((1UL << OFFS_BITS) - 1) |
16 | |
17 | |
17 | #define GLFLOAT_MAX 1e30 |
18 | #define GLFLOAT_MAX 1e30 |
18 | #define GLFLOAT_MIN -1e30 |
19 | #define GLFLOAT_MIN -1e30 |
19 | |
20 | |
20 | struct sector { |
21 | struct sector { |
21 | soffs x, y, z; |
22 | soffs x, y, z; |
|
|
23 | |
|
|
24 | sector (soffs x = 0, soffs y = 0, soffs z = 0) : x(x), y(y), z(z) { }; |
22 | |
25 | |
23 | void offset (int subindex, uoffs extent) |
26 | void offset (int subindex, uoffs extent) |
24 | { |
27 | { |
25 | if (subindex & 1) x += extent; |
28 | if (subindex & 1) x += extent; |
26 | if (subindex & 2) y += extent; |
29 | if (subindex & 2) y += extent; |
… | |
… | |
33 | |
36 | |
34 | point () { }; |
37 | point () { }; |
35 | point (GLfloat x, GLfloat y, GLfloat z) : x(x), y(y), z(z) { }; |
38 | point (GLfloat x, GLfloat y, GLfloat z) : x(x), y(y), z(z) { }; |
36 | }; |
39 | }; |
37 | |
40 | |
38 | inline const point translate (const point &p, const sector &src, const sector &dst) |
41 | inline const sector translate (const sector &p, const sector &src, const sector &dst) |
39 | { |
42 | { |
40 | point r; |
43 | sector r; |
41 | |
44 | |
42 | r.x = p.x + (dst.x - src.x); |
45 | r.x = p.x + (dst.x - src.x); |
43 | r.y = p.y + (dst.y - src.y); |
46 | r.y = p.y + (dst.y - src.y); |
44 | r.z = p.z + (dst.z - src.z); |
47 | r.z = p.z + (dst.z - src.z); |
45 | |
48 | |
… | |
… | |
105 | texc () { }; |
108 | texc () { }; |
106 | texc (GLfloat s, GLfloat t) : s(s), t(t) { }; |
109 | texc (GLfloat s, GLfloat t) : s(s), t(t) { }; |
107 | }; |
110 | }; |
108 | |
111 | |
109 | struct box { |
112 | struct box { |
110 | point a, b; |
113 | sector a, b; |
|
|
114 | |
|
|
115 | box() { }; |
111 | |
116 | |
112 | void reset () |
117 | void reset () |
113 | { |
118 | { |
114 | a = point (GLFLOAT_MAX, GLFLOAT_MAX, GLFLOAT_MAX); |
119 | a = sector (SOFFS_MIN, SOFFS_MIN, SOFFS_MIN); |
115 | b = point (GLFLOAT_MIN, GLFLOAT_MIN, GLFLOAT_MIN); |
120 | b = sector (SOFFS_MAX, SOFFS_MAX, SOFFS_MAX); |
116 | } |
121 | } |
117 | |
122 | |
118 | void add (const box &o); |
123 | void add (const box &o); |
|
|
124 | void add (const sector &p); |
119 | void add (const point &p); |
125 | void add (const point &p); |
120 | }; |
126 | }; |
121 | |
127 | |
122 | inline const box translate (const box &b, const sector &src, const sector &dst) |
128 | inline const box translate (const box &b, const sector &src, const sector &dst) |
123 | { |
129 | { |