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