Newer
Older
/**
* @file llagent.cpp
* @brief LLAgent class implementation
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* 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.
* 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.
* 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
brad kittenbrink
committed
brad kittenbrink
committed
#include "llagentaccess.h"
#include "llagentcamera.h"
brad kittenbrink
committed
#include "llagentlistener.h"
#include "llanimationstates.h"
#include "llchicletbar.h"
William Todd Stinson
committed
#include "lldonotdisturbnotificationstorage.h"
#include "llfirstuse.h"
PavelK ProductEngine
committed
#include "llfloaterimcontainer.h"
#include "llfloaterperms.h"
#include "llfloaterpreference.h"
#include "llfloatersnapshot.h"
#include "llgroupactions.h"
#include "llgroupmgr.h"
#include "llhudmanager.h"
#include "lljoystickbutton.h"
#include "llmorphview.h"
#include "llmoveview.h"
#include "llnavigationbar.h" // to show/hide navigation bar when changing mouse look state
AlexanderP ProductEngine
committed
#include "llfloaterimnearbychat.h"
#include "llnotificationsutil.h"
Andrew Polunin
committed
#include "llpaneltopinfobar.h"
#include "llparcel.h"
#include "llrendersphere.h"
#include "llscriptruntimeperms.h"
Andrew Meadows
committed
#include "llsdutil.h"
brad kittenbrink
committed
#include "llslurl.h"
#include "llsmoothstep.h"
#include "llstartup.h"
brad kittenbrink
committed
#include "llteleportflags.h"
Richard Linden
committed
#include "lltoolbarview.h"
#include "lltoolpie.h"
Leslie Linden
committed
#include "lluictrl.h"
Seth ProductEngine
committed
#include "llurlentry.h"
#include "llviewerdisplay.h"
#include "llviewerobjectlist.h"
#include "llviewerparcelmgr.h"
Todd Stinson
committed
#include "llviewerregion.h"
brad kittenbrink
committed
#include "llviewerwindow.h"
#include "llvoavatarself.h"
#include "llwindow.h"
Nyx (Neal Orman)
committed
#include "stringize.h"
PavelK ProductEngine
committed
#include "boost/foreach.hpp"
#include "llcorehttputil.h"
const BOOL ANIMATE = TRUE;
const U8 AGENT_STATE_TYPING = 0x04;
const U8 AGENT_STATE_EDITING = 0x10;
// Autopilot constants
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
const F32 MAX_VELOCITY_AUTO_LAND_SQUARED = 4.f * 4.f;
const F64 CHAT_AGE_FAST_RATE = 3.0;
// fidget constants
const F32 MIN_FIDGET_TIME = 8.f; // seconds
const F32 MAX_FIDGET_TIME = 20.f; // seconds
Steven Bennetts
committed
// The agent instance.
LLAgent gAgent;
Todd Stinson
committed
class LLTeleportRequest
{
public:
Todd Stinson
committed
enum EStatus
{
kPending,
kStarted,
kFailed,
kRestartPending
};
Todd Stinson
committed
LLTeleportRequest();
virtual ~LLTeleportRequest();
Todd Stinson
committed
EStatus getStatus() const {return mStatus;};
void setStatus(EStatus pStatus) {mStatus = pStatus;};
Todd Stinson
committed
virtual bool canRestartTeleport();
virtual void startTeleport() = 0;
virtual void restartTeleport();
Todd Stinson
committed
protected:
private:
Todd Stinson
committed
EStatus mStatus;
Todd Stinson
committed
};
class LLTeleportRequestViaLandmark : public LLTeleportRequest
{
public:
LLTeleportRequestViaLandmark(const LLUUID &pLandmarkId);
virtual ~LLTeleportRequestViaLandmark();
Todd Stinson
committed
virtual bool canRestartTeleport();
virtual void startTeleport();
virtual void restartTeleport();
Todd Stinson
committed
protected:
inline const LLUUID &getLandmarkId() const {return mLandmarkId;};
private:
LLUUID mLandmarkId;
};
class LLTeleportRequestViaLure : public LLTeleportRequestViaLandmark
{
public:
LLTeleportRequestViaLure(const LLUUID &pLureId, BOOL pIsLureGodLike);
virtual ~LLTeleportRequestViaLure();
Todd Stinson
committed
virtual bool canRestartTeleport();
virtual void startTeleport();
Todd Stinson
committed
protected:
inline BOOL isLureGodLike() const {return mIsLureGodLike;};
private:
BOOL mIsLureGodLike;
};
class LLTeleportRequestViaLocation : public LLTeleportRequest
{
public:
LLTeleportRequestViaLocation(const LLVector3d &pPosGlobal);
virtual ~LLTeleportRequestViaLocation();
Todd Stinson
committed
virtual bool canRestartTeleport();
virtual void startTeleport();
virtual void restartTeleport();
Todd Stinson
committed
protected:
inline const LLVector3d &getPosGlobal() const {return mPosGlobal;};
private:
LLVector3d mPosGlobal;
};
class LLTeleportRequestViaLocationLookAt : public LLTeleportRequestViaLocation
{
public:
LLTeleportRequestViaLocationLookAt(const LLVector3d &pPosGlobal);
virtual ~LLTeleportRequestViaLocationLookAt();
Todd Stinson
committed
virtual bool canRestartTeleport();
virtual void startTeleport();
virtual void restartTeleport();
Todd Stinson
committed
protected:
private:
};
//--------------------------------------------------------------------
/// minimum time after setting away state before coming back based on movement
const F32 LLAgent::MIN_AFK_TIME = 10.0f;
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())
{
gAgentAvatarp->setAnimTimeFactor(0.2f);
}
else
{
gAgentAvatarp->setAnimTimeFactor(1.0f);
}
return true;
}
void LLAgent::setCanEditParcel() // called via mParcelChangedSignal
Leslie Linden
committed
{
bool can_edit = LLToolMgr::getInstance()->canEdit();
gAgent.mCanEditParcel = can_edit;
}
// static
bool LLAgent::isActionAllowed(const LLSD& sdname)
{
bool retval = false;
const std::string& param = sdname.asString();
if (param == "speak")
Leslie Linden
committed
{
andreykproductengine
committed
bool allow_agent_voice = false;
LLVoiceChannel* channel = LLVoiceChannel::getCurrentVoiceChannel();
if (channel != NULL)
{
if (channel->getSessionName().empty() && channel->getSessionID().isNull())
{
// default channel
allow_agent_voice = LLViewerParcelMgr::getInstance()->allowAgentVoice();
}
else
{
allow_agent_voice = channel->isActive() && channel->callStarted();
}
}
if (gAgent.isVoiceConnected() &&
allow_agent_voice &&
!LLVoiceClient::getInstance()->inTuningMode())
{
retval = true;
}
else
{
retval = false;
}
Leslie Linden
committed
}
return retval;
}
void LLAgent::pressMicrophone(const LLSD& name)
LLFirstUse::speak(false);
LLVoiceClient::getInstance()->inputUserControlState(true);
}
// static
void LLAgent::releaseMicrophone(const LLSD& name)
{
LLVoiceClient::getInstance()->inputUserControlState(false);
// static
void LLAgent::toggleMicrophone(const LLSD& name)
{
LLVoiceClient::getInstance()->toggleUserPTTState();
}
// static
bool LLAgent::isMicrophoneOn(const LLSD& sdname)
{
return LLVoiceClient::getInstance()->getUserPTTState();
Leslie Linden
committed
// ************************************************************
// 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()
//-----------------------------------------------------------------------------
brad kittenbrink
committed
mListener(),
mDoubleTapRunTimer(),
mDoubleTapRunMode(DOUBLETAP_NONE),
mbAlwaysRun(false),
mbRunning(false),
brad kittenbrink
committed
mAgentAccess(new LLAgentAccess(gSavedSettings)),
mGodLevelChangeSignal(),
Leslie Linden
committed
mCanEditParcel(false),
brad kittenbrink
committed
mTeleportSourceSLURL(new LLSLURL),
Todd Stinson
committed
mTeleportRequest(),
Todd Stinson
committed
mTeleportFinishedSlot(),
mTeleportFailedSlot(),
mIsMaturityRatingChangingDuringTeleport(false),
mMaturityRatingChange(0U),
Todd Stinson
committed
mIsDoSendMaturityPreferenceToServer(false),
Todd Stinson
committed
mMaturityPreferenceRequestId(0U),
mMaturityPreferenceResponseId(0U),
mMaturityPreferenceNumRetries(0U),
mLastKnownRequestMaturity(SIM_ACCESS_MIN),
mLastKnownResponseMaturity(SIM_ACCESS_MIN),
mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID),
mTeleportState(TELEPORT_NONE),
mRegionp(NULL),
mAgentOriginGlobal(),
mPositionGlobal(),
mLastPositionGlobal(LLVector3d::zero),
mRenderState(0),
mTypingTimer(),
mViewsPushed(FALSE),
William Todd Stinson
committed
mIsDoNotDisturb(false),
mControlFlags(0x00000000),
mbFlagsDirty(FALSE),
mbFlagsNeedReset(FALSE),
mAutoPilot(FALSE),
mAutoPilotFlyOnStop(FALSE),
Dave SIMmONs
committed
mAutoPilotAllowFlying(TRUE),
mAutoPilotTargetGlobal(),
mAutoPilotStopDistance(1.f),
mAutoPilotUseRotation(FALSE),
mAutoPilotTargetFacing(LLVector3::zero),
mAutoPilotTargetDist(0.f),
mAutoPilotNoProgressFrameCount(0),
mAutoPilotRotationThreshold(0.f),
mAutoPilotFinishedCallback(NULL),
mAutoPilotCallbackData(NULL),
Mnikolenko ProductEngine
committed
mMovementKeysLocked(FALSE),
brad kittenbrink
committed
mEffectColor(new LLUIColor(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),
callum_linden
committed
mVoiceConnected(false),
Paul Guslisty
committed
mMouselookModeInSignal(NULL),
mMouselookModeOutSignal(NULL)
for (U32 i = 0; i < TOTAL_CONTROLS; i++)
{
mControlsTakenCount[i] = 0;
mControlsTakenPassedOnCount[i] = 0;
}
brad kittenbrink
committed
mListener.reset(new LLAgentListener(*this));
addParcelChangedCallback(&setCanEditParcel);
}
// Requires gSavedSettings to be initialized.
//-----------------------------------------------------------------------------
// init()
//-----------------------------------------------------------------------------
void LLAgent::init()
{
gSavedSettings.declareBOOL("SlowMotionAnimation", FALSE, "Declared in code", LLControlVariable::PERSIST_NO);
gSavedSettings.getControl("SlowMotionAnimation")->getSignal()->connect(boost::bind(&handleSlowMotionAnimation, _2));
// *Note: this is where LLViewerCamera::getInstance() used to be constructed.
setFlying( gSavedSettings.getBOOL("FlyingAtExit") );
brad kittenbrink
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));
Todd Stinson
committed
mLastKnownResponseMaturity = static_cast<U8>(gSavedSettings.getU32("PreferredMaturity"));
mLastKnownRequestMaturity = mLastKnownResponseMaturity;
Todd Stinson
committed
mIsDoSendMaturityPreferenceToServer = true;
Todd Stinson
committed
if (!mTeleportFinishedSlot.connected())
{
mTeleportFinishedSlot = LLViewerParcelMgr::getInstance()->setTeleportFinishedCallback(boost::bind(&LLAgent::handleTeleportFinished, this));
}
if (!mTeleportFailedSlot.connected())
{
mTeleportFailedSlot = LLViewerParcelMgr::getInstance()->setTeleportFailedCallback(boost::bind(&LLAgent::handleTeleportFailed, this));
}
LLAppCoreHttp & app_core_http(LLAppViewer::instance()->getAppCoreHttp());
Rider Linden
committed
mHttpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_AGENT);
mInitialized = TRUE;
}
//-----------------------------------------------------------------------------
// cleanup()
//-----------------------------------------------------------------------------
void LLAgent::cleanup()
{
mRegionp = NULL;
Todd Stinson
committed
if (mTeleportFinishedSlot.connected())
{
mTeleportFinishedSlot.disconnect();
}
if (mTeleportFailedSlot.connected())
{
mTeleportFailedSlot.disconnect();
}
}
//-----------------------------------------------------------------------------
// LLAgent()
//-----------------------------------------------------------------------------
LLAgent::~LLAgent()
{
cleanup();
Paul Guslisty
committed
delete mMouselookModeInSignal;
brad kittenbrink
committed
mMouselookModeInSignal = NULL;
Paul Guslisty
committed
delete mMouselookModeOutSignal;
brad kittenbrink
committed
mMouselookModeOutSignal = NULL;
Paul Guslisty
committed
brad kittenbrink
committed
delete mAgentAccess;
mAgentAccess = NULL;
delete mEffectColor;
mEffectColor = NULL;
delete mTeleportSourceSLURL;
mTeleportSourceSLURL = NULL;
// 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 == gAgentCamera.getCameraMode())
gAgentCamera.changeCameraToDefault();
LLToolMgr::getInstance()->clearSavedTool();
F64 elapsed_time = (F64)gAgentAvatarp->mChatTimer.getElapsedTimeF32();
gAgentAvatarp->mChatTimer.setAge(elapsed_time + (F64)gFrameDTClamped * (CHAT_AGE_FAST_RATE - 1.0));
}
}
//-----------------------------------------------------------------------------
// moveAt()
//-----------------------------------------------------------------------------
mMoveTimer.reset();
LLFirstUse::notMoving(false);
// age chat timer so it fades more quickly when you are intentionally moving
ageChat();
Loren Shih
committed
gAgentCamera.setAtKey(LLAgentCamera::directionToKey(direction));
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);
}
gAgentCamera.resetView();
}
//-----------------------------------------------------------------------------
// moveAtNudge()
//-----------------------------------------------------------------------------
void LLAgent::moveAtNudge(S32 direction)
{
mMoveTimer.reset();
LLFirstUse::notMoving(false);
// age chat timer so it fades more quickly when you are intentionally moving
ageChat();
Loren Shih
committed
gAgentCamera.setWalkKey(LLAgentCamera::directionToKey(direction));
if (direction > 0)
{
setControlFlags(AGENT_CONTROL_NUDGE_AT_POS);
}
else if (direction < 0)
{
setControlFlags(AGENT_CONTROL_NUDGE_AT_NEG);
}
gAgentCamera.resetView();
}
//-----------------------------------------------------------------------------
// moveLeft()
//-----------------------------------------------------------------------------
void LLAgent::moveLeft(S32 direction)
{
mMoveTimer.reset();
LLFirstUse::notMoving(false);
// age chat timer so it fades more quickly when you are intentionally moving
ageChat();
Loren Shih
committed
gAgentCamera.setLeftKey(LLAgentCamera::directionToKey(direction));
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);
}
gAgentCamera.resetView();
}
//-----------------------------------------------------------------------------
// moveLeftNudge()
//-----------------------------------------------------------------------------
void LLAgent::moveLeftNudge(S32 direction)
{
mMoveTimer.reset();
LLFirstUse::notMoving(false);
// age chat timer so it fades more quickly when you are intentionally moving
ageChat();
Loren Shih
committed
gAgentCamera.setLeftKey(LLAgentCamera::directionToKey(direction));
if (direction > 0)
{
setControlFlags(AGENT_CONTROL_NUDGE_LEFT_POS);
}
else if (direction < 0)
{
setControlFlags(AGENT_CONTROL_NUDGE_LEFT_NEG);
}
gAgentCamera.resetView();
}
//-----------------------------------------------------------------------------
// moveUp()
//-----------------------------------------------------------------------------
void LLAgent::moveUp(S32 direction)
{
mMoveTimer.reset();
LLFirstUse::notMoving(false);
// age chat timer so it fades more quickly when you are intentionally moving
ageChat();
Loren Shih
committed
gAgentCamera.setUpKey(LLAgentCamera::directionToKey(direction));
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);
}
gAgentCamera.resetView();
}
//-----------------------------------------------------------------------------
// moveYaw()
//-----------------------------------------------------------------------------
Loren Shih
committed
gAgentCamera.setYawKey(mag);
if (mag > 0)
{
setControlFlags(AGENT_CONTROL_YAW_POS);
}
else if (mag < 0)
{
setControlFlags(AGENT_CONTROL_YAW_NEG);
}
gAgentCamera.resetView();
}
//-----------------------------------------------------------------------------
// movePitch()
//-----------------------------------------------------------------------------
void LLAgent::movePitch(F32 mag)
Loren Shih
committed
gAgentCamera.setPitchKey(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();
}
BOOL LLAgent::getFlying() const
{
return mControlFlags & AGENT_CONTROL_FLY;
}
//-----------------------------------------------------------------------------
// setFlying()
//-----------------------------------------------------------------------------
void LLAgent::setFlying(BOOL fly)
{
Sergei Litovchuk
committed
// *HACK: Don't allow to start the flying mode if we got ANIM_AGENT_STANDUP signal
// because in this case we won't get a signal to start avatar flying animation and
// it will be walking with flying mode "ON" indication. However we allow to switch
// the flying mode off if we get ANIM_AGENT_STANDUP signal. See process_avatar_animation().
if(fly && gAgentAvatarp->mSignaledAnimations.find(ANIM_AGENT_STANDUP) != gAgentAvatarp->mSignaledAnimations.end())
{
return;
}
// don't allow taking off while sitting
if (fly && gAgentAvatarp->isSitting())
{
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;
Richard Linden
committed
add(LLStatViewer::FLY, 1);
}
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()
//-----------------------------------------------------------------------------
if ( gAgent.mAutoPilot )
{
LLToolPie::instance().stopClickToWalk();
}
BOOL fly = !gAgent.getFlying();
gAgent.mMoveTimer.reset();
LLFirstUse::notMoving(false);
gAgent.setFlying( fly );
gAgentCamera.resetView();
}
// static
bool LLAgent::enableFlying()
{
BOOL sitting = FALSE;
sitting = gAgentAvatarp->isSitting();
}
return !sitting;
void LLAgent::standUp()
{
setControlFlags(AGENT_CONTROL_STAND_UP);
}
void LLAgent::changeParcels()
{
LL_DEBUGS("AgentLocation") << "Calling ParcelChanged callbacks" << LL_ENDL;
// Notify anything that wants to know about parcel changes
mParcelChangedSignal();
}
boost::signals2::connection LLAgent::addParcelChangedCallback(parcel_changed_callback_t cb)
{
return mParcelChangedSignal.connect(cb);
}
//-----------------------------------------------------------------------------
// setRegion()
//-----------------------------------------------------------------------------
void LLAgent::setRegion(LLViewerRegion *regionp)
{
llassert(regionp);
if (mRegionp != regionp)
{
std::string ip = regionp->getHost().getString();
LL_INFOS("AgentLocation") << "Moving agent into region: " << regionp->getName()
<< " located at " << ip << LL_ENDL;
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);
// Pass new region along to metrics components that care about this level of detail.
Monty Brandenberg
committed
LLAppViewer::metricsUpdateRegion(regionp->getHandle());
Mnikolenko ProductEngine
committed
// TODO - most of what follows probably should be moved into callbacks
Seth ProductEngine
committed
// Pass the region host to LLUrlEntryParcel to resolve parcel name
// with a server request.
LLUrlEntryParcel::setRegionHost(getRegionHost());
// 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();
Nyx (Neal Orman)
committed
Mnikolenko ProductEngine
committed
LL_DEBUGS("AgentLocation") << "Calling RegionChanged callbacks" << LL_ENDL;
mRegionChangedSignal();
}
//-----------------------------------------------------------------------------
// getRegion()
//-----------------------------------------------------------------------------
LLViewerRegion *LLAgent::getRegion() const
{
return mRegionp;
}
LLHost LLAgent::getRegionHost() const
{
if (mRegionp)
{
return mRegionp->getHost();
}
else
{
return LLHost();
Ima Mechanique
committed
boost::signals2::connection LLAgent::addRegionChangedCallback(const region_changed_signal_t::slot_type& cb)
{
return mRegionChangedSignal.connect(cb);
}
void LLAgent::removeRegionChangedCallback(boost::signals2::connection callback)
{
mRegionChangedSignal.disconnect(callback);
}
//-----------------------------------------------------------------------------
// inPrelude()
//-----------------------------------------------------------------------------
BOOL LLAgent::inPrelude()
{
return mRegionp && mRegionp->isPrelude();
}
std::string LLAgent::getRegionCapability(const std::string &name)
{
if (!mRegionp)
return std::string();
return mRegionp->getCapability(name);
}
//-----------------------------------------------------------------------------
// canManageEstate()
//-----------------------------------------------------------------------------
BOOL LLAgent::canManageEstate() const
{
return mRegionp && mRegionp->canManageEstate();
}
Josh Bell
committed
//-----------------------------------------------------------------------------
// sendMessage()
//-----------------------------------------------------------------------------
void LLAgent::sendMessage()
{
if (gDisconnected)
{
LL_WARNS() << "Trying to send message when disconnected!" << LL_ENDL;