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
This commit is contained in:
Inusaito Sayori
2013-10-22 07:47:43 -04:00
parent dde18dfc0f
commit 9ec10cf246
6 changed files with 177 additions and 173 deletions

View File

@@ -210,17 +210,6 @@
<integer>100</integer> <integer>100</integer>
</map> </map>
<key>zmm_deffov</key>
<map>
<key>Comment</key>
<string>Default field of viewer for right click mouse zoom.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>1.0</real>
</map>
<key>zmm_mlfov</key> <key>zmm_mlfov</key>
<map> <map>
<key>Comment</key> <key>Comment</key>
@@ -232,28 +221,6 @@
<key>Value</key> <key>Value</key>
<real>1</real> <real>1</real>
</map> </map>
<key>zmm_isinml</key>
<map>
<key>Comment</key>
<string>mouselook</string>
<key>Persist</key>
<integer>0</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>zmm_rightmousedown</key>
<map>
<key>Comment</key>
<string>insert rude comment here</string>
<key>Persist</key>
<integer>0</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>AllowLargeSounds</key> <key>AllowLargeSounds</key>
<map> <map>

View File

@@ -2,31 +2,25 @@
* @file lltoolcomp.cpp * @file lltoolcomp.cpp
* @brief Composite tools * @brief Composite tools
* *
* $LicenseInfo:firstyear=2001&license=viewergpl$ * $LicenseInfo:firstyear=2001&license=viewerlgpl$
*
* Copyright (c) 2001-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code * Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab * Copyright (C) 2010, Linden Research, Inc.
* to you under the terms of the GNU General Public License, version 2.0 *
* ("GPL"), unless you have obtained a separate licensing agreement * This library is free software; you can redistribute it and/or
* ("Other License"), formally executed by you and Linden Lab. Terms of * modify it under the terms of the GNU Lesser General Public
* the GPL can be found in doc/GPL-license.txt in this distribution, or * License as published by the Free Software Foundation;
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 * version 2.1 of the License only.
* *
* There are special exceptions to the terms and conditions of the GPL as * This library is distributed in the hope that it will be useful,
* it is applied to this Source Code. View the full text of the exception * but WITHOUT ANY WARRANTY; without even the implied warranty of
* in the file doc/FLOSS-exception.txt in this software distribution, or * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* online at * Lesser General Public License for more details.
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
* *
* By copying, modifying or distributing this software, you acknowledge * You should have received a copy of the GNU Lesser General Public
* that you have read and understood your obligations described above, * License along with this library; if not, write to the Free Software
* and agree to abide by those obligations. * 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 * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$ * $/LicenseInfo$
*/ */
@@ -49,6 +43,7 @@
#include "lltoolmgr.h" #include "lltoolmgr.h"
#include "lltoolselectrect.h" #include "lltoolselectrect.h"
#include "lltoolplacer.h" #include "lltoolplacer.h"
#include "llviewercamera.h" // <exodus/>
#include "llviewermenu.h" #include "llviewermenu.h"
#include "llviewerobject.h" #include "llviewerobject.h"
#include "llviewerwindow.h" #include "llviewerwindow.h"
@@ -57,7 +52,7 @@
#include "llfloatertools.h" #include "llfloatertools.h"
#include "qtoolalign.h" #include "qtoolalign.h"
#include "llviewercontrol.h" #include "llviewercontrol.h"
#include "llviewercamera.h"
const S32 BUTTON_HEIGHT = 16; const S32 BUTTON_HEIGHT = 16;
const S32 BUTTON_WIDTH_SMALL = 32; const S32 BUTTON_WIDTH_SMALL = 32;
@@ -659,6 +654,7 @@ void LLToolCompRotate::render()
LLToolCompGun::LLToolCompGun() LLToolCompGun::LLToolCompGun()
: LLToolComposite(std::string("Mouselook")) : LLToolComposite(std::string("Mouselook"))
, mRightMouseButton(false), mMenuShown(false), mTimerFOV() // <exodus/>
{ {
mGun = new LLToolGun(this); mGun = new LLToolGun(this);
mGrab = new LLToolGrab(this); mGrab = new LLToolGrab(this);
@@ -666,8 +662,12 @@ LLToolCompGun::LLToolCompGun()
setCurrentTool(mGun); setCurrentTool(mGun);
mDefault = mGun; mDefault = mGun;
}
// <exodus>
mTimerFOV.stop();
mStartFOV = mOriginalFOV = mTargetFOV = LLViewerCamera::getInstance()->getAndSaveDefaultFOV();
// </exodus>
}
LLToolCompGun::~LLToolCompGun() LLToolCompGun::~LLToolCompGun()
{ {
@@ -751,25 +751,9 @@ BOOL LLToolCompGun::handleDoubleClick(S32 x, S32 y, MASK mask)
return LLToolGrab::getInstance()->handleDoubleClick(x, y, 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) 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) BOOL LLToolCompGun::handleMouseUp(S32 x, S32 y, MASK mask)
{ {
@@ -800,27 +784,92 @@ void LLToolCompGun::handleDeselect()
setMouseCapture(FALSE); setMouseCapture(FALSE);
} }
// <exodus>
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) BOOL LLToolCompGun::handleScrollWheel(S32 x, S32 y, S32 clicks)
{ {
//::MOYMOD:: if (mRightMouseButton)
if(gSavedSettings.getBOOL("zmm_isinml") == 1)
{ {
if(clicks > 0) mStartFOV = LLViewerCamera::getInstance()->getDefaultFOV();
{
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();
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; 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();
}
}
// </exodus>

View File

@@ -2,31 +2,25 @@
* @file lltoolcomp.h * @file lltoolcomp.h
* @brief Composite tools * @brief Composite tools
* *
* $LicenseInfo:firstyear=2001&license=viewergpl$ * $LicenseInfo:firstyear=2001&license=viewerlgpl$
*
* Copyright (c) 2001-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code * Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab * Copyright (C) 2010, Linden Research, Inc.
* to you under the terms of the GNU General Public License, version 2.0 *
* ("GPL"), unless you have obtained a separate licensing agreement * This library is free software; you can redistribute it and/or
* ("Other License"), formally executed by you and Linden Lab. Terms of * modify it under the terms of the GNU Lesser General Public
* the GPL can be found in doc/GPL-license.txt in this distribution, or * License as published by the Free Software Foundation;
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 * version 2.1 of the License only.
* *
* There are special exceptions to the terms and conditions of the GPL as * This library is distributed in the hope that it will be useful,
* it is applied to this Source Code. View the full text of the exception * but WITHOUT ANY WARRANTY; without even the implied warranty of
* in the file doc/FLOSS-exception.txt in this software distribution, or * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* online at * Lesser General Public License for more details.
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
* *
* By copying, modifying or distributing this software, you acknowledge * You should have received a copy of the GNU Lesser General Public
* that you have read and understood your obligations described above, * License along with this library; if not, write to the Free Software
* and agree to abide by those obligations. * 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 * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$ * $/LicenseInfo$
*/ */
@@ -219,10 +213,13 @@ public:
LLToolCompGun(); LLToolCompGun();
virtual ~LLToolCompGun(); virtual ~LLToolCompGun();
virtual void draw(); // <exodus/>
// Overridden from LLToolComposite // Overridden from LLToolComposite
virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual BOOL handleHover(S32 x, S32 y, MASK mask);
virtual BOOL handleMouseDown(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 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 handleRightMouseDown(S32 x, S32 y, MASK mask);
virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
@@ -235,6 +232,13 @@ protected:
LLToolGun* mGun; LLToolGun* mGun;
LLToolGrab* mGrab; LLToolGrab* mGrab;
LLTool* mNull; LLTool* mNull;
// <exodus>
private:
bool mRightMouseButton, mMenuShown;
LLTimer mTimerFOV;
F32 mOriginalFOV, mStartFOV, mTargetFOV;
// </exodus>
}; };

View File

@@ -2,31 +2,25 @@
* @file llviewercamera.cpp * @file llviewercamera.cpp
* @brief LLViewerCamera class implementation * @brief LLViewerCamera class implementation
* *
* $LicenseInfo:firstyear=2002&license=viewergpl$ * $LicenseInfo:firstyear=2002&license=viewerlgpl$
*
* Copyright (c) 2002-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code * Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab * Copyright (C) 2010, Linden Research, Inc.
* 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
* *
* There are special exceptions to the terms and conditions of the GPL as * This library is free software; you can redistribute it and/or
* it is applied to this Source Code. View the full text of the exception * modify it under the terms of the GNU Lesser General Public
* in the file doc/FLOSS-exception.txt in this software distribution, or * License as published by the Free Software Foundation;
* online at * version 2.1 of the License only.
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
* *
* By copying, modifying or distributing this software, you acknowledge * This library is distributed in the hope that it will be useful,
* that you have read and understood your obligations described above, * but WITHOUT ANY WARRANTY; without even the implied warranty of
* and agree to abide by those obligations. * 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 * You should have received a copy of the GNU Lesser General Public
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, * License along with this library; if not, write to the Free Software
* COMPLETENESS OR PERFORMANCE. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$ * $/LicenseInfo$
*/ */
@@ -113,6 +107,7 @@ LLViewerCamera::LLViewerCamera() : LLCamera()
{ {
calcProjection(getFar()); calcProjection(getFar());
mCameraFOVDefault = DEFAULT_FIELD_OF_VIEW; mCameraFOVDefault = DEFAULT_FIELD_OF_VIEW;
mSavedFOVDefault = DEFAULT_FIELD_OF_VIEW; // <exodus/>
mCosHalfCameraFOV = cosf(mCameraFOVDefault * 0.5f); mCosHalfCameraFOV = cosf(mCameraFOVDefault * 0.5f);
mPixelMeterRatio = 0.f; mPixelMeterRatio = 0.f;
mScreenPixelArea = 0; mScreenPixelArea = 0;
@@ -927,6 +922,15 @@ void LLViewerCamera::setDefaultFOV(F32 vertical_fov_rads)
mCosHalfCameraFOV = cosf(mCameraFOVDefault * 0.5f); mCosHalfCameraFOV = cosf(mCameraFOVDefault * 0.5f);
} }
// <exodus>
void LLViewerCamera::loadDefaultFOV()
{
setView(mSavedFOVDefault);
mSavedFOVLoaded = true;
mCameraFOVDefault = mSavedFOVDefault;
mCosHalfCameraFOV = cosf(mCameraFOVDefault * 0.5f);
}
// </exodus>
// static // static
void LLViewerCamera::updateCameraAngle( void* user_data, const LLSD& value) void LLViewerCamera::updateCameraAngle( void* user_data, const LLSD& value)

View File

@@ -2,31 +2,25 @@
* @file llviewercamera.h * @file llviewercamera.h
* @brief LLViewerCamera class header file * @brief LLViewerCamera class header file
* *
* $LicenseInfo:firstyear=2002&license=viewergpl$ * $LicenseInfo:firstyear=2002&license=viewerlgpl$
*
* Copyright (c) 2002-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code * Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab * Copyright (C) 2010, Linden Research, Inc.
* 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
* *
* There are special exceptions to the terms and conditions of the GPL as * This library is free software; you can redistribute it and/or
* it is applied to this Source Code. View the full text of the exception * modify it under the terms of the GNU Lesser General Public
* in the file doc/FLOSS-exception.txt in this software distribution, or * License as published by the Free Software Foundation;
* online at * version 2.1 of the License only.
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
* *
* By copying, modifying or distributing this software, you acknowledge * This library is distributed in the hope that it will be useful,
* that you have read and understood your obligations described above, * but WITHOUT ANY WARRANTY; without even the implied warranty of
* and agree to abide by those obligations. * 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 * You should have received a copy of the GNU Lesser General Public
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, * License along with this library; if not, write to the Free Software
* COMPLETENESS OR PERFORMANCE. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$ * $/LicenseInfo$
*/ */
@@ -118,6 +112,11 @@ public:
void setDefaultFOV(F32 fov) ; void setDefaultFOV(F32 fov) ;
F32 getDefaultFOV() { return mCameraFOVDefault; } F32 getDefaultFOV() { return mCameraFOVDefault; }
bool mSavedFOVLoaded; // <exodus/>
F32 getAndSaveDefaultFOV() { mSavedFOVLoaded = false; return mSavedFOVDefault = mCameraFOVDefault; } // <exodus/>
void setAndSaveDefaultFOV(F32 fov) { setDefaultFOV(mSavedFOVDefault = fov); } // <exodus/>
void loadDefaultFOV(); // <exodus/>
BOOL cameraUnderWater() const; BOOL cameraUnderWater() const;
const LLVector3 &getPointOfInterest() { return mLastPointOfInterest; } const LLVector3 &getPointOfInterest() { return mLastPointOfInterest; }
@@ -141,6 +140,7 @@ protected:
mutable LLMatrix4 mProjectionMatrix; // Cache of perspective matrix mutable LLMatrix4 mProjectionMatrix; // Cache of perspective matrix
mutable LLMatrix4 mModelviewMatrix; mutable LLMatrix4 mModelviewMatrix;
F32 mCameraFOVDefault; F32 mCameraFOVDefault;
F32 mSavedFOVDefault; // <exodus/>
F32 mCosHalfCameraFOV; F32 mCosHalfCameraFOV;
LLVector3 mLastPointOfInterest; LLVector3 mLastPointOfInterest;
F32 mPixelMeterRatio; // Divide by distance from camera to get pixels per meter at that distance. F32 mPixelMeterRatio; // Divide by distance from camera to get pixels per meter at that distance.

View File

@@ -1015,18 +1015,6 @@ BOOL LLViewerWindow::handleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask)
BOOL LLViewerWindow::handleRightMouseDown(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 x = pos.mX;
S32 y = pos.mY; S32 y = pos.mY;
x = llround((F32)x / mDisplayScale.mV[VX]); 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) 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; BOOL down = FALSE;
return handleAnyMouseClick(window,pos,mask,LLMouseHandler::CLICK_RIGHT,down); return handleAnyMouseClick(window,pos,mask,LLMouseHandler::CLICK_RIGHT,down);
} }