From d2b253f1f6072beead770519849ad3b18a1a4359 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Wed, 12 Jun 2013 09:16:19 -0700 Subject: Changes to protect against use of normalize3fast on degenerate vectors --- indra/llappearance/llpolymorph.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'indra/llappearance/llpolymorph.cpp') diff --git a/indra/llappearance/llpolymorph.cpp b/indra/llappearance/llpolymorph.cpp index 8a17819083..5e5813b9ac 100644 --- a/indra/llappearance/llpolymorph.cpp +++ b/indra/llappearance/llpolymorph.cpp @@ -568,6 +568,12 @@ void LLPolyMorphTarget::apply( ESex avatar_sex ) F32 *maskWeightArray = (mVertMask) ? mVertMask->getMorphMaskWeights() : NULL; + LLVector4a default_norm; + LLVector4a default_binorm; + + default_norm.set(0,1,0,1); + default_binorm.set(1,0,0,1); + for(U32 vert_index_morph = 0; vert_index_morph < mMorphData->mNumIndices; vert_index_morph++) { S32 vert_index_mesh = mMorphData->mVertexIndices[vert_index_morph]; @@ -597,19 +603,31 @@ void LLPolyMorphTarget::apply( ESex avatar_sex ) norm.mul(delta_weight*maskWeight*NORMAL_SOFTEN_FACTOR); scaled_normals[vert_index_mesh].add(norm); norm = scaled_normals[vert_index_mesh]; - norm.normalize3fast(); + + // guard against degenerate input data before we create NaNs below! + // + norm.normalize3fast_checked(&default_norm); normals[vert_index_mesh] = norm; // calculate new binormals LLVector4a binorm = mMorphData->mBinormals[vert_index_morph]; + + // guard against degenerate input data before we create NaNs below! + // + if (!binorm.isFinite3() || (binorm.dot3(binorm).getF32() <= F_APPROXIMATELY_ZERO)) + { + binorm.set(1,0,0,1); + } + binorm.mul(delta_weight*maskWeight*NORMAL_SOFTEN_FACTOR); scaled_binormals[vert_index_mesh].add(binorm); LLVector4a tangent; tangent.setCross3(scaled_binormals[vert_index_mesh], norm); LLVector4a& normalized_binormal = binormals[vert_index_mesh]; - normalized_binormal.setCross3(norm, tangent); - normalized_binormal.normalize3fast(); - + + normalized_binormal.setCross3(norm, tangent); + normalized_binormal.normalize3fast_checked(&default_binorm); + tex_coords[vert_index_mesh] += mMorphData->mTexCoords[vert_index_morph] * delta_weight * maskWeight; } -- cgit v1.2.3 From 88553c9eb1aee59d092cbd73c64da82497fd095f Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Wed, 12 Jun 2013 12:19:48 -0700 Subject: Cleanup rollback and try point MIPs experiment to see if that's what is hosing the Mac on 10.6.8 --- indra/llappearance/llpolymorph.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'indra/llappearance/llpolymorph.cpp') diff --git a/indra/llappearance/llpolymorph.cpp b/indra/llappearance/llpolymorph.cpp index 5e5813b9ac..93c2f15a53 100644 --- a/indra/llappearance/llpolymorph.cpp +++ b/indra/llappearance/llpolymorph.cpp @@ -568,12 +568,6 @@ void LLPolyMorphTarget::apply( ESex avatar_sex ) F32 *maskWeightArray = (mVertMask) ? mVertMask->getMorphMaskWeights() : NULL; - LLVector4a default_norm; - LLVector4a default_binorm; - - default_norm.set(0,1,0,1); - default_binorm.set(1,0,0,1); - for(U32 vert_index_morph = 0; vert_index_morph < mMorphData->mNumIndices; vert_index_morph++) { S32 vert_index_mesh = mMorphData->mVertexIndices[vert_index_morph]; @@ -606,7 +600,7 @@ void LLPolyMorphTarget::apply( ESex avatar_sex ) // guard against degenerate input data before we create NaNs below! // - norm.normalize3fast_checked(&default_norm); + norm.normalize3fast(); normals[vert_index_mesh] = norm; // calculate new binormals @@ -626,7 +620,7 @@ void LLPolyMorphTarget::apply( ESex avatar_sex ) LLVector4a& normalized_binormal = binormals[vert_index_mesh]; normalized_binormal.setCross3(norm, tangent); - normalized_binormal.normalize3fast_checked(&default_binorm); + normalized_binormal.normalize3fast(); tex_coords[vert_index_mesh] += mMorphData->mTexCoords[vert_index_morph] * delta_weight * maskWeight; } -- cgit v1.2.3