From 7a29b2d1cd471767b58ea30f53900cd2c5a9637c Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:45:35 -0500 Subject: Second Life viewer sources 1.19.1.1 --- linden/indra/llmath/llvolume.cpp | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'linden/indra/llmath') diff --git a/linden/indra/llmath/llvolume.cpp b/linden/indra/llmath/llvolume.cpp index 266ec08..7403724 100644 --- a/linden/indra/llmath/llvolume.cpp +++ b/linden/indra/llmath/llvolume.cpp @@ -2078,6 +2078,14 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, } mSculptLevel = sculpt_level; + + // Delete any existing faces so that they get regenerated + if (mVolumeFaces) + { + delete[] mVolumeFaces; + mVolumeFaces = NULL; + } + createVolumeFaces(); } @@ -4820,29 +4828,33 @@ BOOL LLVolumeFace::createSide(BOOL partial_build) } } - //generate normals - for (U32 i = 0; i < mIndices.size()/3; i++) { //for each triangle - const VertexData& v0 = mVertices[mIndices[i*3+0]]; - const VertexData& v1 = mVertices[mIndices[i*3+1]]; - const VertexData& v2 = mVertices[mIndices[i*3+2]]; + //generate normals + for (U32 i = 0; i < mIndices.size()/3; i++) //for each triangle + { + const S32 i0 = mIndices[i*3+0]; + const S32 i1 = mIndices[i*3+1]; + const S32 i2 = mIndices[i*3+2]; + const VertexData& v0 = mVertices[i0]; + const VertexData& v1 = mVertices[i1]; + const VertexData& v2 = mVertices[i2]; //calculate triangle normal - LLVector3 norm = (v0.mPosition-v1.mPosition)% - (v0.mPosition-v2.mPosition); + LLVector3 norm = (v0.mPosition-v1.mPosition) % (v0.mPosition-v2.mPosition); for (U32 j = 0; j < 3; j++) { //add triangle normal to vertices - mVertices[mIndices[i*3+j]].mNormal += norm; // * (weight_sum - d[j])/weight_sum; + const S32 idx = mIndices[i*3+j]; + mVertices[idx].mNormal += norm; // * (weight_sum - d[j])/weight_sum; } //even out quad contributions - if (i % 2 == 0) + if ((i & 1) == 0) { - mVertices[mIndices[i*3+2]].mNormal += norm; + mVertices[i2].mNormal += norm; } else { - mVertices[mIndices[i*3+1]].mNormal += norm; + mVertices[i1].mNormal += norm; } } -- cgit v1.1