aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llspatialpartition.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llspatialpartition.h
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llspatialpartition.h')
-rw-r--r--linden/indra/newview/llspatialpartition.h228
1 files changed, 228 insertions, 0 deletions
diff --git a/linden/indra/newview/llspatialpartition.h b/linden/indra/newview/llspatialpartition.h
new file mode 100644
index 0000000..737029a
--- /dev/null
+++ b/linden/indra/newview/llspatialpartition.h
@@ -0,0 +1,228 @@
1/**
2 * @file llspatialpartition.h
3 * @brief LLSpatialGroup header file including definitions for supporting functions
4 *
5 * Copyright (c) 2003-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#ifndef LL_LLSPATIALPARTITION_H
29#define LL_LLSPATIALPARTITION_H
30
31#define SG_MIN_DIST_RATIO 0.00001f
32
33#include "llmemory.h"
34#include "lldrawable.h"
35#include "lloctree.h"
36#include "llgltypes.h"
37
38#include <queue>
39
40class LLCullInfo
41{
42public:
43 LLVector3 mPos;
44 F32 mRadius;
45 LLPointer<LLDrawable> mDrawablep;
46};
47
48#define SG_STATE_INHERIT_MASK (CULLED | OCCLUDED)
49class LLSpatialPartition;
50
51class LLSpatialGroup : public LLOctreeListener<LLDrawable>
52{
53 friend class LLSpatialPartition;
54public:
55
56 typedef LLOctreeListener<LLDrawable> BaseType;
57 typedef LLOctreeListener<LLDrawable> OctreeListener;
58 typedef LLTreeNode<LLDrawable> TreeNode;
59 typedef LLOctreeNode<LLDrawable> OctreeNode;
60 typedef LLOctreeRoot<LLDrawable> OctreeRoot;
61 typedef LLOctreeState<LLDrawable> OctreeState;
62 typedef LLOctreeTraveler<LLDrawable> OctreeTraveler;
63
64 typedef enum
65 {
66 IN_QUEUE = 0x00000001,
67 QUERY_PENDING = 0x00000002,
68 CULLED = 0x00000004,
69 OCCLUDED = 0x00000008,
70 DEAD = 0x00000010,
71 ACTIVE_OCCLUSION = 0x00000020,
72 EARLY_FAIL = 0x00000040,
73 DEACTIVATE_OCCLUSION = 0x00000080,
74 RESHADOW = 0x00000100,
75 RESHADOW_QUEUE = 0x00000200,
76 DIRTY = 0x00000400,
77 OBJECT_DIRTY = 0x00000800,
78 DISCARD_QUERY = 0x00001000,
79 QUERY_OUT = 0x00002000,
80 OCCLUDING = 0x00004000,
81 SKIP_FRUSTUM_CHECK = 0x00008000,
82 } eSpatialState;
83
84 typedef enum
85 {
86 STATE_MODE_SINGLE = 0, //set one node
87 STATE_MODE_BRANCH, //set entire branch
88 STATE_MODE_DIFF //set entire branch as long as current state is different
89 } eSetStateMode;
90
91 LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part);
92 BOOL safeToDelete();
93 virtual ~LLSpatialGroup();
94
95 S32 getCount() const { return mObjects.size(); }
96 BOOL isDead() { return isState(DEAD); }
97 BOOL isState(U32 state) const { return mState & state ? TRUE : FALSE; }
98 U32 getState() { return mState; }
99 void setState(U32 state) { mState |= state; }
100 void clearState(U32 state) { mState &= ~state; }
101
102 void validate();
103
104 void setState(U32 state, S32 mode);
105
106
107 void clearState(U32 state, S32 mode);
108 BOOL addObject(LLDrawable *drawablep, BOOL add_all = FALSE, BOOL from_octree = FALSE);
109 BOOL removeObject(LLDrawable *drawablep, BOOL from_octree = FALSE);
110 BOOL updateInGroup(LLDrawable *drawablep, BOOL immediate = FALSE); // Update position if it's in the group
111 BOOL isVisible();
112 void shift(const LLVector3 &offset);
113 BOOL boundObjects(BOOL empty, LLVector3& newMin, LLVector3& newMax);
114 void unbound();
115 BOOL rebound();
116 BOOL changeLOD();
117
118 //LISTENER FUNCTIONS
119 virtual void handleInsertion(const TreeNode* node, LLDrawable* face);
120 virtual void handleRemoval(const TreeNode* node, LLDrawable* face);
121 virtual void handleDestruction(const TreeNode* node);
122 virtual void handleStateChange(const TreeNode* node);
123 virtual void handleChildAddition(const OctreeNode* parent, OctreeNode* child);
124 virtual void handleChildRemoval(const OctreeNode* parent, const OctreeNode* child);
125
126protected:
127 std::vector<LLCullInfo> mObjects;
128 U32 mState;
129 S32 mLODHash;
130 static S32 sLODSeed;
131
132public:
133 OctreeNode* mOctreeNode;
134 LLSpatialPartition* mSpatialPartition;
135 LLVector3 mBounds[2];
136 LLVector3 mExtents[2];
137 LLVector3 mObjectExtents[2];
138 LLVector3 mObjectBounds[2];
139
140};
141
142class LLSpatialPartition
143{
144public:
145 LLSpatialPartition();
146 virtual ~LLSpatialPartition();
147
148 LLSpatialGroup *put(LLDrawable *drawablep);
149 BOOL remove(LLDrawable *drawablep, LLSpatialGroup *curp);
150
151 LLDrawable* pickDrawable(const LLVector3& start, const LLVector3& end, LLVector3& collision);
152
153 // If the drawable moves, move it here.
154 virtual void move(LLDrawable *drawablep, LLSpatialGroup *curp, BOOL immediate = FALSE);
155 void shift(const LLVector3 &offset);
156
157 S32 cull(LLCamera &camera, std::vector<LLDrawable *>* results = NULL, BOOL for_select = FALSE); // Cull on arbitrary frustum
158 BOOL checkOcclusion(LLSpatialGroup* group, LLCamera* camera);
159 void processOcclusion(LLCamera* camera);
160 void doOcclusion(LLCamera* camera);
161 BOOL isVisible(const LLVector3& v);
162
163 S32 getObjects(const LLVector3& pos, F32 rad, LLDrawable::drawable_set_t &results );
164 S32 getLights(const LLVector3& pos, F32 rad, LLDrawable::drawable_set_t &results );
165
166 void renderDebug();
167 void restoreGL();
168
169protected:
170 S32 getDrawables(const LLVector3& pos, F32 rad, LLDrawable::drawable_set_t &results, BOOL get_lights );
171
172 LLSpatialGroup *mLastAddedGroupp;
173
174 typedef std::set<LLSpatialGroup*> spatial_group_set_t;
175 spatial_group_set_t mSpatialGroups;
176
177 //things that might be occluded
178 std::queue<LLSpatialGroup*> mOcclusionQueue;
179
180 //things awaiting query
181 std::queue<LLSpatialGroup*> mQueryQueue;
182
183 std::vector<LLGLuint> mOcclusionQueries;
184
185public:
186 LLSpatialGroup::OctreeNode* mOctree;
187
188 //things that are occluded
189 std::vector<LLSpatialGroup*> mOccludedList;
190
191 std::queue<LLSpatialGroup*> mReshadowQueue;
192
193};
194
195// class for creating bridges between spatial partitions
196class LLSpatialBridge : public LLDrawable, public LLSpatialPartition
197{
198public:
199 LLSpatialBridge(LLDrawable* root);
200 virtual ~LLSpatialBridge();
201
202 virtual BOOL isSpatialBridge() const { return TRUE; }
203
204 virtual void updateSpatialExtents();
205 virtual void updateBinRadius();
206 virtual void setVisible(LLCamera& camera_in, std::vector<LLDrawable*>* results = NULL, BOOL for_select = FALSE);
207 virtual void updateDistance(LLCamera& camera_in);
208 virtual void makeActive();
209 virtual void makeStatic();
210 virtual void move(LLDrawable *drawablep, LLSpatialGroup *curp, BOOL immediate = FALSE);
211 virtual BOOL updateMove();
212 virtual void shiftPos(const LLVector3& vec);
213 virtual void cleanupReferences();
214 virtual LLSpatialPartition* asPartition() { return this; }
215 LLCamera transformCamera(LLCamera& camera);
216
217 LLDrawable* mDrawable;
218};
219
220extern const F32 SG_BOX_SIDE;
221extern const F32 SG_BOX_OFFSET;
222extern const F32 SG_BOX_RAD;
223
224extern const F32 SG_OBJ_SIDE;
225extern const F32 SG_MAX_OBJ_RAD;
226
227#endif //LL_LLSPATIALPARTITION_H
228