/indra/newview/llsurfacepatch.h
C++ Header | 185 lines | 102 code | 42 blank | 41 comment | 0 complexity | 217c86bfd05c4d7f98a72bd4a86d6924 MD5 | raw file
Possible License(s): LGPL-2.1
1/**
2 * @file llsurfacepatch.h
3 * @brief LLSurfacePatch class definition
4 *
5 * $LicenseInfo:firstyear=2001&license=viewerlgpl$
6 * Second Life Viewer Source Code
7 * Copyright (C) 2010, Linden Research, Inc.
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation;
12 * version 2.1 of the License only.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 *
23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
24 * $/LicenseInfo$
25 */
26
27#ifndef LL_LLSURFACEPATCH_H
28#define LL_LLSURFACEPATCH_H
29
30#include "v3math.h"
31#include "v3dmath.h"
32#include "llpointer.h"
33
34class LLSurface;
35class LLVOSurfacePatch;
36class LLVector2;
37class LLColor4U;
38class LLAgent;
39
40// A patch shouldn't know about its visibility since that really depends on the
41// camera that is looking (or not looking) at it. So, anything about a patch
42// that is specific to a camera should be in the class below.
43class LLPatchVisibilityInfo
44{
45public:
46 LLPatchVisibilityInfo() :
47 mbIsVisible(FALSE),
48 mDistance(0.f),
49 mRenderLevel(0),
50 mRenderStride(0) { };
51 ~LLPatchVisibilityInfo() { };
52
53 BOOL mbIsVisible;
54 F32 mDistance; // Distance from camera
55 S32 mRenderLevel;
56 U32 mRenderStride;
57};
58
59
60
61class LLSurfacePatch
62{
63public:
64 LLSurfacePatch();
65 ~LLSurfacePatch();
66
67 void reset(const U32 id);
68 void connectNeighbor(LLSurfacePatch *neighborp, const U32 direction);
69 void disconnectNeighbor(LLSurface *surfacep);
70
71 void setNeighborPatch(const U32 direction, LLSurfacePatch *neighborp);
72 LLSurfacePatch *getNeighborPatch(const U32 direction) const;
73
74 void colorPatch(const U8 r, const U8 g, const U8 b);
75
76 BOOL updateTexture();
77
78 void updateVerticalStats();
79 void updateCompositionStats();
80 void updateNormals();
81
82 void updateEastEdge();
83 void updateNorthEdge();
84
85 void updateCameraDistanceRegion( const LLVector3 &pos_region);
86 void updateVisibility();
87 void updateGL();
88
89 void dirtyZ(); // Dirty the z values of this patch
90 void setHasReceivedData();
91 BOOL getHasReceivedData() const;
92
93 F32 getDistance() const;
94 F32 getMaxZ() const;
95 F32 getMinZ() const;
96 F32 getMeanComposition() const;
97 F32 getMinComposition() const;
98 F32 getMaxComposition() const;
99 const LLVector3 &getCenterRegion() const;
100 const U64 &getLastUpdateTime() const;
101 LLSurface *getSurface() const { return mSurfacep; }
102 LLVector3 getPointAgent(const U32 x, const U32 y) const; // get the point at the offset.
103 LLVector2 getTexCoords(const U32 x, const U32 y) const;
104
105 void calcNormal(const U32 x, const U32 y, const U32 stride);
106 const LLVector3 &getNormal(const U32 x, const U32 y) const;
107
108 void eval(const U32 x, const U32 y, const U32 stride,
109 LLVector3 *vertex, LLVector3 *normal, LLVector2 *tex0, LLVector2 *tex1);
110
111
112
113 LLVector3 getOriginAgent() const;
114 const LLVector3d &getOriginGlobal() const;
115 void setOriginGlobal(const LLVector3d &origin_global);
116
117 // connectivity -- each LLPatch points at 5 neighbors (or NULL)
118 // +---+---+---+
119 // | | 2 | 5 |
120 // +---+---+---+
121 // | 3 | 0 | 1 |
122 // +---+---+---+
123 // | 6 | 4 | |
124 // +---+---+---+
125
126
127 BOOL getVisible() const;
128 U32 getRenderStride() const;
129 S32 getRenderLevel() const;
130
131 void setSurface(LLSurface *surfacep);
132 void setDataZ(F32 *data_z) { mDataZ = data_z; }
133 void setDataNorm(LLVector3 *data_norm) { mDataNorm = data_norm; }
134 F32 *getDataZ() const { return mDataZ; }
135
136 void dirty(); // Mark this surface patch as dirty...
137 void clearDirty() { mDirty = FALSE; }
138
139 void clearVObj();
140
141public:
142 BOOL mHasReceivedData; // has the patch EVER received height data?
143 BOOL mSTexUpdate; // Does the surface texture need to be updated?
144
145protected:
146 LLSurfacePatch *mNeighborPatches[8]; // Adjacent patches
147 BOOL mNormalsInvalid[9]; // Which normals are invalid
148
149 BOOL mDirty;
150 BOOL mDirtyZStats;
151 BOOL mHeightsGenerated;
152
153 U32 mDataOffset;
154 F32 *mDataZ;
155 LLVector3 *mDataNorm;
156
157 // Pointer to the LLVOSurfacePatch object which is used in the new renderer.
158 LLPointer<LLVOSurfacePatch> mVObjp;
159
160 // All of the camera-dependent stuff should be in its own class...
161 LLPatchVisibilityInfo mVisInfo;
162
163 // pointers to beginnings of patch data fields
164 LLVector3d mOriginGlobal;
165 LLVector3 mOriginRegion;
166
167
168 // height field stats
169 LLVector3 mCenterRegion; // Center in region-local coords
170 F32 mMinZ, mMaxZ, mMeanZ;
171 F32 mRadius;
172
173 F32 mMinComposition;
174 F32 mMaxComposition;
175 F32 mMeanComposition;
176
177 U8 mConnectedEdge; // This flag is non-zero iff patch is on at least one edge
178 // of LLSurface that is "connected" to another LLSurface
179 U64 mLastUpdateTime; // Time patch was last updated
180
181 LLSurface *mSurfacep; // Pointer to "parent" surface
182};
183
184
185#endif // LL_LLSURFACEPATCH_H