summaryrefslogtreecommitdiff
path: root/indra/newview/llagent.cpp
diff options
context:
space:
mode:
authorAimee Linden <aimee@lindenlab.com>2010-08-28 16:03:53 +0100
committerAimee Linden <aimee@lindenlab.com>2010-08-28 16:03:53 +0100
commitb1c677a6e70db7a0a56b82045ec60288eee20da4 (patch)
tree5812e9e23987096e3ee3b1ee4f3c592737e2ae7f /indra/newview/llagent.cpp
parentbef304c0a34bfcd7997bd7799995229ddcc1de31 (diff)
parent34a063ae5ae1c8b4be0de8a4448cb11a002a4c61 (diff)
Merge
Diffstat (limited to 'indra/newview/llagent.cpp')
-rw-r--r--indra/newview/llagent.cpp61
1 files changed, 46 insertions, 15 deletions
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index fe7e883d83..b202cb5098 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -167,6 +167,7 @@ LLAgent::LLAgent() :
mbAlwaysRun(false),
mbRunning(false),
+ mbTeleportKeepsLookAt(false),
mAgentAccess(gSavedSettings),
mTeleportState( TELEPORT_NONE ),
@@ -3249,7 +3250,11 @@ bool LLAgent::teleportCore(bool is_local)
// local logic
LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TELEPORT_COUNT);
- if (!is_local)
+ if (is_local)
+ {
+ gAgent.setTeleportState( LLAgent::TELEPORT_LOCAL );
+ }
+ else
{
gTeleportDisplay = TRUE;
gAgent.setTeleportState( LLAgent::TELEPORT_START );
@@ -3268,13 +3273,15 @@ bool LLAgent::teleportCore(bool is_local)
void LLAgent::teleportRequest(
const U64& region_handle,
- const LLVector3& pos_local)
+ const LLVector3& pos_local,
+ bool look_at_from_camera)
{
LLViewerRegion* regionp = getRegion();
- if(regionp && teleportCore())
+ bool is_local = (region_handle == to_region_handle(getPositionGlobal()));
+ if(regionp && teleportCore(is_local))
{
- llinfos << "TeleportRequest: '" << region_handle << "':" << pos_local
- << llendl;
+ LL_INFOS("") << "TeleportLocationRequest: '" << region_handle << "':"
+ << pos_local << LL_ENDL;
LLMessageSystem* msg = gMessageSystem;
msg->newMessage("TeleportLocationRequest");
msg->nextBlockFast(_PREHASH_AgentData);
@@ -3284,6 +3291,10 @@ void LLAgent::teleportRequest(
msg->addU64("RegionHandle", region_handle);
msg->addVector3("Position", pos_local);
LLVector3 look_at(0,1,0);
+ if (look_at_from_camera)
+ {
+ look_at = LLViewerCamera::getInstance()->getAtAxis();
+ }
msg->addVector3("LookAt", look_at);
sendReliableMessage();
}
@@ -3395,6 +3406,16 @@ void LLAgent::teleportViaLocation(const LLVector3d& pos_global)
}
}
+// Teleport to global position, but keep facing in the same direction
+void LLAgent::teleportViaLocationLookAt(const LLVector3d& pos_global)
+{
+ mbTeleportKeepsLookAt = true;
+ gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE); // detach camera form avatar, so it keeps direction
+ U64 region_handle = to_region_handle(pos_global);
+ LLVector3 pos_local = (LLVector3)(pos_global - from_region_handle(region_handle));
+ teleportRequest(region_handle, pos_local, getTeleportKeepsLookAt());
+}
+
void LLAgent::setTeleportState(ETeleportState state)
{
mTeleportState = state;
@@ -3402,18 +3423,28 @@ void LLAgent::setTeleportState(ETeleportState state)
{
LLFloaterReg::hideInstance("snapshot");
}
- if (mTeleportState == TELEPORT_MOVING)
- {
- // We're outa here. Save "back" slurl.
- LLAgentUI::buildSLURL(mTeleportSourceSLURL);
- }
- else if(mTeleportState == TELEPORT_ARRIVING)
+
+ switch (mTeleportState)
{
- // First two position updates after a teleport tend to be weird
- LLViewerStats::getInstance()->mAgentPositionSnaps.mCountOfNextUpdatesToIgnore = 2;
+ case TELEPORT_NONE:
+ mbTeleportKeepsLookAt = false;
+ break;
+
+ case TELEPORT_MOVING:
+ // We're outa here. Save "back" slurl.
+ LLAgentUI::buildSLURL(mTeleportSourceSLURL);
+ break;
- // Let the interested parties know we've teleported.
- LLViewerParcelMgr::getInstance()->onTeleportFinished(false, getPositionGlobal());
+ case TELEPORT_ARRIVING:
+ // First two position updates after a teleport tend to be weird
+ LLViewerStats::getInstance()->mAgentPositionSnaps.mCountOfNextUpdatesToIgnore = 2;
+
+ // Let the interested parties know we've teleported.
+ LLViewerParcelMgr::getInstance()->onTeleportFinished(false, getPositionGlobal());
+ break;
+
+ default:
+ break;
}
}