diff options
author | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2011-01-20 14:49:05 -0500 |
---|---|---|
committer | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2011-01-20 14:49:05 -0500 |
commit | 32d3d2e0503ef81a7d1e40f7e7464ca6743d540f (patch) | |
tree | 02f86ed9727f365131efde15799eae12921760f5 /indra/llprimitive | |
parent | 1b2c082feb91b4837a0cb5652d1668f6582e9bc9 (diff) |
SH-749 FIX: check for zero-extent to avoid div by zero
Diffstat (limited to 'indra/llprimitive')
-rwxr-xr-x | indra/llprimitive/llmodel.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 1869e1dd47..3d03209eaf 100755 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -950,6 +950,25 @@ void LLModel::normalizeVolumeFaces() LLVector4a size; size.setSub(max, min); + // Prevent division by zero. + F32 x = size[0]; + F32 y = size[1]; + F32 z = size[2]; + F32 w = size[3]; + if (fabs(x)<F_APPROXIMATELY_ZERO) + { + x = 1.0; + } + if (fabs(y)<F_APPROXIMATELY_ZERO) + { + y = 1.0; + } + if (fabs(z)<F_APPROXIMATELY_ZERO) + { + z = 1.0; + } + size.set(x,y,z,w); + // Compute scale as reciprocal of size LLVector4a scale; scale.splat(1.f); |