Fri, 15 Mar 2013 20:35:47 +0200
Recolored ends of the conditional line graphic purple instead of red for better distinguishment
0 | 1 | #include "common.h" |
2 | #include "bbox.h" | |
3 | #include "ldtypes.h" | |
4 | ||
5 | void bbox::calculate () { | |
6 | // The bounding box, bbox for short, is the | |
7 | // box that encompasses the model we have open. | |
8 | // v0 is the minimum vertex, v1 is the maximum vertex. | |
9 | for (uint i = 0; i < g_CurrentFile->objects.size(); i++) { | |
10 | LDObject* obj = g_CurrentFile->objects[i]; | |
11 | switch (obj->getType ()) { | |
12 | ||
13 | case OBJ_Line: | |
14 | { | |
15 | LDLine* line = static_cast<LDLine*> (obj); | |
16 | for (short i = 0; i < 2; ++i) | |
17 | checkVertex (line->vaCoords[i]); | |
18 | } | |
19 | break; | |
20 | ||
21 | case OBJ_Triangle: | |
22 | { | |
23 | LDTriangle* tri = static_cast<LDTriangle*> (obj); | |
24 | for (short i = 0; i < 3; ++i) | |
25 | checkVertex (tri->vaCoords[i]); | |
26 | } | |
27 | break; | |
28 | ||
29 | case OBJ_Quad: | |
30 | { | |
31 | LDQuad* quad = static_cast<LDQuad*> (obj); | |
32 | for (short i = 0; i < 4; ++i) | |
33 | checkVertex (quad->vaCoords[i]); | |
34 | } | |
35 | break; | |
36 | ||
37 | case OBJ_CondLine: | |
38 | { | |
39 | LDCondLine* line = static_cast<LDCondLine*> (obj); | |
40 | for (short i = 0; i < 2; ++i) { | |
41 | checkVertex (line->vaCoords[i]); | |
42 | checkVertex (line->vaControl[i]); | |
43 | } | |
44 | } | |
45 | break; | |
46 | ||
47 | default: | |
48 | break; | |
49 | } | |
50 | } | |
51 | } | |
52 | ||
53 | #define CHECK_DIMENSION(V,X) \ | |
54 | if (V.X < v0.X) v0.X = V.X; \ | |
55 | if (V.X > v1.X) v1.X = V.X; | |
56 | void bbox::checkVertex (vertex v) { | |
57 | CHECK_DIMENSION (v, x) | |
58 | CHECK_DIMENSION (v, y) | |
59 | CHECK_DIMENSION (v, z) | |
60 | } | |
61 | #undef CHECK_DIMENSION | |
62 | ||
63 | bbox::bbox () { | |
64 | memset (&v0, 0, sizeof v0); | |
65 | memset (&v1, 0, sizeof v1); | |
66 | } |