diff options
author | Dave Parks <davep@lindenlab.com> | 2011-06-09 17:03:53 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2011-06-09 17:03:53 -0500 |
commit | 91fe50ecc7f6e2c38286a456f2cb795fbcc92dd8 (patch) | |
tree | f987b5246e57fbc1aa15e9929caf2097d66897db | |
parent | 75e366dd6f9abd50263c87e0e8106dc0abbcefb4 (diff) |
SH-1802 Fix for disappearing meshes under some circuimstances.
-rw-r--r-- | indra/llmath/llvolume.cpp | 22 | ||||
-rw-r--r-- | indra/newview/llface.cpp | 31 |
2 files changed, 46 insertions, 7 deletions
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 379ef4b344..8c81f27784 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -2642,14 +2642,20 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size) LLVector4a& min = face.mExtents[0]; LLVector4a& max = face.mExtents[1]; - min.clear(); - max.clear(); - min = max = face.mPositions[0]; - - for (S32 i = 1; i < face.mNumVertices; ++i) + if (face.mNumVertices < 3) + { //empty face, use a dummy 1cm (at 1m scale) bounding box + min.splat(-0.005f); + max.splat(0.005f); + } + else { - min.setMin(min, face.mPositions[i]); - max.setMax(max, face.mPositions[i]); + min = max = face.mPositions[0]; + + for (S32 i = 1; i < face.mNumVertices; ++i) + { + min.setMin(min, face.mPositions[i]); + max.setMax(max, face.mPositions[i]); + } } } } @@ -5506,6 +5512,8 @@ LLVolumeFace::LLVolumeFace() : mOctree(NULL) { mExtents = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*3); + mExtents[0].splat(-0.5f); + mExtents[1].splat(0.5f); mCenter = mExtents+2; } diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 540ed054e9..b6566fcbd0 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -693,6 +693,19 @@ static void xform(LLVector2 &tex_coord, F32 cosAng, F32 sinAng, F32 offS, F32 of } +bool less_than_max_mag(const LLVector4a& vec) +{ + LLVector4a MAX_MAG; + MAX_MAG.splat(1024.f*1024.f); + + LLVector4a val; + val.setAbs(vec); + + S32 lt = val.lessThan(MAX_MAG).getGatheredBits() & 0x7; + + return lt == 0x7; +} + BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f, const LLMatrix4& mat_vert_in, const LLMatrix3& mat_normal_in, BOOL global_volume) { @@ -727,6 +740,8 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f, min = face.mExtents[0]; max = face.mExtents[1]; + llassert(less_than_max_mag(min)); + llassert(less_than_max_mag(max)); //min, max are in volume space, convert to drawable render space LLVector4a center; @@ -738,6 +753,9 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f, size.setSub(max, min); size.mul(0.5f); + llassert(less_than_max_mag(min)); + llassert(less_than_max_mag(max)); + if (!global_volume) { //VECTORIZE THIS @@ -775,6 +793,8 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f, newMin = newMax = center; + llassert(less_than_max_mag(center)); + for (U32 i = 0; i < 4; i++) { LLVector4a delta; @@ -786,6 +806,9 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f, newMin.setMin(newMin,min); newMax.setMax(newMax,max); + + llassert(less_than_max_mag(newMin)); + llassert(less_than_max_mag(newMax)); } if (!mDrawablep->isActive()) @@ -794,14 +817,22 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f, offset.load3(mDrawablep->getRegion()->getOriginAgent().mV); newMin.add(offset); newMax.add(offset); + + llassert(less_than_max_mag(newMin)); + llassert(less_than_max_mag(newMax)); } t.setAdd(newMin, newMax); t.mul(0.5f); + llassert(less_than_max_mag(t)); + //VECTORIZE THIS mCenterLocal.set(t.getF32ptr()); + llassert(less_than_max_mag(newMin)); + llassert(less_than_max_mag(newMax)); + t.setSub(newMax,newMin); mBoundingSphereRadius = t.getLength3().getF32()*0.5f; |