summaryrefslogtreecommitdiff
path: root/indra/newview/llagent.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llagent.cpp')
-rw-r--r--indra/newview/llagent.cpp102
1 files changed, 66 insertions, 36 deletions
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index e85d108bb2..b202cb5098 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -2,31 +2,25 @@
* @file llagent.cpp
* @brief LLAgent class implementation
*
- * $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.
*
- * 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$
*/
@@ -173,6 +167,7 @@ LLAgent::LLAgent() :
mbAlwaysRun(false),
mbRunning(false),
+ mbTeleportKeepsLookAt(false),
mAgentAccess(gSavedSettings),
mTeleportState( TELEPORT_NONE ),
@@ -833,6 +828,11 @@ LLVector3d LLAgent::getPosGlobalFromAgent(const LLVector3 &pos_agent) const
return pos_agent_d + mAgentOriginGlobal;
}
+void LLAgent::sitDown()
+{
+ setControlFlags(AGENT_CONTROL_SIT_ON_GROUND);
+}
+
//-----------------------------------------------------------------------------
// resetAxes()
@@ -3250,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 );
@@ -3269,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);
@@ -3285,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();
}
@@ -3396,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;
@@ -3403,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;
- // Let the interested parties know we've teleported.
- LLViewerParcelMgr::getInstance()->onTeleportFinished(false, getPositionGlobal());
+ case TELEPORT_MOVING:
+ // We're outa here. Save "back" slurl.
+ LLAgentUI::buildSLURL(mTeleportSourceSLURL);
+ break;
+
+ 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;
}
}