Fix Issue 870: Crouch toggle not reset when pressing "Fly" button, causes avatar to run/fly downhill.

Reimplements crouch toggle such that crouch is now tracked by the agent object
Fixes crouch being reset when restoring focus to the viewer window, as well.
This commit is contained in:
Inusaito Sayori
2014-01-24 22:57:19 -05:00
parent 2450b435a7
commit 236fa2a284
5 changed files with 21 additions and 10 deletions

View File

@@ -420,6 +420,7 @@ LLAgent::LLAgent() :
mNextFidgetTime(0.f),
mCurrentFidget(0),
mCrouch(false),
mFirstLogin(FALSE),
mGenderChosen(FALSE),
mAppearanceSerialNum(0),
@@ -639,13 +640,14 @@ void LLAgent::moveUp(S32 direction)
if (direction > 0)
{
setControlFlags(AGENT_CONTROL_UP_POS | AGENT_CONTROL_FAST_UP);
mCrouch = false;
}
else if (direction < 0)
{
setControlFlags(AGENT_CONTROL_UP_NEG | AGENT_CONTROL_FAST_UP);
}
if (!isCrouch) camera_reset_on_motion();
if (!mCrouch) camera_reset_on_motion();
}
//-----------------------------------------------------------------------------
@@ -687,6 +689,11 @@ void LLAgent::movePitch(F32 mag)
}
}
bool LLAgent::isCrouching() const
{
return mCrouch && !getFlying(); // Never crouch when flying
}
// Does this parcel allow you to fly?
BOOL LLAgent::canFly()
@@ -770,6 +777,7 @@ void LLAgent::setFlying(BOOL fly)
{
LLViewerStats::getInstance()->incStat(LLViewerStats::ST_FLY_COUNT);
}
mCrouch = false;
setControlFlags(AGENT_CONTROL_FLY);
}
else

View File

@@ -302,6 +302,15 @@ private:
F32 mNextFidgetTime;
S32 mCurrentFidget;
//--------------------------------------------------------------------
// Crouch
//--------------------------------------------------------------------
public:
bool isCrouching() const;
void toggleCrouch() { mCrouch = !mCrouch; }
private:
bool mCrouch;
//--------------------------------------------------------------------
// Fly
//--------------------------------------------------------------------

View File

@@ -1220,7 +1220,7 @@ bool LLAppViewer::mainLoop()
{
joystick->scanJoystick();
gKeyboard->scanKeyboard();
if(isCrouch)
if (gAgent.isCrouching())
{
gAgent.moveUp(-1);
}

View File

@@ -61,14 +61,11 @@ const F32 YAW_NUDGE_RATE = 0.05f; // fraction of normal speed
LLViewerKeyboard gViewerKeyboard;
bool isCrouch = false; //Shouldn't start crouched.
void agent_jump( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
F32 time = gKeyboard->getCurKeyElapsedTime();
S32 frame_count = llround(gKeyboard->getCurKeyElapsedFrameCount());
isCrouch = false;
if( time < FLY_TIME
|| frame_count <= FLY_FRAMES
|| gAgent.upGrabbed()
@@ -86,18 +83,17 @@ void agent_toggle_down( EKeystate s )
{
if(KEYSTATE_UP == s) return;
gAgent.moveUp(-1);
if(KEYSTATE_DOWN == s && !gAgent.getFlying() && gSavedSettings.getBOOL("SGShiftCrouchToggle"))
{
isCrouch = !isCrouch;
gAgent.toggleCrouch();
}
gAgent.moveUp(-1);
}
void agent_push_down( EKeystate s )
{
if( KEYSTATE_UP == s ) return;
gAgent.moveUp(-1);
isCrouch = false;
}
static void agent_handle_doubletap_run(EKeystate s, LLAgent::EDoubleTapRunMode mode)
@@ -247,7 +243,6 @@ void agent_toggle_fly( EKeystate s )
if (KEYSTATE_DOWN == s )
{
gAgent.toggleFlying();
isCrouch = false;
}
}

View File

@@ -93,6 +93,5 @@ protected:
};
extern LLViewerKeyboard gViewerKeyboard;
extern bool isCrouch;
void agent_push_forward(EKeystate s);
#endif // LL_LLVIEWERKEYBOARD_H