bbox.h

Fri, 03 May 2013 18:49:23 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Fri, 03 May 2013 18:49:23 +0300
changeset 153
03a7bdcce50d
parent 135
c243df39913e
child 164
8c93d8e38494
permissions
-rw-r--r--

Adding objects now actually updates the bounding box like it should be.

30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
1 /*
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
2 * LDForge: LDraw parts authoring CAD
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
3 * Copyright (C) 2013 Santeri Piippo
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
4 *
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
5 * This program is free software: you can redistribute it and/or modify
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
6 * it under the terms of the GNU General Public License as published by
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
8 * (at your option) any later version.
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
9 *
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
10 * This program is distributed in the hope that it will be useful,
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
13 * GNU General Public License for more details.
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
14 *
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
15 * You should have received a copy of the GNU General Public License
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
17 */
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
18
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 121
diff changeset
19 #ifndef BBOX_H
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 121
diff changeset
20 #define BBOX_H
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 #include "common.h"
121
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
23 #include "types.h"
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24
60
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 30
diff changeset
25 // =============================================================================
121
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
26 // bbox
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
27 //
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
28 // The bounding box is the box that encompasses a given set of objects. The
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
29 // global instance g_BBox is the bbox for the model we have open.
60
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 30
diff changeset
30 // v0 is the minimum vertex, v1 is the maximum vertex.
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 30
diff changeset
31 // =============================================================================
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 class bbox {
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 public:
60
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 30
diff changeset
34 vertex v0, v1;
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 bbox ();
60
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 30
diff changeset
37
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 30
diff changeset
38 void reset ();
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 void calculate ();
121
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
40 double size () const;
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
41 void calcObject (LDObject* obj);
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
42 void calcVertex (vertex v);
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
43 vertex center () const;
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44
121
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
45 bbox& operator<< (LDObject* obj) {
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
46 calcObject (obj);
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
47 return *this;
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
48 }
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
49
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
50 bbox& operator<< (vertex& v) {
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
51 calcVertex (v);
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
52 return *this;
7e87c85ad092 Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
53 }
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 };
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 121
diff changeset
56 #endif // BBOX_H

mercurial