summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreyL ProductEngine <alihatskiy@productengine.com>2018-08-08 03:28:37 +0300
committerAndreyL ProductEngine <alihatskiy@productengine.com>2018-08-08 03:28:37 +0300
commit6a54e0948d651963399da82cfc5672125b9442e7 (patch)
tree3b2560f2478a4eb74feb4b0802fdce18f42c393b
parentcd5f7b2c03e87cc5d236eaa5b8c025530571376a (diff)
MAINT-8900 LLVirtualTrackball improvement: added click-to-set mode
-rw-r--r--indra/llui/llvirtualtrackball.cpp73
-rw-r--r--indra/newview/skins/default/xui/en/widgets/sun_moon_trackball.xml2
2 files changed, 56 insertions, 19 deletions
diff --git a/indra/llui/llvirtualtrackball.cpp b/indra/llui/llvirtualtrackball.cpp
index 0ddbe8b9c2..a24c5a420d 100644
--- a/indra/llui/llvirtualtrackball.cpp
+++ b/indra/llui/llvirtualtrackball.cpp
@@ -321,29 +321,66 @@ BOOL LLVirtualTrackball::handleHover(S32 x, S32 y, MASK mask)
{
if (hasMouseCapture())
{
- LLQuaternion delta;
-
- F32 rotX = x - mPrevX;
- F32 rotY = y - mPrevY;
-
- if (abs(rotX) > 1)
- {
- F32 direction = (rotX < 0) ? -1 : 1;
- delta.setAngleAxis(mIncrementMouse * abs(rotX), 0, direction, 0); // changing X - rotate around Y axis
- mValue *= delta;
+ if (mask == MASK_CONTROL)
+ { // trackball (move to roll) mode
+ LLQuaternion delta;
+
+ F32 rotX = x - mPrevX;
+ F32 rotY = y - mPrevY;
+
+ if (abs(rotX) > 1)
+ {
+ F32 direction = (rotX < 0) ? -1 : 1;
+ delta.setAngleAxis(mIncrementMouse * abs(rotX), 0, direction, 0); // changing X - rotate around Y axis
+ mValue *= delta;
+ }
+
+ if (abs(rotY) > 1)
+ {
+ F32 direction = (rotY < 0) ? 1 : -1; // reverse for Y (value increases from bottom to top)
+ delta.setAngleAxis(mIncrementMouse * abs(rotY), direction, 0, 0); // changing Y - rotate around X axis
+ mValue *= delta;
+ }
}
-
- if (abs(rotY) > 1)
- {
- F32 direction = (rotY < 0) ? 1 : -1; // reverse for Y (value increases from bottom to top)
- delta.setAngleAxis(mIncrementMouse * abs(rotY), direction, 0, 0); // changing Y - rotate around X axis
- mValue *= delta;
+ else
+ { // set on click mode
+ if (!pointInTouchCircle(x, y))
+ {
+ return TRUE; // don't drag outside the circle
+ }
+
+ F32 radius = mTouchArea->getRect().getWidth() / 2;
+ F32 xx = x - mTouchArea->getRect().getCenterX();
+ F32 yy = y - mTouchArea->getRect().getCenterY();
+ F32 dist = sqrt(pow(xx, 2) + pow(yy, 2));
+
+ F32 azimuth = llclamp(acosf(xx / dist), 0.0f, F_PI);
+ F32 altitude = llclamp(acosf(dist / radius), 0.0f, F_PI_BY_TWO);
+
+ if (yy < 0)
+ {
+ azimuth = F_TWO_PI - azimuth;
+ }
+
+ LLVector3 draw_point = VectorZero * mValue;
+ if (draw_point.mV[VZ] >= 0.f)
+ {
+ if (is_approx_zero(altitude)) // don't change the hemisphere
+ {
+ altitude = F_APPROXIMATELY_ZERO;
+ }
+ altitude *= -1;
+ }
+
+ mValue.setAngleAxis(altitude, 0, 1, 0);
+ LLQuaternion az_quat;
+ az_quat.setAngleAxis(azimuth, 0, 0, 1);
+ mValue *= az_quat;
}
-
- onCommit();
mPrevX = x;
mPrevY = y;
+ onCommit();
}
return TRUE;
}
diff --git a/indra/newview/skins/default/xui/en/widgets/sun_moon_trackball.xml b/indra/newview/skins/default/xui/en/widgets/sun_moon_trackball.xml
index 68681b8228..3a9655b317 100644
--- a/indra/newview/skins/default/xui/en/widgets/sun_moon_trackball.xml
+++ b/indra/newview/skins/default/xui/en/widgets/sun_moon_trackball.xml
@@ -4,7 +4,7 @@
width="150"
height="150"
user_resize="false"
- increment_angle_mouse="0.5f"
+ increment_angle_mouse="1.5f"
increment_angle_btn="3.0f"
image_sphere="VirtualTrackball_Sphere"
image_moon_back="VirtualTrackball_Moon_Back"