diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llviewerregion.h | |
parent | README.txt (diff) | |
download | meta-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/llviewerregion.h')
-rw-r--r-- | linden/indra/newview/llviewerregion.h | 367 |
1 files changed, 367 insertions, 0 deletions
diff --git a/linden/indra/newview/llviewerregion.h b/linden/indra/newview/llviewerregion.h new file mode 100644 index 0000000..76b9aaf --- /dev/null +++ b/linden/indra/newview/llviewerregion.h | |||
@@ -0,0 +1,367 @@ | |||
1 | /** | ||
2 | * @file llviewerregion.h | ||
3 | * @brief Description of the LLViewerRegion class. | ||
4 | * | ||
5 | * Copyright (c) 2001-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_LLVIEWERREGION_H | ||
29 | #define LL_LLVIEWERREGION_H | ||
30 | |||
31 | // A ViewerRegion is a class that contains a bunch of objects and surfaces | ||
32 | // that are in to a particular region. | ||
33 | #include <string> | ||
34 | |||
35 | #include "lldarray.h" | ||
36 | #include "llwind.h" | ||
37 | #include "llcloud.h" | ||
38 | #include "llstat.h" | ||
39 | #include "v3dmath.h" | ||
40 | #include "llhost.h" | ||
41 | #include "llstring.h" | ||
42 | #include "llregionflags.h" | ||
43 | #include "llptrskipmap.h" | ||
44 | #include "lluuid.h" | ||
45 | #include "lldatapacker.h" | ||
46 | #include "llvocache.h" | ||
47 | |||
48 | // Surface id's | ||
49 | #define LAND 1 | ||
50 | #define WATER 2 | ||
51 | const U32 MAX_OBJECT_CACHE_ENTRIES = 10000; | ||
52 | |||
53 | |||
54 | class LLEventPoll; | ||
55 | class LLVLComposition; | ||
56 | class LLViewerObject; | ||
57 | class LLMessageSystem; | ||
58 | class LLNetMap; | ||
59 | class LLViewerParcelOverlay; | ||
60 | class LLSurface; | ||
61 | class LLVOCache; | ||
62 | class LLVOCacheEntry; | ||
63 | |||
64 | class LLViewerRegion | ||
65 | { | ||
66 | public: | ||
67 | LLViewerRegion(const U64 &handle, | ||
68 | const LLHost &host, | ||
69 | const U32 surface_grid_width, | ||
70 | const U32 patch_grid_width, | ||
71 | const F32 region_width_meters); | ||
72 | ~LLViewerRegion(); | ||
73 | |||
74 | // Call this after you have the region name and handle. | ||
75 | void loadCache(); | ||
76 | |||
77 | void saveCache(); | ||
78 | |||
79 | void sendMessage(); // Send the current message to this region's simulator | ||
80 | void sendReliableMessage(); // Send the current message to this region's simulator | ||
81 | |||
82 | void setOriginGlobal(const LLVector3d &origin); | ||
83 | void setAgentOffset(const LLVector3d &offset); | ||
84 | |||
85 | void setAllowDamage(BOOL b); | ||
86 | void setAllowLandmark(BOOL b); | ||
87 | void setAllowSetHome(BOOL b); | ||
88 | void setResetHomeOnTeleport(BOOL b); | ||
89 | void setSunFixed(BOOL b); | ||
90 | void setBlockFly(BOOL b); | ||
91 | void setAllowDirectTeleport(BOOL b); | ||
92 | |||
93 | inline BOOL getAllowDamage() const; | ||
94 | inline BOOL getAllowLandmark() const; | ||
95 | inline BOOL getAllowSetHome() const; | ||
96 | inline BOOL getResetHomeOnTeleport() const; | ||
97 | inline BOOL getSunFixed() const; | ||
98 | inline BOOL getBlockFly() const; | ||
99 | inline BOOL getAllowDirectTeleport() const; | ||
100 | inline BOOL isPrelude() const; | ||
101 | inline BOOL getAllowTerraform() const; | ||
102 | inline BOOL getRestrictPushObject() const; | ||
103 | |||
104 | void setWaterHeight(F32 water_level); | ||
105 | F32 getWaterHeight() const; | ||
106 | |||
107 | void setBillableFactor(F32 billable_factor) { mBillableFactor = billable_factor; } | ||
108 | F32 getBillableFactor() const { return mBillableFactor; } | ||
109 | |||
110 | // Maximum number of primitives allowed, regardless of object | ||
111 | // bonus factor. | ||
112 | U32 getMaxTasks() const { return mMaxTasks; } | ||
113 | void setMaxTasks(U32 max_tasks) { mMaxTasks = max_tasks; } | ||
114 | |||
115 | // Draw lines in the dirt showing ownership. Return number of | ||
116 | // vertices drawn. | ||
117 | S32 renderPropertyLines(); | ||
118 | |||
119 | // Call this whenever you change the height data in the region. | ||
120 | // (Automatically called by LLSurfacePatch's update routine) | ||
121 | void dirtyHeights(); | ||
122 | |||
123 | LLViewerParcelOverlay *getParcelOverlay() const | ||
124 | { return mParcelOverlay; } | ||
125 | |||
126 | void setRegionFlags(U32 flags); | ||
127 | U32 getRegionFlags() const { return mRegionFlags; } | ||
128 | |||
129 | void setTimeDilation(F32 time_dilation); | ||
130 | F32 getTimeDilation() const { return mTimeDilation; } | ||
131 | |||
132 | // Origin height is at zero. | ||
133 | const LLVector3d &getOriginGlobal() const { return mOriginGlobal; } | ||
134 | LLVector3 getOriginAgent() const; | ||
135 | |||
136 | // Center is at the height of the water table. | ||
137 | const LLVector3d &getCenterGlobal() const { return mCenterGlobal; } | ||
138 | LLVector3 getCenterAgent() const; | ||
139 | |||
140 | void setRegionNameAndZone(const char* name_and_zone); | ||
141 | const LLString& getName() const { return mName; } | ||
142 | const LLString& getZoning() const { return mZoning; } | ||
143 | |||
144 | void setOwner(const LLUUID& owner_id) { mOwnerID = owner_id; } | ||
145 | const LLUUID& getOwner() const { return mOwnerID; } | ||
146 | |||
147 | // Is the current agent on the estate manager list for this region? | ||
148 | void setIsEstateManager(BOOL b) { mIsEstateManager = b; } | ||
149 | BOOL isEstateManager() const { return mIsEstateManager; } | ||
150 | BOOL canManageEstate() const; | ||
151 | |||
152 | void setSimAccess(U8 sim_access) { mSimAccess = sim_access; } | ||
153 | U8 getSimAccess() const { return mSimAccess; } | ||
154 | const char* getSimAccessString() const; | ||
155 | |||
156 | // Returns "Sandbox", "Expensive", etc. | ||
157 | static std::string regionFlagsToString(U32 flags); | ||
158 | |||
159 | // Returns "Mature", "PG", etc. | ||
160 | static const char* accessToString(U8 access); | ||
161 | |||
162 | static U8 stringToAccess(const char* access_str); | ||
163 | |||
164 | // Returns "M", "PG", etc. | ||
165 | static const char* accessToShortString(U8 access); | ||
166 | |||
167 | // helper function which just makes sure all interested parties | ||
168 | // can process the message. | ||
169 | static void processRegionInfo(LLMessageSystem* msg, void**); | ||
170 | |||
171 | void setCacheID(const LLUUID& id) { mCacheID = id; } | ||
172 | |||
173 | F32 getWidth() const { return mWidth; } | ||
174 | |||
175 | BOOL idleUpdate(LLTimer &timer, const F32 max_time); | ||
176 | |||
177 | // Like idleUpdate, but forces everything to complete regardless of | ||
178 | // how long it takes. | ||
179 | void forceUpdate(); | ||
180 | |||
181 | void connectNeighbor(LLViewerRegion *neighborp, U32 direction); | ||
182 | |||
183 | void updateNetStats(); | ||
184 | |||
185 | U32 getPacketsLost() const; | ||
186 | |||
187 | // Get/set named capability URLs for this region. | ||
188 | void setSeedCapability(const std::string& url); | ||
189 | void setCapability(const std::string& name, const std::string& url); | ||
190 | std::string getCapability(const std::string& name) const; | ||
191 | |||
192 | const LLHost &getHost() const { return mHost; } | ||
193 | const U64 &getHandle() const { return mHandle; } | ||
194 | |||
195 | LLSurface &getLand() const { return *mLandp; } | ||
196 | |||
197 | BOOL pointInRegionGlobal(const LLVector3d &point_global) const; | ||
198 | LLVector3 getPosRegionFromGlobal(const LLVector3d &point_global) const; | ||
199 | LLVector3 getPosRegionFromAgent(const LLVector3 &agent_pos) const; | ||
200 | LLVector3 getPosAgentFromRegion(const LLVector3 ®ion_pos) const; | ||
201 | LLVector3d getPosGlobalFromRegion(const LLVector3 &offset) const; | ||
202 | |||
203 | LLVLComposition *getComposition() const { return mCompositionp; } | ||
204 | F32 getCompositionXY(const S32 x, const S32 y) const; | ||
205 | |||
206 | BOOL isOwnedSelf(const LLVector3& pos); | ||
207 | |||
208 | // Owned by a group you belong to? (officer OR member) | ||
209 | BOOL isOwnedGroup(const LLVector3& pos); | ||
210 | |||
211 | // deal with map object updates in the world. | ||
212 | void updateCoarseLocations(LLMessageSystem* msg); | ||
213 | |||
214 | F32 getLandHeightRegion(const LLVector3& region_pos); | ||
215 | |||
216 | LLString getInfoString(); | ||
217 | |||
218 | // handle a full update message | ||
219 | void cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp); | ||
220 | LLDataPacker *getDP(U32 local_id, U32 crc); | ||
221 | void requestCacheMisses(); | ||
222 | void addCacheMissFull(const U32 local_id); | ||
223 | |||
224 | void dumpCache(); | ||
225 | |||
226 | void unpackRegionHandshake(); | ||
227 | |||
228 | void calculateCenterGlobal(); | ||
229 | |||
230 | friend std::ostream& operator<<(std::ostream &s, const LLViewerRegion ®ion); | ||
231 | |||
232 | protected: | ||
233 | void disconnectAllNeighbors(); | ||
234 | void initStats(); | ||
235 | |||
236 | public: | ||
237 | LLWind mWind; | ||
238 | LLCloudLayer mCloudLayer; | ||
239 | LLViewerParcelOverlay *mParcelOverlay; | ||
240 | |||
241 | BOOL mAlive; // can become false if circuit disconnects | ||
242 | |||
243 | LLStat mBitStat; | ||
244 | LLStat mPacketsStat; | ||
245 | LLStat mPacketsLostStat; | ||
246 | |||
247 | LLDynamicArray<U32> mMapAvatars; | ||
248 | |||
249 | protected: | ||
250 | // The surfaces and other layers | ||
251 | LLSurface* mLandp; | ||
252 | |||
253 | // Region geometry data | ||
254 | LLVector3d mOriginGlobal; // Location of southwest corner of region (meters) | ||
255 | LLVector3d mCenterGlobal; // Location of center in world space (meters) | ||
256 | F32 mWidth; // Width of region on a side (meters) | ||
257 | |||
258 | U64 mHandle; | ||
259 | LLHost mHost; | ||
260 | |||
261 | F32 mTimeDilation; // time dilation of physics simulation on simulator | ||
262 | |||
263 | // simulator name | ||
264 | LLString mName; | ||
265 | LLString mZoning; | ||
266 | |||
267 | // region/estate owner - usually null. | ||
268 | LLUUID mOwnerID; | ||
269 | |||
270 | // Is this agent on the estate managers list for this region? | ||
271 | BOOL mIsEstateManager; | ||
272 | |||
273 | // Network statistics for the region's circuit... | ||
274 | LLTimer mLastNetUpdate; | ||
275 | U32 mPacketsIn; | ||
276 | U32 mBitsIn; | ||
277 | U32 mLastBitsIn; | ||
278 | U32 mLastPacketsIn; | ||
279 | U32 mPacketsOut; | ||
280 | U32 mLastPacketsOut; | ||
281 | S32 mPacketsLost; | ||
282 | S32 mLastPacketsLost; | ||
283 | U32 mPingDelay; | ||
284 | F32 mDeltaTime; // Time since last measurement of lastPackets, Bits, etc | ||
285 | |||
286 | LLVLComposition *mCompositionp; // Composition layer for the surface | ||
287 | |||
288 | U32 mRegionFlags; // includes damage flags | ||
289 | U8 mSimAccess; | ||
290 | F32 mBillableFactor; | ||
291 | U32 mMaxTasks; // max prim count | ||
292 | |||
293 | // Maps local ids to cache entries. | ||
294 | // Regions can have order 10,000 objects, so assume | ||
295 | // a structure of size 2^14 = 16,000 | ||
296 | BOOL mCacheLoaded; | ||
297 | LLPtrSkipMap<U32, LLVOCacheEntry *, 14> mCacheMap; | ||
298 | LLVOCacheEntry mCacheStart; | ||
299 | LLVOCacheEntry mCacheEnd; | ||
300 | U32 mCacheEntriesCount; | ||
301 | LLDynamicArray<U32> mCacheMissFull; | ||
302 | LLDynamicArray<U32> mCacheMissCRC; | ||
303 | // time? | ||
304 | // LRU info? | ||
305 | |||
306 | // Cache ID is unique per-region, across renames, moving locations, | ||
307 | // etc. | ||
308 | LLUUID mCacheID; | ||
309 | |||
310 | typedef std::map<std::string, std::string> CapabilityMap; | ||
311 | CapabilityMap mCapabilities; | ||
312 | |||
313 | LLEventPoll* mEventPoll; | ||
314 | }; | ||
315 | |||
316 | inline BOOL LLViewerRegion::getAllowDamage() const | ||
317 | { | ||
318 | return ((mRegionFlags & REGION_FLAGS_ALLOW_DAMAGE) !=0); | ||
319 | } | ||
320 | |||
321 | inline BOOL LLViewerRegion::getAllowLandmark() const | ||
322 | { | ||
323 | return ((mRegionFlags & REGION_FLAGS_ALLOW_LANDMARK) !=0); | ||
324 | } | ||
325 | |||
326 | inline BOOL LLViewerRegion::getAllowSetHome() const | ||
327 | { | ||
328 | return ((mRegionFlags & REGION_FLAGS_ALLOW_SET_HOME) != 0); | ||
329 | } | ||
330 | |||
331 | inline BOOL LLViewerRegion::getResetHomeOnTeleport() const | ||
332 | { | ||
333 | return ((mRegionFlags & REGION_FLAGS_RESET_HOME_ON_TELEPORT) !=0); | ||
334 | } | ||
335 | |||
336 | inline BOOL LLViewerRegion::getSunFixed() const | ||
337 | { | ||
338 | return ((mRegionFlags & REGION_FLAGS_SUN_FIXED) !=0); | ||
339 | } | ||
340 | |||
341 | inline BOOL LLViewerRegion::getBlockFly() const | ||
342 | { | ||
343 | return ((mRegionFlags & REGION_FLAGS_BLOCK_FLY) !=0); | ||
344 | } | ||
345 | |||
346 | inline BOOL LLViewerRegion::getAllowDirectTeleport() const | ||
347 | { | ||
348 | return ((mRegionFlags & REGION_FLAGS_ALLOW_DIRECT_TELEPORT) !=0); | ||
349 | } | ||
350 | |||
351 | inline BOOL LLViewerRegion::isPrelude() const | ||
352 | { | ||
353 | return is_prelude( mRegionFlags ); | ||
354 | } | ||
355 | |||
356 | inline BOOL LLViewerRegion::getAllowTerraform() const | ||
357 | { | ||
358 | return ((mRegionFlags & REGION_FLAGS_BLOCK_TERRAFORM) == 0); | ||
359 | } | ||
360 | |||
361 | inline BOOL LLViewerRegion::getRestrictPushObject() const | ||
362 | { | ||
363 | return ((mRegionFlags & REGION_FLAGS_RESTRICT_PUSHOBJECT) != 0); | ||
364 | } | ||
365 | |||
366 | #endif | ||
367 | |||