diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llmath/llbbox.h | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/linden/indra/llmath/llbbox.h b/linden/indra/llmath/llbbox.h new file mode 100644 index 0000000..3559284 --- /dev/null +++ b/linden/indra/llmath/llbbox.h | |||
@@ -0,0 +1,103 @@ | |||
1 | /** | ||
2 | * @file llbbox.h | ||
3 | * @brief General purpose bounding box class | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2001-2010, /linden Research, Inc. | ||
8 | * | ||
9 | * Second Life Viewer Source Code | ||
10 | * The source code in this file ("Source Code") is provided by /linden Lab | ||
11 | * to you under the terms of the GNU General Public License, version 2.0 | ||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
13 | * ("Other License"), formally executed by you and /linden Lab. Terms of | ||
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
16 | * | ||
17 | * There are special exceptions to the terms and conditions of the GPL as | ||
18 | * it is applied to this Source Code. View the full text of the exception | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at | ||
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
22 | * | ||
23 | * By copying, modifying or distributing this software, you acknowledge | ||
24 | * that you have read and understood your obligations described above, | ||
25 | * and agree to abide by those obligations. | ||
26 | * | ||
27 | * ALL /linden LAB SOURCE CODE IS PROVIDED "AS IS." /linden LAB MAKES NO | ||
28 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
29 | * COMPLETENESS OR PERFORMANCE. | ||
30 | * $/LicenseInfo$ | ||
31 | */ | ||
32 | |||
33 | #ifndef LL_BBOX_H | ||
34 | #define LL_BBOX_H | ||
35 | |||
36 | #include "v3math.h" | ||
37 | #include "llquaternion.h" | ||
38 | |||
39 | // Note: "local space" for an LLBBox is defined relative to agent space in terms of | ||
40 | // a translation followed by a rotation. There is no scale term since the LLBBox's min and | ||
41 | // max are not necessarily symetrical and define their own extents. | ||
42 | |||
43 | class LLBBox | ||
44 | { | ||
45 | public: | ||
46 | LLBBox() {mEmpty = TRUE;} | ||
47 | LLBBox( const LLVector3& pos_agent, | ||
48 | const LLQuaternion& rot, | ||
49 | const LLVector3& min_local, | ||
50 | const LLVector3& max_local ) | ||
51 | : | ||
52 | mMinLocal( min_local ), mMaxLocal( max_local ), mPosAgent(pos_agent), mRotation( rot), mEmpty( TRUE ) | ||
53 | {} | ||
54 | |||
55 | // Default copy constructor is OK. | ||
56 | |||
57 | const LLVector3& getPositionAgent() const { return mPosAgent; } | ||
58 | const LLQuaternion& getRotation() const { return mRotation; } | ||
59 | |||
60 | const LLVector3& getMinLocal() const { return mMinLocal; } | ||
61 | void setMinLocal( const LLVector3& min ) { mMinLocal = min; } | ||
62 | |||
63 | const LLVector3& getMaxLocal() const { return mMaxLocal; } | ||
64 | void setMaxLocal( const LLVector3& max ) { mMaxLocal = max; } | ||
65 | |||
66 | LLVector3 getCenterLocal() const { return (mMaxLocal - mMinLocal) * 0.5f + mMinLocal; } | ||
67 | LLVector3 getCenterAgent() const { return localToAgent( getCenterLocal() ); } | ||
68 | |||
69 | LLVector3 getExtentLocal() const { return mMaxLocal - mMinLocal; } | ||
70 | |||
71 | BOOL containsPointLocal(const LLVector3& p) const; | ||
72 | BOOL containsPointAgent(const LLVector3& p) const; | ||
73 | |||
74 | void addPointAgent(LLVector3 p); | ||
75 | void addBBoxAgent(const LLBBox& b); | ||
76 | |||
77 | void addPointLocal(const LLVector3& p); | ||
78 | void addBBoxLocal(const LLBBox& b) { addPointLocal( b.mMinLocal ); addPointLocal( b.mMaxLocal ); } | ||
79 | |||
80 | void expand( F32 delta ); | ||
81 | |||
82 | LLVector3 localToAgent( const LLVector3& v ) const; | ||
83 | LLVector3 agentToLocal( const LLVector3& v ) const; | ||
84 | |||
85 | // Changes rotation but not position | ||
86 | LLVector3 localToAgentBasis(const LLVector3& v) const; | ||
87 | LLVector3 agentToLocalBasis(const LLVector3& v) const; | ||
88 | |||
89 | |||
90 | // friend LLBBox operator*(const LLBBox& a, const LLMatrix4& b); | ||
91 | |||
92 | private: | ||
93 | LLVector3 mMinLocal; | ||
94 | LLVector3 mMaxLocal; | ||
95 | LLVector3 mPosAgent; // Position relative to Agent's Region | ||
96 | LLQuaternion mRotation; | ||
97 | BOOL mEmpty; // Nothing has been added to this bbox yet | ||
98 | }; | ||
99 | |||
100 | //LLBBox operator*(const LLBBox &a, const LLMatrix4 &b); | ||
101 | |||
102 | |||
103 | #endif // LL_BBOX_H | ||