diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 656cb7002704d3e824a0e9b2170462569f4969bc..26683ae70087e9304c3d39689c554864f20104ab 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -210,7 +210,10 @@ class LLTeleportRequestViaLocation : public LLTeleportRequest class LLTeleportRequestViaLocationLookAt : public LLTeleportRequestViaLocation { public: - LLTeleportRequestViaLocationLookAt(const LLVector3d &pPosGlobal); +// [RLVa:KB] - Checked: RLVa-2.0.0 + LLTeleportRequestViaLocationLookAt(const LLVector3d &pPosGlobal, const LLVector3& look_at); +// [/RLVa:KB] +// LLTeleportRequestViaLocationLookAt(const LLVector3d &pPosGlobal); virtual ~LLTeleportRequestViaLocationLookAt(); virtual bool canRestartTeleport(); @@ -219,8 +222,14 @@ class LLTeleportRequestViaLocationLookAt : public LLTeleportRequestViaLocation virtual void restartTeleport(); protected: +// [RLVa:KB] - Checked: RLVa-2.0.0 + const LLVector3& getLookAt() const { return mLookAt; } +// [/RLVa:KB] private: +// [RLVa:KB] - Checked: RLVa-2.0.0 + LLVector3 mLookAt; +// [/RLVa:KB] }; @@ -4007,10 +4016,13 @@ void LLAgent::handleTeleportFailed() } } -void LLAgent::teleportRequest( - const U64& region_handle, - const LLVector3& pos_local, - bool look_at_from_camera) +//void LLAgent::teleportRequest( +// const U64& region_handle, +// const LLVector3& pos_local, +// bool look_at_from_camera) +// [RLVa:KB] - Checked: RLVa-2.0.0 +void LLAgent::teleportRequest(const U64& region_handle, const LLVector3& pos_local, const LLVector3& look_at) +// [/RLVa:KB] { LLViewerRegion* regionp = getRegion(); bool is_local = (region_handle == regionp->getHandle()); @@ -4026,11 +4038,11 @@ void LLAgent::teleportRequest( msg->nextBlockFast(_PREHASH_Info); 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(); - } +// LLVector3 look_at(0,1,0); +// if (look_at_from_camera) +// { +// look_at = LLViewerCamera::getInstance()->getAtAxis(); +// } msg->addVector3("LookAt", look_at); sendReliableMessage(); } @@ -4211,9 +4223,9 @@ void LLAgent::doTeleportViaLocation(const LLVector3d& pos_global) } // Teleport to global position, but keep facing in the same direction -void LLAgent::teleportViaLocationLookAt(const LLVector3d& pos_global) -{ // [RLVa:KB] - Checked: RLVa-2.0.0 +void LLAgent::teleportViaLocationLookAt(const LLVector3d& pos_global, const LLVector3& look_at) +{ if ( (RlvActions::isRlvEnabled()) && (!RlvUtil::isForceTp()) ) { if ( (RlvActions::isLocalTp(pos_global)) ? !RlvActions::canTeleportToLocal() : !RlvActions::canTeleportToLocation() ) @@ -4227,15 +4239,21 @@ void LLAgent::teleportViaLocationLookAt(const LLVector3d& pos_global) gRlvHandler.setCanCancelTp(false); } } -// [/RLVa:KB] - mTeleportRequest = LLTeleportRequestPtr(new LLTeleportRequestViaLocationLookAt(pos_global)); + mTeleportRequest = LLTeleportRequestPtr(new LLTeleportRequestViaLocationLookAt(pos_global, (look_at.isExactlyZero()) ? LLViewerCamera::getInstance()->getAtAxis() : look_at)); startTeleportRequest(); } +// [/RLVa:KB] +//void LLAgent::teleportViaLocationLookAt(const LLVector3d& pos_global) +//{ +// mTeleportRequest = LLTeleportRequestPtr(new LLTeleportRequestViaLocationLookAt(pos_global)); +// startTeleportRequest(); +//} -void LLAgent::doTeleportViaLocationLookAt(const LLVector3d& pos_global) +// [RLVa:KB] - Checked: RLVa-2.0.0 +void LLAgent::doTeleportViaLocationLookAt(const LLVector3d& pos_global, const LLVector3& look_at) { - mbTeleportKeepsLookAt = true; + mbTeleportKeepsLookAt = look_at.isExactlyZero(); if(!gAgentCamera.isfollowCamLocked()) { @@ -4244,8 +4262,23 @@ void LLAgent::doTeleportViaLocationLookAt(const LLVector3d& pos_global) 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()); + teleportRequest(region_handle, pos_local, look_at); } +// [/RLVa:KB] +//void LLAgent::doTeleportViaLocationLookAt(const LLVector3d& pos_global, const LLVector3& look_at) +//{ +// mbTeleportKeepsLookAt = true; +// +// if(!gAgentCamera.isfollowCamLocked()) +// { +// 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, look_at); +// teleportRequest(region_handle, pos_local, getTeleportKeepsLookAt()); +//} void LLAgent::setTeleportState(ETeleportState state) { @@ -4685,10 +4718,17 @@ void LLTeleportRequestViaLocation::restartTeleport() // LLTeleportRequestViaLocationLookAt //----------------------------------------------------------------------------- -LLTeleportRequestViaLocationLookAt::LLTeleportRequestViaLocationLookAt(const LLVector3d &pPosGlobal) - : LLTeleportRequestViaLocation(pPosGlobal) +// [RLVa:KB] - Checked: RLVa-2.0.0 +LLTeleportRequestViaLocationLookAt::LLTeleportRequestViaLocationLookAt(const LLVector3d &pPosGlobal, const LLVector3& look_at) + : LLTeleportRequestViaLocation(pPosGlobal), mLookAt(look_at) { } +// [/RLVa:KB] + +//LLTeleportRequestViaLocationLookAt::LLTeleportRequestViaLocationLookAt(const LLVector3d &pPosGlobal) +// : LLTeleportRequestViaLocation(pPosGlobal) +//{ +//} LLTeleportRequestViaLocationLookAt::~LLTeleportRequestViaLocationLookAt() { @@ -4701,12 +4741,18 @@ bool LLTeleportRequestViaLocationLookAt::canRestartTeleport() void LLTeleportRequestViaLocationLookAt::startTeleport() { - gAgent.doTeleportViaLocationLookAt(getPosGlobal()); +// [RLVa:KB] - Checked: RLVa-2.0.0 + gAgent.doTeleportViaLocationLookAt(getPosGlobal(), getLookAt()); +// [/RLVa:KB] +// gAgent.doTeleportViaLocationLookAt(getPosGlobal()); } void LLTeleportRequestViaLocationLookAt::restartTeleport() { - gAgent.doTeleportViaLocationLookAt(getPosGlobal()); +// [RLVa:KB] - Checked: RLVa-2.0.0 + gAgent.doTeleportViaLocationLookAt(getPosGlobal(), getLookAt()); +// [/RLVa:KB] +// gAgent.doTeleportViaLocationLookAt(getPosGlobal()); } // EOF diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 8d5453cdd2827dd37a6f35f00d93f68f2dc2b807..c564e3efd562558cb7a43dfc038f8ba18369b4ed 100755 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -628,7 +628,10 @@ class LLAgent : public LLOldEvents::LLObservable void teleportHome() { teleportViaLandmark(LLUUID::null); } // Go home void teleportViaLure(const LLUUID& lure_id, BOOL godlike); // To an invited location void teleportViaLocation(const LLVector3d& pos_global); // To a global location - this will probably need to be deprecated - void teleportViaLocationLookAt(const LLVector3d& pos_global);// To a global location, preserving camera rotation +// [RLVa:KB] - Checked: RLVa-2.0.0 + void teleportViaLocationLookAt(const LLVector3d& pos_global, const LLVector3& look_at = LLVector3::zero);// To a global location, preserving camera rotation +// [/RLVa:KB] +// void teleportViaLocationLookAt(const LLVector3d& pos_global);// To a global location, preserving camera rotation void teleportCancel(); // May or may not be allowed by server void restoreCanceledTeleportRequest(); bool getTeleportKeepsLookAt() { return mbTeleportKeepsLookAt; } // Whether look-at reset after teleport @@ -663,13 +666,19 @@ class LLAgent : public LLOldEvents::LLObservable bool hasPendingTeleportRequest(); void startTeleportRequest(); - void teleportRequest(const U64& region_handle, - const LLVector3& pos_local, // Go to a named location home - bool look_at_from_camera = false); +// [RLVa:KB] - Checked: RLVa-2.0.0 + void teleportRequest(const U64& region_handle, const LLVector3& pos_local, const LLVector3& look_at = LLVector3(0, 1, 0)); +// [/RLVa:KB] +// void teleportRequest(const U64& region_handle, +// const LLVector3& pos_local, // Go to a named location home +// bool look_at_from_camera = false); void doTeleportViaLandmark(const LLUUID& landmark_id); // Teleport to a landmark void doTeleportViaLure(const LLUUID& lure_id, BOOL godlike); // To an invited location void doTeleportViaLocation(const LLVector3d& pos_global); // To a global location - this will probably need to be deprecated - void doTeleportViaLocationLookAt(const LLVector3d& pos_global);// To a global location, preserving camera rotation +// [RLVa:KB] - Checked: RLVa-2.0.0 + void doTeleportViaLocationLookAt(const LLVector3d& pos_global, const LLVector3& look_at);// To a global location, preserving camera rotation +// [/RLVa:KB] +// void doTeleportViaLocationLookAt(const LLVector3d& pos_global);// To a global location, preserving camera rotation void handleTeleportFinished(); void handleTeleportFailed(); diff --git a/indra/newview/rlvactions.cpp b/indra/newview/rlvactions.cpp index 01c4be8357568ded61258bafd90acfafeace6f0c..102729a68bb353a2895a1e531390c29013f083fe 100644 --- a/indra/newview/rlvactions.cpp +++ b/indra/newview/rlvactions.cpp @@ -95,7 +95,7 @@ bool RlvActions::autoAcceptTeleportRequest(const LLUUID& idRequester) bool RlvActions::canTeleportToLocal() { - return (!gRlvHandler.hasBehaviour(RLV_BHVR_SITTP)) && (!gRlvHandler.hasBehaviour(RLV_BHVR_TPLOCAL) && (RlvActions::canStand()); + return (!gRlvHandler.hasBehaviour(RLV_BHVR_SITTP)) && (!gRlvHandler.hasBehaviour(RLV_BHVR_TPLOCAL)) && (RlvActions::canStand()); } bool RlvActions::canTeleportToLocation() diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp index 57129f659f90a2c6788484bca1586ec2353f8660..8cbdbb1f3522326374986ca8e61ffce25ab4810c 100644 --- a/indra/newview/rlvhandler.cpp +++ b/indra/newview/rlvhandler.cpp @@ -29,6 +29,7 @@ #include "llviewerregion.h" // Command specific includes +#include "llagentcamera.h" // @tpto #include "llenvmanager.h" // @setenv #include "lloutfitslist.h" // @showinv - "Appearance / My Outfits" panel #include "llpaneloutfitsinventory.h" // @showinv - "Appearance" floater @@ -1933,17 +1934,36 @@ ERlvCmdRet RlvForceHandler<RLV_BHVR_SIT>::onCommand(const RlvCommand& rlvCmd) return RLV_RET_SUCCESS; } -// Handles: @tpto:<vector>=force +// Handles: @tpto:<vector>[;<angle>]=force template<> template<> ERlvCmdRet RlvForceHandler<RLV_BHVR_TPTO>::onCommand(const RlvCommand& rlvCmd) { + std::vector<std::string> optionList; + if (!RlvCommandOptionHelper::parseStringList(rlvCmd.getOption(), optionList)) + return RLV_RET_FAILED; + + // First option specifies the destination LLVector3d posGlobal; - if (RlvCommandOptionHelper::parseOption(rlvCmd.getOption(), posGlobal)) + if (!RlvCommandOptionHelper::parseOption(optionList[0], posGlobal)) + return RLV_RET_FAILED_OPTION; + + if (optionList.size() == 1) { gAgent.teleportViaLocation(posGlobal); - return RLV_RET_SUCCESS; } - return RLV_RET_FAILED_OPTION; + else + { + // Second option specifies the angle + float nAngle = 0.0f; + if (!RlvCommandOptionHelper::parseOption(optionList[1], nAngle)) + return RLV_RET_FAILED_OPTION; + + LLVector3 vecLookAt(LLVector3::x_axis); + vecLookAt.rotVec(nAngle, LLVector3::z_axis); + vecLookAt.normalize(); + gAgent.teleportViaLocationLookAt(posGlobal, vecLookAt); + } + return RLV_RET_SUCCESS; } // ============================================================================ diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp index cdd5fecf5bc272288d8b9fc53eeab3f3936fd550..453c4cb8978f6757645faf6c7d5e820e69ac1e06 100644 --- a/indra/newview/rlvhelper.cpp +++ b/indra/newview/rlvhelper.cpp @@ -434,6 +434,17 @@ bool RlvCommandOptionHelper::parseOption<LLViewerInventoryCategory*>(const std:: return pFolder != NULL; } +template<> +bool RlvCommandOptionHelper::parseOption<LLVector3>(const std::string& strOption, LLVector3& vecOption) + { + if (!strOption.empty()) + { + S32 cntToken = sscanf(strOption.c_str(), "%f/%f/%f", vecOption.mV + 0, vecOption.mV + 1, vecOption.mV + 2); + return (3 == cntToken); + } + return false; +} + template<> bool RlvCommandOptionHelper::parseOption<LLVector3d>(const std::string& strOption, LLVector3d& vecOption) {