00001
00032 #ifndef LL_LLVIEWERREGION_H
00033 #define LL_LLVIEWERREGION_H
00034
00035
00036
00037 #include <string>
00038
00039 #include "lldarray.h"
00040 #include "llwind.h"
00041 #include "llcloud.h"
00042 #include "llstat.h"
00043 #include "v3dmath.h"
00044 #include "llhost.h"
00045 #include "llstring.h"
00046 #include "llregionflags.h"
00047 #include "llptrskipmap.h"
00048 #include "lluuid.h"
00049 #include "lldatapacker.h"
00050 #include "llvocache.h"
00051
00052
00053 #define LAND 1
00054 #define WATER 2
00055 const U32 MAX_OBJECT_CACHE_ENTRIES = 10000;
00056
00057
00058 class LLEventPoll;
00059 class LLVLComposition;
00060 class LLViewerObject;
00061 class LLMessageSystem;
00062 class LLNetMap;
00063 class LLViewerParcelOverlay;
00064 class LLSurface;
00065 class LLVOCache;
00066 class LLVOCacheEntry;
00067
00068 class LLViewerRegion
00069 {
00070 public:
00071 LLViewerRegion(const U64 &handle,
00072 const LLHost &host,
00073 const U32 surface_grid_width,
00074 const U32 patch_grid_width,
00075 const F32 region_width_meters);
00076 ~LLViewerRegion();
00077
00078
00079 void loadCache();
00080
00081 void saveCache();
00082
00083 void sendMessage();
00084 void sendReliableMessage();
00085
00086 void setOriginGlobal(const LLVector3d &origin);
00087 void setAgentOffset(const LLVector3d &offset);
00088
00089 void setAllowDamage(BOOL b) { setFlags(b, REGION_FLAGS_ALLOW_DAMAGE); }
00090 void setAllowLandmark(BOOL b) { setFlags(b, REGION_FLAGS_ALLOW_LANDMARK); }
00091 void setAllowSetHome(BOOL b) { setFlags(b, REGION_FLAGS_ALLOW_SET_HOME); }
00092 void setResetHomeOnTeleport(BOOL b) { setFlags(b, REGION_FLAGS_RESET_HOME_ON_TELEPORT); }
00093 void setSunFixed(BOOL b) { setFlags(b, REGION_FLAGS_SUN_FIXED); }
00094 void setBlockFly(BOOL b) { setFlags(b, REGION_FLAGS_BLOCK_FLY); }
00095 void setAllowDirectTeleport(BOOL b) { setFlags(b, REGION_FLAGS_ALLOW_DIRECT_TELEPORT); }
00096
00097
00098 inline BOOL getAllowDamage() const;
00099 inline BOOL getAllowLandmark() const;
00100 inline BOOL getAllowSetHome() const;
00101 inline BOOL getResetHomeOnTeleport() const;
00102 inline BOOL getSunFixed() const;
00103 inline BOOL getBlockFly() const;
00104 inline BOOL getAllowDirectTeleport() const;
00105 inline BOOL isPrelude() const;
00106 inline BOOL getAllowTerraform() const;
00107 inline BOOL getRestrictPushObject() const;
00108
00109 void setWaterHeight(F32 water_level);
00110 F32 getWaterHeight() const;
00111
00112 void setBillableFactor(F32 billable_factor) { mBillableFactor = billable_factor; }
00113 F32 getBillableFactor() const { return mBillableFactor; }
00114
00115
00116
00117 U32 getMaxTasks() const { return mMaxTasks; }
00118 void setMaxTasks(U32 max_tasks) { mMaxTasks = max_tasks; }
00119
00120
00121
00122 S32 renderPropertyLines();
00123
00124
00125
00126 void dirtyHeights();
00127
00128 LLViewerParcelOverlay *getParcelOverlay() const
00129 { return mParcelOverlay; }
00130
00131 void setRegionFlags(U32 flags);
00132 U32 getRegionFlags() const { return mRegionFlags; }
00133
00134 void setTimeDilation(F32 time_dilation);
00135 F32 getTimeDilation() const { return mTimeDilation; }
00136
00137
00138 const LLVector3d &getOriginGlobal() const { return mOriginGlobal; }
00139 LLVector3 getOriginAgent() const;
00140
00141
00142 const LLVector3d &getCenterGlobal() const { return mCenterGlobal; }
00143 LLVector3 getCenterAgent() const;
00144
00145 void setRegionNameAndZone(const char* name_and_zone);
00146 const LLString& getName() const { return mName; }
00147 const LLString& getZoning() const { return mZoning; }
00148
00149 void setOwner(const LLUUID& owner_id) { mOwnerID = owner_id; }
00150 const LLUUID& getOwner() const { return mOwnerID; }
00151
00152
00153 void setIsEstateManager(BOOL b) { mIsEstateManager = b; }
00154 BOOL isEstateManager() const { return mIsEstateManager; }
00155 BOOL canManageEstate() const;
00156
00157 void setSimAccess(U8 sim_access) { mSimAccess = sim_access; }
00158 U8 getSimAccess() const { return mSimAccess; }
00159 const char* getSimAccessString() const;
00160
00161
00162 static std::string regionFlagsToString(U32 flags);
00163
00164
00165 static const char* accessToString(U8 access);
00166
00167 static U8 stringToAccess(const char* access_str);
00168
00169
00170 static const char* accessToShortString(U8 access);
00171
00172
00173
00174 static void processRegionInfo(LLMessageSystem* msg, void**);
00175
00176 void setCacheID(const LLUUID& id) { mCacheID = id; }
00177
00178 F32 getWidth() const { return mWidth; }
00179
00180 BOOL idleUpdate(F32 max_update_time);
00181
00182
00183
00184 void forceUpdate();
00185
00186 void connectNeighbor(LLViewerRegion *neighborp, U32 direction);
00187
00188 void updateNetStats();
00189
00190 U32 getPacketsLost() const;
00191
00192
00193 void setSeedCapability(const std::string& url);
00194 void setCapability(const std::string& name, const std::string& url);
00195 std::string getCapability(const std::string& name) const;
00196 void logActiveCapabilities() const;
00197
00198 const LLHost &getHost() const { return mHost; }
00199 const U64 &getHandle() const { return mHandle; }
00200
00201 LLSurface &getLand() const { return *mLandp; }
00202
00203
00204 const LLUUID& getRegionID() const { return mRegionID; }
00205 void setRegionID(const LLUUID& region_id) { mRegionID = region_id; }
00206
00207 BOOL pointInRegionGlobal(const LLVector3d &point_global) const;
00208 LLVector3 getPosRegionFromGlobal(const LLVector3d &point_global) const;
00209 LLVector3 getPosRegionFromAgent(const LLVector3 &agent_pos) const;
00210 LLVector3 getPosAgentFromRegion(const LLVector3 ®ion_pos) const;
00211 LLVector3d getPosGlobalFromRegion(const LLVector3 &offset) const;
00212
00213 LLVLComposition *getComposition() const { return mCompositionp; }
00214 F32 getCompositionXY(const S32 x, const S32 y) const;
00215
00216 BOOL isOwnedSelf(const LLVector3& pos);
00217
00218
00219 BOOL isOwnedGroup(const LLVector3& pos);
00220
00221
00222 void updateCoarseLocations(LLMessageSystem* msg);
00223
00224 F32 getLandHeightRegion(const LLVector3& region_pos);
00225
00226 LLString getInfoString();
00227
00228
00229 void cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp);
00230 LLDataPacker *getDP(U32 local_id, U32 crc);
00231 void requestCacheMisses();
00232 void addCacheMissFull(const U32 local_id);
00233
00234 void dumpCache();
00235
00236 void unpackRegionHandshake();
00237
00238 void calculateCenterGlobal();
00239 void calculateCameraDistance();
00240
00241 friend std::ostream& operator<<(std::ostream &s, const LLViewerRegion ®ion);
00242
00243
00244 U32 getNetDetailsForLCD();
00245
00246 public:
00247 struct CompareDistance
00248 {
00249 bool operator()(const LLViewerRegion* const& lhs, const LLViewerRegion* const& rhs)
00250 {
00251 return lhs->mCameraDistanceSquared < rhs->mCameraDistanceSquared;
00252 }
00253 };
00254
00255 protected:
00256 void disconnectAllNeighbors();
00257 void initStats();
00258 void setFlags(BOOL b, U32 flags);
00259
00260 public:
00261 LLWind mWind;
00262 LLCloudLayer mCloudLayer;
00263 LLViewerParcelOverlay *mParcelOverlay;
00264
00265 BOOL mAlive;
00266
00267 LLStat mBitStat;
00268 LLStat mPacketsStat;
00269 LLStat mPacketsLostStat;
00270
00271
00272
00273
00274
00275
00276 LLDynamicArray<U32> mMapAvatars;
00277 LLDynamicArray<LLUUID> mMapAvatarIDs;
00278
00279 protected:
00280
00281 LLSurface* mLandp;
00282
00283
00284 LLVector3d mOriginGlobal;
00285 LLVector3d mCenterGlobal;
00286 F32 mWidth;
00287
00288 U64 mHandle;
00289 LLHost mHost;
00290
00291
00292 LLUUID mRegionID;
00293
00294 F32 mTimeDilation;
00295
00296
00297 LLString mName;
00298 LLString mZoning;
00299
00300
00301 LLUUID mOwnerID;
00302
00303
00304 BOOL mIsEstateManager;
00305
00306
00307 LLTimer mLastNetUpdate;
00308 U32 mPacketsIn;
00309 U32 mBitsIn;
00310 U32 mLastBitsIn;
00311 U32 mLastPacketsIn;
00312 U32 mPacketsOut;
00313 U32 mLastPacketsOut;
00314 S32 mPacketsLost;
00315 S32 mLastPacketsLost;
00316 U32 mPingDelay;
00317 F32 mDeltaTime;
00318
00319
00320 LLVLComposition *mCompositionp;
00321
00322 U32 mRegionFlags;
00323 U8 mSimAccess;
00324 F32 mBillableFactor;
00325 U32 mMaxTasks;
00326 F32 mCameraDistanceSquared;
00327
00328
00329
00330
00331 BOOL mCacheLoaded;
00332 LLPtrSkipMap<U32, LLVOCacheEntry *, 14> mCacheMap;
00333 LLVOCacheEntry mCacheStart;
00334 LLVOCacheEntry mCacheEnd;
00335 U32 mCacheEntriesCount;
00336 LLDynamicArray<U32> mCacheMissFull;
00337 LLDynamicArray<U32> mCacheMissCRC;
00338
00339
00340
00341
00342
00343 LLUUID mCacheID;
00344
00345 typedef std::map<std::string, std::string> CapabilityMap;
00346 CapabilityMap mCapabilities;
00347
00348 LLEventPoll* mEventPoll;
00349 };
00350
00351 inline BOOL LLViewerRegion::getAllowDamage() const
00352 {
00353 return ((mRegionFlags & REGION_FLAGS_ALLOW_DAMAGE) !=0);
00354 }
00355
00356 inline BOOL LLViewerRegion::getAllowLandmark() const
00357 {
00358 return ((mRegionFlags & REGION_FLAGS_ALLOW_LANDMARK) !=0);
00359 }
00360
00361 inline BOOL LLViewerRegion::getAllowSetHome() const
00362 {
00363 return ((mRegionFlags & REGION_FLAGS_ALLOW_SET_HOME) != 0);
00364 }
00365
00366 inline BOOL LLViewerRegion::getResetHomeOnTeleport() const
00367 {
00368 return ((mRegionFlags & REGION_FLAGS_RESET_HOME_ON_TELEPORT) !=0);
00369 }
00370
00371 inline BOOL LLViewerRegion::getSunFixed() const
00372 {
00373 return ((mRegionFlags & REGION_FLAGS_SUN_FIXED) !=0);
00374 }
00375
00376 inline BOOL LLViewerRegion::getBlockFly() const
00377 {
00378 return ((mRegionFlags & REGION_FLAGS_BLOCK_FLY) !=0);
00379 }
00380
00381 inline BOOL LLViewerRegion::getAllowDirectTeleport() const
00382 {
00383 return ((mRegionFlags & REGION_FLAGS_ALLOW_DIRECT_TELEPORT) !=0);
00384 }
00385
00386 inline BOOL LLViewerRegion::isPrelude() const
00387 {
00388 return is_prelude( mRegionFlags );
00389 }
00390
00391 inline BOOL LLViewerRegion::getAllowTerraform() const
00392 {
00393 return ((mRegionFlags & REGION_FLAGS_BLOCK_TERRAFORM) == 0);
00394 }
00395
00396 inline BOOL LLViewerRegion::getRestrictPushObject() const
00397 {
00398 return ((mRegionFlags & REGION_FLAGS_RESTRICT_PUSHOBJECT) != 0);
00399 }
00400
00401 #endif
00402
00403