aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llagent.cpp
diff options
context:
space:
mode:
authorthickbrick2010-09-21 18:23:43 +0200
committerthickbrick2010-09-21 18:23:43 +0200
commit070a8e6c351ac115c3063615a1a7c8a31ef33a48 (patch)
tree9e34845ac1c1028d446f30a61fcc6e0cf0095561 /linden/indra/newview/llagent.cpp
parentChanged version to Experimental 2010.09.18 (diff)
downloadmeta-impy-070a8e6c351ac115c3063615a1a7c8a31ef33a48.zip
meta-impy-070a8e6c351ac115c3063615a1a7c8a31ef33a48.tar.gz
meta-impy-070a8e6c351ac115c3063615a1a7c8a31ef33a48.tar.bz2
meta-impy-070a8e6c351ac115c3063615a1a7c8a31ef33a48.tar.xz
Double-click teleport:
- clean up duplicated (and subtly and needlessly different) code. - keep the camera heading in inter-sim double-click teleport in a hackish way, since SL sims give LookAt info that is kind of random in AgentMovementComplete.
Diffstat (limited to 'linden/indra/newview/llagent.cpp')
-rw-r--r--linden/indra/newview/llagent.cpp81
1 files changed, 39 insertions, 42 deletions
diff --git a/linden/indra/newview/llagent.cpp b/linden/indra/newview/llagent.cpp
index 51b6c53..077da53 100644
--- a/linden/indra/newview/llagent.cpp
+++ b/linden/indra/newview/llagent.cpp
@@ -400,7 +400,8 @@ LLAgent::LLAgent() :
400 mAgentWearablesUpdateSerialNum(0), 400 mAgentWearablesUpdateSerialNum(0),
401 mWearablesLoaded(FALSE), 401 mWearablesLoaded(FALSE),
402 mTextureCacheQueryID(0), 402 mTextureCacheQueryID(0),
403 mAppearanceSerialNum(0) 403 mAppearanceSerialNum(0),
404 mbTeleportKeepsLookAt(false)
404{ 405{
405 U32 i; 406 U32 i;
406 for (i = 0; i < TOTAL_CONTROLS; i++) 407 for (i = 0; i < TOTAL_CONTROLS; i++)
@@ -6099,16 +6100,21 @@ bool LLAgent::teleportCore(bool is_local)
6099 6100
6100void LLAgent::teleportRequest( 6101void LLAgent::teleportRequest(
6101 const U64& region_handle, 6102 const U64& region_handle,
6102 const LLVector3& pos_local) 6103 const LLVector3& pos_local,
6104 bool keep_look_at)
6103{ 6105{
6104 LLViewerRegion* regionp = getRegion(); 6106 LLViewerRegion* regionp = getRegion();
6105 6107 if (!regionp)
6108 {
6109 return;
6110 }
6106 // Set last region data for teleport history 6111 // Set last region data for teleport history
6107 gAgent.setLastRegionData(regionp->getName(),gAgent.getPositionAgent()); 6112 gAgent.setLastRegionData(regionp->getName(),gAgent.getPositionAgent());
6108 6113
6109 if(regionp && teleportCore()) 6114 bool is_local = (region_handle == to_region_handle(getPositionGlobal()));
6115 if(teleportCore(is_local))
6110 { 6116 {
6111 llinfos << "TeleportRequest: '" << region_handle << "':" << pos_local 6117 llinfos << "TeleportLocationRequest: '" << region_handle << "':" << pos_local
6112 << llendl; 6118 << llendl;
6113 LLMessageSystem* msg = gMessageSystem; 6119 LLMessageSystem* msg = gMessageSystem;
6114 msg->newMessage("TeleportLocationRequest"); 6120 msg->newMessage("TeleportLocationRequest");
@@ -6119,6 +6125,10 @@ void LLAgent::teleportRequest(
6119 msg->addU64("RegionHandle", region_handle); 6125 msg->addU64("RegionHandle", region_handle);
6120 msg->addVector3("Position", pos_local); 6126 msg->addVector3("Position", pos_local);
6121 LLVector3 look_at(0,1,0); 6127 LLVector3 look_at(0,1,0);
6128 if (keep_look_at)
6129 {
6130 look_at = LLViewerCamera::getInstance()->getAtAxis();
6131 }
6122 msg->addVector3("LookAt", look_at); 6132 msg->addVector3("LookAt", look_at);
6123 sendReliableMessage(); 6133 sendReliableMessage();
6124 } 6134 }
@@ -6219,46 +6229,29 @@ void LLAgent::teleportViaLocation(const LLVector3d& pos_global)
6219 } 6229 }
6220// [/RLVa:KB] 6230// [/RLVa:KB]
6221 6231
6222 LLViewerRegion* regionp = getRegion(); 6232 U64 region_handle = to_region_handle(pos_global);
6223 LLSimInfo* info = LLWorldMap::getInstance()->simInfoFromPosGlobal(pos_global); 6233 LLVector3 pos_local = (LLVector3)(pos_global - from_region_handle(region_handle));
6224 if(regionp && info) 6234 teleportRequest(region_handle, pos_local, false);
6225 { 6235}
6226 U32 x_pos;
6227 U32 y_pos;
6228 from_region_handle(info->mHandle, &x_pos, &y_pos);
6229 LLVector3 pos_local(
6230 (F32)(pos_global.mdV[VX] - x_pos),
6231 (F32)(pos_global.mdV[VY] - y_pos),
6232 (F32)(pos_global.mdV[VZ]));
6233 teleportRequest(info->mHandle, pos_local);
6234 }
6235 else if(regionp &&
6236 teleportCore(regionp->getHandle() == to_region_handle_global((F32)pos_global.mdV[VX], (F32)pos_global.mdV[VY])))
6237 {
6238 llwarns << "Using deprecated teleportlocationrequest." << llendl;
6239 // send the message
6240 LLMessageSystem* msg = gMessageSystem;
6241 msg->newMessageFast(_PREHASH_TeleportLocationRequest);
6242 msg->nextBlockFast(_PREHASH_AgentData);
6243 msg->addUUIDFast(_PREHASH_AgentID, getID());
6244 msg->addUUIDFast(_PREHASH_SessionID, getSessionID());
6245 6236
6246 msg->nextBlockFast(_PREHASH_Info); 6237// Teleport to global position, but keep facing in the same direction
6247 F32 width = regionp->getWidth(); 6238void LLAgent::teleportViaLocationLookAt(const LLVector3d& pos_global)
6248 LLVector3 pos(fmod((F32)pos_global.mdV[VX], width), 6239{
6249 fmod((F32)pos_global.mdV[VY], width), 6240 // RLVa stuff copied from LLAgent::teleportViaLocation
6250 (F32)pos_global.mdV[VZ]); 6241 if ( (rlv_handler_t::isEnabled()) &&
6251 F32 region_x = (F32)(pos_global.mdV[VX]); 6242 ( (gRlvHandler.hasBehaviourExcept(RLV_BHVR_TPLOC, gRlvHandler.getCurrentObject())) ||
6252 F32 region_y = (F32)(pos_global.mdV[VY]); 6243 ( (mAvatarObject.notNull()) && (mAvatarObject->mIsSitting) &&
6253 U64 region_handle = to_region_handle_global(region_x, region_y); 6244 (gRlvHandler.hasBehaviourExcept(RLV_BHVR_UNSIT, gRlvHandler.getCurrentObject()))) ) )
6254 msg->addU64Fast(_PREHASH_RegionHandle, region_handle); 6245 {
6255 msg->addVector3Fast(_PREHASH_Position, pos); 6246 return;
6256 pos.mV[VX] += 1;
6257 msg->addVector3Fast(_PREHASH_LookAt, pos);
6258 sendReliableMessage();
6259 } 6247 }
6260}
6261 6248
6249 mbTeleportKeepsLookAt = true;
6250 setFocusOnAvatar(FALSE, ANIMATE); // detach camera form avatar, so it keeps direction
6251 U64 region_handle = to_region_handle(pos_global);
6252 LLVector3 pos_local = (LLVector3)(pos_global - from_region_handle(region_handle));
6253 teleportRequest(region_handle, pos_local, mbTeleportKeepsLookAt);
6254}
6262 6255
6263void LLAgent::teleportHome() 6256void LLAgent::teleportHome()
6264{ 6257{
@@ -6286,6 +6279,10 @@ bool LLAgent::teleportHomeCallback( const LLSD& notification, const LLSD& respon
6286void LLAgent::setTeleportState(ETeleportState state) 6279void LLAgent::setTeleportState(ETeleportState state)
6287{ 6280{
6288 mTeleportState = state; 6281 mTeleportState = state;
6282 if (mTeleportState == TELEPORT_NONE)
6283 {
6284 mbTeleportKeepsLookAt = false;
6285 }
6289 if (mTeleportState > TELEPORT_NONE && gSavedSettings.getBOOL("FreezeTime")) 6286 if (mTeleportState > TELEPORT_NONE && gSavedSettings.getBOOL("FreezeTime"))
6290 { 6287 {
6291 LLFloaterSnapshot::hide(0); 6288 LLFloaterSnapshot::hide(0);