llviewerregion.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853
  1. /**
  2. * @file llviewerregion.h
  3. * @brief Description of the LLViewerRegion class.
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, 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. #ifndef LL_LLVIEWERREGION_H
  33. #define LL_LLVIEWERREGION_H
  34. // A ViewerRegion is a class that contains a bunch of objects and surfaces
  35. // that are in to a particular region.
  36. #include <map>
  37. #include <set>
  38. #include <string>
  39. #include <vector>
  40. #include "boost/signals2.hpp"
  41. #include "llcorehttpheaders.h"
  42. #include "llcorehttpoptions.h"
  43. #include "llframetimer.h"
  44. #include "llhost.h"
  45. #include "llregionflags.h"
  46. #include "llstat.h"
  47. #include "llstring.h"
  48. #include "lluuid.h"
  49. #include "llwind.h"
  50. #include "llmatrix4.h"
  51. #include "llcloud.h"
  52. #include "llreflectionmapmanager.h"
  53. #include "llvocache.h"
  54. // Surface id's
  55. #define LAND 1
  56. #define WATER 2
  57. constexpr U32 MAX_OBJECT_CACHE_ENTRIES = 50000;
  58. // Region handshake flags
  59. constexpr U32 REGION_HANDSHAKE_SUPPORTS_SELF_APPEARANCE = 1U << 2;
  60. class LLBBox;
  61. class LLDrawable;
  62. class LLEventPoll;
  63. class LLMessageSystem;
  64. class LLSpatialGroup;
  65. class LLSpatialPartition;
  66. class LLSurface;
  67. class LLViewerObject;
  68. class LLViewerOctreeGroup;
  69. class LLViewerParcelOverlay;
  70. class LLVLComposition;
  71. class LLVOCache;
  72. class LLVOCacheEntry;
  73. class LLVOCachePartition;
  74. class LLViewerRegion
  75. {
  76. protected:
  77. LOG_CLASS(LLViewerRegion);
  78. public:
  79. // MUST MATCH THE ORDER OF DECLARATION IN CONSTRUCTOR
  80. typedef enum
  81. {
  82. PARTITION_HUD = 0,
  83. PARTITION_TERRAIN,
  84. PARTITION_VOIDWATER,
  85. PARTITION_WATER,
  86. PARTITION_TREE,
  87. PARTITION_PARTICLE,
  88. PARTITION_CLOUD,
  89. PARTITION_GRASS,
  90. PARTITION_VOLUME,
  91. PARTITION_BRIDGE,
  92. PARTITION_AVATAR,
  93. PARTITION_PUPPET,
  94. PARTITION_HUD_PARTICLE,
  95. PARTITION_VO_CACHE,
  96. PARTITION_NONE,
  97. NUM_PARTITIONS
  98. } eObjectPartitions;
  99. typedef boost::signals2::signal<void(const LLUUID& region_id)> caps_received_sig_t;
  100. typedef caps_received_sig_t::slot_type caps_received_cb_t;
  101. LLViewerRegion(const U64& handle, const LLHost& host,
  102. U32 surface_grid_width, U32 patch_grid_width,
  103. F32 region_width_meters);
  104. ~LLViewerRegion();
  105. // Sends the current message to this region's simulator
  106. void sendMessage();
  107. // Sends the current message to this region's simulator
  108. void sendReliableMessage();
  109. // Sends a EstateCovenantInfoRequest request message for this region.
  110. void sendEstateCovenantRequest();
  111. void setOriginGlobal(const LLVector3d& origin);
  112. void updateRenderMatrix();
  113. LL_INLINE void setAllowDamage(bool b) { setRegionFlag(REGION_FLAGS_ALLOW_DAMAGE, b); }
  114. LL_INLINE void setAllowLandmark(bool b) { setRegionFlag(REGION_FLAGS_ALLOW_LANDMARK, b); }
  115. LL_INLINE void setAllowSetHome(bool b) { setRegionFlag(REGION_FLAGS_ALLOW_SET_HOME, b); }
  116. LL_INLINE void setResetHomeOnTeleport(bool b) { setRegionFlag(REGION_FLAGS_RESET_HOME_ON_TELEPORT, b); }
  117. LL_INLINE void setSunFixed(bool b) { setRegionFlag(REGION_FLAGS_SUN_FIXED, b); }
  118. LL_INLINE void setAllowDirectTeleport(bool b) { setRegionFlag(REGION_FLAGS_ALLOW_DIRECT_TELEPORT, b); }
  119. LL_INLINE bool getAllowDamage() const { return (mRegionFlags & REGION_FLAGS_ALLOW_DAMAGE) != 0; }
  120. LL_INLINE bool getAllowLandmark() const { return (mRegionFlags & REGION_FLAGS_ALLOW_LANDMARK) != 0; }
  121. LL_INLINE bool getAllowSetHome() const { return (mRegionFlags & REGION_FLAGS_ALLOW_SET_HOME) != 0; }
  122. LL_INLINE bool getResetHomeOnTeleport() const { return (mRegionFlags & REGION_FLAGS_RESET_HOME_ON_TELEPORT) != 0; }
  123. LL_INLINE bool getSunFixed() const { return (mRegionFlags & REGION_FLAGS_SUN_FIXED) != 0; }
  124. LL_INLINE bool getBlockFly() const { return (mRegionFlags & REGION_FLAGS_BLOCK_FLY) != 0; }
  125. LL_INLINE bool getAllowDirectTeleport() const { return (mRegionFlags & REGION_FLAGS_ALLOW_DIRECT_TELEPORT) != 0; }
  126. LL_INLINE bool isPrelude() const { return is_prelude(mRegionFlags); }
  127. LL_INLINE bool getAllowTerraform() const { return (mRegionFlags & REGION_FLAGS_BLOCK_TERRAFORM) == 0; }
  128. LL_INLINE bool getRestrictPushObject() const { return (mRegionFlags & REGION_FLAGS_RESTRICT_PUSHOBJECT) != 0; }
  129. LL_INLINE bool getAllowEnvironmentOverride() const { return (mRegionFlags & REGION_FLAGS_ALLOW_ENVIRONMENT_OVERRIDE) != 0; }
  130. // Can become false if circuit disconnects
  131. LL_INLINE bool isAlive() { return mAlive; }
  132. void setWaterHeight(F32 water_level);
  133. F32 getWaterHeight() const;
  134. LL_INLINE bool isVoiceEnabled() const { return getRegionFlag(REGION_FLAGS_ALLOW_VOICE); }
  135. LL_INLINE void setBillableFactor(F32 billable_factor) { mBillableFactor = billable_factor; }
  136. LL_INLINE F32 getBillableFactor() const { return mBillableFactor; }
  137. // Maximum number of primitives allowed, regardless of object bonus factor.
  138. LL_INLINE U32 getMaxTasks() const { return mMaxTasks; }
  139. LL_INLINE void setMaxTasks(U32 max_tasks) { mMaxTasks = max_tasks; }
  140. // Draw lines in the dirt showing ownership. Return number of
  141. // vertices drawn.
  142. void renderPropertyLines() const;
  143. // 'scale' is in pixels_per_meter. 'color' is a pointer on a LLColor4
  144. void renderParcelBorders(F32 scale, const F32* color) const;
  145. // Returns true when at least one banned parcel got drawn
  146. bool renderBannedParcels(F32 scale, const F32* color) const;
  147. // Call this whenever you change the height data in the region.
  148. // (Automatically called by LLSurfacePatch's update routine)
  149. void dirtyHeights();
  150. LL_INLINE LLViewerParcelOverlay* getParcelOverlay() const
  151. {
  152. return mParcelOverlay;
  153. }
  154. LL_INLINE void setRegionFlag(U64 flag, bool on)
  155. {
  156. if (on)
  157. {
  158. mRegionFlags |= flag;
  159. }
  160. else
  161. {
  162. mRegionFlags &= ~flag;
  163. }
  164. }
  165. LL_INLINE bool getRegionFlag(U64 flag) const { return (mRegionFlags & flag) != 0; }
  166. LL_INLINE void setRegionFlags(U64 flags) { mRegionFlags = flags; }
  167. LL_INLINE U64 getRegionFlags() const { return mRegionFlags; }
  168. LL_INLINE void setRegionProtocol(U64 protocol, bool on)
  169. {
  170. if (on)
  171. {
  172. mRegionProtocols |= protocol;
  173. }
  174. else
  175. {
  176. mRegionProtocols &= ~protocol;
  177. }
  178. }
  179. bool getRegionProtocol(U64 protocol) const { return (mRegionProtocols & protocol) != 0; }
  180. LL_INLINE void setRegionProtocols(U64 protocols) { mRegionProtocols = protocols; }
  181. LL_INLINE U64 getRegionProtocols() const { return mRegionProtocols; }
  182. LL_INLINE void setTimeDilation(F32 time_dilation) { mTimeDilation = time_dilation; }
  183. LL_INLINE F32 getTimeDilation() const { return mTimeDilation; }
  184. // Origin height is at zero.
  185. LL_INLINE const LLVector3d& getOriginGlobal() const { return mOriginGlobal; }
  186. LLVector3 getOriginAgent() const;
  187. // Center is at the height of the water table.
  188. LL_INLINE const LLVector3d& getCenterGlobal() const { return mCenterGlobal; }
  189. LLVector3 getCenterAgent() const;
  190. void setRegionNameAndZone(const std::string& name_and_zone);
  191. LL_INLINE const std::string& getName() const { return mName; }
  192. LL_INLINE const std::string& getZoning() const { return mZoning; }
  193. LL_INLINE void setOwner(const LLUUID& owner_id) { mOwnerID = owner_id; }
  194. LL_INLINE const LLUUID& getOwner() const { return mOwnerID; }
  195. // Is the current agent on the estate manager list for this region?
  196. LL_INLINE void setIsEstateManager(bool b) { mIsEstateManager = b; }
  197. LL_INLINE bool isEstateManager() const { return mIsEstateManager; }
  198. bool canManageEstate() const;
  199. LL_INLINE void setSimAccess(U8 sim_access) { mSimAccess = sim_access; }
  200. LL_INLINE U8 getSimAccess() const { return mSimAccess; }
  201. LL_INLINE const std::string getSimAccessString() const { return accessToString(mSimAccess); }
  202. // Homestead-related getters; there are no setters as nobody should be
  203. // setting them other than the individual message handler which is a member
  204. LL_INLINE S32 getSimClassID() const { return mClassID; }
  205. LL_INLINE S32 getSimCPURatio() const { return mCPURatio; }
  206. LL_INLINE const std::string& getSimColoName() const { return mColoName; }
  207. LL_INLINE const std::string& getSimProductSKU() const { return mProductSKU; }
  208. LL_INLINE const std::string& getSimProductName() const { return mProductName; }
  209. // Returns translated version of "Mature", "PG", "Adult", etc.
  210. static std::string accessToString(U8 sim_access);
  211. // Returns "M", "PG", "A" etc.
  212. static std::string accessToShortString(U8 sim_access);
  213. // Returns the maturity rating icon name for sim_access
  214. static const std::string& getMaturityIconName(U8 sim_access);
  215. // Used by LLVOCache once the cache has been read, to populate the cache
  216. // and signal that the handshake reply can be sent. HB
  217. static void cacheLoadedCallback(U64 region_handle,
  218. LLVOCacheEntry::map_t* cachep,
  219. LLVOCacheEntry::emap_t* extrasp);
  220. // Callback for the "RegionInfo" sim message. Fills up LLRegionInfoModel
  221. // variable members and calls interested parties (hard-coded "observers").
  222. static void processRegionInfo(LLMessageSystem* msg, void**);
  223. // Check if the viewer camera is static
  224. static bool isViewerCameraStatic();
  225. static void calcNewObjectCreationThrottle();
  226. LL_INLINE void setCacheID(const LLUUID& id) { mCacheID = id; }
  227. // Variable region size support
  228. LL_INLINE F32 getWidth() const { return mWidth; }
  229. LL_INLINE S32 getLastUpdate() const { return mLastUpdate; }
  230. void idleUpdate(F32 max_update_time);
  231. void lightIdleUpdate();
  232. bool addVisibleGroup(LLViewerOctreeGroup* group);
  233. void addVisibleChildCacheEntry(LLVOCacheEntry* parent,
  234. LLVOCacheEntry* child);
  235. void addActiveCacheEntry(LLVOCacheEntry* entry);
  236. void removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* drawablep);
  237. // Physically delete the cache entry
  238. void killCacheEntry(U32 local_id);
  239. // Updates the land surface and parcel.
  240. void forceUpdate();
  241. void connectNeighbor(LLViewerRegion* neighborp, U32 direction);
  242. void updateNetStats();
  243. U32 getPacketsLost() const;
  244. LL_INLINE U32 getHttpResponderID() const { return mHttpResponderID; }
  245. // Get/set named capability URLs for this region.
  246. void setSeedCapability(const std::string& url);
  247. void setCapability(const std::string& name, const std::string& url);
  248. const std::string& getCapability(const char* name) const;
  249. const std::string& getTextureUrl() const;
  250. LL_INLINE const std::string& getViewerAssetUrl() const { return mViewerAssetUrl; }
  251. const std::string& getMeshUrl(bool* is_mesh2 = NULL) const;
  252. LL_INLINE size_t getCapabilitiesCount() const { return mCapabilities.size(); }
  253. // Has region received its final (not seed) capability list ?
  254. LL_INLINE bool capabilitiesReceived() const { return mCapabilitiesState == CAPABILITIES_STATE_RECEIVED; }
  255. void setCapabilitiesReceived(bool received);
  256. LL_INLINE void setCapabilitiesError() { mCapabilitiesState = CAPABILITIES_STATE_ERROR; }
  257. LL_INLINE bool capabilitiesError() const { return mCapabilitiesState == CAPABILITIES_STATE_ERROR; }
  258. LL_INLINE U32 getNumSeedCapRetries() const { return mSeedCapAttempts; }
  259. void onCapabilitiesReceived();
  260. boost::signals2::connection setCapsReceivedCB(const caps_received_cb_t& cb);
  261. boost::signals2::connection setFeaturesReceivedCB(const caps_received_cb_t& cb);
  262. static bool isSpecialCapabilityName(const std::string& name);
  263. void logActiveCapabilities() const;
  264. // When the "InterestList" capability is available, this method switches
  265. // the interest list mode to 360° or default for 'this' region, whenever it
  266. // happens to be the current agent region, and based on the corresponding
  267. // debug setting. Returns true on success to call the capability. When
  268. // set_default is true, the default interest list mode is forced (used when
  269. // leaving a region for another with 360° mode debug setting on).
  270. bool setInterestListMode(bool set_default = false) const;
  271. std::string getSimHostName();
  272. LL_INLINE const LLHost& getHost() const { return mHost; }
  273. LL_INLINE U64 getHandle() const { return mHandle; }
  274. LL_INLINE LLSurface& getLand() const { return *mLandp; }
  275. // Gets the region Id
  276. LL_INLINE const LLUUID& getRegionID() const { return mRegionID; }
  277. // Sets the region Id
  278. LL_INLINE void setRegionID(const LLUUID& region_id) { mRegionID = region_id; }
  279. // Returns a string with the region name (or the sim host IP when the
  280. // region name is empty) and, when not null, the region Id enclosed in
  281. // parentheses. Useful for log messages... HB
  282. std::string getIdentity() const;
  283. bool pointInRegionGlobal(const LLVector3d& point_global) const;
  284. LL_INLINE LLVector3 getPosRegionFromGlobal(const LLVector3d& pos) const
  285. {
  286. return LLVector3(pos - mOriginGlobal);
  287. }
  288. LL_INLINE LLVector3d getPosGlobalFromRegion(const LLVector3& offset) const
  289. {
  290. return LLVector3d(offset) + mOriginGlobal;
  291. }
  292. LL_INLINE LLVector3 getPosRegionFromAgent(const LLVector3& pos_agent) const
  293. {
  294. return pos_agent - getOriginAgent();
  295. }
  296. LLVector3 getPosAgentFromRegion(const LLVector3& region_pos) const;
  297. LL_INLINE LLVLComposition* getComposition() const { return mCompositionp; }
  298. F32 getCompositionXY(S32 x, S32 y) const;
  299. bool isOwnedSelf(const LLVector3& pos);
  300. // Owned by a group you belong to (as officer OR member) ?
  301. bool isOwnedGroup(const LLVector3& pos);
  302. // Deals with map object updates in the world.
  303. void updateCoarseLocations(LLMessageSystem* msg);
  304. F32 getLandHeightRegion(const LLVector3& region_pos);
  305. LL_INLINE U8 getCentralBakeVersion() { return mCentralBakeVersion; }
  306. void getInfo(LLSD& info);
  307. LL_INLINE bool getFeaturesReceived() const { return mFeaturesReceived; }
  308. LL_INLINE bool meshRezEnabled() const { return mMeshRezEnabled; }
  309. LL_INLINE bool meshUploadEnabled() const { return mMeshUploadEnabled; }
  310. LL_INLINE bool physicsShapeTypes() const { return mPhysicsShapeTypes; }
  311. LL_INLINE bool hasDynamicPathfinding() const { return mDynamicPathfinding; }
  312. LL_INLINE bool dynamicPathfindingEnabled() const { return mDynamicPathfindingEnabled; }
  313. LL_INLINE bool bakesOnMeshEnabled() const { return mBakesOnMeshEnabled; }
  314. LL_INLINE bool isOSExportPermSupported() const { return mOSExportPermSupported; }
  315. LL_INLINE bool avatarHoverHeightEnabled() const { return mHoverHeigthFeature; }
  316. LL_INLINE U32 getWhisperRange() const { return mWhisperRange; }
  317. LL_INLINE U32 getChatRange() const { return mChatRange; }
  318. LL_INLINE U32 getShoutRange() const { return mShoutRange; }
  319. LL_INLINE const LLSD& getSimulatorFeatures() { return mSimulatorFeatures; }
  320. void setSimulatorFeatures(const LLSD& info);
  321. typedef enum
  322. {
  323. CACHE_MISS_TYPE_FULL = 0,
  324. CACHE_MISS_TYPE_CRC,
  325. CACHE_MISS_TYPE_NONE
  326. } eCacheMissType;
  327. typedef enum
  328. {
  329. CACHE_UPDATE_DUPE = 0,
  330. CACHE_UPDATE_CHANGED,
  331. CACHE_UPDATE_ADDED,
  332. CACHE_UPDATE_REPLACED
  333. } eCacheUpdateResult;
  334. // Handles a full update message
  335. eCacheUpdateResult cacheFullUpdate(LLDataPackerBinaryBuffer& dp,
  336. U32 flags);
  337. LL_INLINE eCacheUpdateResult cacheFullUpdate(LLViewerObject* objectp,
  338. LLDataPackerBinaryBuffer& dp,
  339. U32 flags)
  340. {
  341. return cacheFullUpdate(dp, flags);
  342. }
  343. void cacheFullUpdateGLTFOverride(const LLGLTFOverrideCacheEntry& data);
  344. LLVOCacheEntry* getCacheEntryForOctree(U32 local_id);
  345. LLVOCacheEntry* getCacheEntry(U32 local_id, bool valid = true);
  346. bool probeCache(U32 local_id, U32 crc, U32 flags, U8& cache_miss_type);
  347. void requestCacheMisses();
  348. void addCacheMissFull(U32 local_id);
  349. // Updates object cache if the object receives a full-update or terse
  350. // update:
  351. LLViewerObject* updateCacheEntry(U32 local_id, LLViewerObject* objectp);
  352. void findOrphans(U32 parent_id);
  353. void clearCachedVisibleObjects();
  354. void dumpCache();
  355. void unpackRegionHandshake();
  356. void calculateCenterGlobal();
  357. void calculateCameraDistance();
  358. friend std::ostream& operator<<(std::ostream& s, const LLViewerRegion& region);
  359. LL_INLINE U32 getNumOfVisibleGroups() const { return mVisibleGroups.size(); }
  360. LL_INLINE U32 getNumOfActiveCachedObjects() const { return mActiveSet.size(); }
  361. LLSpatialPartition* getSpatialPartition(U32 type);
  362. LLVOCachePartition* getVOCachePartition();
  363. bool objectIsReturnable(const LLVector3& pos,
  364. const std::vector<LLBBox>& boxes) const;
  365. bool childrenObjectReturnable(const std::vector<LLBBox>& boxes) const;
  366. void getNeighboringRegions(std::vector<LLViewerRegion*>& regions);
  367. void getNeighboringRegionsStatus(std::vector<S32>& regions);
  368. // Implements the materials capability throttle
  369. LL_INLINE bool materialsCapThrottled() const
  370. {
  371. return !mMaterialsCapThrottleTimer.hasExpired();
  372. }
  373. LL_INLINE void resetMaterialsCapThrottle()
  374. {
  375. mMaterialsCapThrottleTimer.resetWithExpiry(mRenderMaterialsCapability);
  376. }
  377. LL_INLINE U32 getMaxMaterialsPerTransaction() const
  378. {
  379. return mMaxMaterialsPerTransaction;
  380. }
  381. LL_INLINE S32 getMaxTextureSize() const { return mMaxTextureSize; }
  382. LL_INLINE bool hasPBRTerrain() const { return mHasPBRTerrain; }
  383. LL_INLINE bool isGLTFEnabled() const { return mGLTFEnabled; }
  384. void removeFromCreatedList(U32 local_id);
  385. void addToCreatedList(U32 local_id);
  386. LL_INLINE bool isPaused() const { return mPaused; }
  387. LL_INLINE static bool isNewObjectCreationThrottleDisabled()
  388. {
  389. return sNewObjectCreationThrottle < 0;
  390. }
  391. // Rebuilds the reflection probe list
  392. void updateReflectionProbes();
  393. void dumpSettings();
  394. bool isEventPollInFlight() const;
  395. F32 getEventPollRequestAge() const;
  396. private:
  397. // Call this after you have the region name and handle.
  398. void loadObjectCache();
  399. void saveObjectCache();
  400. void sendHandshakeReply();
  401. void addToVOCacheTree(LLVOCacheEntry* entry);
  402. LLViewerObject* addNewObject(LLVOCacheEntry* entry);
  403. void killObject(LLVOCacheEntry* entry,
  404. std::vector<LLDrawable*>& delete_list);
  405. void removeFromVOCacheTree(LLVOCacheEntry* entry);
  406. // Physically deletes the cache entry:
  407. void killCacheEntry(LLVOCacheEntry* entry, bool for_rendering = false);
  408. void killInvisibleObjects(F32 max_time);
  409. void createVisibleObjects(F32 max_time);
  410. void updateVisibleEntries();
  411. void addCacheMiss(U32 id, LLViewerRegion::eCacheMissType miss_type);
  412. void decodeBoundingInfo(LLVOCacheEntry* entry);
  413. bool isNonCacheableObjectCreated(U32 local_id);
  414. static void buildCapabilityNames(LLSD& capability_names);
  415. static void requestBaseCapabilitiesCoro(U64 region_handle);
  416. static void requestBaseCapabilitiesCompleteCoro(U64 region_handle);
  417. static void requestSimulatorFeatureCoro(std::string url,
  418. U64 region_handle);
  419. public:
  420. void loadCacheMiscExtras(LLViewerObject* objp);
  421. void applyCacheMiscExtras(LLViewerObject* objp);
  422. struct CompareDistance
  423. {
  424. LL_INLINE bool operator()(const LLViewerRegion* const& lhs,
  425. const LLViewerRegion* const& rhs) const
  426. {
  427. return lhs->mCameraDistanceSquared < rhs->mCameraDistanceSquared;
  428. }
  429. };
  430. struct CompareRegionByLastUpdate
  431. {
  432. LL_INLINE bool operator()(const LLViewerRegion* const& lhs,
  433. const LLViewerRegion* const& rhs) const
  434. {
  435. S32 lpa = lhs->getLastUpdate();
  436. S32 rpa = rhs->getLastUpdate();
  437. // Small (older) mLastUpdate first
  438. if (lpa < rpa)
  439. {
  440. return true;
  441. }
  442. if (lpa > rpa)
  443. {
  444. return false;
  445. }
  446. return lhs < rhs;
  447. }
  448. };
  449. typedef std::set<LLViewerRegion*, CompareRegionByLastUpdate> prio_list_t;
  450. // *HACK: allow public access to these two methods in order to deal with
  451. // long teleports causing octree insertion failures (these are called from
  452. // the process_agent_movement_complete() function in llviewermessage.cpp).
  453. void initPartitions();
  454. void deletePartitions();
  455. protected:
  456. void disconnectAllNeighbors();
  457. void initStats();
  458. public:
  459. LLMatrix4 mRenderMatrix;
  460. LLViewerParcelOverlay* mParcelOverlay;
  461. // These vectors are maintained in parallel. Ideally they would be combined
  462. // into a single array of an aggregate data type but for compatibility with
  463. // the old messaging system in which the previous message only sends and
  464. // parses the positions stored in the first array, they are maintained
  465. // separately until we stop supporting the old CoarseLocationUpdate message
  466. std::vector<U32> mMapAvatars;
  467. uuid_vec_t mMapAvatarIDs;
  468. LLWind mWind;
  469. LLCloudLayer mCloudLayer;
  470. LLStat mBitStat;
  471. LLStat mPacketsStat;
  472. LLStat mPacketsLostStat;
  473. F32 mFirstWindLayerReceivedTime;
  474. bool mGotClouds;
  475. static S32 sLastCameraUpdated;
  476. static bool sVOCacheCullingEnabled; // vo cache culling enabled or not.
  477. private:
  478. LLEventPoll* mEventPoll;
  479. // The surfaces and other layers
  480. LLSurface* mLandp;
  481. // Composition layer for the surface
  482. LLVLComposition* mCompositionp;
  483. // The materials capability throttle
  484. LLFrameTimer mMaterialsCapThrottleTimer;
  485. // Simulator name
  486. std::string mName;
  487. std::string mZoning;
  488. // Region geometry data
  489. // Location of southwest corner of region (meters)
  490. LLVector3d mOriginGlobal;
  491. // Location of center in world space (meters)
  492. LLVector3d mCenterGlobal;
  493. // Variable region size support; width of region on a side (meters)
  494. F32 mWidth;
  495. // Simulator host data
  496. U64 mHandle;
  497. LLHost mHost;
  498. std::string mHostName; // Taken from sim features data
  499. // The unique ID for this region.
  500. LLUUID mRegionID;
  501. // Region/estate owner - usually null.
  502. LLUUID mOwnerID;
  503. // Cache ID is unique per-region, across renames, moving locations, etc.
  504. LLUUID mCacheID;
  505. F32 mCreationTime;
  506. // Time dilation of physics simulation on simulator
  507. F32 mTimeDilation;
  508. S32 mLastUpdate; // Last call to idleUpdate()
  509. LLVOCacheEntry* mLastVisitedEntry;
  510. U32 mInvisibilityCheckHistory;
  511. // Network statistics for the region's circuit...
  512. LLTimer mLastNetUpdate;
  513. U32 mPacketsIn;
  514. U32 mBitsIn;
  515. U32 mLastBitsIn;
  516. U32 mLastPacketsIn;
  517. U32 mPacketsOut;
  518. U32 mLastPacketsOut;
  519. S32 mPacketsLost;
  520. S32 mLastPacketsLost;
  521. U32 mPingDelay;
  522. // Time since last measurement of lastPackets, Bits, etc
  523. F32 mDeltaTime;
  524. // Misc
  525. U64 mRegionFlags; // Includes damage flags
  526. // Protocols supported by this region
  527. U64 mRegionProtocols;
  528. F32 mBillableFactor;
  529. U32 mMaxTasks; // Max prim count
  530. F32 mCameraDistanceSquared; // Updated once per frame
  531. U8 mSimAccess;
  532. U8 mCentralBakeVersion;
  533. LLVOCacheEntry::emap_t mGLTFOverrides; // For GLTF materials
  534. // Maps local ids to cache entries.
  535. // Regions can have order 10,000 objects, so assume
  536. // a structure of size 2^14 = 16,384
  537. LLVOCacheEntry::map_t mCacheMap; // All cached entries
  538. LLVOCacheEntry::set_t mActiveSet; // All active entries
  539. // Entries waiting for LLDrawable to be generated:
  540. LLVOCacheEntry::set_t mWaitingSet;
  541. LLVOCachePartition* mVOCachePartition;
  542. // Must-be-created visible entries wait for objects creation:
  543. LLVOCacheEntry::set_t mVisibleEntries;
  544. // Transient list storing sorted visible entries waiting for object
  545. // creation:
  546. LLVOCacheEntry::prio_list_t mWaitingList;
  547. // Visible groups
  548. typedef std::vector<LLPointer<LLViewerOctreeGroup> > visible_groups_vec_t;
  549. visible_groups_vec_t mVisibleGroups;
  550. // List of local ids of all non-cacheable objects:
  551. typedef fast_hset<U32> non_cacheable_list_t;
  552. non_cacheable_list_t mNonCacheableCreatedList;
  553. // List of reflection maps being managed by this region.
  554. LLReflectionMapManager::prmap_vec_t mReflectionMaps;
  555. typedef std::map<std::string, std::string> capability_map_t;
  556. capability_map_t mCapabilities;
  557. U32 mSeedCapAttempts;
  558. U32 mHttpResponderID;
  559. caps_received_sig_t mCapabilitiesReceivedSignal;
  560. caps_received_sig_t mFeaturesReceivedSignal;
  561. typedef enum
  562. {
  563. CAPABILITIES_STATE_INIT = 0,
  564. CAPABILITIES_STATE_ERROR,
  565. CAPABILITIES_STATE_RECEIVED
  566. } eCababilitiesState;
  567. eCababilitiesState mCapabilitiesState;
  568. U32 mPendingHandshakes;
  569. bool mFeaturesReceived;
  570. // Is this agent on the estate managers list for this region ?
  571. bool mIsEstateManager;
  572. bool mCacheLoading;
  573. bool mCacheLoaded;
  574. bool mCacheDirty;
  575. // Can become false if circuit disconnects
  576. bool mAlive;
  577. bool mDead;
  578. bool mPaused;
  579. // Variables mirroring the data from mSimulatorFeatures, for quick access
  580. bool mMeshRezEnabled;
  581. bool mMeshUploadEnabled;
  582. bool mPhysicsShapeTypes;
  583. bool mDynamicPathfinding;
  584. bool mDynamicPathfindingEnabled;
  585. bool mBakesOnMeshEnabled;
  586. bool mOSExportPermSupported;
  587. bool mHoverHeigthFeature;
  588. bool mHasPBRTerrain;
  589. bool mGLTFEnabled;
  590. U32 mWhisperRange;
  591. U32 mChatRange;
  592. U32 mShoutRange;
  593. U32 mMaxMaterialsPerTransaction;
  594. F32 mRenderMaterialsCapability;
  595. S32 mMaxTextureSize;
  596. LLVector3 mLastCameraOrigin;
  597. U32 mLastCameraUpdate;
  598. // Information for Homestead / CR-53
  599. S32 mClassID;
  600. S32 mCPURatio;
  601. std::string mColoName;
  602. std::string mProductSKU;
  603. std::string mProductName;
  604. // Validated (trailing "/" added if missing from the caps), cached caps
  605. std::string mGetTextureUrl;
  606. std::string mGetMeshUrl;
  607. std::string mGetMesh2Url;
  608. std::string mViewerAssetUrl;
  609. typedef std::map<U32, std::vector<U32> > orphan_list_t;
  610. orphan_list_t mOrphanMap;
  611. class CacheMissItem
  612. {
  613. public:
  614. CacheMissItem(U32 id, LLViewerRegion::eCacheMissType miss_type)
  615. : mID(id),
  616. mType(miss_type)
  617. {
  618. }
  619. typedef std::list<CacheMissItem> cache_miss_list_t;
  620. public:
  621. U32 mID; // Local object id
  622. LLViewerRegion::eCacheMissType mType; // Cache miss type
  623. };
  624. CacheMissItem::cache_miss_list_t mCacheMissList;
  625. // Spatial partitions for objects in this region
  626. std::vector<LLViewerOctreePartition*> mObjectPartition;
  627. LLSD mSimulatorFeatures;
  628. static LLCore::HttpHeaders::ptr_t sHttpHeaders;
  629. static LLCore::HttpOptions::ptr_t sHttpOptions;
  630. static S32 sNewObjectCreationThrottle;
  631. };
  632. // Purely static class (a singleton in LL's viewer, but LL coders love to
  633. // complicate and slow down things for no reason)... It is used to store data
  634. // for the agent region (as such, it could as well be part of LLAgent) and its
  635. // member variables are filled up by LLViewerRegion::processRegionInfo(). HB
  636. class LLRegionInfoModel
  637. {
  638. LLRegionInfoModel() = delete;
  639. ~LLRegionInfoModel() = delete;
  640. public:
  641. LL_INLINE static void setUseFixedSun(bool fixed)
  642. {
  643. if (fixed)
  644. {
  645. sRegionFlags |= REGION_FLAGS_SUN_FIXED;
  646. }
  647. else
  648. {
  649. sRegionFlags &= ~REGION_FLAGS_SUN_FIXED;
  650. }
  651. }
  652. LL_INLINE static bool getUseFixedSun()
  653. {
  654. return (sRegionFlags & REGION_FLAGS_SUN_FIXED) != 0;
  655. }
  656. public:
  657. static U64 sRegionFlags;
  658. static U32 sEstateID;
  659. static U32 sParentEstateID;
  660. static S32 sPricePerMeter;
  661. static S32 sRedirectGridX;
  662. static S32 sRedirectGridY;
  663. static std::string sSimName;
  664. static std::string sSimType;
  665. static F32 sBillableFactor;
  666. static F32 sObjectBonusFactor;
  667. static F32 sWaterHeight;
  668. static F32 sTerrainRaiseLimit;
  669. static F32 sTerrainLowerLimit;
  670. static F32 sSunHour; // 6... 30
  671. static S32 sHardAgentLimit;
  672. static U8 sSimAccess;
  673. static U8 sAgentLimit;
  674. static bool sUseEstateSun;
  675. };
  676. #endif