From 9ec10cf2462df368202668a05a7417bedff08865 Mon Sep 17 00:00:00 2001 From: Inusaito Sayori Date: Tue, 22 Oct 2013 07:47:43 -0400 Subject: [PATCH] Reworked LLToolCompGun so piemenu in mouselook plays nicer with zoom feature Switches to exodus implementation Includes relicensing of LLViewerCamera and LLToolComp Maintains use of the old saved zoomed setting --- indra/newview/app_settings/settings.xml | 33 ----- indra/newview/lltoolcomp.cpp | 163 +++++++++++++++--------- indra/newview/lltoolcomp.h | 46 ++++--- indra/newview/llviewercamera.cpp | 46 ++++--- indra/newview/llviewercamera.h | 42 +++--- indra/newview/llviewerwindow.cpp | 20 --- 6 files changed, 177 insertions(+), 173 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 1fce571f3..c3f3f2aa8 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -210,17 +210,6 @@ 100 - zmm_deffov - - Comment - Default field of viewer for right click mouse zoom. - Persist - 1 - Type - F32 - Value - 1.0 - zmm_mlfov Comment @@ -232,28 +221,6 @@ Value 1 - zmm_isinml - - Comment - mouselook - Persist - 0 - Type - Boolean - Value - 0 - - zmm_rightmousedown - - Comment - insert rude comment here - Persist - 0 - Type - Boolean - Value - 0 - AllowLargeSounds diff --git a/indra/newview/lltoolcomp.cpp b/indra/newview/lltoolcomp.cpp index 9d520eaef..a205ca7ef 100644 --- a/indra/newview/lltoolcomp.cpp +++ b/indra/newview/lltoolcomp.cpp @@ -2,31 +2,25 @@ * @file lltoolcomp.cpp * @brief Composite tools * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * 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. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * 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. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * 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 * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -49,6 +43,7 @@ #include "lltoolmgr.h" #include "lltoolselectrect.h" #include "lltoolplacer.h" +#include "llviewercamera.h" // #include "llviewermenu.h" #include "llviewerobject.h" #include "llviewerwindow.h" @@ -57,7 +52,7 @@ #include "llfloatertools.h" #include "qtoolalign.h" #include "llviewercontrol.h" -#include "llviewercamera.h" + const S32 BUTTON_HEIGHT = 16; const S32 BUTTON_WIDTH_SMALL = 32; @@ -659,6 +654,7 @@ void LLToolCompRotate::render() LLToolCompGun::LLToolCompGun() : LLToolComposite(std::string("Mouselook")) + , mRightMouseButton(false), mMenuShown(false), mTimerFOV() // { mGun = new LLToolGun(this); mGrab = new LLToolGrab(this); @@ -666,8 +662,12 @@ LLToolCompGun::LLToolCompGun() setCurrentTool(mGun); mDefault = mGun; -} + // + mTimerFOV.stop(); + mStartFOV = mOriginalFOV = mTargetFOV = LLViewerCamera::getInstance()->getAndSaveDefaultFOV(); + // +} LLToolCompGun::~LLToolCompGun() { @@ -751,25 +751,9 @@ BOOL LLToolCompGun::handleDoubleClick(S32 x, S32 y, MASK mask) return LLToolGrab::getInstance()->handleDoubleClick(x, y, mask); } - +/* Singu Note: Moved to bottom, upstream is Exodus BOOL LLToolCompGun::handleRightMouseDown(S32 x, S32 y, MASK mask) -{ - /* JC - suppress context menu 8/29/2002 - - // On right mouse, go through some convoluted steps to - // make the build menu appear. - setCurrentTool( (LLTool*) mNull ); - - // This should return FALSE, meaning the context menu will - // be shown. - return FALSE; - */ - if (gSavedSettings.getBOOL("LiruMouselookMenu") && mask & MASK_ALT) return false; - - // Returning true will suppress the context menu - return TRUE; -} - +*/ BOOL LLToolCompGun::handleMouseUp(S32 x, S32 y, MASK mask) { @@ -800,27 +784,92 @@ void LLToolCompGun::handleDeselect() setMouseCapture(FALSE); } +// + +BOOL LLToolCompGun::handleRightMouseUp(S32 x, S32 y, MASK mask) +{ + // Singu Note: Beware the alt-click menu + if (mRightMouseButton) + { + mRightMouseButton = false; + + mStartFOV = LLViewerCamera::getInstance()->getDefaultFOV(); + mTargetFOV = mOriginalFOV; + mTimerFOV.start(); + } + + if (mMenuShown) + { + mMenuShown = false; + return LLToolComposite::handleRightMouseUp(x, y, mask); + } + + return TRUE; +} + +BOOL LLToolCompGun::handleRightMouseDown(S32 x, S32 y, MASK mask) +{ + // Singu Note: Beware the alt-click menu + if (gSavedSettings.getBOOL("LiruMouselookMenu") && mask & MASK_ALT) + { + mMenuShown = true; + return false; + } + + mRightMouseButton = true; + + if(!mTimerFOV.getStarted()) + { + mStartFOV = LLViewerCamera::getInstance()->getAndSaveDefaultFOV(); + mOriginalFOV = mStartFOV; + } + else mStartFOV = LLViewerCamera::getInstance()->getDefaultFOV(); + + mTargetFOV = gSavedPerAccountSettings.getF32("zmm_mlfov"); + mTimerFOV.start(); + + return TRUE; +} BOOL LLToolCompGun::handleScrollWheel(S32 x, S32 y, S32 clicks) { - //::MOYMOD:: - if(gSavedSettings.getBOOL("zmm_isinml") == 1) + if (mRightMouseButton) { - if(clicks > 0) - { - gSavedSettings.setF32("zmm_mlfov", gSavedSettings.getF32("zmm_mlfov") / 1.1); - } - else if(clicks < 0) - { - gSavedSettings.setF32("zmm_mlfov", gSavedSettings.getF32("zmm_mlfov") * 1.1); - } - LLViewerCamera::getInstance()->setDefaultFOV(gSavedSettings.getF32("zmm_deffov") / gSavedSettings.getF32("zmm_mlfov")); - return TRUE; - } - if (clicks > 0) - { - gAgentCamera.changeCameraToDefault(); + mStartFOV = LLViewerCamera::getInstance()->getDefaultFOV(); + gSavedPerAccountSettings.setF32( + "zmm_mlfov", + mTargetFOV = clicks > 0 ? + llclamp(mTargetFOV += (0.05f * clicks), 0.1f, 3.0f) : + llclamp(mTargetFOV -= (0.05f * -clicks), 0.1f, 3.0f) + ); + + mTimerFOV.start(); } + else if (clicks > 0) gAgentCamera.changeCameraToDefault(); + return TRUE; } + +// Zoom related stuff... + +void LLToolCompGun::draw() +{ + if (mTimerFOV.getStarted()) + { + if (!LLViewerCamera::getInstance()->mSavedFOVLoaded && mStartFOV != mTargetFOV) + { + F32 timer = mTimerFOV.getElapsedTimeF32(); + + if (timer > 0.15f) + { + LLViewerCamera::getInstance()->setDefaultFOV(mTargetFOV); + mTimerFOV.stop(); + } + else LLViewerCamera::getInstance()->setDefaultFOV(lerp(mStartFOV, mTargetFOV, timer * 6.66f)); + } + else mTimerFOV.stop(); + } +} + +// diff --git a/indra/newview/lltoolcomp.h b/indra/newview/lltoolcomp.h index 81ed0ba8e..07cf2815b 100644 --- a/indra/newview/lltoolcomp.h +++ b/indra/newview/lltoolcomp.h @@ -2,31 +2,25 @@ * @file lltoolcomp.h * @brief Composite tools * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * 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. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * 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. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * 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 * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -219,10 +213,13 @@ public: LLToolCompGun(); virtual ~LLToolCompGun(); + virtual void draw(); // + // Overridden from LLToolComposite virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask); + virtual BOOL handleRightMouseUp(S32 x, S32 y, MASK mask); virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); @@ -235,6 +232,13 @@ protected: LLToolGun* mGun; LLToolGrab* mGrab; LLTool* mNull; + + // +private: + bool mRightMouseButton, mMenuShown; + LLTimer mTimerFOV; + F32 mOriginalFOV, mStartFOV, mTargetFOV; + // }; diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp index 9266dc434..b70183fd4 100644 --- a/indra/newview/llviewercamera.cpp +++ b/indra/newview/llviewercamera.cpp @@ -2,31 +2,25 @@ * @file llviewercamera.cpp * @brief LLViewerCamera class implementation * - * $LicenseInfo:firstyear=2002&license=viewergpl$ - * - * Copyright (c) 2002-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * 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. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * 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. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * 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$ */ @@ -113,6 +107,7 @@ LLViewerCamera::LLViewerCamera() : LLCamera() { calcProjection(getFar()); mCameraFOVDefault = DEFAULT_FIELD_OF_VIEW; + mSavedFOVDefault = DEFAULT_FIELD_OF_VIEW; // mCosHalfCameraFOV = cosf(mCameraFOVDefault * 0.5f); mPixelMeterRatio = 0.f; mScreenPixelArea = 0; @@ -927,6 +922,15 @@ void LLViewerCamera::setDefaultFOV(F32 vertical_fov_rads) mCosHalfCameraFOV = cosf(mCameraFOVDefault * 0.5f); } +// +void LLViewerCamera::loadDefaultFOV() +{ + setView(mSavedFOVDefault); + mSavedFOVLoaded = true; + mCameraFOVDefault = mSavedFOVDefault; + mCosHalfCameraFOV = cosf(mCameraFOVDefault * 0.5f); +} +// // static void LLViewerCamera::updateCameraAngle( void* user_data, const LLSD& value) diff --git a/indra/newview/llviewercamera.h b/indra/newview/llviewercamera.h index 82d88bc3d..d9ac2af30 100644 --- a/indra/newview/llviewercamera.h +++ b/indra/newview/llviewercamera.h @@ -2,31 +2,25 @@ * @file llviewercamera.h * @brief LLViewerCamera class header file * - * $LicenseInfo:firstyear=2002&license=viewergpl$ - * - * Copyright (c) 2002-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * 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. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * 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. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * 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$ */ @@ -118,6 +112,11 @@ public: void setDefaultFOV(F32 fov) ; F32 getDefaultFOV() { return mCameraFOVDefault; } + bool mSavedFOVLoaded; // + F32 getAndSaveDefaultFOV() { mSavedFOVLoaded = false; return mSavedFOVDefault = mCameraFOVDefault; } // + void setAndSaveDefaultFOV(F32 fov) { setDefaultFOV(mSavedFOVDefault = fov); } // + void loadDefaultFOV(); // + BOOL cameraUnderWater() const; const LLVector3 &getPointOfInterest() { return mLastPointOfInterest; } @@ -141,6 +140,7 @@ protected: mutable LLMatrix4 mProjectionMatrix; // Cache of perspective matrix mutable LLMatrix4 mModelviewMatrix; F32 mCameraFOVDefault; + F32 mSavedFOVDefault; // F32 mCosHalfCameraFOV; LLVector3 mLastPointOfInterest; F32 mPixelMeterRatio; // Divide by distance from camera to get pixels per meter at that distance. diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 691df6035..1348d23b8 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -1015,18 +1015,6 @@ BOOL LLViewerWindow::handleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask) BOOL LLViewerWindow::handleRightMouseDown(LLWindow *window, LLCoordGL pos, MASK mask) { - //From Phoenix - // Singu TODO: Change these from debug settings to externs? - gSavedSettings.setBOOL("zmm_rightmousedown", true); - if (gAgentCamera.cameraMouselook() && !gSavedSettings.getBOOL("zmm_isinml")) - { - llinfos << "zmmisinml set to true" << llendl; - gSavedSettings.setBOOL("zmm_isinml", true); - F32 deffov = LLViewerCamera::getInstance()->getDefaultFOV(); - gSavedSettings.setF32("zmm_deffov", deffov); - LLViewerCamera::getInstance()->setDefaultFOV(deffov/gSavedSettings.getF32("zmm_mlfov")); - } - S32 x = pos.mX; S32 y = pos.mY; x = llround((F32)x / mDisplayScale.mV[VX]); @@ -1055,14 +1043,6 @@ BOOL LLViewerWindow::handleRightMouseDown(LLWindow *window, LLCoordGL pos, MASK BOOL LLViewerWindow::handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK mask) { - gSavedSettings.setBOOL("zmm_rightmousedown", false); - if(gSavedSettings.getBOOL("zmm_isinml")==1) - { - llinfos << "zmmisinml set to false" << llendl; - gSavedSettings.setBOOL("zmm_isinml",0); - LLViewerCamera::getInstance()->setDefaultFOV(gSavedSettings.getF32("zmm_deffov")); - } - BOOL down = FALSE; return handleAnyMouseClick(window,pos,mask,LLMouseHandler::CLICK_RIGHT,down); }