aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llsurfacepatch.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llsurfacepatch.h177
1 files changed, 177 insertions, 0 deletions
diff --git a/linden/indra/newview/llsurfacepatch.h b/linden/indra/newview/llsurfacepatch.h
new file mode 100644
index 0000000..8db92a1
--- /dev/null
+++ b/linden/indra/newview/llsurfacepatch.h
@@ -0,0 +1,177 @@
1/**
2 * @file llsurfacepatch.h
3 * @brief LLSurfacePatch class definition
4 *
5 * Copyright (c) 2001-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_LLSURFACEPATCH_H
29#define LL_LLSURFACEPATCH_H
30
31#include "v3math.h"
32#include "v3dmath.h"
33#include "llmemory.h"
34
35class LLSurface;
36class LLVOSurfacePatch;
37class LLVector2;
38class LLColor4U;
39class LLAgent;
40
41// A patch shouldn't know about its visibility since that really depends on the
42// camera that is looking (or not looking) at it. So, anything about a patch
43// that is specific to a camera should be in the struct below.
44struct LLPatchVisibilityInfo
45{
46 BOOL mbIsVisible;
47 F32 mDistance; // Distance from camera
48 S32 mRenderLevel;
49 U32 mRenderStride;
50};
51
52
53
54class LLSurfacePatch
55{
56public:
57 LLSurfacePatch();
58 ~LLSurfacePatch();
59
60 void reset(const U32 id);
61 void connectNeighbor(LLSurfacePatch *neighborp, const U32 direction);
62 void disconnectNeighbor(LLSurface *surfacep);
63
64 void setNeighborPatch(const U32 direction, LLSurfacePatch *neighborp);
65 LLSurfacePatch *getNeighborPatch(const U32 direction) const;
66
67 void colorPatch(const U8 r, const U8 g, const U8 b);
68
69 BOOL updateTexture();
70
71 void updateVerticalStats();
72 void updateCompositionStats();
73 void updateNormals();
74
75 void updateEastEdge();
76 void updateNorthEdge();
77
78 void updateCameraDistanceRegion( const LLVector3 &pos_region);
79 void updateVisibility();
80
81 void dirtyZ(); // Dirty the z values of this patch
82 void setHasReceivedData();
83 BOOL getHasReceivedData() const;
84
85 F32 getDistance() const;
86 F32 getMaxZ() const;
87 F32 getMinZ() const;
88 F32 getMeanComposition() const;
89 F32 getMinComposition() const;
90 F32 getMaxComposition() const;
91 const LLVector3 &getCenterRegion() const;
92 const U64 &getLastUpdateTime() const;
93 LLSurface *getSurface() const { return mSurfacep; }
94 LLVector3 getPointAgent(const U32 x, const U32 y) const; // get the point at the offset.
95 LLVector2 getTexCoords(const U32 x, const U32 y) const;
96
97 void calcNormal(const U32 x, const U32 y, const U32 stride);
98 const LLVector3 &getNormal(const U32 x, const U32 y) const;
99
100 void eval(const U32 x, const U32 y, const U32 stride,
101 LLVector3 *vertex, LLVector3 *normal, LLVector2 *tex0, LLVector2 *tex1);
102
103
104
105 LLVector3 getOriginAgent() const;
106 const LLVector3d &getOriginGlobal() const;
107 void setOriginGlobal(const LLVector3d &origin_global);
108
109 // connectivity -- each LLPatch points at 5 neighbors (or NULL)
110 // +---+---+---+
111 // | | 2 | 5 |
112 // +---+---+---+
113 // | 3 | 0 | 1 |
114 // +---+---+---+
115 // | 6 | 4 | |
116 // +---+---+---+
117
118
119 BOOL getVisible() const;
120 U32 getRenderStride() const;
121 S32 getRenderLevel() const;
122
123 void setSurface(LLSurface *surfacep);
124 void setDataZ(F32 *data_z) { mDataZ = data_z; }
125 void setDataNorm(LLVector3 *data_norm) { mDataNorm = data_norm; }
126 F32 *getDataZ() const { return mDataZ; }
127
128 void dirty(); // Mark this surface patch as dirty...
129 void clearDirty() { mDirty = FALSE; }
130
131 void clearVObj();
132
133public:
134 BOOL mHasReceivedData; // has the patch EVER received height data?
135 BOOL mSTexUpdate; // Does the surface texture need to be updated?
136
137protected:
138 LLSurfacePatch *mNeighborPatches[8]; // Adjacent patches
139 BOOL mNormalsInvalid[9]; // Which normals are invalid
140
141 BOOL mDirty;
142 BOOL mDirtyZStats;
143 BOOL mHeightsGenerated;
144
145 U32 mDataOffset;
146 F32 *mDataZ;
147 LLVector3 *mDataNorm;
148
149 // Pointer to the LLVOSurfacePatch object which is used in the new renderer.
150 LLPointer<LLVOSurfacePatch> mVObjp;
151
152 // All of the camera-dependent stuff should be in its own structure...
153 LLPatchVisibilityInfo mVisInfo;
154
155 // pointers to beginnings of patch data fields
156 LLVector3d mOriginGlobal;
157 LLVector3 mOriginRegion;
158
159
160 // height field stats
161 LLVector3 mCenterRegion; // Center in region-local coords
162 F32 mMinZ, mMaxZ, mMeanZ;
163 F32 mRadius;
164
165 F32 mMinComposition;
166 F32 mMaxComposition;
167 F32 mMeanComposition;
168
169 U8 mConnectedEdge; // This flag is non-zero iff patch is on at least one edge
170 // of LLSurface that is "connected" to another LLSurface
171 U64 mLastUpdateTime; // Time patch was last updated
172
173 LLSurface *mSurfacep; // Pointer to "parent" surface
174};
175
176
177#endif // LL_LLSURFACEPATCH_H