/indra/newview/llworld.h

https://bitbucket.org/lindenlab/viewer-beta/ · C Header · 204 lines · 102 code · 44 blank · 58 comment · 0 complexity · 7815710d86f2b837f121d5ddcf20c392 MD5 · raw file

  1. /**
  2. * @file llworld.h
  3. * @brief Collection of viewer regions in the vacinity of the user.
  4. *
  5. * Represents the whole world, so far as 3D functionality is conserned.
  6. * Always contains the region that the user's avatar is in along with
  7. * neighboring regions. As the user crosses region boundaries, new
  8. * regions are added to the world and distant ones are rolled up.
  9. *
  10. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  11. * Second Life Viewer Source Code
  12. * Copyright (C) 2010, Linden Research, Inc.
  13. *
  14. * This library is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU Lesser General Public
  16. * License as published by the Free Software Foundation;
  17. * version 2.1 of the License only.
  18. *
  19. * This library is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  22. * Lesser General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Lesser General Public
  25. * License along with this library; if not, write to the Free Software
  26. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  27. *
  28. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  29. * $/LicenseInfo$
  30. */
  31. #ifndef LL_LLWORLD_H
  32. #define LL_LLWORLD_H
  33. #include "llpatchvertexarray.h"
  34. #include "llmath.h"
  35. #include "v3math.h"
  36. #include "llsingleton.h"
  37. #include "llstring.h"
  38. #include "llviewerpartsim.h"
  39. #include "llviewertexture.h"
  40. #include "llvowater.h"
  41. class LLViewerRegion;
  42. class LLVector3d;
  43. class LLMessageSystem;
  44. class LLNetMap;
  45. class LLHost;
  46. class LLViewerObject;
  47. class LLSurfacePatch;
  48. class LLCloudPuff;
  49. class LLCloudGroup;
  50. class LLVOAvatar;
  51. // LLWorld maintains a stack of unused viewer_regions and an array of pointers to viewer regions
  52. // as simulators are connected to, viewer_regions are popped off the stack and connected as required
  53. // as simulators are removed, they are pushed back onto the stack
  54. class LLWorld : public LLSingleton<LLWorld>
  55. {
  56. public:
  57. LLWorld();
  58. void destroyClass();
  59. LLViewerRegion* addRegion(const U64 &region_handle, const LLHost &host);
  60. // safe to call if already present, does the "right thing" if
  61. // hosts are same, or if hosts are different, etc...
  62. void removeRegion(const LLHost &host);
  63. void disconnectRegions(); // Send quit messages to all child regions
  64. LLViewerRegion* getRegion(const LLHost &host);
  65. LLViewerRegion* getRegionFromPosGlobal(const LLVector3d &pos);
  66. LLViewerRegion* getRegionFromPosAgent(const LLVector3 &pos);
  67. LLViewerRegion* getRegionFromHandle(const U64 &handle);
  68. BOOL positionRegionValidGlobal(const LLVector3d& pos); // true if position is in valid region
  69. LLVector3d clipToVisibleRegions(const LLVector3d &start_pos, const LLVector3d &end_pos);
  70. void updateAgentOffset(const LLVector3d &offset);
  71. // All of these should be in the agent coordinate frame
  72. LLViewerRegion* resolveRegionGlobal(LLVector3 &localpos, const LLVector3d &position);
  73. LLViewerRegion* resolveRegionAgent(LLVector3 &localpos, const LLVector3 &position);
  74. F32 resolveLandHeightGlobal(const LLVector3d &position);
  75. F32 resolveLandHeightAgent(const LLVector3 &position);
  76. // Return the lowest allowed Z point to prevent objects from being moved
  77. // underground.
  78. F32 getMinAllowedZ(LLViewerObject* object, const LLVector3d &global_pos);
  79. // takes a line segment defined by point_a and point_b, then
  80. // determines the closest (to point_a) point of intersection that is
  81. // on the land surface or on an object of the world.
  82. // Stores results in "intersection" and "intersection_normal" and
  83. // returns a scalar value that is the normalized (by length of line segment)
  84. // distance along the line from "point_a" to "intersection".
  85. //
  86. // Currently assumes point_a and point_b only differ in z-direction,
  87. // but it may eventually become more general.
  88. F32 resolveStepHeightGlobal(const LLVOAvatar* avatarp, const LLVector3d &point_a, const LLVector3d &point_b,
  89. LLVector3d &intersection, LLVector3 &intersection_normal,
  90. LLViewerObject** viewerObjectPtr=NULL);
  91. LLSurfacePatch * resolveLandPatchGlobal(const LLVector3d &position);
  92. LLVector3 resolveLandNormalGlobal(const LLVector3d &position); // absolute frame
  93. U32 getRegionWidthInPoints() const { return mWidth; }
  94. F32 getRegionScale() const { return mScale; }
  95. // region X and Y size in meters
  96. F32 getRegionWidthInMeters() const { return mWidthInMeters; }
  97. F32 getRegionMinHeight() const { return -mWidthInMeters; }
  98. F32 getRegionMaxHeight() const { return MAX_OBJECT_Z; }
  99. void updateRegions(F32 max_update_time);
  100. void updateVisibilities();
  101. void updateParticles();
  102. void updateClouds(const F32 dt);
  103. LLCloudGroup * findCloudGroup(const LLCloudPuff &puff);
  104. void renderPropertyLines();
  105. void resetStats();
  106. void updateNetStats(); // Update network statistics for all the regions...
  107. void printPacketsLost();
  108. void requestCacheMisses();
  109. // deal with map object updates in the world.
  110. static void processCoarseUpdate(LLMessageSystem* msg, void** user_data);
  111. F32 getLandFarClip() const;
  112. void setLandFarClip(const F32 far_clip);
  113. LLViewerTexture *getDefaultWaterTexture();
  114. void updateWaterObjects();
  115. void waterHeightRegionInfo(std::string const& sim_name, F32 water_height);
  116. void shiftRegions(const LLVector3& offset);
  117. void setSpaceTimeUSec(const U64 space_time_usec);
  118. U64 getSpaceTimeUSec() const;
  119. void getInfo(LLSD& info);
  120. public:
  121. typedef std::list<LLViewerRegion*> region_list_t;
  122. const region_list_t& getRegionList() const { return mActiveRegionList; }
  123. // Returns lists of avatar IDs and their world-space positions within a given distance of a point.
  124. // All arguments are optional. Given containers will be emptied and then filled.
  125. // Not supplying origin or radius input returns data on all avatars in the known regions.
  126. void getAvatars(
  127. uuid_vec_t* avatar_ids = NULL,
  128. std::vector<LLVector3d>* positions = NULL,
  129. const LLVector3d& relative_to = LLVector3d(), F32 radius = FLT_MAX) const;
  130. private:
  131. region_list_t mActiveRegionList;
  132. region_list_t mRegionList;
  133. region_list_t mVisibleRegionList;
  134. region_list_t mCulledRegionList;
  135. // Number of points on edge
  136. static const U32 mWidth;
  137. // meters/point, therefore mWidth * mScale = meters per edge
  138. static const F32 mScale;
  139. static const F32 mWidthInMeters;
  140. F32 mLandFarClip; // Far clip distance for land.
  141. LLPatchVertexArray mLandPatch;
  142. S32 mLastPacketsIn;
  143. S32 mLastPacketsOut;
  144. S32 mLastPacketsLost;
  145. U64 mSpaceTimeUSec;
  146. BOOL mClassicCloudsEnabled;
  147. ////////////////////////////
  148. //
  149. // Data for "Fake" objects
  150. //
  151. std::list<LLVOWater*> mHoleWaterObjects;
  152. LLPointer<LLVOWater> mEdgeWaterObjects[8];
  153. LLPointer<LLViewerTexture> mDefaultWaterTexturep;
  154. };
  155. void process_enable_simulator(LLMessageSystem *mesgsys, void **user_data);
  156. void process_disable_simulator(LLMessageSystem *mesgsys, void **user_data);
  157. void process_region_handshake(LLMessageSystem* msg, void** user_data);
  158. void send_agent_pause();
  159. void send_agent_resume();
  160. #endif