Newer
Older
/**
* @file llagent.cpp
* @brief LLAgent class implementation
*
* $LicenseInfo:firstyear=2001&license=viewergpl$
*
* Copyright (c) 2001-2009, Linden Research, Inc.
*
* 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
*
* 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
*
* 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.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llagent.h"
#include "llagentwearables.h"
brad kittenbrink
committed
#include "llagentlistener.h"
#include "llanimationstates.h"
#include "llcallingcard.h"
#include "llconsole.h"
#include "lldrawable.h"
#include "llfirstuse.h"
#include "llfloaterreg.h"
Igor Borovkov
committed
#include "llspeakers.h"
#include "llfloatersnapshot.h"
#include "llfloatertools.h"
#include "llfloaterworldmap.h"
#include "llgroupactions.h"
#include "llfocusmgr.h"
Andrew Meadows
committed
#include "llhomelocationresponder.h"
#include "llimview.h"
#include "llhudmanager.h"
#include "lljoystickbutton.h"
#include "llmenugl.h"
#include "llmorphview.h"
#include "llmoveview.h"
#include "llparcel.h"
#include "llquantize.h"
#include "llrand.h"
#include "llregionhandle.h"
Andrew Meadows
committed
#include "llsdutil.h"
#include "llslurl.h"
#include "llsmoothstep.h"
#include "llsidetray.h"
#include "llteleportflags.h"
#include "llteleporthistory.h"
#include "lltexturestats.h"
#include "lltexturestats.h"
#include "lluictrlfactory.h"
#include "llurldispatcher.h"
#include "llviewerdisplay.h"
#include "llviewerobjectlist.h"
#include "llviewerparcelmgr.h"
#include "llviewerstats.h"
#include "llviewerwindow.h"
#include "llviewercontrol.h"
#include "llviewerjoystick.h"
#include "llvoavatarself.h"
#include "llwindow.h"
#include "lltrans.h"
#include "llbottomtray.h"
#include "stringize.h"
#include "llcapabilitylistener.h"
#include "llnavigationbar.h" //to show/hide navigation bar when changing mouse look state
using namespace LLVOAvatarDefines;
const BOOL ANIMATE = TRUE;
const U8 AGENT_STATE_TYPING = 0x04;
const U8 AGENT_STATE_EDITING = 0x10;
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
//drone wandering constants
const F32 MAX_WANDER_TIME = 20.f; // seconds
const F32 MAX_HEADING_HALF_ERROR = 0.2f; // radians
const F32 WANDER_MAX_SLEW_RATE = 2.f * DEG_TO_RAD; // radians / frame
const F32 WANDER_TARGET_MIN_DISTANCE = 10.f; // meters
// Autopilot constants
const F32 AUTOPILOT_HEADING_HALF_ERROR = 10.f * DEG_TO_RAD; // radians
const F32 AUTOPILOT_MAX_SLEW_RATE = 1.f * DEG_TO_RAD; // radians / frame
const F32 AUTOPILOT_STOP_DISTANCE = 2.f; // meters
const F32 AUTOPILOT_HEIGHT_ADJUST_DISTANCE = 8.f; // meters
const F32 AUTOPILOT_MIN_TARGET_HEIGHT_OFF_GROUND = 1.f; // meters
const F32 AUTOPILOT_MAX_TIME_NO_PROGRESS = 1.5f; // seconds
// face editing constants
const LLVector3d FACE_EDIT_CAMERA_OFFSET(0.4f, -0.05f, 0.07f);
const LLVector3d FACE_EDIT_TARGET_OFFSET(0.f, 0.f, 0.05f);
// Mousewheel camera zoom
const F32 MIN_ZOOM_FRACTION = 0.25f;
const F32 INITIAL_ZOOM_FRACTION = 1.f;
const F32 MAX_ZOOM_FRACTION = 8.f;
const F32 METERS_PER_WHEEL_CLICK = 1.f;
const F32 MAX_TIME_DELTA = 1.f;
const F32 CAMERA_ZOOM_HALF_LIFE = 0.07f; // seconds
const F32 FOV_ZOOM_HALF_LIFE = 0.07f; // seconds
const F32 CAMERA_FOCUS_HALF_LIFE = 0.f;//0.02f;
const F32 CAMERA_LAG_HALF_LIFE = 0.25f;
const F32 MIN_CAMERA_LAG = 0.5f;
const F32 MAX_CAMERA_LAG = 5.f;
const F32 CAMERA_COLLIDE_EPSILON = 0.1f;
const F32 MIN_CAMERA_DISTANCE = 0.1f;
const F32 AVATAR_ZOOM_MIN_X_FACTOR = 0.55f;
const F32 AVATAR_ZOOM_MIN_Y_FACTOR = 0.7f;
const F32 AVATAR_ZOOM_MIN_Z_FACTOR = 1.15f;
const F32 MAX_CAMERA_DISTANCE_FROM_AGENT = 50.f;
const F32 MAX_CAMERA_SMOOTH_DISTANCE = 50.0f;
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
const F32 HEAD_BUFFER_SIZE = 0.3f;
const F32 CUSTOMIZE_AVATAR_CAMERA_ANIM_SLOP = 0.2f;
const F32 LAND_MIN_ZOOM = 0.15f;
const F32 AVATAR_MIN_ZOOM = 0.5f;
const F32 OBJECT_MIN_ZOOM = 0.02f;
const F32 APPEARANCE_MIN_ZOOM = 0.39f;
const F32 APPEARANCE_MAX_ZOOM = 8.f;
// fidget constants
const F32 MIN_FIDGET_TIME = 8.f; // seconds
const F32 MAX_FIDGET_TIME = 20.f; // seconds
const S32 MAX_NUM_CHAT_POSITIONS = 10;
const F32 GROUND_TO_AIR_CAMERA_TRANSITION_TIME = 0.5f;
const F32 GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME = 0.5f;
const F32 MAX_VELOCITY_AUTO_LAND_SQUARED = 4.f * 4.f;
const F32 MAX_FOCUS_OFFSET = 20.f;
const F32 OBJECT_EXTENTS_PADDING = 0.5f;
const F32 MIN_RADIUS_ALPHA_SIZZLE = 0.5f;
const F64 CHAT_AGE_FAST_RATE = 3.0;
Steven Bennetts
committed
// The agent instance.
LLAgent gAgent;
//--------------------------------------------------------------------
// Statics
//
const F32 LLAgent::TYPING_TIMEOUT_SECS = 5.f;
std::map<std::string, std::string> LLAgent::sTeleportErrorMessages;
std::map<std::string, std::string> LLAgent::sTeleportProgressMessages;
Don Kjer
committed
class LLAgentFriendObserver : public LLFriendObserver
{
public:
LLAgentFriendObserver() {}
virtual ~LLAgentFriendObserver() {}
virtual void changed(U32 mask);
};
void LLAgentFriendObserver::changed(U32 mask)
{
// if there's a change we're interested in.
if((mask & (LLFriendObserver::POWERS)) != 0)
{
gAgent.friendsChanged();
}
}
bool handleSlowMotionAnimation(const LLSD& newvalue)
{
if (newvalue.asBoolean())
{
gAgent.getAvatarObject()->setAnimTimeFactor(0.2f);
}
else
{
gAgent.getAvatarObject()->setAnimTimeFactor(1.0f);
}
return true;
}
// ************************************************************
// Enabled this definition to compile a 'hacked' viewer that
// locally believes the end user has godlike powers.
// #define HACKED_GODLIKE_VIEWER
// For a toggled version, see viewer.h for the
// TOGGLE_HACKED_GODLIKE_VIEWER define, instead.
// ************************************************************
// Constructors and Destructors
// JC - Please try to make this order match the order in the header
// file. Otherwise it's hard to find variables that aren't initialized.
//-----------------------------------------------------------------------------
// LLAgent()
//-----------------------------------------------------------------------------
LLAgent::LLAgent() :
mDrawDistance( DEFAULT_FAR_PLANE ),
mHUDTargetZoom(1.f),
mHUDCurZoom(1.f),
brad kittenbrink
committed
mListener(),
mDoubleTapRunTimer(),
mDoubleTapRunMode(DOUBLETAP_NONE),
mbAlwaysRun(false),
mbRunning(false),
Dave Simmons
committed
mAgentAccess(gSavedSettings),
mTeleportState( TELEPORT_NONE ),
mRegionp(NULL),
mAgentOriginGlobal(),
mPositionGlobal(),
mLastPositionGlobal(LLVector3d::zero),
mAvatarObject(NULL),
mRenderState(0),
mTypingTimer(),
mCameraMode( CAMERA_MODE_THIRD_PERSON ),
mLastCameraMode( CAMERA_MODE_THIRD_PERSON ),
mViewsPushed(FALSE),
mCameraPreset(CAMERA_PRESET_REAR_VIEW),
mShowAvatar(TRUE),
mCameraAnimating( FALSE ),
mAnimationCameraStartGlobal(),
mAnimationFocusStartGlobal(),
mAnimationTimer(),
mAnimationDuration(0.33f),
mCameraFOVZoomFactor(0.f),
mCameraCurrentFOVZoomFactor(0.f),
mCameraFocusOffset(),
mCameraFOVDefault(DEFAULT_FIELD_OF_VIEW),
mCurrentCameraDistance(2.f), // meters, set in init()
mTargetCameraDistance(2.f),
mCameraZoomFraction(1.f), // deprecated
mThirdPersonHeadOffset(0.f, 0.f, 1.f),
mSitCameraEnabled(FALSE),
mCameraSmoothingLastPositionGlobal(),
mCameraSmoothingLastPositionAgent(),
mCameraSmoothingStop(FALSE),
mCameraUpVector(LLVector3::z_axis), // default is straight up
mFocusOnAvatar(TRUE),
mFocusGlobal(),
mFocusTargetGlobal(),
mFocusObject(NULL),
mFocusObjectOffset(),
mFocusDotRadius( 0.1f ), // meters
mTrackFocusObject(TRUE),
mAtKey(0), // Either 1, 0, or -1... indicates that movement-key is pressed
mWalkKey(0), // like AtKey, but causes less forward thrust
mLeftKey(0),
mUpKey(0),
mYawKey(0.f),
mOrbitLeftKey(0.f),
mOrbitRightKey(0.f),
mOrbitUpKey(0.f),
mOrbitDownKey(0.f),
mOrbitInKey(0.f),
mOrbitOutKey(0.f),
mPanUpKey(0.f),
mPanDownKey(0.f),
mPanLeftKey(0.f),
mPanRightKey(0.f),
mPanInKey(0.f),
mPanOutKey(0.f),
mControlFlags(0x00000000),
mbFlagsDirty(FALSE),
mbFlagsNeedReset(FALSE),
mbJump(FALSE),
mAutoPilot(FALSE),
mAutoPilotFlyOnStop(FALSE),
mAutoPilotTargetGlobal(),
mAutoPilotStopDistance(1.f),
mAutoPilotUseRotation(FALSE),
mAutoPilotTargetFacing(LLVector3::zero),
mAutoPilotTargetDist(0.f),
mAutoPilotNoProgressFrameCount(0),
mAutoPilotRotationThreshold(0.f),
mAutoPilotFinishedCallback(NULL),
mAutoPilotCallbackData(NULL),
James Cook
committed
mEffectColor(LLColor4(0.f, 1.f, 1.f, 1.f)),
mHaveHomePosition(FALSE),
mHomeRegionHandle( 0 ),
mNearChatRadius(CHAT_NORMAL_RADIUS / 2.f),
mNextFidgetTime(0.f),
mCurrentFidget(0),
mFirstLogin(FALSE),
mGenderChosen(FALSE),
for (U32 i = 0; i < TOTAL_CONTROLS; i++)
{
mControlsTakenCount[i] = 0;
mControlsTakenPassedOnCount[i] = 0;
}
mFollowCam.setMaxCameraDistantFromSubject( MAX_CAMERA_DISTANCE_FROM_AGENT );
brad kittenbrink
committed
mListener.reset(new LLAgentListener(*this));
}
// Requires gSavedSettings to be initialized.
//-----------------------------------------------------------------------------
// init()
//-----------------------------------------------------------------------------
void LLAgent::init()
{
gSavedSettings.declareBOOL("SlowMotionAnimation", FALSE, "Declared in code", FALSE);
gSavedSettings.getControl("SlowMotionAnimation")->getSignal()->connect(boost::bind(&handleSlowMotionAnimation, _2));
mDrawDistance = gSavedSettings.getF32("RenderFarClip");
// *Note: this is where LLViewerCamera::getInstance() used to be constructed.
LLViewerCamera::getInstance()->setView(DEFAULT_FIELD_OF_VIEW);
// Leave at 0.1 meters until we have real near clip management
LLViewerCamera::getInstance()->setNear(0.1f);
LLViewerCamera::getInstance()->setFar(mDrawDistance); // if you want to change camera settings, do so in camera.h
LLViewerCamera::getInstance()->setAspect( gViewerWindow->getWorldViewAspectRatio() ); // default, overridden in LLViewerWindow::reshape
LLViewerCamera::getInstance()->setViewHeightInPixels(768); // default, overridden in LLViewerWindow::reshape
setFlying( gSavedSettings.getBOOL("FlyingAtExit") );
mCameraFocusOffsetTarget = LLVector4(gSavedSettings.getVector3("CameraOffsetBuild"));
mCameraPreset = (ECameraPreset) gSavedSettings.getU32("CameraPreset");
mCameraOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getVector3("CameraOffsetRearView");
mCameraOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getVector3("CameraOffsetFrontView");
mCameraOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getVector3("CameraOffsetGroupView");
mFocusOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getVector3d("FocusOffsetRearView");
mFocusOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getVector3d("FocusOffsetFrontView");
mFocusOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getVector3d("FocusOffsetGroupView");
mCurrentCameraDistance = getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale");
mTargetCameraDistance = mCurrentCameraDistance;
mCameraZoomFraction = 1.f;
mTrackFocusObject = gSavedSettings.getBOOL("TrackFocusObject");
James Cook
committed
mEffectColor = LLUIColorTable::instance().getColor("EffectColor");
gSavedSettings.getControl("PreferredMaturity")->getValidateSignal()->connect(boost::bind(&LLAgent::validateMaturity, this, _2));
gSavedSettings.getControl("PreferredMaturity")->getSignal()->connect(boost::bind(&LLAgent::handleMaturity, this, _2));
mInitialized = TRUE;
}
//-----------------------------------------------------------------------------
// cleanup()
//-----------------------------------------------------------------------------
void LLAgent::cleanup()
{
setSitCamera(LLUUID::null);
if(mLookAt)
{
mLookAt->markDead() ;
mLookAt = NULL;
}
if(mPointAt)
{
mPointAt->markDead() ;
mPointAt = NULL;
}
mRegionp = NULL;
setFocusObject(NULL);
}
//-----------------------------------------------------------------------------
// LLAgent()
//-----------------------------------------------------------------------------
LLAgent::~LLAgent()
{
cleanup();
// *Note: this is where LLViewerCamera::getInstance() used to be deleted.
}
// Change camera back to third person, stop the autopilot,
// deselect stuff, etc.
//-----------------------------------------------------------------------------
// resetView()
//-----------------------------------------------------------------------------
void LLAgent::resetView(BOOL reset_camera, BOOL change_camera)
{
if (mAutoPilot)
{
stopAutoPilot(TRUE);
}
if (!gNoRender)
{
LLSelectMgr::getInstance()->unhighlightAll();
// By popular request, keep land selection while walking around. JC
// LLViewerParcelMgr::getInstance()->deselectLand();
// force deselect when walking and attachment is selected
// this is so people don't wig out when their avatar moves without animating
if (LLSelectMgr::getInstance()->getSelection()->isAttachment())
LLSelectMgr::getInstance()->deselectAll();
gMenuHolder->hideMenus();
if (change_camera && !gSavedSettings.getBOOL("FreezeTime"))
{
changeCameraToDefault();
if (LLViewerJoystick::getInstance()->getOverrideCamera())
{
handle_toggle_flycam();
}
// reset avatar mode from eventual residual motion
if (LLToolMgr::getInstance()->inBuildMode())
{
LLViewerJoystick::getInstance()->moveAvatar(true);
}
//Camera Tool is needed for Free Camera Control Mode
if (!LLFloaterCamera::inFreeCameraMode())
{
LLFloaterReg::hideInstance("build");
// Switch back to basic toolset
LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
}
gViewerWindow->showCursor();
}
if (reset_camera && !gSavedSettings.getBOOL("FreezeTime"))
{
if (!gViewerWindow->getLeftMouseDown() && cameraThirdPerson())
{
// leaving mouse-steer mode
LLVector3 agent_at_axis = getAtAxis();
agent_at_axis -= projected_vec(agent_at_axis, getReferenceUpVector());
Andrew Meadows
committed
agent_at_axis.normalize();
gAgent.resetAxes(lerp(getAtAxis(), agent_at_axis, LLCriticalDamp::getInterpolant(0.3f)));
}
setFocusOnAvatar(TRUE, ANIMATE);
}
Karl Steifvater
committed
mHUDTargetZoom = 1.f;
// Handle any actions that need to be performed when the main app gains focus
// (such as through alt-tab).
//-----------------------------------------------------------------------------
// onAppFocusGained()
//-----------------------------------------------------------------------------
void LLAgent::onAppFocusGained()
{
if (CAMERA_MODE_MOUSELOOK == mCameraMode)
{
changeCameraToDefault();
LLToolMgr::getInstance()->clearSavedTool();
{
// get amount of time since I last chatted
F64 elapsed_time = (F64)mAvatarObject->mChatTimer.getElapsedTimeF32();
// add in frame time * 3 (so it ages 4x)
mAvatarObject->mChatTimer.setAge(elapsed_time + (F64)gFrameDTClamped * (CHAT_AGE_FAST_RATE - 1.0));
}
}
// Allow camera to be moved somewhere other than behind avatar.
//-----------------------------------------------------------------------------
// unlockView()
//-----------------------------------------------------------------------------
void LLAgent::unlockView()
{
if (getFocusOnAvatar())
{
{
setFocusGlobal( LLVector3d::zero, mAvatarObject->mID );
}
setFocusOnAvatar(FALSE, FALSE); // no animation
}
}
//-----------------------------------------------------------------------------
// moveAt()
//-----------------------------------------------------------------------------
{
// age chat timer so it fades more quickly when you are intentionally moving
ageChat();
setKey(direction, mAtKey);
if (direction > 0)
{
setControlFlags(AGENT_CONTROL_AT_POS | AGENT_CONTROL_FAST_AT);
}
else if (direction < 0)
{
setControlFlags(AGENT_CONTROL_AT_NEG | AGENT_CONTROL_FAST_AT);
}
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
}
//-----------------------------------------------------------------------------
// moveAtNudge()
//-----------------------------------------------------------------------------
void LLAgent::moveAtNudge(S32 direction)
{
// age chat timer so it fades more quickly when you are intentionally moving
ageChat();
setKey(direction, mWalkKey);
if (direction > 0)
{
setControlFlags(AGENT_CONTROL_NUDGE_AT_POS);
}
else if (direction < 0)
{
setControlFlags(AGENT_CONTROL_NUDGE_AT_NEG);
}
resetView();
}
//-----------------------------------------------------------------------------
// moveLeft()
//-----------------------------------------------------------------------------
void LLAgent::moveLeft(S32 direction)
{
// age chat timer so it fades more quickly when you are intentionally moving
ageChat();
setKey(direction, mLeftKey);
if (direction > 0)
{
setControlFlags(AGENT_CONTROL_LEFT_POS | AGENT_CONTROL_FAST_LEFT);
}
else if (direction < 0)
{
setControlFlags(AGENT_CONTROL_LEFT_NEG | AGENT_CONTROL_FAST_LEFT);
}
resetView();
}
//-----------------------------------------------------------------------------
// moveLeftNudge()
//-----------------------------------------------------------------------------
void LLAgent::moveLeftNudge(S32 direction)
{
// age chat timer so it fades more quickly when you are intentionally moving
ageChat();
setKey(direction, mLeftKey);
if (direction > 0)
{
setControlFlags(AGENT_CONTROL_NUDGE_LEFT_POS);
}
else if (direction < 0)
{
setControlFlags(AGENT_CONTROL_NUDGE_LEFT_NEG);
}
resetView();
}
//-----------------------------------------------------------------------------
// moveUp()
//-----------------------------------------------------------------------------
void LLAgent::moveUp(S32 direction)
{
// age chat timer so it fades more quickly when you are intentionally moving
ageChat();
setKey(direction, mUpKey);
if (direction > 0)
{
setControlFlags(AGENT_CONTROL_UP_POS | AGENT_CONTROL_FAST_UP);
}
else if (direction < 0)
{
setControlFlags(AGENT_CONTROL_UP_NEG | AGENT_CONTROL_FAST_UP);
}
resetView();
}
//-----------------------------------------------------------------------------
// moveYaw()
//-----------------------------------------------------------------------------
{
mYawKey = mag;
if (mag > 0)
{
setControlFlags(AGENT_CONTROL_YAW_POS);
}
else if (mag < 0)
{
setControlFlags(AGENT_CONTROL_YAW_NEG);
}
}
//-----------------------------------------------------------------------------
// movePitch()
//-----------------------------------------------------------------------------
void LLAgent::movePitch(F32 mag)
setControlFlags(AGENT_CONTROL_PITCH_POS);
{
setControlFlags(AGENT_CONTROL_PITCH_NEG);
}
}
// Does this parcel allow you to fly?
BOOL LLAgent::canFly()
{
if (isGodlike()) return TRUE;
LLViewerRegion* regionp = getRegion();
if (regionp && regionp->getBlockFly()) return FALSE;
LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
if (!parcel) return FALSE;
// Allow owners to fly on their own land.
if (LLViewerParcelMgr::isParcelOwnedByAgent(parcel, GP_LAND_ALLOW_FLY))
{
return TRUE;
}
return parcel->getAllowFly();
}
//-----------------------------------------------------------------------------
// setFlying()
//-----------------------------------------------------------------------------
void LLAgent::setFlying(BOOL fly)
{
if (mAvatarObject.notNull())
{
if(mAvatarObject->mSignaledAnimations.find(ANIM_AGENT_STANDUP) != mAvatarObject->mSignaledAnimations.end())
{
return;
}
// don't allow taking off while sitting
{
return;
}
}
if (fly)
{
BOOL was_flying = getFlying();
if (!canFly() && !was_flying)
// parcel doesn't let you start fly
// gods can always fly
// and it's OK if you're already flying
make_ui_sound("UISndBadKeystroke");
return;
LLViewerStats::getInstance()->incStat(LLViewerStats::ST_FLY_COUNT);
}
setControlFlags(AGENT_CONTROL_FLY);
}
else
{
clearControlFlags(AGENT_CONTROL_FLY);
}
// Update Movement Controls according to Fly mode
LLFloaterMove::setFlyingMode(fly);
mbFlagsDirty = TRUE;
}
// UI based mechanism of setting fly state
//-----------------------------------------------------------------------------
// toggleFlying()
//-----------------------------------------------------------------------------
BOOL fly = !(gAgent.mControlFlags & AGENT_CONTROL_FLY);
gAgent.setFlying( fly );
gAgent.resetView();
}
// static
bool LLAgent::enableFlying()
{
BOOL sitting = FALSE;
if (gAgent.getAvatarObject())
{
}
return !sitting;
void LLAgent::standUp()
{
setControlFlags(AGENT_CONTROL_STAND_UP);
}
//-----------------------------------------------------------------------------
// setRegion()
//-----------------------------------------------------------------------------
void LLAgent::setRegion(LLViewerRegion *regionp)
{
llassert(regionp);
if (mRegionp != regionp)
{
// std::string host_name;
// host_name = regionp->getHost().getHostName();
std::string ip = regionp->getHost().getString();
llinfos << "Moving agent into region: " << regionp->getName()
<< " located at " << ip << llendl;
if (mRegionp)
{
// We've changed regions, we're now going to change our agent coordinate frame.
mAgentOriginGlobal = regionp->getOriginGlobal();
LLVector3d agent_offset_global = mRegionp->getOriginGlobal();
LLVector3 delta;
delta.setVec(regionp->getOriginGlobal() - mRegionp->getOriginGlobal());
setPositionAgent(getPositionAgent() - delta);
LLVector3 camera_position_agent = LLViewerCamera::getInstance()->getOrigin();
LLViewerCamera::getInstance()->setOrigin(camera_position_agent - delta);
LLWorld::getInstance()->updateAgentOffset(agent_offset_global);
// Hack to keep sky in the agent's region, otherwise it may get deleted - DJS 08/02/02
// *TODO: possibly refactor into gSky->setAgentRegion(regionp)? -Brad
if (gSky.mVOSkyp)
{
gSky.mVOSkyp->setRegion(regionp);
}
if (gSky.mVOGroundp)
{
gSky.mVOGroundp->setRegion(regionp);
}
}
else
{
// First time initialization.
// We've changed regions, we're now going to change our agent coordinate frame.
mAgentOriginGlobal = regionp->getOriginGlobal();
LLVector3 delta;
delta.setVec(regionp->getOriginGlobal());
setPositionAgent(getPositionAgent() - delta);
LLVector3 camera_position_agent = LLViewerCamera::getInstance()->getOrigin();
LLViewerCamera::getInstance()->setOrigin(camera_position_agent - delta);
LLWorld::getInstance()->updateAgentOffset(mAgentOriginGlobal);
}
}
mRegionp = regionp;
// Must shift hole-covering water object locations because local
// coordinate frame changed.
LLWorld::getInstance()->updateWaterObjects();
// keep a list of regions we've been too
// this is just an interesting stat, logged at the dataserver
// we could trake this at the dataserver side, but that's harder
U64 handle = regionp->getHandle();
mRegionsVisited.insert(handle);
Josh Bell
committed
LLSelectMgr::getInstance()->updateSelectionCenter();
}
//-----------------------------------------------------------------------------
// getRegion()
//-----------------------------------------------------------------------------
LLViewerRegion *LLAgent::getRegion() const
{
return mRegionp;
}
LLHost LLAgent::getRegionHost() const
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
{
if (mRegionp)
{
return mRegionp->getHost();
}
else
{
return LLHost::invalid;
}
}
//-----------------------------------------------------------------------------
// inPrelude()
//-----------------------------------------------------------------------------
BOOL LLAgent::inPrelude()
{
return mRegionp && mRegionp->isPrelude();
}
//-----------------------------------------------------------------------------
// canManageEstate()
//-----------------------------------------------------------------------------
BOOL LLAgent::canManageEstate() const
{
return mRegionp && mRegionp->canManageEstate();
}
Josh Bell
committed
//-----------------------------------------------------------------------------
// sendMessage()
//-----------------------------------------------------------------------------
void LLAgent::sendMessage()
{
if (gDisconnected)
{
llwarns << "Trying to send message when disconnected!" << llendl;
return;
}
if (!mRegionp)
{
llerrs << "No region for agent yet!" << llendl;
}
gMessageSystem->sendMessage(mRegionp->getHost());
}
//-----------------------------------------------------------------------------
// sendReliableMessage()
//-----------------------------------------------------------------------------
void LLAgent::sendReliableMessage()
{
if (gDisconnected)
{
Steven Bennetts
committed
lldebugs << "Trying to send message when disconnected!" << llendl;
Steven Bennetts
committed
lldebugs << "LLAgent::sendReliableMessage No region for agent yet, not sending message!" << llendl;
return;
}
gMessageSystem->sendReliable(mRegionp->getHost());
}
//-----------------------------------------------------------------------------
// getVelocity()