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

Generated on Thu Jul 1 06:09:47 2010 for Second Life Viewer by  doxygen 1.4.7