summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2021-02-16 21:47:34 +0200
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2021-02-16 21:47:34 +0200
commit9eae41e5825662564125b9f5edf87e1aa3c0c508 (patch)
tree191d7110a181b5a48f52a31ff9dd7568c75a5c1d /indra
parentfa35eeecd7854b92e52f7bac2dc31bfc07ce012b (diff)
SL-14725 Validate trackball elevation
Diffstat (limited to 'indra')
-rw-r--r--indra/llui/llvirtualtrackball.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/indra/llui/llvirtualtrackball.cpp b/indra/llui/llvirtualtrackball.cpp
index 728e86af08..6e0aef740d 100644
--- a/indra/llui/llvirtualtrackball.cpp
+++ b/indra/llui/llvirtualtrackball.cpp
@@ -370,7 +370,10 @@ void LLVirtualTrackball::getAzimuthAndElevation(const LLQuaternion &quat, F32 &a
azimuth += F_PI * 2;
}
- elevation = asin(point.mV[VZ]); // because VectorZero is '1'
+ // while vector is '1', F32 is not sufficiently precise and we can get
+ // values like 1.0000012 which will result in -90deg angle instead of 90deg
+ F32 z = llclamp(point.mV[VZ], -1.f, 1.f);
+ elevation = asin(z); // because VectorZero's length is '1'
}
// static
@@ -442,6 +445,10 @@ BOOL LLVirtualTrackball::handleHover(S32 x, S32 y, MASK mask)
mValue *= az_quat;
}
+ // we are doing a lot of F32 mathematical operations with loss of precision,
+ // re-normalize to compensate
+ mValue.normalize();
+
mPrevX = x;
mPrevY = y;
onCommit();