diff options
Diffstat (limited to 'indra/newview/llvowater.cpp')
-rw-r--r-- | indra/newview/llvowater.cpp | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/indra/newview/llvowater.cpp b/indra/newview/llvowater.cpp index 71f08ec36d..cd78157944 100644 --- a/indra/newview/llvowater.cpp +++ b/indra/newview/llvowater.cpp @@ -160,22 +160,24 @@ BOOL LLVOWater::updateGeometry(LLDrawable *drawable) static const unsigned int vertices_per_quad = 4; static const unsigned int indices_per_quad = 6; - const S32 size = gSavedSettings.getBOOL("RenderTransparentWater") ? 16 : 1; + const S32 size = gSavedSettings.getBOOL("RenderTransparentWater") && LLGLSLShader::sNoFixedFunction ? 16 : 1; const S32 num_quads = size * size; face->setSize(vertices_per_quad * num_quads, indices_per_quad * num_quads); - if (face->mVertexBuffer.isNull()) + LLVertexBuffer* buff = face->getVertexBuffer(); + if (!buff || !buff->isWriteable()) { - face->mVertexBuffer = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK, GL_DYNAMIC_DRAW_ARB); - face->mVertexBuffer->allocateBuffer(face->getGeomCount(), face->getIndicesCount(), TRUE); + buff = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK, GL_DYNAMIC_DRAW_ARB); + buff->allocateBuffer(face->getGeomCount(), face->getIndicesCount(), TRUE); face->setIndicesIndex(0); face->setGeomIndex(0); + face->setVertexBuffer(buff); } else { - face->mVertexBuffer->resizeBuffer(face->getGeomCount(), face->getIndicesCount()); + buff->resizeBuffer(face->getGeomCount(), face->getIndicesCount()); } index_offset = face->getGeometry(verticesp,normalsp,texCoordsp, indicesp); @@ -195,6 +197,13 @@ BOOL LLVOWater::updateGeometry(LLDrawable *drawable) F32 size_inv = 1.f / size; + F32 z_fudge = 0.f; + + if (getIsEdgePatch()) + { //bump edge patches down 10 cm to prevent aliasing along edges + z_fudge = -0.1f; + } + for (y = 0; y < size; y++) { for (x = 0; x < size; x++) @@ -203,6 +212,7 @@ BOOL LLVOWater::updateGeometry(LLDrawable *drawable) position_agent = getPositionAgent() - getScale() * 0.5f; position_agent.mV[VX] += (x + 0.5f) * step_x; position_agent.mV[VY] += (y + 0.5f) * step_y; + position_agent.mV[VZ] += z_fudge; *verticesp++ = position_agent - right + up; *verticesp++ = position_agent - right - up; @@ -229,7 +239,7 @@ BOOL LLVOWater::updateGeometry(LLDrawable *drawable) } } - face->mVertexBuffer->setBuffer(0); + buff->flush(); mDrawable->movePartition(); LLPipeline::sCompiles++; @@ -261,19 +271,30 @@ void LLVOWater::setIsEdgePatch(const BOOL edge_patch) mIsEdgePatch = edge_patch; } -void LLVOWater::updateSpatialExtents(LLVector3 &newMin, LLVector3& newMax) +void LLVOWater::updateSpatialExtents(LLVector4a &newMin, LLVector4a& newMax) { - LLVector3 pos = getPositionAgent(); - LLVector3 scale = getScale(); - - newMin = pos - scale * 0.5f; - newMax = pos + scale * 0.5f; + LLVector4a pos; + pos.load3(getPositionAgent().mV); + LLVector4a scale; + scale.load3(getScale().mV); + scale.mul(0.5f); + + newMin.setSub(pos, scale); + newMax.setAdd(pos, scale); + + pos.setAdd(newMin,newMax); + pos.mul(0.5f); - mDrawable->setPositionGroup((newMin + newMax) * 0.5f); + mDrawable->setPositionGroup(pos); } U32 LLVOWater::getPartitionType() const { + if (mIsEdgePatch) + { + return LLViewerRegion::PARTITION_VOIDWATER; + } + return LLViewerRegion::PARTITION_WATER; } @@ -283,7 +304,7 @@ U32 LLVOVoidWater::getPartitionType() const } LLWaterPartition::LLWaterPartition() -: LLSpatialPartition(0, FALSE, 0) +: LLSpatialPartition(0, FALSE, GL_DYNAMIC_DRAW_ARB) { mInfiniteFarClip = TRUE; mDrawableType = LLPipeline::RENDER_TYPE_WATER; @@ -292,6 +313,7 @@ LLWaterPartition::LLWaterPartition() LLVoidWaterPartition::LLVoidWaterPartition() { + mOcclusionEnabled = FALSE; mDrawableType = LLPipeline::RENDER_TYPE_VOIDWATER; mPartitionType = LLViewerRegion::PARTITION_VOIDWATER; } |