diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llsurface.h | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llsurface.h')
-rw-r--r-- | linden/indra/newview/llsurface.h | 268 |
1 files changed, 268 insertions, 0 deletions
diff --git a/linden/indra/newview/llsurface.h b/linden/indra/newview/llsurface.h new file mode 100644 index 0000000..12c1afc --- /dev/null +++ b/linden/indra/newview/llsurface.h | |||
@@ -0,0 +1,268 @@ | |||
1 | /** | ||
2 | * @file llsurface.h | ||
3 | * @brief Description of LLSurface class | ||
4 | * | ||
5 | * Copyright (c) 2000-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #ifndef LL_LLSURFACE_H | ||
29 | #define LL_LLSURFACE_H | ||
30 | |||
31 | //#include "vmath.h" | ||
32 | #include "v3math.h" | ||
33 | #include "v3dmath.h" | ||
34 | #include "v4math.h" | ||
35 | #include "m3math.h" | ||
36 | #include "m4math.h" | ||
37 | #include "llquaternion.h" | ||
38 | |||
39 | #include "v4coloru.h" | ||
40 | #include "v4color.h" | ||
41 | |||
42 | #include "llvowater.h" | ||
43 | #include "llpatchvertexarray.h" | ||
44 | #include "lldarray.h" | ||
45 | #include "llviewerimage.h" | ||
46 | |||
47 | class LLTimer; | ||
48 | class LLUUID; | ||
49 | class LLAgent; | ||
50 | class LLStat; | ||
51 | |||
52 | static const U8 NO_EDGE = 0x00; | ||
53 | static const U8 EAST_EDGE = 0x01; | ||
54 | static const U8 NORTH_EDGE = 0x02; | ||
55 | static const U8 WEST_EDGE = 0x04; | ||
56 | static const U8 SOUTH_EDGE = 0x08; | ||
57 | |||
58 | static const S32 ONE_MORE_THAN_NEIGHBOR = 1; | ||
59 | static const S32 EQUAL_TO_NEIGHBOR = 0; | ||
60 | static const S32 ONE_LESS_THAN_NEIGHBOR = -1; | ||
61 | |||
62 | const S32 ABOVE_WATERLINE_ALPHA = 32; // The alpha of water when the land elevation is above the waterline. | ||
63 | |||
64 | class LLViewerRegion; | ||
65 | class LLSurfacePatch; | ||
66 | class LLBitPack; | ||
67 | class LLGroupHeader; | ||
68 | |||
69 | class LLSurface | ||
70 | { | ||
71 | public: | ||
72 | LLSurface(U32 type, LLViewerRegion *regionp = NULL); | ||
73 | virtual ~LLSurface(); | ||
74 | |||
75 | static void initClasses(); // Do class initialization for LLSurface and its child classes. | ||
76 | |||
77 | void create(const S32 surface_grid_width, | ||
78 | const S32 surface_patch_width, | ||
79 | const LLVector3d &origin_global, | ||
80 | const F32 width); // Allocates and initializes surface | ||
81 | |||
82 | void setRegion(LLViewerRegion *regionp); | ||
83 | |||
84 | void setOriginGlobal(const LLVector3d &origin_global); | ||
85 | |||
86 | void connectNeighbor(LLSurface *neighborp, U32 direction); | ||
87 | void disconnectNeighbor(LLSurface *neighborp); | ||
88 | void disconnectAllNeighbors(); | ||
89 | |||
90 | virtual void decompressDCTPatch(LLBitPack &bitpack, LLGroupHeader *gopp, BOOL b_large_patch); | ||
91 | virtual void updatePatchVisibilities(LLAgent &agent); | ||
92 | |||
93 | inline F32 getZ(const U32 k) const { return mSurfaceZ[k]; } | ||
94 | inline F32 getZ(const S32 i, const S32 j) const { return mSurfaceZ[i + j*mGridsPerEdge]; } | ||
95 | |||
96 | LLVector3 getOriginAgent() const; | ||
97 | const LLVector3d &getOriginGlobal() const; | ||
98 | F32 getMetersPerGrid() const; | ||
99 | S32 getGridsPerEdge() const; | ||
100 | S32 getPatchesPerEdge() const; | ||
101 | S32 getGridsPerPatchEdge() const; | ||
102 | U32 getRenderStride(const U32 render_level) const; | ||
103 | U32 getRenderLevel(const U32 render_stride) const; | ||
104 | |||
105 | // Returns the height of the surface immediately above (or below) location, | ||
106 | // or if location is not above surface returns zero. | ||
107 | F32 resolveHeightRegion(const F32 x, const F32 y) const; | ||
108 | F32 resolveHeightRegion(const LLVector3 &location) const | ||
109 | { return resolveHeightRegion( location.mV[VX], location.mV[VY] ); } | ||
110 | F32 resolveHeightGlobal(const LLVector3d &position_global) const; | ||
111 | LLVector3 resolveNormalGlobal(const LLVector3d& v) const; // Returns normal to surface | ||
112 | |||
113 | LLSurfacePatch *resolvePatchRegion(const F32 x, const F32 y) const; | ||
114 | LLSurfacePatch *resolvePatchRegion(const LLVector3 &position_region) const; | ||
115 | LLSurfacePatch *resolvePatchGlobal(const LLVector3d &position_global) const; | ||
116 | |||
117 | // Update methods (called during idle, normally) | ||
118 | BOOL idleUpdate(); | ||
119 | |||
120 | void renderSurfaceBounds(); | ||
121 | |||
122 | BOOL containsPosition(const LLVector3 &position); | ||
123 | |||
124 | void moveZ(const S32 x, const S32 y, const F32 delta); | ||
125 | |||
126 | LLViewerRegion *getRegion() const { return mRegionp; } | ||
127 | |||
128 | F32 getMinZ() const { return mMinZ; } | ||
129 | F32 getMaxZ() const { return mMaxZ; } | ||
130 | |||
131 | void setWaterHeight(F32 height); | ||
132 | F32 getWaterHeight() const; | ||
133 | |||
134 | LLViewerImage *getSTexture(); | ||
135 | LLViewerImage *getWaterTexture(); | ||
136 | BOOL hasZData() const { return mHasZData; } | ||
137 | |||
138 | void dirtyAllPatches(); // Use this to dirty all patches when changing terrain parameters | ||
139 | |||
140 | void dirtySurfacePatch(LLSurfacePatch *patchp); | ||
141 | LLVOWater *getWaterObj() { return mWaterObjp; } | ||
142 | |||
143 | static void setTextureSize(const S32 texture_size); | ||
144 | |||
145 | friend class LLSurfacePatch; | ||
146 | friend std::ostream& operator<<(std::ostream &s, const LLSurface &S); | ||
147 | public: | ||
148 | // Number of grid points on one side of a region, including +1 buffer for | ||
149 | // north and east edge. | ||
150 | S32 mGridsPerEdge; | ||
151 | |||
152 | F32 mOOGridsPerEdge; // Inverse of grids per edge | ||
153 | |||
154 | S32 mPatchesPerEdge; // Number of patches on one side of a region | ||
155 | S32 mNumberOfPatches; // Total number of patches | ||
156 | |||
157 | |||
158 | // Each surface points at 8 neighbors (or NULL) | ||
159 | // +---+---+---+ | ||
160 | // |NW | N | NE| | ||
161 | // +---+---+---+ | ||
162 | // | W | 0 | E | | ||
163 | // +---+---+---+ | ||
164 | // |SW | S | SE| | ||
165 | // +---+---+---+ | ||
166 | LLSurface *mNeighbors[8]; // Adjacent patches | ||
167 | |||
168 | U32 mType; // Useful for identifying derived classes | ||
169 | |||
170 | F32 mDetailTextureScale; // Number of times to repeat detail texture across this surface | ||
171 | |||
172 | static F32 sTextureUpdateTime; | ||
173 | static S32 sTexelsUpdated; | ||
174 | static LLStat sTexelsUpdatedPerSecStat; | ||
175 | |||
176 | protected: | ||
177 | void createSTexture(); | ||
178 | void createWaterTexture(); | ||
179 | void initTextures(); | ||
180 | void initWater(); | ||
181 | |||
182 | |||
183 | void createPatchData(); // Allocates memory for patches. | ||
184 | void destroyPatchData(); // Deallocates memory for patches. | ||
185 | |||
186 | BOOL generateWaterTexture(const F32 x, const F32 y, | ||
187 | const F32 width, const F32 height); // Generate texture from composition values. | ||
188 | |||
189 | //F32 updateTexture(LLSurfacePatch *ppatch); | ||
190 | |||
191 | LLSurfacePatch *getPatch(const S32 x, const S32 y) const; | ||
192 | |||
193 | protected: | ||
194 | LLVector3d mOriginGlobal; // In absolute frame | ||
195 | LLSurfacePatch *mPatchList; // Array of all patches | ||
196 | |||
197 | // Array of grid data, mGridsPerEdge * mGridsPerEdge | ||
198 | F32 *mSurfaceZ; | ||
199 | |||
200 | // Array of grid normals, mGridsPerEdge * mGridsPerEdge | ||
201 | LLVector3 *mNorm; | ||
202 | |||
203 | LLDynamicArray<LLSurfacePatch *> mDirtyPatchList; | ||
204 | |||
205 | |||
206 | // The textures should never be directly initialized - use the setter methods! | ||
207 | LLPointer<LLViewerImage> mSTexturep; // Texture for surface | ||
208 | LLPointer<LLViewerImage> mWaterTexturep; // Water texture | ||
209 | |||
210 | LLPointer<LLVOWater> mWaterObjp; | ||
211 | |||
212 | // When we want multiple cameras we'll need one of each these for each camera | ||
213 | S32 mVisiblePatchCount; | ||
214 | |||
215 | U32 mGridsPerPatchEdge; // Number of grid points on a side of a patch | ||
216 | F32 mMetersPerGrid; // Converts (i,j) indecies to distance | ||
217 | F32 mMetersPerEdge; // = mMetersPerGrid * (mGridsPerEdge-1) | ||
218 | |||
219 | F32 mSurfaceTexScale; // Scale factors for automatic tex coord generation | ||
220 | F32 mDetailTexScale; | ||
221 | |||
222 | LLPatchVertexArray mPVArray; | ||
223 | |||
224 | BOOL mHasZData; // We've received any patch data for this surface. | ||
225 | F32 mMinZ; // min z for this region (during the session) | ||
226 | F32 mMaxZ; // max z for this region (during the session) | ||
227 | |||
228 | S32 mSurfacePatchUpdateCount; // Number of frames since last update. | ||
229 | |||
230 | private: | ||
231 | LLViewerRegion *mRegionp; // Patch whose coordinate system this surface is using. | ||
232 | static S32 sTextureSize; // Size of the surface texture | ||
233 | }; | ||
234 | |||
235 | |||
236 | |||
237 | // . __. | ||
238 | // Z /|\ /| Y North | ||
239 | // | / | ||
240 | // | / |<----------------- mGridsPerSurfaceEdge --------------->| | ||
241 | // | / __________________________________________________________ | ||
242 | // |/______\ X /_______________________________________________________ / | ||
243 | // / / / / / / / /M*M-2 /M*M-1 / / | ||
244 | // /______/______/______/______/______/______/______/______/ / | ||
245 | // / / / / / / / / / / | ||
246 | // /______/______/______/______/______/______/______/______/ / | ||
247 | // / / / / / / / / / / | ||
248 | // /______/______/______/______/______/______/______/______/ / | ||
249 | // West / / / / / / / / / / | ||
250 | // /______/______/______/______/______/______/______/______/ / East | ||
251 | // /... / / / / / / / / / | ||
252 | // /______/______/______/______/______/______/______/______/ / | ||
253 | // _. / 2M / / / / / / / / / | ||
254 | // /| /______/______/______/______/______/______/______/______/ / | ||
255 | // / / M / M+1 / M+2 / ... / / / / 2M-1 / / | ||
256 | // j /______/______/______/______/______/______/______/______/ / | ||
257 | // / 0 / 1 / 2 / ... / / / / M-1 / / | ||
258 | // /______/______/______/______/______/______/______/______/_/ | ||
259 | // South |<-L->| | ||
260 | // i --> | ||
261 | // | ||
262 | // where M = mSurfPatchWidth | ||
263 | // and L = mPatchGridWidth | ||
264 | // | ||
265 | // Notice that mGridsPerSurfaceEdge = a power of two + 1 | ||
266 | // This provides a buffer on the east and north edges that will allow us to | ||
267 | // fill the cracks between adjacent surfaces when rendering. | ||
268 | #endif | ||