From fabf9607af47ead8530d0feff41effb9736d0120 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 25 Feb 2011 15:44:31 -0800 Subject: SOCIAL-548 FIX shorten delay for avatar inspector tooltips --- indra/newview/lltoolpie.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/lltoolpie.cpp') diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index 562b9219b4..19d7b70101 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -936,7 +936,7 @@ BOOL LLToolPie::handleTooltipObject( LLViewerObject* hover_object, std::string l p.click_callback(boost::bind(showAvatarInspector, hover_object->getID())); p.visible_time_near(6.f); p.visible_time_far(3.f); - p.delay_time(0.35f); + p.delay_time(gSavedSettings.getF32("AvatarInspectorTooltipDelay")); p.wrap(false); LLToolTipMgr::instance().show(p); @@ -1054,7 +1054,7 @@ BOOL LLToolPie::handleTooltipObject( LLViewerObject* hover_object, std::string l p.click_homepage_callback(boost::bind(VisitHomePage, mHoverPick)); p.visible_time_near(6.f); p.visible_time_far(3.f); - p.delay_time(0.35f); + p.delay_time(gSavedSettings.getF32("ObjectInspectorTooltipDelay")); p.wrap(false); LLToolTipMgr::instance().show(p); -- cgit v1.3 From b815dc9aa4dc60bf405c10e426579950570d5436 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 10 Mar 2011 20:20:17 -0800 Subject: SOCIAL-530 WIP When double clicking a nearby location I want my avatar to walk to that spot Initial mouse-based steering and single click to walk --- indra/newview/lltoolpie.cpp | 221 ++++++++++++++++++++++++++++++++++++-------- indra/newview/lltoolpie.h | 15 ++- 2 files changed, 195 insertions(+), 41 deletions(-) (limited to 'indra/newview/lltoolpie.cpp') diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index 19d7b70101..e539174a4b 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -79,7 +79,7 @@ static ECursorType cursor_from_parcel_media(U8 click_action); LLToolPie::LLToolPie() : LLTool(std::string("Pie")), - mGrabMouseButtonDown( FALSE ), + mMouseButtonDown( FALSE ), mMouseOutsideSlop( FALSE ), mClickAction(0), mClickActionBuyEnabled( gSavedSettings.getBOOL("ClickActionBuyEnabled") ), @@ -99,12 +99,18 @@ BOOL LLToolPie::handleAnyMouseClick(S32 x, S32 y, MASK mask, EClickType clicktyp BOOL LLToolPie::handleMouseDown(S32 x, S32 y, MASK mask) { + mMouseOutsideSlop = FALSE; + mMouseDownX = x; + mMouseDownY = y; + mLastYaw = 0.f; //left mouse down always picks transparent mPick = gViewerWindow->pickImmediate(x, y, TRUE); mPick.mKeyMask = mask; - mGrabMouseButtonDown = TRUE; + + mDragPick = mPick; + mMouseButtonDown = TRUE; - pickLeftMouseDownCallback(); + handleLeftClickPick(); return TRUE; } @@ -119,7 +125,7 @@ BOOL LLToolPie::handleRightMouseDown(S32 x, S32 y, MASK mask) // claim not handled so UI focus stays same - pickRightMouseDownCallback(); + handleRightClickPick(); return FALSE; } @@ -136,7 +142,7 @@ BOOL LLToolPie::handleScrollWheel(S32 x, S32 y, S32 clicks) } // True if you selected an object. -BOOL LLToolPie::pickLeftMouseDownCallback() +BOOL LLToolPie::handleLeftClickPick() { S32 x = mPick.mMousePt.mX; S32 y = mPick.mMousePt.mY; @@ -319,7 +325,7 @@ BOOL LLToolPie::pickLeftMouseDownCallback() if (!gSavedSettings.getBOOL("LeftClickShowMenu")) { // mouse already released - if (!mGrabMouseButtonDown) + if (!mMouseButtonDown) { return TRUE; } @@ -513,7 +519,27 @@ void LLToolPie::selectionPropertiesReceived() BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask) { + if (!mMouseOutsideSlop && mMouseButtonDown) + { + S32 delta_x = x - mMouseDownX; + S32 delta_y = y - mMouseDownY; + S32 threshold = gSavedSettings.getS32("DragAndDropDistanceThreshold"); + if (delta_x * delta_x + delta_y * delta_y > threshold * threshold) + { + startCameraSteering(); + mMouseOutsideSlop = TRUE; + setMouseCapture(TRUE); + } + } + mHoverPick = gViewerWindow->pickImmediate(x, y, FALSE); + + if (mMouseOutsideSlop) + { + steerCameraWithMouse(x, y); + return TRUE; + } + // perform a separate pick that detects transparent objects since they respond to 1-click actions LLPickInfo click_action_pick = gViewerWindow->pickImmediate(x, y, TRUE); @@ -584,37 +610,31 @@ BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask) BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) { LLViewerObject* obj = mPick.getObject(); + U8 click_action = final_click_action(obj); - handleMediaMouseUp(); + if (hasMouseCapture()) + { + setMouseCapture(FALSE); + } - U8 click_action = final_click_action(obj); - if (click_action != CLICK_ACTION_NONE) + bool media_handled_click = handleMediaMouseUp() || LLViewerMediaFocus::getInstance()->getFocus(); + bool mouse_moved = mMouseOutsideSlop; + mMouseOutsideSlop = FALSE; + mMouseButtonDown = FALSE; + + if (!media_handled_click && click_action == CLICK_ACTION_NONE && !mouse_moved) { - switch(click_action) + if (gSavedSettings.getBOOL("ClickToWalk") // click to walk enabled + && !mPick.mPosGlobal.isExactlyZero() // valid coordinates for pick + && (mPick.mPickType == LLPickInfo::PICK_LAND // we clicked on land + || mPick.mObjectID.notNull())) // or on an object { - // NOTE: mClickActionBuyEnabled flag enables/disables BUY action but setting cursor to default is okay - case CLICK_ACTION_BUY: - // NOTE: mClickActionPayEnabled flag enables/disables PAY action but setting cursor to default is okay - case CLICK_ACTION_PAY: - case CLICK_ACTION_OPEN: - case CLICK_ACTION_ZOOM: - case CLICK_ACTION_PLAY: - case CLICK_ACTION_OPEN_MEDIA: - // Because these actions open UI dialogs, we won't change - // the cursor again until the next hover and GL pick over - // the world. Keep the cursor an arrow, assuming that - // after the user moves off the UI, they won't be on the - // same object anymore. - gViewerWindow->setCursor(UI_CURSOR_ARROW); - // Make sure the hover-picked object is ignored. - //gToolTipView->resetLastHoverObject(); - break; - default: - break; + handle_go_to(); + return TRUE; } } + gViewerWindow->setCursor(UI_CURSOR_ARROW); - mGrabMouseButtonDown = FALSE; LLToolMgr::getInstance()->clearTransientTool(); gAgentCamera.setLookAt(LOOKAT_TARGET_CONVERSATION, obj); // maybe look at object/person clicked on return LLTool::handleMouseUp(x, y, mask); @@ -1276,6 +1296,7 @@ void LLToolPie::stopEditing() void LLToolPie::onMouseCaptureLost() { mMouseOutsideSlop = FALSE; + mMouseButtonDown = FALSE; handleMediaMouseUp(); } @@ -1444,8 +1465,6 @@ bool LLToolPie::handleMediaMouseUp() mMediaMouseCaptureID.setNull(); - setMouseCapture(FALSE); - result = true; } @@ -1508,7 +1527,7 @@ static ECursorType cursor_from_parcel_media(U8 click_action) // True if we handled the event. -BOOL LLToolPie::pickRightMouseDownCallback() +BOOL LLToolPie::handleRightClickPick() { S32 x = mPick.mMousePt.mX; S32 y = mPick.mMousePt.mY; @@ -1630,10 +1649,136 @@ BOOL LLToolPie::pickRightMouseDownCallback() void LLToolPie::showVisualContextMenuEffect() { - // VEFFECT: ShowPie - LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_SPHERE, TRUE); - effectp->setPositionGlobal(mPick.mPosGlobal); - effectp->setColor(LLColor4U(gAgent.getEffectColor())); - effectp->setDuration(0.25f); + // VEFFECT: ShowPie + LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_SPHERE, TRUE); + effectp->setPositionGlobal(mPick.mPosGlobal); + effectp->setColor(LLColor4U(gAgent.getEffectColor())); + effectp->setDuration(0.25f); +} + + +LLVector3 intersect_ray_with_sphere( const LLVector3& ray_pt, const LLVector3& ray_dir, const LLVector3& sphere_center, F32 sphere_radius) +{ + // from http://www.siggraph.org/education/materials/HyperGraph/raytrace/rtinter1.htm + LLVector3 sphere_to_ray_start_vec = ray_pt - sphere_center; + F32 B = 2.f * ray_dir * sphere_to_ray_start_vec; + F32 C = sphere_to_ray_start_vec.lengthSquared() - (sphere_radius * sphere_radius); + + LLVector3 intersection_pt; + + F32 discriminant = B*B - 4.f*C; + if (discriminant < 0.f) + { + // no intersection, compute closest intersection point + LLVector3 ray_to_sphere(sphere_to_ray_start_vec * -1.f); + + LLVector3 ray_orthogonal_dir = ray_pt + projected_vec(ray_to_sphere, ray_dir) - sphere_center; + ray_orthogonal_dir.normalize(); + intersection_pt = sphere_center + ray_orthogonal_dir * sphere_radius; + } + else + { + F32 t0 = (-B - sqrtf(discriminant)) / 2.f; + if (t0 > 0.f) + { + intersection_pt = ray_pt + ray_dir * t0; + } + else + { + F32 t1 = (-B + sqrtf(discriminant)) / 2.f; + intersection_pt = ray_pt + ray_dir * t1; + } + } + + return intersection_pt; + //LLVector3 ray_pt_to_center = sphere_center - ray_pt; + //F32 center_distance = ray_pt_to_center.normVec(); + + //F32 dot = ray_dir * ray_pt_to_center; + + //if (dot == 0.f) + //{ + // return LLVector3::zero; + //} + + //// point which ray hits plane centered on sphere origin, facing ray origin + //LLVector3 intersection_sphere_plane = ray_pt + (ray_dir * center_distance / dot); + //// vector from sphere origin to the point, normalized to sphere radius + //LLVector3 sphere_center_to_intersection = (intersection_sphere_plane - sphere_center) / sphere_radius; + + //F32 dist_squared = sphere_center_to_intersection.magVecSquared(); + //LLVector3 result; + + //if (dist_squared > 1.f) + //{ + // result = sphere_center_to_intersection; + // result.normVec(); + //} + //else + //{ + // result = sphere_center_to_intersection - ray_dir * sqrtf(1.f - dist_squared); + //} + + //return sphere_center + (result * sphere_radius); } + +void LLToolPie::startCameraSteering() +{ + mMouseSteerX = mMouseDownX; + mMouseSteerY = mMouseDownY; +} + +void LLToolPie::steerCameraWithMouse(S32 x, S32 y) +{ + const F32 MIN_ROTATION_RADIUS = 1.f; + + const LLVector3 pick_pos = gAgent.getPosAgentFromGlobal(mDragPick.mPosGlobal); + const LLVector3 rotation_center = gAgent.getFrameAgent().getOrigin(); + const LLVector3 rotation_up_axis(gAgent.getReferenceUpVector()); + + LLVector3 pick_offset = pick_pos - rotation_center; + F32 up_distance = pick_offset * rotation_up_axis; + LLVector3 object_rotation_center = rotation_center + rotation_up_axis * up_distance; + F32 pick_distance_from_rotation_center = llclamp(dist_vec(pick_pos, object_rotation_center), MIN_ROTATION_RADIUS, F32_MAX); + + LLVector3 screen_rotation_up_axis = rotation_up_axis - projected_vec(rotation_up_axis, LLViewerCamera::instance().getAtAxis()); + screen_rotation_up_axis.normalize(); + LLVector3 screen_rotation_left_axis = screen_rotation_up_axis % LLViewerCamera::instance().getAtAxis(); + + LLVector3 mouse_ray = gViewerWindow->mouseDirectionGlobal(x, y); + mouse_ray = mouse_ray - projected_vec(mouse_ray, rotation_up_axis); + mouse_ray.normalize(); + + LLVector3 old_mouse_ray = gViewerWindow->mouseDirectionGlobal(mMouseSteerX, mMouseSteerY); + old_mouse_ray = old_mouse_ray - projected_vec(old_mouse_ray, rotation_up_axis); + old_mouse_ray.normalize(); + + LLVector3 camera_pos = gAgentCamera.getCameraPositionAgent(); + LLVector3 camera_to_rotation_center = object_rotation_center - camera_pos; + LLVector3 adjusted_camera_pos = camera_pos + projected_vec(camera_to_rotation_center, rotation_up_axis); + LLVector3 rotation_fwd_axis = LLViewerCamera::instance().getAtAxis() - projected_vec(LLViewerCamera::instance().getAtAxis(), rotation_up_axis); + rotation_fwd_axis.normalize(); + F64 pick_dist = dist_vec(pick_pos, adjusted_camera_pos); + LLVector3 mouse_on_sphere = intersect_ray_with_sphere(adjusted_camera_pos + (mouse_ray * pick_dist * 1.1f), + -1.f * mouse_ray, + object_rotation_center, + pick_distance_from_rotation_center); + LLVector3 old_mouse_on_sphere = intersect_ray_with_sphere(adjusted_camera_pos + (old_mouse_ray * pick_dist * 1.1f), + -1.f * old_mouse_ray, + object_rotation_center, + pick_distance_from_rotation_center); + + + LLVector3 rotation_furthest_pt = object_rotation_center + pick_distance_from_rotation_center * rotation_fwd_axis; + F32 mouse_lateral_distance = llclamp(((mouse_on_sphere - rotation_furthest_pt) * screen_rotation_left_axis) / pick_distance_from_rotation_center, -1.f, 1.f); + F32 old_mouse_lateral_distance = llclamp(((old_mouse_on_sphere - rotation_furthest_pt) * screen_rotation_left_axis) / pick_distance_from_rotation_center, -1.f, 1.f); + + F32 yaw_angle = -1.f * asinf(mouse_lateral_distance); + F32 old_yaw_angle = -1.f * asinf(old_mouse_lateral_distance); + + // apply delta + gAgent.yaw(yaw_angle - old_yaw_angle); + mMouseSteerX = x; + mMouseSteerY = y; +} \ No newline at end of file diff --git a/indra/newview/lltoolpie.h b/indra/newview/lltoolpie.h index 77200a1da4..c46fdd6799 100644 --- a/indra/newview/lltoolpie.h +++ b/indra/newview/lltoolpie.h @@ -75,8 +75,8 @@ public: private: BOOL outsideSlop (S32 x, S32 y, S32 start_x, S32 start_y); - BOOL pickLeftMouseDownCallback(); - BOOL pickRightMouseDownCallback(); + BOOL handleLeftClickPick(); + BOOL handleRightClickPick(); BOOL useClickAction (MASK mask, LLViewerObject* object,LLViewerObject* parent); void showVisualContextMenuEffect(); @@ -88,12 +88,21 @@ private: BOOL handleTooltipLand(std::string line, std::string tooltip_msg); BOOL handleTooltipObject( LLViewerObject* hover_object, std::string line, std::string tooltip_msg); + void steerCameraWithMouse(S32 x, S32 y); + void startCameraSteering(); + private: - BOOL mGrabMouseButtonDown; + BOOL mMouseButtonDown; BOOL mMouseOutsideSlop; // for this drag, has mouse moved outside slop region + S32 mMouseDownX; + S32 mMouseDownY; + S32 mMouseSteerX; + S32 mMouseSteerY; + F32 mLastYaw; LLUUID mMediaMouseCaptureID; LLPickInfo mPick; LLPickInfo mHoverPick; + LLPickInfo mDragPick; LLPointer mClickActionObject; U8 mClickAction; LLSafeHandle mLeftClickSelection; -- cgit v1.3 From 1c5d2516e0d926c8bd0bc2faad0f8ccaa2725339 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 11 Mar 2011 00:21:22 -0800 Subject: SOCIAL-530 WIP When double clicking a nearby location I want my avatar to walk to that spot can drag objects in front of avatar in opposite direction now reliably release mouse capture min rotation radius is now scaled by camera distance from rotation center --- indra/newview/lltoolpie.cpp | 125 ++++++++++++++++++-------------------------- indra/newview/lltoolpie.h | 6 +-- 2 files changed, 53 insertions(+), 78 deletions(-) (limited to 'indra/newview/lltoolpie.cpp') diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index e539174a4b..c52111ab54 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -102,7 +102,7 @@ BOOL LLToolPie::handleMouseDown(S32 x, S32 y, MASK mask) mMouseOutsideSlop = FALSE; mMouseDownX = x; mMouseDownY = y; - mLastYaw = 0.f; + //left mouse down always picks transparent mPick = gViewerWindow->pickImmediate(x, y, TRUE); mPick.mKeyMask = mask; @@ -612,11 +612,6 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) LLViewerObject* obj = mPick.getObject(); U8 click_action = final_click_action(obj); - if (hasMouseCapture()) - { - setMouseCapture(FALSE); - } - bool media_handled_click = handleMediaMouseUp() || LLViewerMediaFocus::getInstance()->getFocus(); bool mouse_moved = mMouseOutsideSlop; mMouseOutsideSlop = FALSE; @@ -634,6 +629,10 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) } } gViewerWindow->setCursor(UI_CURSOR_ARROW); + if (hasMouseCapture()) + { + setMouseCapture(FALSE); + } LLToolMgr::getInstance()->clearTransientTool(); gAgentCamera.setLookAt(LOOKAT_TARGET_CONVERSATION, obj); // maybe look at object/person clicked on @@ -1657,28 +1656,16 @@ void LLToolPie::showVisualContextMenuEffect() } -LLVector3 intersect_ray_with_sphere( const LLVector3& ray_pt, const LLVector3& ray_dir, const LLVector3& sphere_center, F32 sphere_radius) +bool intersect_ray_with_sphere( const LLVector3& ray_pt, const LLVector3& ray_dir, const LLVector3& sphere_center, F32 sphere_radius, LLVector3& intersection_pt) { - // from http://www.siggraph.org/education/materials/HyperGraph/raytrace/rtinter1.htm + // do ray/sphere intersection by solving quadratic equation LLVector3 sphere_to_ray_start_vec = ray_pt - sphere_center; F32 B = 2.f * ray_dir * sphere_to_ray_start_vec; F32 C = sphere_to_ray_start_vec.lengthSquared() - (sphere_radius * sphere_radius); - LLVector3 intersection_pt; - F32 discriminant = B*B - 4.f*C; - if (discriminant < 0.f) - { - // no intersection, compute closest intersection point - LLVector3 ray_to_sphere(sphere_to_ray_start_vec * -1.f); - - LLVector3 ray_orthogonal_dir = ray_pt + projected_vec(ray_to_sphere, ray_dir) - sphere_center; - ray_orthogonal_dir.normalize(); - - intersection_pt = sphere_center + ray_orthogonal_dir * sphere_radius; - } - else - { + if (discriminant > 0.f) + { // intersection detected, now find closest one F32 t0 = (-B - sqrtf(discriminant)) / 2.f; if (t0 > 0.f) { @@ -1689,49 +1676,25 @@ LLVector3 intersect_ray_with_sphere( const LLVector3& ray_pt, const LLVector3& r F32 t1 = (-B + sqrtf(discriminant)) / 2.f; intersection_pt = ray_pt + ray_dir * t1; } + return true; } - return intersection_pt; - //LLVector3 ray_pt_to_center = sphere_center - ray_pt; - //F32 center_distance = ray_pt_to_center.normVec(); - - //F32 dot = ray_dir * ray_pt_to_center; - - //if (dot == 0.f) - //{ - // return LLVector3::zero; - //} - - //// point which ray hits plane centered on sphere origin, facing ray origin - //LLVector3 intersection_sphere_plane = ray_pt + (ray_dir * center_distance / dot); - //// vector from sphere origin to the point, normalized to sphere radius - //LLVector3 sphere_center_to_intersection = (intersection_sphere_plane - sphere_center) / sphere_radius; - - //F32 dist_squared = sphere_center_to_intersection.magVecSquared(); - //LLVector3 result; - - //if (dist_squared > 1.f) - //{ - // result = sphere_center_to_intersection; - // result.normVec(); - //} - //else - //{ - // result = sphere_center_to_intersection - ray_dir * sqrtf(1.f - dist_squared); - //} - - //return sphere_center + (result * sphere_radius); + return false; } void LLToolPie::startCameraSteering() { mMouseSteerX = mMouseDownX; mMouseSteerY = mMouseDownY; + const LLVector3 camera_to_rotation_center = gAgent.getFrameAgent().getOrigin() - LLViewerCamera::instance().getOrigin(); + const LLVector3 rotation_center_to_pick = gAgent.getPosAgentFromGlobal(mDragPick.mPosGlobal) - gAgent.getFrameAgent().getOrigin(); + + mClockwise = camera_to_rotation_center * rotation_center_to_pick < 0.f; } void LLToolPie::steerCameraWithMouse(S32 x, S32 y) { - const F32 MIN_ROTATION_RADIUS = 1.f; + const F32 MIN_ROTATION_RADIUS_FRACTION = 0.2f; const LLVector3 pick_pos = gAgent.getPosAgentFromGlobal(mDragPick.mPosGlobal); const LLVector3 rotation_center = gAgent.getFrameAgent().getOrigin(); @@ -1740,7 +1703,8 @@ void LLToolPie::steerCameraWithMouse(S32 x, S32 y) LLVector3 pick_offset = pick_pos - rotation_center; F32 up_distance = pick_offset * rotation_up_axis; LLVector3 object_rotation_center = rotation_center + rotation_up_axis * up_distance; - F32 pick_distance_from_rotation_center = llclamp(dist_vec(pick_pos, object_rotation_center), MIN_ROTATION_RADIUS, F32_MAX); + F32 min_rotation_radius = MIN_ROTATION_RADIUS_FRACTION * dist_vec(rotation_center, LLViewerCamera::instance().getOrigin());; + F32 pick_distance_from_rotation_center = llclamp(dist_vec(pick_pos, object_rotation_center), min_rotation_radius, F32_MAX); LLVector3 screen_rotation_up_axis = rotation_up_axis - projected_vec(rotation_up_axis, LLViewerCamera::instance().getAtAxis()); screen_rotation_up_axis.normalize(); @@ -1760,25 +1724,36 @@ void LLToolPie::steerCameraWithMouse(S32 x, S32 y) LLVector3 rotation_fwd_axis = LLViewerCamera::instance().getAtAxis() - projected_vec(LLViewerCamera::instance().getAtAxis(), rotation_up_axis); rotation_fwd_axis.normalize(); F64 pick_dist = dist_vec(pick_pos, adjusted_camera_pos); - LLVector3 mouse_on_sphere = intersect_ray_with_sphere(adjusted_camera_pos + (mouse_ray * pick_dist * 1.1f), - -1.f * mouse_ray, - object_rotation_center, - pick_distance_from_rotation_center); - LLVector3 old_mouse_on_sphere = intersect_ray_with_sphere(adjusted_camera_pos + (old_mouse_ray * pick_dist * 1.1f), - -1.f * old_mouse_ray, - object_rotation_center, - pick_distance_from_rotation_center); - - - LLVector3 rotation_furthest_pt = object_rotation_center + pick_distance_from_rotation_center * rotation_fwd_axis; - F32 mouse_lateral_distance = llclamp(((mouse_on_sphere - rotation_furthest_pt) * screen_rotation_left_axis) / pick_distance_from_rotation_center, -1.f, 1.f); - F32 old_mouse_lateral_distance = llclamp(((old_mouse_on_sphere - rotation_furthest_pt) * screen_rotation_left_axis) / pick_distance_from_rotation_center, -1.f, 1.f); - - F32 yaw_angle = -1.f * asinf(mouse_lateral_distance); - F32 old_yaw_angle = -1.f * asinf(old_mouse_lateral_distance); - - // apply delta - gAgent.yaw(yaw_angle - old_yaw_angle); - mMouseSteerX = x; - mMouseSteerY = y; + + LLVector3 mouse_on_sphere; + bool mouse_hit_sphere = intersect_ray_with_sphere(adjusted_camera_pos + (mouse_ray * pick_dist * 1.1f), + -1.f * mouse_ray, + object_rotation_center, + pick_distance_from_rotation_center, + mouse_on_sphere); + + LLVector3 old_mouse_on_sphere; + intersect_ray_with_sphere(adjusted_camera_pos + (old_mouse_ray * pick_dist * 1.1f), + -1.f * old_mouse_ray, + object_rotation_center, + pick_distance_from_rotation_center, + old_mouse_on_sphere); + + if (mouse_hit_sphere) + { + + LLVector3 rotation_furthest_pt = object_rotation_center + pick_distance_from_rotation_center * rotation_fwd_axis; + F32 mouse_lateral_distance = llclamp(((mouse_on_sphere - rotation_furthest_pt) * screen_rotation_left_axis) / pick_distance_from_rotation_center, -1.f, 1.f); + F32 old_mouse_lateral_distance = llclamp(((old_mouse_on_sphere - rotation_furthest_pt) * screen_rotation_left_axis) / pick_distance_from_rotation_center, -1.f, 1.f); + + F32 yaw_angle = -1.f * asinf(mouse_lateral_distance); + F32 old_yaw_angle = -1.f * asinf(old_mouse_lateral_distance); + + F32 delta_angle = yaw_angle - old_yaw_angle; + if (mClockwise) delta_angle *= -1.f; + + gAgent.yaw(delta_angle); + mMouseSteerX = x; + mMouseSteerY = y; + } } \ No newline at end of file diff --git a/indra/newview/lltoolpie.h b/indra/newview/lltoolpie.h index c46fdd6799..26dcbd35e6 100644 --- a/indra/newview/lltoolpie.h +++ b/indra/newview/lltoolpie.h @@ -92,13 +92,13 @@ private: void startCameraSteering(); private: - BOOL mMouseButtonDown; - BOOL mMouseOutsideSlop; // for this drag, has mouse moved outside slop region + bool mMouseButtonDown; + bool mMouseOutsideSlop; // for this drag, has mouse moved outside slop region S32 mMouseDownX; S32 mMouseDownY; S32 mMouseSteerX; S32 mMouseSteerY; - F32 mLastYaw; + bool mClockwise; LLUUID mMediaMouseCaptureID; LLPickInfo mPick; LLPickInfo mHoverPick; -- cgit v1.3 From 34807845ab6c6440d17624e1cbf042472d25ce9e Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 11 Mar 2011 11:20:20 -0800 Subject: fixed avatar picker url fixed linux build --- indra/newview/app_settings/settings_minimal.xml | 2 +- indra/newview/lltoolpie.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/lltoolpie.cpp') diff --git a/indra/newview/app_settings/settings_minimal.xml b/indra/newview/app_settings/settings_minimal.xml index 73c7c1e4bd..646f5e85bc 100644 --- a/indra/newview/app_settings/settings_minimal.xml +++ b/indra/newview/app_settings/settings_minimal.xml @@ -323,7 +323,7 @@ Type String Value - http://lecs-static-secondlife-com.s3.amazonaws.com/viewer/agni/avatars.html + http://common-flash-secondlife-com.s3.amazonaws.com/viewer/v2.6/damballah/avatars.html LogInventoryDecline diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index c52111ab54..c98feca91c 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -1756,4 +1756,4 @@ void LLToolPie::steerCameraWithMouse(S32 x, S32 y) mMouseSteerX = x; mMouseSteerY = y; } -} \ No newline at end of file +} -- cgit v1.3 From 426ff3fbbbd5b274c7258adabfea2802d93d27fd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 11 Mar 2011 16:46:13 -0800 Subject: SOCIAL-690 FIX Mouse captured by camera after clicking on scripted object --- indra/newview/lltoolpie.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'indra/newview/lltoolpie.cpp') diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index c98feca91c..b6e99ac09f 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -79,8 +79,8 @@ static ECursorType cursor_from_parcel_media(U8 click_action); LLToolPie::LLToolPie() : LLTool(std::string("Pie")), - mMouseButtonDown( FALSE ), - mMouseOutsideSlop( FALSE ), + mMouseButtonDown( false ), + mMouseOutsideSlop( false ), mClickAction(0), mClickActionBuyEnabled( gSavedSettings.getBOOL("ClickActionBuyEnabled") ), mClickActionPayEnabled( gSavedSettings.getBOOL("ClickActionPayEnabled") ) @@ -108,7 +108,7 @@ BOOL LLToolPie::handleMouseDown(S32 x, S32 y, MASK mask) mPick.mKeyMask = mask; mDragPick = mPick; - mMouseButtonDown = TRUE; + mMouseButtonDown = true; handleLeftClickPick(); @@ -310,6 +310,7 @@ BOOL LLToolPie::handleLeftClickPick() ) { gGrabTransientTool = this; + mMouseButtonDown = false; LLToolMgr::getInstance()->getCurrentToolset()->selectTool( LLToolGrab::getInstance() ); return LLToolGrab::getInstance()->handleObjectHit( mPick ); } @@ -327,7 +328,7 @@ BOOL LLToolPie::handleLeftClickPick() // mouse already released if (!mMouseButtonDown) { - return TRUE; + return true; } while( object && object->isAttachment() && !object->flagHandleTouch()) @@ -339,9 +340,10 @@ BOOL LLToolPie::handleLeftClickPick() } object = (LLViewerObject*)object->getParent(); } - if (object && object == gAgentAvatarp) + if (object && object == gAgentAvatarp && !gSavedSettings.getBOOL("ClickToWalk")) { // we left clicked on avatar, switch to focus mode + mMouseButtonDown = false; LLToolMgr::getInstance()->setTransientTool(LLToolCamera::getInstance()); gViewerWindow->hideCursor(); LLToolCamera::getInstance()->setMouseCapture(TRUE); @@ -537,6 +539,7 @@ BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask) if (mMouseOutsideSlop) { steerCameraWithMouse(x, y); + gViewerWindow->setCursor(UI_CURSOR_TOOLGRAB); return TRUE; } @@ -614,8 +617,8 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) bool media_handled_click = handleMediaMouseUp() || LLViewerMediaFocus::getInstance()->getFocus(); bool mouse_moved = mMouseOutsideSlop; - mMouseOutsideSlop = FALSE; - mMouseButtonDown = FALSE; + mMouseOutsideSlop = false; + mMouseButtonDown = false; if (!media_handled_click && click_action == CLICK_ACTION_NONE && !mouse_moved) { @@ -1294,8 +1297,8 @@ void LLToolPie::stopEditing() void LLToolPie::onMouseCaptureLost() { - mMouseOutsideSlop = FALSE; - mMouseButtonDown = FALSE; + mMouseOutsideSlop = false; + mMouseButtonDown = false; handleMediaMouseUp(); } @@ -1698,7 +1701,8 @@ void LLToolPie::steerCameraWithMouse(S32 x, S32 y) const LLVector3 pick_pos = gAgent.getPosAgentFromGlobal(mDragPick.mPosGlobal); const LLVector3 rotation_center = gAgent.getFrameAgent().getOrigin(); - const LLVector3 rotation_up_axis(gAgent.getReferenceUpVector()); + // FIXME: get this to work with camera tilt (i.e. sitting on a rotating object) + const LLVector3 rotation_up_axis(LLVector3::z_axis); LLVector3 pick_offset = pick_pos - rotation_center; F32 up_distance = pick_offset * rotation_up_axis; -- cgit v1.3 From 184c454222ff509629de8abc49a72122c75f0487 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 11 Mar 2011 20:44:57 -0800 Subject: visual feedback for click to walk --- indra/newview/CMakeLists.txt | 2 ++ indra/newview/llhudeffectblob.cpp | 42 ++++++++++++++++++++++++++++++++++ indra/newview/llhudeffectblob.h | 47 +++++++++++++++++++++++++++++++++++++++ indra/newview/llhudobject.cpp | 3 +++ indra/newview/llhudobject.h | 3 ++- indra/newview/lltoolpie.cpp | 39 ++++++++++++++++++++++++++------ indra/newview/lltoolpie.h | 5 +++++ 7 files changed, 133 insertions(+), 8 deletions(-) create mode 100644 indra/newview/llhudeffectblob.cpp create mode 100644 indra/newview/llhudeffectblob.h (limited to 'indra/newview/lltoolpie.cpp') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 4ed59f039e..66869288b6 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -246,6 +246,7 @@ set(viewer_SOURCE_FILES llhudeffectlookat.cpp llhudeffectpointat.cpp llhudeffecttrail.cpp + llhudeffectblob.cpp llhudicon.cpp llhudmanager.cpp llhudnametag.cpp @@ -786,6 +787,7 @@ set(viewer_HEADER_FILES llhudeffectlookat.h llhudeffectpointat.h llhudeffecttrail.h + llhudeffectblob.h llhudicon.h llhudmanager.h llhudnametag.h diff --git a/indra/newview/llhudeffectblob.cpp b/indra/newview/llhudeffectblob.cpp new file mode 100644 index 0000000000..e790c954b0 --- /dev/null +++ b/indra/newview/llhudeffectblob.cpp @@ -0,0 +1,42 @@ +/** + * @file llhudeffecttrail.cpp + * @brief LLHUDEffectSpiral class implementation + * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llhudeffectblob.h" + +LLHUDEffectBlob::LLHUDEffectBlob(const U8 type) : LLHUDEffect(type) +{ +} + +LLHUDEffectBlob::~LLHUDEffectBlob() +{ +} + +void LLHUDEffectBlob::render() +{ +} + diff --git a/indra/newview/llhudeffectblob.h b/indra/newview/llhudeffectblob.h new file mode 100644 index 0000000000..7757dc787c --- /dev/null +++ b/indra/newview/llhudeffectblob.h @@ -0,0 +1,47 @@ +/** + * @file llhudeffectblob.h + * @brief LLHUDEffectBlob class definition + * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLHUDEFFECTBLOB_H +#define LL_LLHUDEFFECTBLOB_H + +#include "llhudeffect.h" + +class LLHUDEffectBlob : public LLHUDEffect +{ +public: + friend class LLHUDObject; + +protected: + LLHUDEffectBlob(const U8 type); + ~LLHUDEffectBlob(); + + /*virtual*/ void render(); + /*virtual*/ void renderForTimer(); +private: + +}; + +#endif // LL_LLHUDEFFECTBLOB_H diff --git a/indra/newview/llhudobject.cpp b/indra/newview/llhudobject.cpp index 5e762ee037..3efb8d287d 100644 --- a/indra/newview/llhudobject.cpp +++ b/indra/newview/llhudobject.cpp @@ -32,6 +32,7 @@ #include "llhudtext.h" #include "llhudicon.h" #include "llhudeffectbeam.h" +#include "llhudeffectblob.h" #include "llhudeffecttrail.h" #include "llhudeffectlookat.h" #include "llhudeffectpointat.h" @@ -237,6 +238,8 @@ LLHUDEffect *LLHUDObject::addHUDEffect(const U8 type) case LL_HUD_EFFECT_POINTAT: hud_objectp = new LLHUDEffectPointAt(type); break; + case LL_HUD_EFFECT_BLOB: + hud_objectp = new LLHUDEffectBlob(type); default: llwarns << "Unknown type of hud effect:" << (U32) type << llendl; } diff --git a/indra/newview/llhudobject.h b/indra/newview/llhudobject.h index 33e6394445..2f7a98c86c 100644 --- a/indra/newview/llhudobject.h +++ b/indra/newview/llhudobject.h @@ -95,7 +95,8 @@ public: LL_HUD_EFFECT_LOOKAT, LL_HUD_EFFECT_POINTAT, LL_HUD_EFFECT_VOICE_VISUALIZER, // Ventrella - LL_HUD_NAME_TAG + LL_HUD_NAME_TAG, + LL_HUD_EFFECT_BLOB }; protected: static void sortObjects(); diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index b6e99ac09f..5bfc69016b 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -42,6 +42,7 @@ #include "llfloaterreg.h" #include "llfloaterscriptdebug.h" #include "lltooltip.h" +#include "llhudeffectblob.h" #include "llhudeffecttrail.h" #include "llhudmanager.h" #include "llkeyboard.h" @@ -81,6 +82,8 @@ LLToolPie::LLToolPie() : LLTool(std::string("Pie")), mMouseButtonDown( false ), mMouseOutsideSlop( false ), + mMouseSteerX(-1), + mMouseSteerY(-1), mClickAction(0), mClickActionBuyEnabled( gSavedSettings.getBOOL("ClickActionBuyEnabled") ), mClickActionPayEnabled( gSavedSettings.getBOOL("ClickActionPayEnabled") ) @@ -529,14 +532,12 @@ BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask) if (delta_x * delta_x + delta_y * delta_y > threshold * threshold) { startCameraSteering(); - mMouseOutsideSlop = TRUE; - setMouseCapture(TRUE); } } mHoverPick = gViewerWindow->pickImmediate(x, y, FALSE); - if (mMouseOutsideSlop) + if (inCameraSteerMode()) { steerCameraWithMouse(x, y); gViewerWindow->setCursor(UI_CURSOR_TOOLGRAB); @@ -617,16 +618,23 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) bool media_handled_click = handleMediaMouseUp() || LLViewerMediaFocus::getInstance()->getFocus(); bool mouse_moved = mMouseOutsideSlop; - mMouseOutsideSlop = false; + stopCameraSteering(); mMouseButtonDown = false; if (!media_handled_click && click_action == CLICK_ACTION_NONE && !mouse_moved) { if (gSavedSettings.getBOOL("ClickToWalk") // click to walk enabled + && !gFocusMgr.getKeyboardFocus() // focus is on world && !mPick.mPosGlobal.isExactlyZero() // valid coordinates for pick && (mPick.mPickType == LLPickInfo::PICK_LAND // we clicked on land || mPick.mObjectID.notNull())) // or on an object { + gAgentCamera.setFocusOnAvatar(TRUE, TRUE); + mAutoPilotDestination = (LLHUDEffectBlob *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BLOB, FALSE); + mAutoPilotDestination->setPositionGlobal(mPick.mPosGlobal); + mAutoPilotDestination->setColor(LLColor4U::white); + mAutoPilotDestination->setDuration(5.f); + handle_go_to(); return TRUE; } @@ -1297,11 +1305,21 @@ void LLToolPie::stopEditing() void LLToolPie::onMouseCaptureLost() { - mMouseOutsideSlop = false; + stopCameraSteering(); mMouseButtonDown = false; handleMediaMouseUp(); } +void LLToolPie::stopCameraSteering() +{ + mMouseOutsideSlop = false; + mMouseSteerGrabPoint = NULL; +} + +bool LLToolPie::inCameraSteerMode() +{ + return mMouseButtonDown && mMouseOutsideSlop; +} // true if x,y outside small box around start_x,start_y BOOL LLToolPie::outsideSlop(S32 x, S32 y, S32 start_x, S32 start_y) @@ -1687,12 +1705,19 @@ bool intersect_ray_with_sphere( const LLVector3& ray_pt, const LLVector3& ray_di void LLToolPie::startCameraSteering() { + mMouseOutsideSlop = true; + setMouseCapture(TRUE); + mMouseSteerX = mMouseDownX; mMouseSteerY = mMouseDownY; - const LLVector3 camera_to_rotation_center = gAgent.getFrameAgent().getOrigin() - LLViewerCamera::instance().getOrigin(); - const LLVector3 rotation_center_to_pick = gAgent.getPosAgentFromGlobal(mDragPick.mPosGlobal) - gAgent.getFrameAgent().getOrigin(); + const LLVector3 camera_to_rotation_center = gAgent.getFrameAgent().getOrigin() - LLViewerCamera::instance().getOrigin(); + const LLVector3 rotation_center_to_pick = gAgent.getPosAgentFromGlobal(mDragPick.mPosGlobal) - gAgent.getFrameAgent().getOrigin(); mClockwise = camera_to_rotation_center * rotation_center_to_pick < 0.f; + mMouseSteerGrabPoint= (LLHUDEffectBlob *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BLOB, FALSE); + mMouseSteerGrabPoint->setPositionGlobal(mPick.mPosGlobal); + mMouseSteerGrabPoint->setColor(LLColor4U::white); + mMouseSteerGrabPoint->setDuration(1000.f); } void LLToolPie::steerCameraWithMouse(S32 x, S32 y) diff --git a/indra/newview/lltoolpie.h b/indra/newview/lltoolpie.h index 26dcbd35e6..1ac1c35bcc 100644 --- a/indra/newview/lltoolpie.h +++ b/indra/newview/lltoolpie.h @@ -33,6 +33,7 @@ class LLViewerObject; class LLObjectSelection; +class LLHUDEffectBlob; class LLToolPie : public LLTool, public LLSingleton { @@ -90,6 +91,8 @@ private: void steerCameraWithMouse(S32 x, S32 y); void startCameraSteering(); + void stopCameraSteering(); + bool inCameraSteerMode(); private: bool mMouseButtonDown; @@ -98,6 +101,8 @@ private: S32 mMouseDownY; S32 mMouseSteerX; S32 mMouseSteerY; + LLHUDEffectBlob* mAutoPilotDestination; + LLHUDEffectBlob* mMouseSteerGrabPoint; bool mClockwise; LLUUID mMediaMouseCaptureID; LLPickInfo mPick; -- cgit v1.3 From 5dc467b4f7940f31b0e98798eb6aa2d82a2d4919 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 13 Mar 2011 11:51:44 -0700 Subject: only enable click to steer with "ClickToWalk" is turned on --- indra/newview/lltoolpie.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/lltoolpie.cpp') diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index 5bfc69016b..698d55836c 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -524,7 +524,7 @@ void LLToolPie::selectionPropertiesReceived() BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask) { - if (!mMouseOutsideSlop && mMouseButtonDown) + if (!mMouseOutsideSlop && mMouseButtonDown && gSavedSettings.getBOOL("ClickToWalk")) { S32 delta_x = x - mMouseDownX; S32 delta_y = y - mMouseDownY; @@ -1318,7 +1318,7 @@ void LLToolPie::stopCameraSteering() bool LLToolPie::inCameraSteerMode() { - return mMouseButtonDown && mMouseOutsideSlop; + return mMouseButtonDown && mMouseOutsideSlop && gSavedSettings.getBOOL("ClickToWalk"); } // true if x,y outside small box around start_x,start_y -- cgit v1.3 From 5038c068eac20425c702fd1dff06ccdacdec9e6f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 14 Mar 2011 12:39:50 -0700 Subject: SOCIAL-695 FIX clicking on world to give it focus will make your avatar walk --- indra/llmath/v3math.h | 13 +++++++++ indra/newview/lltoolpie.cpp | 71 ++++++++++++++++++++++++--------------------- indra/newview/lltoolpie.h | 3 +- 3 files changed, 53 insertions(+), 34 deletions(-) (limited to 'indra/newview/lltoolpie.cpp') diff --git a/indra/llmath/v3math.h b/indra/llmath/v3math.h index dbd38c1c3f..ef002fe9f2 100644 --- a/indra/llmath/v3math.h +++ b/indra/llmath/v3math.h @@ -156,6 +156,8 @@ F32 dist_vec(const LLVector3 &a, const LLVector3 &b); // Returns distance betwe F32 dist_vec_squared(const LLVector3 &a, const LLVector3 &b);// Returns distance squared between a and b F32 dist_vec_squared2D(const LLVector3 &a, const LLVector3 &b);// Returns distance squared between a and b ignoring Z component LLVector3 projected_vec(const LLVector3 &a, const LLVector3 &b); // Returns vector a projected on vector b +LLVector3 parallel_component(const LLVector3 &a, const LLVector3 &b); // Returns vector a projected on vector b (same as projected_vec) +LLVector3 orthogonal_component(const LLVector3 &a, const LLVector3 &b); // Returns component of vector a not parallel to vector b (same as projected_vec) LLVector3 lerp(const LLVector3 &a, const LLVector3 &b, F32 u); // Returns a vector that is a linear interpolation between a and b inline LLVector3::LLVector3(void) @@ -490,6 +492,17 @@ inline LLVector3 projected_vec(const LLVector3 &a, const LLVector3 &b) return project_axis * (a * project_axis); } +inline LLVector3 parallel_component(const LLVector3 &a, const LLVector3 &b) +{ + return projected_vec(a, b); +} + +inline LLVector3 orthogonal_component(const LLVector3 &a, const LLVector3 &b) +{ + return a - projected_vec(a, b); +} + + inline LLVector3 lerp(const LLVector3 &a, const LLVector3 &b, F32 u) { return LLVector3( diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index 698d55836c..23290e5cc6 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -84,6 +84,7 @@ LLToolPie::LLToolPie() mMouseOutsideSlop( false ), mMouseSteerX(-1), mMouseSteerY(-1), + mAbortClickToWalk(false), mClickAction(0), mClickActionBuyEnabled( gSavedSettings.getBOOL("ClickActionBuyEnabled") ), mClickActionPayEnabled( gSavedSettings.getBOOL("ClickActionPayEnabled") ) @@ -112,6 +113,7 @@ BOOL LLToolPie::handleMouseDown(S32 x, S32 y, MASK mask) mDragPick = mPick; mMouseButtonDown = true; + mAbortClickToWalk = false; handleLeftClickPick(); @@ -301,7 +303,12 @@ BOOL LLToolPie::handleLeftClickPick() } // put focus back "in world" - gFocusMgr.setKeyboardFocus(NULL); + if (gFocusMgr.getKeyboardFocus()) + { + // don't click to walk on attempt to give focus to world + mAbortClickToWalk = true; + gFocusMgr.setKeyboardFocus(NULL); + } BOOL touchable = (object && object->flagHandleTouch()) || (parent && parent->flagHandleTouch()); @@ -616,28 +623,28 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) LLViewerObject* obj = mPick.getObject(); U8 click_action = final_click_action(obj); - bool media_handled_click = handleMediaMouseUp() || LLViewerMediaFocus::getInstance()->getFocus(); - bool mouse_moved = mMouseOutsideSlop; + if (handleMediaMouseUp() || LLViewerMediaFocus::getInstance()->getFocus()) + { + mAbortClickToWalk = true; + } stopCameraSteering(); mMouseButtonDown = false; - if (!media_handled_click && click_action == CLICK_ACTION_NONE && !mouse_moved) + if (click_action == CLICK_ACTION_NONE // not doing 1-click action + && gSavedSettings.getBOOL("ClickToWalk") // click to walk enabled + && !mAbortClickToWalk // another behavior hasn't cancelled click to walk + && !mPick.mPosGlobal.isExactlyZero() // valid coordinates for pick + && (mPick.mPickType == LLPickInfo::PICK_LAND // we clicked on land + || mPick.mObjectID.notNull())) // or on an object { - if (gSavedSettings.getBOOL("ClickToWalk") // click to walk enabled - && !gFocusMgr.getKeyboardFocus() // focus is on world - && !mPick.mPosGlobal.isExactlyZero() // valid coordinates for pick - && (mPick.mPickType == LLPickInfo::PICK_LAND // we clicked on land - || mPick.mObjectID.notNull())) // or on an object - { - gAgentCamera.setFocusOnAvatar(TRUE, TRUE); - mAutoPilotDestination = (LLHUDEffectBlob *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BLOB, FALSE); - mAutoPilotDestination->setPositionGlobal(mPick.mPosGlobal); - mAutoPilotDestination->setColor(LLColor4U::white); - mAutoPilotDestination->setDuration(5.f); + gAgentCamera.setFocusOnAvatar(TRUE, TRUE); + mAutoPilotDestination = (LLHUDEffectBlob *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BLOB, FALSE); + mAutoPilotDestination->setPositionGlobal(mPick.mPosGlobal); + mAutoPilotDestination->setColor(LLColor4U::white); + mAutoPilotDestination->setDuration(5.f); - handle_go_to(); - return TRUE; - } + handle_go_to(); + return TRUE; } gViewerWindow->setCursor(UI_CURSOR_ARROW); if (hasMouseCapture()) @@ -1706,6 +1713,7 @@ bool intersect_ray_with_sphere( const LLVector3& ray_pt, const LLVector3& ray_di void LLToolPie::startCameraSteering() { mMouseOutsideSlop = true; + mAbortClickToWalk = true; setMouseCapture(TRUE); mMouseSteerX = mMouseDownX; @@ -1729,22 +1737,14 @@ void LLToolPie::steerCameraWithMouse(S32 x, S32 y) // FIXME: get this to work with camera tilt (i.e. sitting on a rotating object) const LLVector3 rotation_up_axis(LLVector3::z_axis); - LLVector3 pick_offset = pick_pos - rotation_center; - F32 up_distance = pick_offset * rotation_up_axis; - LLVector3 object_rotation_center = rotation_center + rotation_up_axis * up_distance; + LLVector3 object_rotation_center = rotation_center + parallel_component(pick_pos - rotation_center, rotation_up_axis); F32 min_rotation_radius = MIN_ROTATION_RADIUS_FRACTION * dist_vec(rotation_center, LLViewerCamera::instance().getOrigin());; F32 pick_distance_from_rotation_center = llclamp(dist_vec(pick_pos, object_rotation_center), min_rotation_radius, F32_MAX); - LLVector3 screen_rotation_up_axis = rotation_up_axis - projected_vec(rotation_up_axis, LLViewerCamera::instance().getAtAxis()); - screen_rotation_up_axis.normalize(); - LLVector3 screen_rotation_left_axis = screen_rotation_up_axis % LLViewerCamera::instance().getAtAxis(); - - LLVector3 mouse_ray = gViewerWindow->mouseDirectionGlobal(x, y); - mouse_ray = mouse_ray - projected_vec(mouse_ray, rotation_up_axis); + LLVector3 mouse_ray = orthogonal_component(gViewerWindow->mouseDirectionGlobal(x, y), rotation_up_axis); mouse_ray.normalize(); - LLVector3 old_mouse_ray = gViewerWindow->mouseDirectionGlobal(mMouseSteerX, mMouseSteerY); - old_mouse_ray = old_mouse_ray - projected_vec(old_mouse_ray, rotation_up_axis); + LLVector3 old_mouse_ray = orthogonal_component(gViewerWindow->mouseDirectionGlobal(mMouseSteerX, mMouseSteerY), rotation_up_axis); old_mouse_ray.normalize(); LLVector3 camera_pos = gAgentCamera.getCameraPositionAgent(); @@ -1752,7 +1752,7 @@ void LLToolPie::steerCameraWithMouse(S32 x, S32 y) LLVector3 adjusted_camera_pos = camera_pos + projected_vec(camera_to_rotation_center, rotation_up_axis); LLVector3 rotation_fwd_axis = LLViewerCamera::instance().getAtAxis() - projected_vec(LLViewerCamera::instance().getAtAxis(), rotation_up_axis); rotation_fwd_axis.normalize(); - F64 pick_dist = dist_vec(pick_pos, adjusted_camera_pos); + F32 pick_dist = dist_vec(pick_pos, adjusted_camera_pos); LLVector3 mouse_on_sphere; bool mouse_hit_sphere = intersect_ray_with_sphere(adjusted_camera_pos + (mouse_ray * pick_dist * 1.1f), @@ -1770,16 +1770,21 @@ void LLToolPie::steerCameraWithMouse(S32 x, S32 y) if (mouse_hit_sphere) { + // calculate rotation frame in screen space + LLVector3 screen_rotation_up_axis = orthogonal_component(rotation_up_axis, LLViewerCamera::instance().getAtAxis()); + screen_rotation_up_axis.normalize(); + + LLVector3 screen_rotation_left_axis = screen_rotation_up_axis % LLViewerCamera::instance().getAtAxis(); LLVector3 rotation_furthest_pt = object_rotation_center + pick_distance_from_rotation_center * rotation_fwd_axis; F32 mouse_lateral_distance = llclamp(((mouse_on_sphere - rotation_furthest_pt) * screen_rotation_left_axis) / pick_distance_from_rotation_center, -1.f, 1.f); F32 old_mouse_lateral_distance = llclamp(((old_mouse_on_sphere - rotation_furthest_pt) * screen_rotation_left_axis) / pick_distance_from_rotation_center, -1.f, 1.f); - F32 yaw_angle = -1.f * asinf(mouse_lateral_distance); - F32 old_yaw_angle = -1.f * asinf(old_mouse_lateral_distance); + F32 yaw_angle = asinf(mouse_lateral_distance); + F32 old_yaw_angle = asinf(old_mouse_lateral_distance); F32 delta_angle = yaw_angle - old_yaw_angle; - if (mClockwise) delta_angle *= -1.f; + if (!mClockwise) delta_angle *= -1.f; gAgent.yaw(delta_angle); mMouseSteerX = x; diff --git a/indra/newview/lltoolpie.h b/indra/newview/lltoolpie.h index 1ac1c35bcc..dca661d26d 100644 --- a/indra/newview/lltoolpie.h +++ b/indra/newview/lltoolpie.h @@ -103,7 +103,8 @@ private: S32 mMouseSteerY; LLHUDEffectBlob* mAutoPilotDestination; LLHUDEffectBlob* mMouseSteerGrabPoint; - bool mClockwise; + bool mClockwise; + bool mAbortClickToWalk; LLUUID mMediaMouseCaptureID; LLPickInfo mPick; LLPickInfo mHoverPick; -- cgit v1.3 From a3edf75015508f6b518d6f49387a5d180554b71c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 14 Mar 2011 12:43:46 -0700 Subject: SOCIAL-701 FIX Clicking on world while flying moves avatar to location and avatar and camera shake... --- indra/newview/lltoolpie.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/lltoolpie.cpp') diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index 23290e5cc6..65c9f2b8f6 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -623,6 +623,7 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) LLViewerObject* obj = mPick.getObject(); U8 click_action = final_click_action(obj); + // let media have first pass at click if (handleMediaMouseUp() || LLViewerMediaFocus::getInstance()->getFocus()) { mAbortClickToWalk = true; @@ -632,6 +633,7 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) if (click_action == CLICK_ACTION_NONE // not doing 1-click action && gSavedSettings.getBOOL("ClickToWalk") // click to walk enabled + && !gAgent.getFlying() // don't auto-navigate while flying until that works && !mAbortClickToWalk // another behavior hasn't cancelled click to walk && !mPick.mPosGlobal.isExactlyZero() // valid coordinates for pick && (mPick.mPickType == LLPickInfo::PICK_LAND // we clicked on land -- cgit v1.3 From c650b9cf8202ffc63d58bbcbf05f7eddf9ae6c3c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 14 Mar 2011 13:18:15 -0700 Subject: clicking on sky or on own avatar to steer now works --- indra/newview/lltoolpie.cpp | 31 ++++++++++++++++++++++++++++--- indra/newview/lltoolpie.h | 2 +- 2 files changed, 29 insertions(+), 4 deletions(-) (limited to 'indra/newview/lltoolpie.cpp') diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index 65c9f2b8f6..c0b5c8de70 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -111,7 +111,6 @@ BOOL LLToolPie::handleMouseDown(S32 x, S32 y, MASK mask) mPick = gViewerWindow->pickImmediate(x, y, TRUE); mPick.mKeyMask = mask; - mDragPick = mPick; mMouseButtonDown = true; mAbortClickToWalk = false; @@ -1714,6 +1713,32 @@ bool intersect_ray_with_sphere( const LLVector3& ray_pt, const LLVector3& ray_di void LLToolPie::startCameraSteering() { + mSteerPick = mPick; + + LLPointer pick_object = mSteerPick.getObject(); + // handle special cases of steering picks + if (pick_object) + { + LLViewerObject* avatar_object = pick_object; + + // get pointer to avatar + while (avatar_object && !avatar_object->isAvatar()) + { + avatar_object = (LLViewerObject*)avatar_object->getParent(); + } + + if (avatar_object && ((LLVOAvatar*)avatar_object)->isSelf()) + { + // project pick point a few meters in front of avatar + mSteerPick.mPosGlobal = gAgent.getPositionGlobal() + LLVector3d(LLViewerCamera::instance().getAtAxis()) * 3.0; + } + } + else if (!mSteerPick.isValid()) + { + mSteerPick.mPosGlobal = gAgent.getPosGlobalFromAgent( + LLViewerCamera::instance().getOrigin() + gViewerWindow->mouseDirectionGlobal(mSteerPick.mMousePt.mX, mSteerPick.mMousePt.mY) * 100.f); + } + mMouseOutsideSlop = true; mAbortClickToWalk = true; setMouseCapture(TRUE); @@ -1721,7 +1746,7 @@ void LLToolPie::startCameraSteering() mMouseSteerX = mMouseDownX; mMouseSteerY = mMouseDownY; const LLVector3 camera_to_rotation_center = gAgent.getFrameAgent().getOrigin() - LLViewerCamera::instance().getOrigin(); - const LLVector3 rotation_center_to_pick = gAgent.getPosAgentFromGlobal(mDragPick.mPosGlobal) - gAgent.getFrameAgent().getOrigin(); + const LLVector3 rotation_center_to_pick = gAgent.getPosAgentFromGlobal(mSteerPick.mPosGlobal) - gAgent.getFrameAgent().getOrigin(); mClockwise = camera_to_rotation_center * rotation_center_to_pick < 0.f; mMouseSteerGrabPoint= (LLHUDEffectBlob *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BLOB, FALSE); @@ -1734,7 +1759,7 @@ void LLToolPie::steerCameraWithMouse(S32 x, S32 y) { const F32 MIN_ROTATION_RADIUS_FRACTION = 0.2f; - const LLVector3 pick_pos = gAgent.getPosAgentFromGlobal(mDragPick.mPosGlobal); + const LLVector3 pick_pos = gAgent.getPosAgentFromGlobal(mSteerPick.mPosGlobal); const LLVector3 rotation_center = gAgent.getFrameAgent().getOrigin(); // FIXME: get this to work with camera tilt (i.e. sitting on a rotating object) const LLVector3 rotation_up_axis(LLVector3::z_axis); diff --git a/indra/newview/lltoolpie.h b/indra/newview/lltoolpie.h index dca661d26d..01e74a20d7 100644 --- a/indra/newview/lltoolpie.h +++ b/indra/newview/lltoolpie.h @@ -108,7 +108,7 @@ private: LLUUID mMediaMouseCaptureID; LLPickInfo mPick; LLPickInfo mHoverPick; - LLPickInfo mDragPick; + LLPickInfo mSteerPick; LLPointer mClickActionObject; U8 mClickAction; LLSafeHandle mLeftClickSelection; -- cgit v1.3 From 731037245f5ad7a85c223b5e4a5f56e570bb42fe Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 14 Mar 2011 13:35:04 -0700 Subject: SOCIAL-715 FIX clicking on own nametag or head causes avatar to walk backward --- indra/newview/lltoolpie.cpp | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) (limited to 'indra/newview/lltoolpie.cpp') diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index c0b5c8de70..959535d224 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -638,6 +638,21 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) && (mPick.mPickType == LLPickInfo::PICK_LAND // we clicked on land || mPick.mObjectID.notNull())) // or on an object { + // handle special cases of steering picks + LLViewerObject* avatar_object = mPick.getObject(); + + // get pointer to avatar + while (avatar_object && !avatar_object->isAvatar()) + { + avatar_object = (LLViewerObject*)avatar_object->getParent(); + } + + if (avatar_object && ((LLVOAvatar*)avatar_object)->isSelf()) + { + const F64 SELF_CLICK_WALK_DISTANCE = 3.0; + // pretend we picked some point a bit in front of avatar + mPick.mPosGlobal = gAgent.getPositionGlobal() + LLVector3d(LLViewerCamera::instance().getAtAxis()) * SELF_CLICK_WALK_DISTANCE; + } gAgentCamera.setFocusOnAvatar(TRUE, TRUE); mAutoPilotDestination = (LLHUDEffectBlob *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BLOB, FALSE); mAutoPilotDestination->setPositionGlobal(mPick.mPosGlobal); @@ -1715,25 +1730,23 @@ void LLToolPie::startCameraSteering() { mSteerPick = mPick; - LLPointer pick_object = mSteerPick.getObject(); // handle special cases of steering picks - if (pick_object) - { - LLViewerObject* avatar_object = pick_object; + LLViewerObject* avatar_object = mSteerPick.getObject(); - // get pointer to avatar - while (avatar_object && !avatar_object->isAvatar()) - { - avatar_object = (LLViewerObject*)avatar_object->getParent(); - } + // get pointer to avatar + while (avatar_object && !avatar_object->isAvatar()) + { + avatar_object = (LLViewerObject*)avatar_object->getParent(); + } - if (avatar_object && ((LLVOAvatar*)avatar_object)->isSelf()) - { - // project pick point a few meters in front of avatar - mSteerPick.mPosGlobal = gAgent.getPositionGlobal() + LLVector3d(LLViewerCamera::instance().getAtAxis()) * 3.0; - } + // if clicking on own avatar... + if (avatar_object && ((LLVOAvatar*)avatar_object)->isSelf()) + { + // ...project pick point a few meters in front of avatar + mSteerPick.mPosGlobal = gAgent.getPositionGlobal() + LLVector3d(LLViewerCamera::instance().getAtAxis()) * 3.0; } - else if (!mSteerPick.isValid()) + + if (!mSteerPick.isValid()) { mSteerPick.mPosGlobal = gAgent.getPosGlobalFromAgent( LLViewerCamera::instance().getOrigin() + gViewerWindow->mouseDirectionGlobal(mSteerPick.mMousePt.mX, mSteerPick.mMousePt.mY) * 100.f); -- cgit v1.3 From 068a4ce9e6fd060b16117820651eb2e3e51e5680 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 14 Mar 2011 13:39:51 -0700 Subject: fixed line endings --- indra/newview/lltoolpie.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'indra/newview/lltoolpie.cpp') diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index 959535d224..e41b84af55 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -640,11 +640,11 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) { // handle special cases of steering picks LLViewerObject* avatar_object = mPick.getObject(); - - // get pointer to avatar - while (avatar_object && !avatar_object->isAvatar()) - { - avatar_object = (LLViewerObject*)avatar_object->getParent(); + + // get pointer to avatar + while (avatar_object && !avatar_object->isAvatar()) + { + avatar_object = (LLViewerObject*)avatar_object->getParent(); } if (avatar_object && ((LLVOAvatar*)avatar_object)->isSelf()) @@ -1732,12 +1732,12 @@ void LLToolPie::startCameraSteering() // handle special cases of steering picks LLViewerObject* avatar_object = mSteerPick.getObject(); - - // get pointer to avatar - while (avatar_object && !avatar_object->isAvatar()) - { - avatar_object = (LLViewerObject*)avatar_object->getParent(); - } + + // get pointer to avatar + while (avatar_object && !avatar_object->isAvatar()) + { + avatar_object = (LLViewerObject*)avatar_object->getParent(); + } // if clicking on own avatar... if (avatar_object && ((LLVOAvatar*)avatar_object)->isSelf()) -- cgit v1.3 From 2de88a99d9de776ea9bc3cef293d0e3bf40f9b7e Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 14 Mar 2011 13:52:53 -0700 Subject: SOCIAL-529 FIX Click and drag camera does not work when using orbit and pan tools disabled click-drag when camera not in default position since behavior would be weird at best --- indra/newview/lltoolpie.cpp | 74 ++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 34 deletions(-) (limited to 'indra/newview/lltoolpie.cpp') diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index e41b84af55..ef9f5a855c 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -530,7 +530,9 @@ void LLToolPie::selectionPropertiesReceived() BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask) { - if (!mMouseOutsideSlop && mMouseButtonDown && gSavedSettings.getBOOL("ClickToWalk")) + if (!mMouseOutsideSlop + && mMouseButtonDown + && gSavedSettings.getBOOL("ClickToWalk")) { S32 delta_x = x - mMouseDownX; S32 delta_y = y - mMouseDownY; @@ -1728,44 +1730,48 @@ bool intersect_ray_with_sphere( const LLVector3& ray_pt, const LLVector3& ray_di void LLToolPie::startCameraSteering() { - mSteerPick = mPick; - - // handle special cases of steering picks - LLViewerObject* avatar_object = mSteerPick.getObject(); + mMouseOutsideSlop = true; + mAbortClickToWalk = true; - // get pointer to avatar - while (avatar_object && !avatar_object->isAvatar()) + if (gAgentCamera.getFocusOnAvatar()) { - avatar_object = (LLViewerObject*)avatar_object->getParent(); - } + mSteerPick = mPick; - // if clicking on own avatar... - if (avatar_object && ((LLVOAvatar*)avatar_object)->isSelf()) - { - // ...project pick point a few meters in front of avatar - mSteerPick.mPosGlobal = gAgent.getPositionGlobal() + LLVector3d(LLViewerCamera::instance().getAtAxis()) * 3.0; - } + // handle special cases of steering picks + LLViewerObject* avatar_object = mSteerPick.getObject(); - if (!mSteerPick.isValid()) - { - mSteerPick.mPosGlobal = gAgent.getPosGlobalFromAgent( - LLViewerCamera::instance().getOrigin() + gViewerWindow->mouseDirectionGlobal(mSteerPick.mMousePt.mX, mSteerPick.mMousePt.mY) * 100.f); - } + // get pointer to avatar + while (avatar_object && !avatar_object->isAvatar()) + { + avatar_object = (LLViewerObject*)avatar_object->getParent(); + } - mMouseOutsideSlop = true; - mAbortClickToWalk = true; - setMouseCapture(TRUE); - - mMouseSteerX = mMouseDownX; - mMouseSteerY = mMouseDownY; - const LLVector3 camera_to_rotation_center = gAgent.getFrameAgent().getOrigin() - LLViewerCamera::instance().getOrigin(); - const LLVector3 rotation_center_to_pick = gAgent.getPosAgentFromGlobal(mSteerPick.mPosGlobal) - gAgent.getFrameAgent().getOrigin(); - - mClockwise = camera_to_rotation_center * rotation_center_to_pick < 0.f; - mMouseSteerGrabPoint= (LLHUDEffectBlob *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BLOB, FALSE); - mMouseSteerGrabPoint->setPositionGlobal(mPick.mPosGlobal); - mMouseSteerGrabPoint->setColor(LLColor4U::white); - mMouseSteerGrabPoint->setDuration(1000.f); + // if clicking on own avatar... + if (avatar_object && ((LLVOAvatar*)avatar_object)->isSelf()) + { + // ...project pick point a few meters in front of avatar + mSteerPick.mPosGlobal = gAgent.getPositionGlobal() + LLVector3d(LLViewerCamera::instance().getAtAxis()) * 3.0; + } + + if (!mSteerPick.isValid()) + { + mSteerPick.mPosGlobal = gAgent.getPosGlobalFromAgent( + LLViewerCamera::instance().getOrigin() + gViewerWindow->mouseDirectionGlobal(mSteerPick.mMousePt.mX, mSteerPick.mMousePt.mY) * 100.f); + } + + setMouseCapture(TRUE); + + mMouseSteerX = mMouseDownX; + mMouseSteerY = mMouseDownY; + const LLVector3 camera_to_rotation_center = gAgent.getFrameAgent().getOrigin() - LLViewerCamera::instance().getOrigin(); + const LLVector3 rotation_center_to_pick = gAgent.getPosAgentFromGlobal(mSteerPick.mPosGlobal) - gAgent.getFrameAgent().getOrigin(); + + mClockwise = camera_to_rotation_center * rotation_center_to_pick < 0.f; + mMouseSteerGrabPoint= (LLHUDEffectBlob *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BLOB, FALSE); + mMouseSteerGrabPoint->setPositionGlobal(mPick.mPosGlobal); + mMouseSteerGrabPoint->setColor(LLColor4U::white); + mMouseSteerGrabPoint->setDuration(1000.f); + } } void LLToolPie::steerCameraWithMouse(S32 x, S32 y) -- cgit v1.3 From 0e10a83b6bc11d0a40f09e6ba59b30c0e1e343bd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 14 Mar 2011 16:46:10 -0700 Subject: SOCIAL-695 FIX Selecting UI and then clicking on world to give focus back to viewer moves you to that location made this work when clicking on SL with another app in foreground visual feedback of ClickToWalk behavior --- indra/newview/llhudeffectblob.cpp | 34 +++++++++++++++++++++++++++++++++- indra/newview/llhudeffectblob.h | 5 ++++- indra/newview/llhudobject.cpp | 1 + indra/newview/lltoolpie.cpp | 26 ++++++++++++++++++-------- indra/newview/lltoolpie.h | 5 +++-- 5 files changed, 59 insertions(+), 12 deletions(-) (limited to 'indra/newview/lltoolpie.cpp') diff --git a/indra/newview/llhudeffectblob.cpp b/indra/newview/llhudeffectblob.cpp index 6ef8fab4a6..f976a320ee 100644 --- a/indra/newview/llhudeffectblob.cpp +++ b/indra/newview/llhudeffectblob.cpp @@ -28,8 +28,15 @@ #include "llhudeffectblob.h" -LLHUDEffectBlob::LLHUDEffectBlob(const U8 type) : LLHUDEffect(type) +#include "llagent.h" +#include "llviewercamera.h" +#include "llrendersphere.h" + +LLHUDEffectBlob::LLHUDEffectBlob(const U8 type) +: LLHUDEffect(type), + mPixelSize(10) { + mTimer.start(); } LLHUDEffectBlob::~LLHUDEffectBlob() @@ -38,6 +45,31 @@ LLHUDEffectBlob::~LLHUDEffectBlob() void LLHUDEffectBlob::render() { + F32 time = mTimer.getElapsedTimeF32(); + if (mDuration < time) + { + markDead(); + } + + LLVector3 pos_agent = gAgent.getPosAgentFromGlobal(mPositionGlobal); + + LLVector3 pixel_up, pixel_right; + + LLViewerCamera::instance().getPixelVectors(pos_agent, pixel_up, pixel_right); + + LLGLSPipelineAlpha gls_pipeline_alpha; + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + + LLColor4U color = mColor; + color.mV[VALPHA] = clamp_rescale(time, 0.f, mDuration, 255.f, 0.f); + glColor4ubv(color.mV); + + glPushMatrix(); + glTranslatef(pos_agent.mV[0], pos_agent.mV[1], pos_agent.mV[2]); + F32 scale = pixel_up.magVec() * (F32)mPixelSize; + glScalef(scale, scale, scale); + gSphere.render(0); + glPopMatrix(); } void LLHUDEffectBlob::renderForTimer() diff --git a/indra/newview/llhudeffectblob.h b/indra/newview/llhudeffectblob.h index 7757dc787c..5b0703cdaa 100644 --- a/indra/newview/llhudeffectblob.h +++ b/indra/newview/llhudeffectblob.h @@ -34,6 +34,8 @@ class LLHUDEffectBlob : public LLHUDEffect public: friend class LLHUDObject; + void setPixelSize(S32 pixels) { mPixelSize = pixels; } + protected: LLHUDEffectBlob(const U8 type); ~LLHUDEffectBlob(); @@ -41,7 +43,8 @@ protected: /*virtual*/ void render(); /*virtual*/ void renderForTimer(); private: - + S32 mPixelSize; + LLFrameTimer mTimer; }; #endif // LL_LLHUDEFFECTBLOB_H diff --git a/indra/newview/llhudobject.cpp b/indra/newview/llhudobject.cpp index 3efb8d287d..95d57d08d8 100644 --- a/indra/newview/llhudobject.cpp +++ b/indra/newview/llhudobject.cpp @@ -240,6 +240,7 @@ LLHUDEffect *LLHUDObject::addHUDEffect(const U8 type) break; case LL_HUD_EFFECT_BLOB: hud_objectp = new LLHUDEffectBlob(type); + break; default: llwarns << "Unknown type of hud effect:" << (U32) type << llendl; } diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index ef9f5a855c..f258b5d875 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -112,7 +112,6 @@ BOOL LLToolPie::handleMouseDown(S32 x, S32 y, MASK mask) mPick.mKeyMask = mask; mMouseButtonDown = true; - mAbortClickToWalk = false; handleLeftClickPick(); @@ -656,12 +655,16 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) mPick.mPosGlobal = gAgent.getPositionGlobal() + LLVector3d(LLViewerCamera::instance().getAtAxis()) * SELF_CLICK_WALK_DISTANCE; } gAgentCamera.setFocusOnAvatar(TRUE, TRUE); + if(mAutoPilotDestination) { mAutoPilotDestination->markDead(); } mAutoPilotDestination = (LLHUDEffectBlob *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BLOB, FALSE); mAutoPilotDestination->setPositionGlobal(mPick.mPosGlobal); - mAutoPilotDestination->setColor(LLColor4U::white); - mAutoPilotDestination->setDuration(5.f); + mAutoPilotDestination->setPixelSize(5); + mAutoPilotDestination->setColor(LLColor4U(50, 50, 200)); + mAutoPilotDestination->setDuration(3.f); handle_go_to(); + mAbortClickToWalk = false; + return TRUE; } gViewerWindow->setCursor(UI_CURSOR_ARROW); @@ -672,6 +675,8 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) LLToolMgr::getInstance()->clearTransientTool(); gAgentCamera.setLookAt(LOOKAT_TARGET_CONVERSATION, obj); // maybe look at object/person clicked on + + mAbortClickToWalk = false; return LLTool::handleMouseUp(x, y, mask); } @@ -1292,6 +1297,10 @@ void LLToolPie::VisitHomePage(const LLPickInfo& info) } } +void LLToolPie::handleSelect() +{ + mAbortClickToWalk = true; +} void LLToolPie::handleDeselect() { @@ -1338,7 +1347,6 @@ void LLToolPie::onMouseCaptureLost() void LLToolPie::stopCameraSteering() { mMouseOutsideSlop = false; - mMouseSteerGrabPoint = NULL; } bool LLToolPie::inCameraSteerMode() @@ -1767,10 +1775,12 @@ void LLToolPie::startCameraSteering() const LLVector3 rotation_center_to_pick = gAgent.getPosAgentFromGlobal(mSteerPick.mPosGlobal) - gAgent.getFrameAgent().getOrigin(); mClockwise = camera_to_rotation_center * rotation_center_to_pick < 0.f; - mMouseSteerGrabPoint= (LLHUDEffectBlob *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BLOB, FALSE); - mMouseSteerGrabPoint->setPositionGlobal(mPick.mPosGlobal); - mMouseSteerGrabPoint->setColor(LLColor4U::white); - mMouseSteerGrabPoint->setDuration(1000.f); + if (mMouseSteerGrabPoint) { mMouseSteerGrabPoint->markDead(); } + mMouseSteerGrabPoint = (LLHUDEffectBlob *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BLOB, FALSE); + mMouseSteerGrabPoint->setPositionGlobal(mSteerPick.mPosGlobal); + mMouseSteerGrabPoint->setColor(LLColor4U(50, 50, 200)); + mMouseSteerGrabPoint->setPixelSize(5); + mMouseSteerGrabPoint->setDuration(2.f); } } diff --git a/indra/newview/lltoolpie.h b/indra/newview/lltoolpie.h index 01e74a20d7..c324b50c65 100644 --- a/indra/newview/lltoolpie.h +++ b/indra/newview/lltoolpie.h @@ -57,6 +57,7 @@ public: virtual void stopEditing(); virtual void onMouseCaptureLost(); + virtual void handleSelect(); virtual void handleDeselect(); virtual LLTool* getOverrideTool(MASK mask); @@ -101,8 +102,8 @@ private: S32 mMouseDownY; S32 mMouseSteerX; S32 mMouseSteerY; - LLHUDEffectBlob* mAutoPilotDestination; - LLHUDEffectBlob* mMouseSteerGrabPoint; + LLPointer mAutoPilotDestination; + LLPointer mMouseSteerGrabPoint; bool mClockwise; bool mAbortClickToWalk; LLUUID mMediaMouseCaptureID; -- cgit v1.3 From 2c22863888eefbfb0f4245011be989d155583db7 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 15 Mar 2011 09:54:17 -0700 Subject: another attempt at fixing gcc --- indra/newview/lltoolpie.cpp | 1 - indra/newview/lltoolpie.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/newview/lltoolpie.cpp') diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index f258b5d875..582f50ba37 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -42,7 +42,6 @@ #include "llfloaterreg.h" #include "llfloaterscriptdebug.h" #include "lltooltip.h" -#include "llhudeffectblob.h" #include "llhudeffecttrail.h" #include "llhudmanager.h" #include "llkeyboard.h" diff --git a/indra/newview/lltoolpie.h b/indra/newview/lltoolpie.h index c324b50c65..22e77a3159 100644 --- a/indra/newview/lltoolpie.h +++ b/indra/newview/lltoolpie.h @@ -30,10 +30,10 @@ #include "lltool.h" #include "lluuid.h" #include "llviewerwindow.h" // for LLPickInfo +#include "llhudeffectblob.h" // for LLPointer, apparently class LLViewerObject; class LLObjectSelection; -class LLHUDEffectBlob; class LLToolPie : public LLTool, public LLSingleton { -- cgit v1.3 From 5f05157fb74a6b3c1e20b024055e7fccf434c15c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 17 Mar 2011 15:50:51 -0700 Subject: SOCIAL-749 FIX Clicking on world to dismiss context menus causes your avatar to walk to click --- indra/newview/lltoolpie.cpp | 17 +++++++++-------- indra/newview/lltoolpie.h | 3 ++- indra/newview/llviewermenu.cpp | 8 +++++++- 3 files changed, 18 insertions(+), 10 deletions(-) (limited to 'indra/newview/lltoolpie.cpp') diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index 582f50ba37..78df193dc3 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -83,7 +83,7 @@ LLToolPie::LLToolPie() mMouseOutsideSlop( false ), mMouseSteerX(-1), mMouseSteerY(-1), - mAbortClickToWalk(false), + mBlockClickToWalk(false), mClickAction(0), mClickActionBuyEnabled( gSavedSettings.getBOOL("ClickActionBuyEnabled") ), mClickActionPayEnabled( gSavedSettings.getBOOL("ClickActionPayEnabled") ) @@ -303,7 +303,7 @@ BOOL LLToolPie::handleLeftClickPick() if (gFocusMgr.getKeyboardFocus()) { // don't click to walk on attempt to give focus to world - mAbortClickToWalk = true; + mBlockClickToWalk = true; gFocusMgr.setKeyboardFocus(NULL); } @@ -625,7 +625,7 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) // let media have first pass at click if (handleMediaMouseUp() || LLViewerMediaFocus::getInstance()->getFocus()) { - mAbortClickToWalk = true; + mBlockClickToWalk = true; } stopCameraSteering(); mMouseButtonDown = false; @@ -633,7 +633,7 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) if (click_action == CLICK_ACTION_NONE // not doing 1-click action && gSavedSettings.getBOOL("ClickToWalk") // click to walk enabled && !gAgent.getFlying() // don't auto-navigate while flying until that works - && !mAbortClickToWalk // another behavior hasn't cancelled click to walk + && !mBlockClickToWalk // another behavior hasn't cancelled click to walk && !mPick.mPosGlobal.isExactlyZero() // valid coordinates for pick && (mPick.mPickType == LLPickInfo::PICK_LAND // we clicked on land || mPick.mObjectID.notNull())) // or on an object @@ -662,7 +662,7 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) mAutoPilotDestination->setDuration(3.f); handle_go_to(); - mAbortClickToWalk = false; + mBlockClickToWalk = false; return TRUE; } @@ -675,7 +675,7 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) LLToolMgr::getInstance()->clearTransientTool(); gAgentCamera.setLookAt(LOOKAT_TARGET_CONVERSATION, obj); // maybe look at object/person clicked on - mAbortClickToWalk = false; + mBlockClickToWalk = false; return LLTool::handleMouseUp(x, y, mask); } @@ -1298,7 +1298,8 @@ void LLToolPie::VisitHomePage(const LLPickInfo& info) void LLToolPie::handleSelect() { - mAbortClickToWalk = true; + // tool is reselected when app gets focus, etc. + mBlockClickToWalk = true; } void LLToolPie::handleDeselect() @@ -1738,7 +1739,7 @@ bool intersect_ray_with_sphere( const LLVector3& ray_pt, const LLVector3& ray_di void LLToolPie::startCameraSteering() { mMouseOutsideSlop = true; - mAbortClickToWalk = true; + mBlockClickToWalk = true; if (gAgentCamera.getFocusOnAvatar()) { diff --git a/indra/newview/lltoolpie.h b/indra/newview/lltoolpie.h index 22e77a3159..22359a6db8 100644 --- a/indra/newview/lltoolpie.h +++ b/indra/newview/lltoolpie.h @@ -66,6 +66,7 @@ public: LLViewerObject* getClickActionObject() { return mClickActionObject; } LLObjectSelection* getLeftClickSelection() { return (LLObjectSelection*)mLeftClickSelection; } void resetSelection(); + void blockClickToWalk() { mBlockClickToWalk = true; } static void selectionPropertiesReceived(); @@ -105,7 +106,7 @@ private: LLPointer mAutoPilotDestination; LLPointer mMouseSteerGrabPoint; bool mClockwise; - bool mAbortClickToWalk; + bool mBlockClickToWalk; LLUUID mMediaMouseCaptureID; LLPickInfo mPick; LLPickInfo mHoverPick; diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 75cf2efc69..3e0363849b 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -7158,7 +7158,13 @@ LLViewerMenuHolderGL::LLViewerMenuHolderGL(const LLViewerMenuHolderGL::Params& p BOOL LLViewerMenuHolderGL::hideMenus() { - BOOL handled = LLMenuHolderGL::hideMenus(); + BOOL handled = FALSE; + + if (LLMenuHolderGL::hideMenus()) + { + LLToolPie::instance().blockClickToWalk(); + handled = TRUE; + } // drop pie menu selection mParcelSelection = NULL; -- cgit v1.3 From 1db1c3443ea4e9cde52bfb3c0e127426f02a742f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 17 Mar 2011 18:09:36 -0700 Subject: SOCIAL-741 FIX Gesture graphic for click to move in-world --- indra/newview/llhudeffectblob.cpp | 30 ++++++++++++++------- indra/newview/llhudeffectblob.h | 2 ++ indra/newview/lltoolpie.cpp | 4 +-- indra/newview/skins/default/textures/textures.xml | 1 + .../skins/default/textures/world/CameraDragDot.png | Bin 0 -> 3101 bytes 5 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 indra/newview/skins/default/textures/world/CameraDragDot.png (limited to 'indra/newview/lltoolpie.cpp') diff --git a/indra/newview/llhudeffectblob.cpp b/indra/newview/llhudeffectblob.cpp index 26e8251899..d8687eed8d 100644 --- a/indra/newview/llhudeffectblob.cpp +++ b/indra/newview/llhudeffectblob.cpp @@ -30,13 +30,14 @@ #include "llagent.h" #include "llviewercamera.h" -#include "llrendersphere.h" +#include "llui.h" LLHUDEffectBlob::LLHUDEffectBlob(const U8 type) : LLHUDEffect(type), mPixelSize(10) { mTimer.start(); + mImage = LLUI::getUIImage("Camera_Drag_Dot"); } LLHUDEffectBlob::~LLHUDEffectBlob() @@ -58,18 +59,29 @@ void LLHUDEffectBlob::render() LLViewerCamera::instance().getPixelVectors(pos_agent, pixel_up, pixel_right); LLGLSPipelineAlpha gls_pipeline_alpha; - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->bind(mImage->getImage()); LLColor4U color = mColor; color.mV[VALPHA] = (U8)clamp_rescale(time, 0.f, mDuration, 255.f, 0.f); - glColor4ubv(color.mV); + gGL.color4ubv(color.mV); - glPushMatrix(); - glTranslatef(pos_agent.mV[0], pos_agent.mV[1], pos_agent.mV[2]); - F32 scale = pixel_up.magVec() * (F32)mPixelSize; - glScalef(scale, scale, scale); - gSphere.render(0); - glPopMatrix(); + { gGL.pushMatrix(); + gGL.translatef(pos_agent.mV[0], pos_agent.mV[1], pos_agent.mV[2]); + LLVector3 u_scale = pixel_right * (F32)mPixelSize; + LLVector3 v_scale = pixel_up * (F32)mPixelSize; + + { gGL.begin(LLRender::QUADS); + gGL.texCoord2f(0.f, 1.f); + gGL.vertex3fv((v_scale - u_scale).mV); + gGL.texCoord2f(0.f, 0.f); + gGL.vertex3fv((-v_scale - u_scale).mV); + gGL.texCoord2f(1.f, 0.f); + gGL.vertex3fv((-v_scale + u_scale).mV); + gGL.texCoord2f(1.f, 1.f); + gGL.vertex3fv((v_scale + u_scale).mV); + } gGL.end(); + + } gGL.popMatrix(); } void LLHUDEffectBlob::renderForTimer() diff --git a/indra/newview/llhudeffectblob.h b/indra/newview/llhudeffectblob.h index 5b0703cdaa..f4c1691108 100644 --- a/indra/newview/llhudeffectblob.h +++ b/indra/newview/llhudeffectblob.h @@ -28,6 +28,7 @@ #define LL_LLHUDEFFECTBLOB_H #include "llhudeffect.h" +#include "lluiimage.h" class LLHUDEffectBlob : public LLHUDEffect { @@ -45,6 +46,7 @@ protected: private: S32 mPixelSize; LLFrameTimer mTimer; + LLPointer mImage; }; #endif // LL_LLHUDEFFECTBLOB_H diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index 78df193dc3..9549f180df 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -658,7 +658,7 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) mAutoPilotDestination = (LLHUDEffectBlob *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BLOB, FALSE); mAutoPilotDestination->setPositionGlobal(mPick.mPosGlobal); mAutoPilotDestination->setPixelSize(5); - mAutoPilotDestination->setColor(LLColor4U(50, 50, 200)); + mAutoPilotDestination->setColor(LLColor4U(170, 210, 190)); mAutoPilotDestination->setDuration(3.f); handle_go_to(); @@ -1778,7 +1778,7 @@ void LLToolPie::startCameraSteering() if (mMouseSteerGrabPoint) { mMouseSteerGrabPoint->markDead(); } mMouseSteerGrabPoint = (LLHUDEffectBlob *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BLOB, FALSE); mMouseSteerGrabPoint->setPositionGlobal(mSteerPick.mPosGlobal); - mMouseSteerGrabPoint->setColor(LLColor4U(50, 50, 200)); + mMouseSteerGrabPoint->setColor(LLColor4U(170, 210, 190)); mMouseSteerGrabPoint->setPixelSize(5); mMouseSteerGrabPoint->setDuration(2.f); } diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index cec2942b35..d79d660724 100644 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -673,4 +673,5 @@ with the same filename but different name + diff --git a/indra/newview/skins/default/textures/world/CameraDragDot.png b/indra/newview/skins/default/textures/world/CameraDragDot.png new file mode 100644 index 0000000000..57698e1956 Binary files /dev/null and b/indra/newview/skins/default/textures/world/CameraDragDot.png differ -- cgit v1.3