aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llvowater.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llvowater.cpp
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llvowater.cpp84
1 files changed, 38 insertions, 46 deletions
diff --git a/linden/indra/newview/llvowater.cpp b/linden/indra/newview/llvowater.cpp
index 16bdc2f..1acda16 100644
--- a/linden/indra/newview/llvowater.cpp
+++ b/linden/indra/newview/llvowater.cpp
@@ -48,6 +48,7 @@
48#include "llviewerregion.h" 48#include "llviewerregion.h"
49#include "llworld.h" 49#include "llworld.h"
50#include "pipeline.h" 50#include "pipeline.h"
51#include "llspatialpartition.h"
51 52
52const BOOL gUseRoam = FALSE; 53const BOOL gUseRoam = FALSE;
53 54
@@ -76,6 +77,7 @@ LLVOWater::LLVOWater(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regi
76 setScale(LLVector3(256.f, 256.f, 0.f)); // Hack for setting scale for bounding boxes/visibility. 77 setScale(LLVector3(256.f, 256.f, 0.f)); // Hack for setting scale for bounding boxes/visibility.
77 78
78 mUseTexture = TRUE; 79 mUseTexture = TRUE;
80 mIsEdgePatch = FALSE;
79} 81}
80 82
81 83
@@ -106,14 +108,14 @@ void LLVOWater::updateTextures(LLAgent &agent)
106// Never gets called 108// Never gets called
107BOOL LLVOWater::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) 109BOOL LLVOWater::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
108{ 110{
109 if (mDead || !(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_WATER))) 111 /*if (mDead || !(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_WATER)))
110 { 112 {
111 return TRUE; 113 return TRUE;
112 } 114 }
113 if (mDrawable) 115 if (mDrawable)
114 { 116 {
115 gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE); 117 gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE);
116 } 118 }*/
117 return TRUE; 119 return TRUE;
118} 120}
119 121
@@ -149,23 +151,23 @@ BOOL LLVOWater::updateGeometry(LLDrawable *drawable)
149 } 151 }
150 face = drawable->getFace(0); 152 face = drawable->getFace(0);
151 153
152 LLVector2 uvs[4]; 154// LLVector2 uvs[4];
153 LLVector3 vtx[4]; 155// LLVector3 vtx[4];
154 156
155 LLStrider<LLVector3> verticesp, normalsp; 157 LLStrider<LLVector3> verticesp, normalsp;
156 LLStrider<LLVector2> texCoordsp; 158 LLStrider<LLVector2> texCoordsp;
157 LLStrider<U32> indicesp; 159 LLStrider<U16> indicesp;
158 S32 index_offset; 160 U16 index_offset;
159 161
160 S32 size = 16; 162 S32 size = 16;
161 163
164 S32 num_quads = size*size;
165 face->setSize(4*num_quads, 6*num_quads);
166
162 if (face->mVertexBuffer.isNull()) 167 if (face->mVertexBuffer.isNull())
163 { 168 {
164 S32 num_quads = size*size;
165 face->setSize(4*num_quads, 6*num_quads);
166
167 face->mVertexBuffer = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK, GL_DYNAMIC_DRAW_ARB); 169 face->mVertexBuffer = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK, GL_DYNAMIC_DRAW_ARB);
168 face->mVertexBuffer->allocateBuffer(4*num_quads, 6*num_quads, TRUE); 170 face->mVertexBuffer->allocateBuffer(face->getGeomCount(), face->getIndicesCount(), TRUE);
169 face->setIndicesIndex(0); 171 face->setIndicesIndex(0);
170 face->setGeomIndex(0); 172 face->setGeomIndex(0);
171 } 173 }
@@ -175,11 +177,7 @@ BOOL LLVOWater::updateGeometry(LLDrawable *drawable)
175 } 177 }
176 178
177 index_offset = face->getGeometry(verticesp,normalsp,texCoordsp, indicesp); 179 index_offset = face->getGeometry(verticesp,normalsp,texCoordsp, indicesp);
178 if (-1 == index_offset) 180
179 {
180 return TRUE;
181 }
182
183 LLVector3 position_agent; 181 LLVector3 position_agent;
184 position_agent = getPositionAgent(); 182 position_agent = getPositionAgent();
185 face->mCenterAgent = position_agent; 183 face->mCenterAgent = position_agent;
@@ -204,34 +202,20 @@ BOOL LLVOWater::updateGeometry(LLDrawable *drawable)
204 position_agent.mV[VX] += (x + 0.5f) * step_x; 202 position_agent.mV[VX] += (x + 0.5f) * step_x;
205 position_agent.mV[VY] += (y + 0.5f) * step_y; 203 position_agent.mV[VY] += (y + 0.5f) * step_y;
206 204
207 vtx[0] = position_agent - right + up; 205 *verticesp++ = position_agent - right + up;
208 vtx[1] = position_agent - right - up; 206 *verticesp++ = position_agent - right - up;
209 vtx[2] = position_agent + right + up; 207 *verticesp++ = position_agent + right + up;
210 vtx[3] = position_agent + right - up; 208 *verticesp++ = position_agent + right - up;
211 209
212 *(verticesp++) = vtx[0]; 210 *texCoordsp++ = LLVector2(x*size_inv, (y+1)*size_inv);
213 *(verticesp++) = vtx[1]; 211 *texCoordsp++ = LLVector2(x*size_inv, y*size_inv);
214 *(verticesp++) = vtx[2]; 212 *texCoordsp++ = LLVector2((x+1)*size_inv, (y+1)*size_inv);
215 *(verticesp++) = vtx[3]; 213 *texCoordsp++ = LLVector2((x+1)*size_inv, y*size_inv);
216 214
217 uvs[0].setVec(x*size_inv, (y+1)*size_inv); 215 *normalsp++ = normal;
218 uvs[1].setVec(x*size_inv, y*size_inv); 216 *normalsp++ = normal;
219 uvs[2].setVec((x+1)*size_inv, (y+1)*size_inv); 217 *normalsp++ = normal;
220 uvs[3].setVec((x+1)*size_inv, y*size_inv); 218 *normalsp++ = normal;
221
222 *(texCoordsp) = uvs[0];
223 texCoordsp++;
224 *(texCoordsp) = uvs[1];
225 texCoordsp++;
226 *(texCoordsp) = uvs[2];
227 texCoordsp++;
228 *(texCoordsp) = uvs[3];
229 texCoordsp++;
230
231 *(normalsp++) = normal;
232 *(normalsp++) = normal;
233 *(normalsp++) = normal;
234 *(normalsp++) = normal;
235 219
236 *indicesp++ = toffset + 0; 220 *indicesp++ = toffset + 0;
237 *indicesp++ = toffset + 1; 221 *indicesp++ = toffset + 1;
@@ -243,6 +227,8 @@ BOOL LLVOWater::updateGeometry(LLDrawable *drawable)
243 } 227 }
244 } 228 }
245 229
230 face->mVertexBuffer->setBuffer(0);
231
246 mDrawable->movePartition(); 232 mDrawable->movePartition();
247 LLPipeline::sCompiles++; 233 LLPipeline::sCompiles++;
248 return TRUE; 234 return TRUE;
@@ -268,6 +254,11 @@ void LLVOWater::setUseTexture(const BOOL use_texture)
268 mUseTexture = use_texture; 254 mUseTexture = use_texture;
269} 255}
270 256
257void LLVOWater::setIsEdgePatch(const BOOL edge_patch)
258{
259 mIsEdgePatch = edge_patch;
260}
261
271void LLVOWater::updateSpatialExtents(LLVector3 &newMin, LLVector3& newMax) 262void LLVOWater::updateSpatialExtents(LLVector3 &newMin, LLVector3& newMax)
272{ 263{
273 LLVector3 pos = getPositionAgent(); 264 LLVector3 pos = getPositionAgent();
@@ -281,13 +272,14 @@ void LLVOWater::updateSpatialExtents(LLVector3 &newMin, LLVector3& newMax)
281 272
282U32 LLVOWater::getPartitionType() const 273U32 LLVOWater::getPartitionType() const
283{ 274{
284 return LLPipeline::PARTITION_WATER; 275 return LLViewerRegion::PARTITION_WATER;
285} 276}
286 277
287LLWaterPartition::LLWaterPartition() 278LLWaterPartition::LLWaterPartition()
288: LLSpatialPartition(0) 279: LLSpatialPartition(0)
289{ 280{
290 mRenderByGroup = FALSE; 281 mRenderByGroup = FALSE;
282 mInfiniteFarClip = TRUE;
291 mDrawableType = LLPipeline::RENDER_TYPE_WATER; 283 mDrawableType = LLPipeline::RENDER_TYPE_WATER;
292 mPartitionType = LLPipeline::PARTITION_WATER; 284 mPartitionType = LLViewerRegion::PARTITION_WATER;
293} 285}