summaryrefslogtreecommitdiff
path: root/indra/llprimitive
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2011-01-20 14:49:05 -0500
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2011-01-20 14:49:05 -0500
commit32d3d2e0503ef81a7d1e40f7e7464ca6743d540f (patch)
tree02f86ed9727f365131efde15799eae12921760f5 /indra/llprimitive
parent1b2c082feb91b4837a0cb5652d1668f6582e9bc9 (diff)
SH-749 FIX: check for zero-extent to avoid div by zero
Diffstat (limited to 'indra/llprimitive')
-rwxr-xr-xindra/llprimitive/llmodel.cpp19
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);