PageRenderTime 507ms CodeModel.GetById 185ms app.highlight 156ms RepoModel.GetById 163ms app.codeStats 0ms

/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
 32#ifndef LL_LLWORLD_H
 33#define LL_LLWORLD_H
 34
 35#include "llpatchvertexarray.h"
 36
 37#include "llmath.h"
 38#include "v3math.h"
 39#include "llsingleton.h"
 40#include "llstring.h"
 41#include "llviewerpartsim.h"
 42#include "llviewertexture.h"
 43#include "llvowater.h"
 44
 45class LLViewerRegion;
 46class LLVector3d;
 47class LLMessageSystem;
 48class LLNetMap;
 49class LLHost;
 50
 51class LLViewerObject;
 52class LLSurfacePatch;
 53
 54class LLCloudPuff;
 55class LLCloudGroup;
 56class LLVOAvatar;
 57
 58// LLWorld maintains a stack of unused viewer_regions and an array of pointers to viewer regions
 59// as simulators are connected to, viewer_regions are popped off the stack and connected as required
 60// as simulators are removed, they are pushed back onto the stack
 61
 62class LLWorld : public LLSingleton<LLWorld>
 63{
 64public:
 65	LLWorld();
 66	void destroyClass();
 67
 68	LLViewerRegion*	addRegion(const U64 &region_handle, const LLHost &host);
 69		// safe to call if already present, does the "right thing" if
 70		// hosts are same, or if hosts are different, etc...
 71	void			removeRegion(const LLHost &host);
 72
 73	void	disconnectRegions(); // Send quit messages to all child regions
 74
 75	LLViewerRegion*			getRegion(const LLHost &host);
 76	LLViewerRegion*			getRegionFromPosGlobal(const LLVector3d &pos);
 77	LLViewerRegion*			getRegionFromPosAgent(const LLVector3 &pos);
 78	LLViewerRegion*			getRegionFromHandle(const U64 &handle);
 79	BOOL					positionRegionValidGlobal(const LLVector3d& pos);			// true if position is in valid region
 80	LLVector3d				clipToVisibleRegions(const LLVector3d &start_pos, const LLVector3d &end_pos);
 81
 82	void					updateAgentOffset(const LLVector3d &offset);
 83
 84	// All of these should be in the agent coordinate frame
 85	LLViewerRegion*			resolveRegionGlobal(LLVector3 &localpos, const LLVector3d &position);
 86	LLViewerRegion*			resolveRegionAgent(LLVector3 &localpos, const LLVector3 &position);
 87	F32						resolveLandHeightGlobal(const LLVector3d &position);
 88	F32						resolveLandHeightAgent(const LLVector3 &position);
 89
 90	// Return the lowest allowed Z point to prevent objects from being moved
 91	// underground.
 92	F32 getMinAllowedZ(LLViewerObject* object, const LLVector3d &global_pos);
 93
 94	// takes a line segment defined by point_a and point_b, then
 95	// determines the closest (to point_a) point of intersection that is
 96	// on the land surface or on an object of the world.
 97	// Stores results in "intersection" and "intersection_normal" and
 98	// returns a scalar value that is the normalized (by length of line segment) 
 99	// distance along the line from "point_a" to "intersection".
100	//
101	// Currently assumes point_a and point_b only differ in z-direction,
102	// but it may eventually become more general.
103	F32 resolveStepHeightGlobal(const LLVOAvatar* avatarp, const LLVector3d &point_a, const LLVector3d &point_b,
104							LLVector3d &intersection, LLVector3 &intersection_normal,
105							LLViewerObject** viewerObjectPtr=NULL);
106
107	LLSurfacePatch *		resolveLandPatchGlobal(const LLVector3d &position);
108	LLVector3				resolveLandNormalGlobal(const LLVector3d &position);		// absolute frame
109
110	U32						getRegionWidthInPoints() const	{ return mWidth; }
111	F32						getRegionScale() const			{ return mScale; }
112
113	// region X and Y size in meters
114	F32						getRegionWidthInMeters() const	{ return mWidthInMeters; }
115	F32						getRegionMinHeight() const		{ return -mWidthInMeters; }
116	F32						getRegionMaxHeight() const		{ return MAX_OBJECT_Z; }
117
118	void					updateRegions(F32 max_update_time);
119	void					updateVisibilities();
120	void					updateParticles();
121	void					updateClouds(const F32 dt);
122	LLCloudGroup *			findCloudGroup(const LLCloudPuff &puff);
123
124	void					renderPropertyLines();
125
126	void resetStats();
127	void updateNetStats(); // Update network statistics for all the regions...
128
129	void printPacketsLost();
130	void requestCacheMisses();
131
132	// deal with map object updates in the world.
133	static void processCoarseUpdate(LLMessageSystem* msg, void** user_data);
134
135	F32 getLandFarClip() const;
136	void setLandFarClip(const F32 far_clip);
137
138	LLViewerTexture *getDefaultWaterTexture();
139	void updateWaterObjects();
140	void waterHeightRegionInfo(std::string const& sim_name, F32 water_height);
141	void shiftRegions(const LLVector3& offset);
142
143	void setSpaceTimeUSec(const U64 space_time_usec);
144	U64 getSpaceTimeUSec() const;
145
146	void getInfo(LLSD& info);
147
148public:
149	typedef std::list<LLViewerRegion*> region_list_t;
150	const region_list_t& getRegionList() const { return mActiveRegionList; }
151
152	// Returns lists of avatar IDs and their world-space positions within a given distance of a point.
153	// All arguments are optional. Given containers will be emptied and then filled.
154	// Not supplying origin or radius input returns data on all avatars in the known regions.
155	void getAvatars(
156		uuid_vec_t* avatar_ids = NULL,
157		std::vector<LLVector3d>* positions = NULL, 
158		const LLVector3d& relative_to = LLVector3d(), F32 radius = FLT_MAX) const;
159
160private:
161	region_list_t	mActiveRegionList;
162	region_list_t	mRegionList;
163	region_list_t	mVisibleRegionList;
164	region_list_t	mCulledRegionList;
165
166	// Number of points on edge
167	static const U32 mWidth;
168
169	// meters/point, therefore mWidth * mScale = meters per edge
170	static const F32 mScale;
171
172	static const F32 mWidthInMeters;
173
174	F32 mLandFarClip;					// Far clip distance for land.
175	LLPatchVertexArray		mLandPatch;
176	S32 mLastPacketsIn;
177	S32 mLastPacketsOut;
178	S32 mLastPacketsLost;
179
180	U64 mSpaceTimeUSec;
181
182	BOOL mClassicCloudsEnabled;
183
184	////////////////////////////
185	//
186	// Data for "Fake" objects
187	//
188
189	std::list<LLVOWater*> mHoleWaterObjects;
190	LLPointer<LLVOWater> mEdgeWaterObjects[8];
191
192	LLPointer<LLViewerTexture> mDefaultWaterTexturep;
193};
194
195
196void process_enable_simulator(LLMessageSystem *mesgsys, void **user_data);
197void process_disable_simulator(LLMessageSystem *mesgsys, void **user_data);
198
199void process_region_handshake(LLMessageSystem* msg, void** user_data);
200
201void send_agent_pause();
202void send_agent_resume();
203
204#endif