aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llvowater.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:50 -0500
committerJacek Antonelli2008-08-15 23:44:50 -0500
commit89fe5dab825a62a0e3fd8d248cbc91c65eb2a426 (patch)
treebcff14b7888d04a2fec799c59369f6095224bd08 /linden/indra/newview/llvowater.h
parentSecond Life viewer sources 1.13.3.2 (diff)
downloadmeta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.zip
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.gz
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.bz2
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.xz
Second Life viewer sources 1.14.0.0
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llvowater.h199
1 files changed, 12 insertions, 187 deletions
diff --git a/linden/indra/newview/llvowater.h b/linden/indra/newview/llvowater.h
index 11dc0e5..20fda7e 100644
--- a/linden/indra/newview/llvowater.h
+++ b/linden/indra/newview/llvowater.h
@@ -35,195 +35,25 @@
35 35
36#include "llwaterpatch.h" 36#include "llwaterpatch.h"
37 37
38
39const U32 N_RES = 16; //32 // number of subdivisions of wave tile 38const U32 N_RES = 16; //32 // number of subdivisions of wave tile
40const U8 WAVE_STEP = 8; 39const U8 WAVE_STEP = 8;
41 40
42/*
43#define N_DET 32 // number of subdivisions of wave tile for details
44
45class LLWaterDetail
46{
47protected:
48 S32 mResolution;
49 LLViewerImage *mTex;
50 U8 *mTexData;
51
52public:
53 LLWaterDetail() : mResolution(N_DET), mTex(0), mTexData(0) {init();}
54 void init();
55
56 ~LLWaterDetail()
57 {
58 delete[] mTexData;
59 mTexData = NULL;
60 }
61
62
63 //void initEmpty();
64
65 void setPixel(const LLVector3 &norm, const S32 i, const S32 j)
66 {
67 S32 offset = (i * mResolution + j) * 3;
68 mTexData[offset] = llround(norm.mV[VX] * 255);
69 mTexData[offset+1] = llround(norm.mV[VX] * 255);
70 mTexData[offset+2] = llround(norm.mV[VX] * 255);
71 }
72 void setPixel(F32 x, F32 y, F32 z, const S32 i, const S32 j)
73 {
74 S32 offset = (i * mResolution + j) * 3;
75 mTexData[offset] = llround(x * 255);
76 mTexData[offset+1] = llround(y * 255);
77 mTexData[offset+2] = llround(z * 255);
78 }
79
80 S32 getResolution() { return mResolution; }
81
82 void createDetailBumpmap(F32* u, F32* v);
83 void createTexture() const { mTex->createTexture(); }
84 void bindTexture() const { mTex->bindTexture(); }
85 LLViewerImage* getTexture() const { return mTex; }
86};
87*/
88
89class LLWaterSurface
90{
91protected:
92 BOOL mInitialized;
93 LLVector3 mWind;
94 F32 mA;
95 F32 mVisc; // viscosity of the fluid
96 F32 mShininess;
97
98 //LLWaterDetail* mDetail;
99
100 LLFFTPlan mPlan;
101 F32 mOmega[N_RES+1][N_RES+1]; // wave frequency
102 COMPLEX mHtilda0[N_RES+1][N_RES+1]; // wave amplitudes and phases at time 0.
103 LLVector3 mNorms[N_RES][N_RES];
104 COMPLEX mHtilda[N_RES * N_RES];
105
106public:
107 LLWaterSurface();
108 ~LLWaterSurface() {}
109
110 //void initSpecularLookup();
111
112 F32 phillips(const LLVector2& k, const LLVector2& wind_n, F32 L, F32 L_small);
113
114 void initAmplitudes();
115
116 F32 height(S32 i, S32 j) const { return mHtilda[i * N_RES + j].re; }
117 F32 heightWrapped(S32 i, S32 j) const
118 {
119 return height((i + N_RES) % N_RES, (j + N_RES) % N_RES);
120 }
121
122 void generateWaterHeightField(F64 time);
123 void calcNormals();
124
125 void getHeightAndNormal(F32 i, F32 j, F32& height, LLVector3& normal) const;
126 void getIntegerHeightAndNormal(S32 i, S32 j, F32& height, LLVector3& normal) const;
127 F32 agentDepth() const;
128
129// const LLWaterHeightField* hField() const { return &mHeightField; }
130
131 //void generateDetail(F64 t);
132 //void fluidSolver(F32* u, F32* v, F32* u0, F32* v0, F64 dt);
133
134 const LLVector3& getWind() const { return mWind; }
135 void setWind(const LLVector3& w) { mWind = w; } // initialized = 0?
136 F32 A() const { return mA; }
137 void setA(F32 a) { mA = a; }
138 F32 getShininess() const { return mShininess; }
139 //LLViewerImage* getSpecularLookup() const { return mSpecularLookup; }
140 //LLViewerImage* getDetail() const { return mDetail->getTexture(); }
141};
142
143class LLVOWater;
144
145class LLWaterGrid
146{
147public:
148 LLWaterGrid();
149
150 void init();
151 void cleanup();
152
153 LLWaterSurface* getWaterSurface() { return &mWater; }
154
155 void update();
156 void updateTree(const LLVector3 &camera_pos, const LLVector3 &look_at, F32 clip_far,
157 BOOL restart);
158 void updateVisibility(const LLVector3 &camera_pos, const LLVector3 &look_at, F32 clip_far);
159
160 LLVector3 mRegionOrigin;
161
162 LLVector3* mVtx;
163 LLVector3* mNorms;
164 U32 mRegionWidth;
165 U32 mMaxGridSize;
166 U32 mPatchRes;
167 U32 mMinStep;
168 U32 mStepsInRegion;
169 LLWaterPatch* mPatches;
170 LLRoam mRoam;
171 F32 mResIncrease;
172 U32 mResDecrease;
173
174 LLVOWater* mTab[5][5];
175
176 U32 gridDim() const { return mGridDim; }
177 U32 rowSize() const { return mGridDim1; }
178 void setGridDim(U32 gd) { mGridDim = gd; mGridDim1 = mGridDim + 1; }
179 U32 index(const LL2Coord& c) const { return c.y() * mGridDim1 + c.x(); }
180 U32 index(U32 x, U32 y) const { return y * mGridDim1 + x; }
181
182 LLVector3 vtx(const LL2Coord& c, F32 raised) const
183 {
184 LLVector3 v = mVtx[index(c)];
185 v.mV[VZ] += raised;
186 return v;
187 }
188
189 LLVector3 vtx(U32 x, U32 y, F32 raised) const
190 {
191 LLVector3 v = mVtx[index(x, y)];
192 v.mV[VZ] += raised;
193 return v;
194 }
195
196 void setVertex(const U32 x, const U32 y, const F32 raised, LLVector3 &vertex) const
197 {
198 vertex = mVtx[index(x, y)];
199 vertex.mV[VZ] += raised;
200 }
201
202 void setCamPosition(LL2Coord& cam, const LLVector3& cam_pos)
203 {
204 cam.x() = llround((cam_pos.mV[VX] - mRegionOrigin.mV[VX]) / mMinStep);
205 cam.y() = llround((cam_pos.mV[VY] - mRegionOrigin.mV[VY]) / mMinStep);
206 }
207
208 LLVector3 vtx(const LL2Coord& c) const { return mVtx[index(c)]; }
209 LLVector3 norm(const LL2Coord& c) const { return mNorms[index(c)]; }
210 LLVector3 vtx(U32 x, U32 y) const { return mVtx[index(x, y)]; }
211 LLVector3 norm(U32 x, U32 y) const { return mNorms[index(x, y)]; }
212
213protected:
214 LLWaterSurface mWater;
215 U32 mGridDim;
216 U32 mGridDim1;
217};
218
219class LLSurface; 41class LLSurface;
220class LLHeavenBody; 42class LLHeavenBody;
221class LLVOSky; 43class LLVOSky;
222class LLFace; 44class LLFace;
223 45
224class LLVOWater : public LLViewerObject 46class LLVOWater : public LLStaticViewerObject
225{ 47{
226public: 48public:
49 enum
50 {
51 VERTEX_DATA_MASK = (1 << LLVertexBuffer::TYPE_VERTEX) |
52 (1 << LLVertexBuffer::TYPE_NORMAL) |
53 (1 << LLVertexBuffer::TYPE_TEXCOORD)
54 }
55 eVertexDataMask;
56
227 LLVOWater(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp); 57 LLVOWater(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
228 virtual ~LLVOWater() {} 58 virtual ~LLVOWater() {}
229 59
@@ -236,24 +66,19 @@ public:
236 /*virtual*/ BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time); 66 /*virtual*/ BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
237 /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline); 67 /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline);
238 /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); 68 /*virtual*/ BOOL updateGeometry(LLDrawable *drawable);
239 BOOL updateGeometryFlat(LLDrawable *drawable); 69 /*virtual*/ void updateSpatialExtents(LLVector3& newMin, LLVector3& newMax);
240 BOOL updateGeometryHeightFieldSimple(LLDrawable *drawable);
241 BOOL updateGeometryHeightFieldRoam(LLDrawable *drawable);
242 70
243 /*virtual*/ void updateDrawable(BOOL force_damped);
244 /*virtual*/ void updateTextures(LLAgent &agent); 71 /*virtual*/ void updateTextures(LLAgent &agent);
245 /*virtual*/ void setPixelAreaAndAngle(LLAgent &agent); // generate accurate apparent angle and area 72 /*virtual*/ void setPixelAreaAndAngle(LLAgent &agent); // generate accurate apparent angle and area
246 73
74 virtual U32 getPartitionType() const;
75
247 /*virtual*/ BOOL isActive() const; // Whether this object needs to do an idleUpdate. 76 /*virtual*/ BOOL isActive() const; // Whether this object needs to do an idleUpdate.
248 77
249 void setUseTexture(const BOOL use_texture); 78 void setUseTexture(const BOOL use_texture);
250 79
251 static void generateNewWaves(F64 time);
252 static LLWaterSurface* getWaterSurface() { return sGrid->getWaterSurface(); }//return &mWater; }
253 static const LLWaterGrid* getGrid() { return sGrid; }
254protected: 80protected:
255 BOOL mUseTexture; 81 BOOL mUseTexture;
256 static LLWaterGrid *sGrid;
257}; 82};
258 83
259#endif // LL_VOSURFACEPATCH_H 84#endif // LL_VOSURFACEPATCH_H