llworld.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLWORLD_H
00033 #define LL_LLWORLD_H
00034 
00035 #include "llpatchvertexarray.h"
00036 
00037 #include "llmath.h"
00038 #include "v3math.h"
00039 #include "llmemory.h"
00040 #include "llstring.h"
00041 #include "llviewerpartsim.h"
00042 #include "llviewerimage.h"
00043 #include "llvowater.h"
00044 
00045 class LLViewerRegion;
00046 class LLVector3d;
00047 class LLMessageSystem;
00048 class LLNetMap;
00049 class LLHost;
00050 
00051 class LLViewerObject;
00052 class LLSurfacePatch;
00053 
00054 class LLCloudPuff;
00055 class LLCloudGroup;
00056 class LLVOAvatar;
00057 
00058 // LLWorld maintains a stack of unused viewer_regions and an array of pointers to viewer regions
00059 // as simulators are connected to, viewer_regions are popped off the stack and connected as required
00060 // as simulators are removed, they are pushed back onto the stack
00061 
00062 class LLWorld : public LLSingleton<LLWorld>
00063 {
00064 public:
00065         LLWorld();
00066         void destroyClass();
00067 
00068         LLViewerRegion* addRegion(const U64 &region_handle, const LLHost &host);
00069                 // safe to call if already present, does the "right thing" if
00070                 // hosts are same, or if hosts are different, etc...
00071         void                    removeRegion(const LLHost &host);
00072 
00073         void    disconnectRegions(); // Send quit messages to all child regions
00074 
00075         LLViewerRegion*                 getRegion(const LLHost &host);
00076         LLViewerRegion*                 getRegionFromPosGlobal(const LLVector3d &pos);
00077         LLViewerRegion*                 getRegionFromPosAgent(const LLVector3 &pos);
00078         LLViewerRegion*                 getRegionFromHandle(const U64 &handle);
00079         BOOL                                    positionRegionValidGlobal(const LLVector3d& pos);                       // true if position is in valid region
00080         LLVector3d                              clipToVisibleRegions(const LLVector3d &start_pos, const LLVector3d &end_pos);
00081 
00082         void                                    updateAgentOffset(const LLVector3d &offset);
00083 
00084         // All of these should be in the agent coordinate frame
00085         LLViewerRegion*                 resolveRegionGlobal(LLVector3 &localpos, const LLVector3d &position);
00086         LLViewerRegion*                 resolveRegionAgent(LLVector3 &localpos, const LLVector3 &position);
00087         F32                                             resolveLandHeightGlobal(const LLVector3d &position);
00088         F32                                             resolveLandHeightAgent(const LLVector3 &position);
00089 
00090         // Return the lowest allowed Z point to prevent objects from being moved
00091         // underground.
00092         F32 getMinAllowedZ(LLViewerObject* object);
00093 
00094         // takes a line segment defined by point_a and point_b, then
00095         // determines the closest (to point_a) point of intersection that is
00096         // on the land surface or on an object of the world.
00097         // Stores results in "intersection" and "intersection_normal" and
00098         // returns a scalar value that is the normalized (by length of line segment) 
00099         // distance along the line from "point_a" to "intersection".
00100         //
00101         // Currently assumes point_a and point_b only differ in z-direction,
00102         // but it may eventually become more general.
00103         F32 resolveStepHeightGlobal(const LLVOAvatar* avatarp, const LLVector3d &point_a, const LLVector3d &point_b,
00104                                                         LLVector3d &intersection, LLVector3 &intersection_normal,
00105                                                         LLViewerObject** viewerObjectPtr=NULL);
00106 
00107         LLSurfacePatch *                resolveLandPatchGlobal(const LLVector3d &position);
00108         LLVector3                               resolveLandNormalGlobal(const LLVector3d &position);            // absolute frame
00109 
00110         U32                                             getRegionWidthInPoints() const  { return mWidth; }
00111         F32                                             getRegionScale() const                  { return mScale; }
00112 
00113         // region X and Y size in meters
00114         F32                                             getRegionWidthInMeters() const  { return mWidthInMeters; }
00115         F32                                             getRegionMinHeight() const              { return -mWidthInMeters; }
00116         F32                                             getRegionMaxHeight() const              { return MAX_OBJECT_Z; }
00117 
00118         void                                    updateRegions(F32 max_update_time);
00119         void                                    updateVisibilities();
00120         void                                    updateParticles();
00121         void                                    updateClouds(const F32 dt);
00122         LLCloudGroup *                  findCloudGroup(const LLCloudPuff &puff);
00123 
00124         void                                    renderPropertyLines();
00125 
00126         void resetStats();
00127         void updateNetStats(); // Update network statistics for all the regions...
00128 
00129         void printPacketsLost();
00130         void requestCacheMisses();
00131 
00132         // deal with map object updates in the world.
00133         static void processCoarseUpdate(LLMessageSystem* msg, void** user_data);
00134 
00135         F32 getLandFarClip() const;
00136         void setLandFarClip(const F32 far_clip);
00137 
00138         LLViewerImage *getDefaultWaterTexture();
00139         void updateWaterObjects();
00140         void shiftRegions(const LLVector3& offset);
00141 
00142         void setSpaceTimeUSec(const U64 space_time_usec);
00143         U64 getSpaceTimeUSec() const;
00144 
00145         void getInfo(LLSD& info);
00146 
00147 public:
00148         typedef std::list<LLViewerRegion*> region_list_t;
00149         
00150         region_list_t   mActiveRegionList;
00151 
00152         region_list_t& getRegionList() { return mActiveRegionList; }
00153 
00154 private:
00155         region_list_t   mRegionList;
00156         region_list_t   mVisibleRegionList;
00157         region_list_t   mCulledRegionList;
00158 
00159         // Number of points on edge
00160         static const U32 mWidth;
00161 
00162         // meters/point, therefore mWidth * mScale = meters per edge
00163         static const F32 mScale;
00164 
00165         static const F32 mWidthInMeters;
00166 
00167         F32 mLandFarClip;                                       // Far clip distance for land.
00168         LLPatchVertexArray              mLandPatch;
00169         S32 mLastPacketsIn;
00170         S32 mLastPacketsOut;
00171         S32 mLastPacketsLost;
00172 
00174         //
00175         // Data for "Fake" objects
00176         //
00177 
00178         // Used to define the "Square" which we need to fill in
00179         U32 mMinRegionX;
00180         U32 mMaxRegionX;
00181         U32 mMinRegionY;
00182         U32 mMaxRegionY;
00183 
00184         std::list<LLVOWater*> mHoleWaterObjects;
00185         LLPointer<LLVOWater> mEdgeWaterObjects[8];
00186 
00187         LLPointer<LLViewerImage> mDefaultWaterTexturep;
00188         U64 mSpaceTimeUSec;
00189 };
00190 
00191 
00192 void process_enable_simulator(LLMessageSystem *mesgsys, void **user_data);
00193 void process_disable_simulator(LLMessageSystem *mesgsys, void **user_data);
00194 
00195 void process_region_handshake(LLMessageSystem* msg, void** user_data);
00196 
00197 void send_agent_pause();
00198 void send_agent_resume();
00199 
00200 #endif

Generated on Fri May 16 08:34:26 2008 for SecondLife by  doxygen 1.5.5