Added @tpto:<position>;<lookat>=force to specify which direction to face when arriving

--HG--
branch : RLVa
master
Kitty Barnett 2016-05-29 19:27:54 +02:00
parent 0c188a4d40
commit 86cb92d899
5 changed files with 117 additions and 31 deletions

View File

@ -210,7 +210,10 @@ private:
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 @@ public:
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

View File

@ -628,7 +628,10 @@ public:
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 @@ private:
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();

View File

@ -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()

View File

@ -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;
}
// ============================================================================

View File

@ -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)
{