diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2021-02-16 21:47:34 +0200 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2021-02-16 21:47:34 +0200 |
commit | 9eae41e5825662564125b9f5edf87e1aa3c0c508 (patch) | |
tree | 191d7110a181b5a48f52a31ff9dd7568c75a5c1d /indra/llui | |
parent | fa35eeecd7854b92e52f7bac2dc31bfc07ce012b (diff) |
SL-14725 Validate trackball elevation
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llvirtualtrackball.cpp | 9 |
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(); |