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>
</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>
<map>
<key>Comment</key>
@@ -232,28 +221,6 @@
<key>Value</key>
<real>1</real>
</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>
<map>

View File

@@ -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" // <exodus/>
#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() // <exodus/>
{
mGun = new LLToolGun(this);
mGrab = new LLToolGrab(this);
@@ -666,8 +662,12 @@ LLToolCompGun::LLToolCompGun()
setCurrentTool(mGun);
mDefault = mGun;
}
// <exodus>
mTimerFOV.stop();
mStartFOV = mOriginalFOV = mTargetFOV = LLViewerCamera::getInstance()->getAndSaveDefaultFOV();
// </exodus>
}
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);
}
// <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)
{
//::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();
}
}
// </exodus>

View File

@@ -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(); // <exodus/>
// 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;
// <exodus>
private:
bool mRightMouseButton, mMenuShown;
LLTimer mTimerFOV;
F32 mOriginalFOV, mStartFOV, mTargetFOV;
// </exodus>
};

View File

@@ -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; // <exodus/>
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);
}
// <exodus>
void LLViewerCamera::loadDefaultFOV()
{
setView(mSavedFOVDefault);
mSavedFOVLoaded = true;
mCameraFOVDefault = mSavedFOVDefault;
mCosHalfCameraFOV = cosf(mCameraFOVDefault * 0.5f);
}
// </exodus>
// static
void LLViewerCamera::updateCameraAngle( void* user_data, const LLSD& value)

View File

@@ -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; // <exodus/>
F32 getAndSaveDefaultFOV() { mSavedFOVLoaded = false; return mSavedFOVDefault = mCameraFOVDefault; } // <exodus/>
void setAndSaveDefaultFOV(F32 fov) { setDefaultFOV(mSavedFOVDefault = fov); } // <exodus/>
void loadDefaultFOV(); // <exodus/>
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; // <exodus/>
F32 mCosHalfCameraFOV;
LLVector3 mLastPointOfInterest;
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)
{
//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);
}