diff options
Diffstat (limited to 'indra/newview/llvowater.cpp')
-rw-r--r-- | indra/newview/llvowater.cpp | 63 |
1 files changed, 30 insertions, 33 deletions
diff --git a/indra/newview/llvowater.cpp b/indra/newview/llvowater.cpp index 089a7712c0..77ad967cef 100644 --- a/indra/newview/llvowater.cpp +++ b/indra/newview/llvowater.cpp @@ -35,7 +35,6 @@ #include "llface.h" #include "llsky.h" #include "llsurface.h" -#include "llvosky.h" #include "llviewercamera.h" #include "llviewertexturelist.h" #include "llviewerregion.h" @@ -143,17 +142,26 @@ BOOL LLVOWater::updateGeometry(LLDrawable *drawable) static const unsigned int vertices_per_quad = 4; static const unsigned int indices_per_quad = 6; - const S32 size = LLPipeline::sRenderTransparentWater ? 16 : 1; + S32 size_x = LLPipeline::sRenderTransparentWater ? 8 : 1; + S32 size_y = LLPipeline::sRenderTransparentWater ? 8 : 1; - const S32 num_quads = size * size; + const LLVector3& scale = getScale(); + size_x *= llmin(llround(scale.mV[0] / 256.f), 8); + size_y *= llmin(llround(scale.mV[1] / 256.f), 8); + + const S32 num_quads = size_x * size_y; face->setSize(vertices_per_quad * num_quads, indices_per_quad * num_quads); LLVertexBuffer* buff = face->getVertexBuffer(); - if (!buff || !buff->isWriteable()) + if (!buff || + buff->getNumIndices() != face->getIndicesCount() || + buff->getNumVerts() != face->getGeomCount() || + face->getIndicesStart() != 0 || + face->getGeomIndex() != 0) { - buff = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK, GL_DYNAMIC_DRAW_ARB); - if (!buff->allocateBuffer(face->getGeomCount(), face->getIndicesCount(), TRUE)) + buff = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK); + if (!buff->allocateBuffer(face->getGeomCount(), face->getIndicesCount())) { LL_WARNS() << "Failed to allocate Vertex Buffer on water update to " << face->getGeomCount() << " vertices and " @@ -163,13 +171,6 @@ BOOL LLVOWater::updateGeometry(LLDrawable *drawable) face->setGeomIndex(0); face->setVertexBuffer(buff); } - else - { - if (!buff->resizeBuffer(face->getGeomCount(), face->getIndicesCount())) - { - LL_WARNS() << "Failed to resize Vertex Buffer" << LL_ENDL; - } - } index_offset = face->getGeometry(verticesp,normalsp,texCoordsp, indicesp); @@ -179,41 +180,37 @@ BOOL LLVOWater::updateGeometry(LLDrawable *drawable) face->mCenterLocal = position_agent; S32 x, y; - F32 step_x = getScale().mV[0] / size; - F32 step_y = getScale().mV[1] / size; + F32 step_x = getScale().mV[0] / size_x; + F32 step_y = getScale().mV[1] / size_y; const LLVector3 up(0.f, step_y * 0.5f, 0.f); const LLVector3 right(step_x * 0.5f, 0.f, 0.f); const LLVector3 normal(0.f, 0.f, 1.f); - F32 size_inv = 1.f / size; - - F32 z_fudge = 0.f; + F32 size_inv_x = 1.f / size_x; + F32 size_inv_y = 1.f / size_y; - if (getIsEdgePatch()) - { //bump edge patches down 10 cm to prevent aliasing along edges - z_fudge = -0.1f; - } - - for (y = 0; y < size; y++) + for (y = 0; y < size_y; y++) { - for (x = 0; x < size; x++) + for (x = 0; x < size_x; x++) { - S32 toffset = index_offset + 4*(y*size + x); + S32 toffset = index_offset + 4*(y*size_x + x); 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; + + position_agent.mV[VX] = llround(position_agent.mV[VX]); + position_agent.mV[VY] = llround(position_agent.mV[VY]); *verticesp++ = position_agent - right + up; *verticesp++ = position_agent - right - up; *verticesp++ = position_agent + right + up; *verticesp++ = position_agent + right - up; - *texCoordsp++ = LLVector2(x*size_inv, (y+1)*size_inv); - *texCoordsp++ = LLVector2(x*size_inv, y*size_inv); - *texCoordsp++ = LLVector2((x+1)*size_inv, (y+1)*size_inv); - *texCoordsp++ = LLVector2((x+1)*size_inv, y*size_inv); + *texCoordsp++ = LLVector2(x*size_inv_x, (y+1)*size_inv_y); + *texCoordsp++ = LLVector2(x*size_inv_x, y*size_inv_y); + *texCoordsp++ = LLVector2((x+1)*size_inv_x, (y+1)*size_inv_y); + *texCoordsp++ = LLVector2((x+1)*size_inv_x, y*size_inv_y); *normalsp++ = normal; *normalsp++ = normal; @@ -230,7 +227,7 @@ BOOL LLVOWater::updateGeometry(LLDrawable *drawable) } } - buff->flush(); + buff->unmapBuffer(); mDrawable->movePartition(); LLPipeline::sCompiles++; @@ -295,7 +292,7 @@ U32 LLVOVoidWater::getPartitionType() const } LLWaterPartition::LLWaterPartition(LLViewerRegion* regionp) -: LLSpatialPartition(0, FALSE, GL_DYNAMIC_DRAW_ARB, regionp) +: LLSpatialPartition(0, FALSE, regionp) { mInfiniteFarClip = TRUE; mDrawableType = LLPipeline::RENDER_TYPE_WATER; |