aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmath
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:35 -0500
committerJacek Antonelli2008-08-15 23:45:35 -0500
commit7a29b2d1cd471767b58ea30f53900cd2c5a9637c (patch)
treea2f7b5eb90ec41f903f2558e57d47f5ebd913a8f /linden/indra/llmath
parentSecond Life viewer sources 1.19.1.0 (diff)
downloadmeta-impy-7a29b2d1cd471767b58ea30f53900cd2c5a9637c.zip
meta-impy-7a29b2d1cd471767b58ea30f53900cd2c5a9637c.tar.gz
meta-impy-7a29b2d1cd471767b58ea30f53900cd2c5a9637c.tar.bz2
meta-impy-7a29b2d1cd471767b58ea30f53900cd2c5a9637c.tar.xz
Second Life viewer sources 1.19.1.1
Diffstat (limited to 'linden/indra/llmath')
-rw-r--r--linden/indra/llmath/llvolume.cpp34
1 files changed, 23 insertions, 11 deletions
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,
2078 } 2078 }
2079 2079
2080 mSculptLevel = sculpt_level; 2080 mSculptLevel = sculpt_level;
2081
2082 // Delete any existing faces so that they get regenerated
2083 if (mVolumeFaces)
2084 {
2085 delete[] mVolumeFaces;
2086 mVolumeFaces = NULL;
2087 }
2088
2081 createVolumeFaces(); 2089 createVolumeFaces();
2082} 2090}
2083 2091
@@ -4820,29 +4828,33 @@ BOOL LLVolumeFace::createSide(BOOL partial_build)
4820 } 4828 }
4821 } 4829 }
4822 4830
4823 //generate normals 4831 //generate normals
4824 for (U32 i = 0; i < mIndices.size()/3; i++) { //for each triangle 4832 for (U32 i = 0; i < mIndices.size()/3; i++) //for each triangle
4825 const VertexData& v0 = mVertices[mIndices[i*3+0]]; 4833 {
4826 const VertexData& v1 = mVertices[mIndices[i*3+1]]; 4834 const S32 i0 = mIndices[i*3+0];
4827 const VertexData& v2 = mVertices[mIndices[i*3+2]]; 4835 const S32 i1 = mIndices[i*3+1];
4836 const S32 i2 = mIndices[i*3+2];
4837 const VertexData& v0 = mVertices[i0];
4838 const VertexData& v1 = mVertices[i1];
4839 const VertexData& v2 = mVertices[i2];
4828 4840
4829 //calculate triangle normal 4841 //calculate triangle normal
4830 LLVector3 norm = (v0.mPosition-v1.mPosition)% 4842 LLVector3 norm = (v0.mPosition-v1.mPosition) % (v0.mPosition-v2.mPosition);
4831 (v0.mPosition-v2.mPosition);
4832 4843
4833 for (U32 j = 0; j < 3; j++) 4844 for (U32 j = 0; j < 3; j++)
4834 { //add triangle normal to vertices 4845 { //add triangle normal to vertices
4835 mVertices[mIndices[i*3+j]].mNormal += norm; // * (weight_sum - d[j])/weight_sum; 4846 const S32 idx = mIndices[i*3+j];
4847 mVertices[idx].mNormal += norm; // * (weight_sum - d[j])/weight_sum;
4836 } 4848 }
4837 4849
4838 //even out quad contributions 4850 //even out quad contributions
4839 if (i % 2 == 0) 4851 if ((i & 1) == 0)
4840 { 4852 {
4841 mVertices[mIndices[i*3+2]].mNormal += norm; 4853 mVertices[i2].mNormal += norm;
4842 } 4854 }
4843 else 4855 else
4844 { 4856 {
4845 mVertices[mIndices[i*3+1]].mNormal += norm; 4857 mVertices[i1].mNormal += norm;
4846 } 4858 }
4847 } 4859 }
4848 4860