[RLVa] @camdistmax, @camdistmin

This needs testing, this all needs testing...
but hey, at least it's here, right?
This commit is contained in:
Inusaito Sayori
2015-05-26 06:16:28 -04:00
parent 1720f2ebe4
commit 75ba6cc67d
3 changed files with 82 additions and 4 deletions

View File

@@ -972,6 +972,26 @@ void LLAgentCamera::cameraZoomIn(const F32 fraction)
//-----------------------------------------------------------------------------
void LLAgentCamera::cameraOrbitIn(const F32 meters)
{
// [RLVa:LF] - @camdistmax, @camdistmin
if (gRlvHandler.hasBehaviour(RLV_BHVR_CAMDISTMAX))
{
F32 dist_max(gRlvHandler.camMax(RLV_BHVR_CAMDISTMAX));
if (0 >= dist_max)
{
if (!cameraMouselook())
changeCameraToMouselook();
return; // There's no getting out of mouselook
}
}
if (gRlvHandler.hasBehaviour(RLV_BHVR_CAMDISTMIN))
{
F32 dist_min(gRlvHandler.camMin(RLV_BHVR_CAMDISTMIN));
if (cameraMouselook() && dist_min > 0)
changeCameraToDefault(); // Just to be sure we're not in mouselook
}
// [/RLVa:LF]
if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON)
{
static const LLCachedControl<F32> camera_offset_scale("CameraOffsetScale");
@@ -2011,6 +2031,35 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
// }
}
// [RLVa:LF] - @camdistmax, @camdistmin
if (rlv_handler_t::isEnabled() && !cameraMouselook())
{
// Constrainy stuffs ish based off above code
const LLVector3d agent_pos(gAgent.getPositionGlobal());
const LLVector3d offset(camera_position_global - agent_pos);
const F32 total_dist(offset.magVec());
bool rlvConstrained = false; // You Only Constrain Once
if (gRlvHandler.hasBehaviour(RLV_BHVR_CAMDISTMAX))
{
F32 max_dist(gRlvHandler.camMax(RLV_BHVR_CAMDISTMAX));
if (total_dist > max_dist)
{
camera_position_global = agent_pos + (max_dist/total_dist)*offset;
rlvConstrained = isConstrained = true;
}
}
if (!rlvConstrained && gRlvHandler.hasBehaviour(RLV_BHVR_CAMDISTMIN))
{
F32 min_dist(gRlvHandler.camMin(RLV_BHVR_CAMDISTMIN));
if (total_dist < min_dist)
{
camera_position_global = agent_pos + (min_dist/total_dist)*offset;
rlvConstrained = isConstrained = true;
}
}
}
// [/RLVa:LF]
// Don't let camera go underground
F32 camera_min_off_ground = getCameraMinOffGround();
@@ -2176,6 +2225,8 @@ void LLAgentCamera::resetCamera()
//-----------------------------------------------------------------------------
void LLAgentCamera::changeCameraToMouselook(BOOL animate)
{
if (gRlvHandler.hasBehaviour(RLV_BHVR_CAMDISTMIN) && gRlvHandler.camMin(RLV_BHVR_CAMDISTMIN) > 0) return; // [RLVa:LF] - @camdistmin
if (!gSavedSettings.getBOOL("EnableMouselook")
|| LLViewerJoystick::getInstance()->getOverrideCamera())
{
@@ -2264,6 +2315,8 @@ void LLAgentCamera::changeCameraToDefault()
//-----------------------------------------------------------------------------
void LLAgentCamera::changeCameraToFollow(BOOL animate)
{
if (gRlvHandler.hasBehaviour(RLV_BHVR_CAMDISTMAX) && 0 >= gRlvHandler.camMax(RLV_BHVR_CAMDISTMAX)) return; // [RLVa:LF] - @camdistmax
if (LLViewerJoystick::getInstance()->getOverrideCamera())
{
return;
@@ -2322,6 +2375,8 @@ void LLAgentCamera::changeCameraToFollow(BOOL animate)
//-----------------------------------------------------------------------------
void LLAgentCamera::changeCameraToThirdPerson(BOOL animate)
{
if (gRlvHandler.hasBehaviour(RLV_BHVR_CAMDISTMAX) && 0 >= gRlvHandler.camMax(RLV_BHVR_CAMDISTMAX)) return; // [RLVa:LF] - @camdistmax
if (LLViewerJoystick::getInstance()->getOverrideCamera())
{
return;
@@ -2405,6 +2460,8 @@ void LLAgentCamera::changeCameraToThirdPerson(BOOL animate)
//-----------------------------------------------------------------------------
void LLAgentCamera::changeCameraToCustomizeAvatar()
{
if (gRlvHandler.hasBehaviour(RLV_BHVR_CAMDISTMAX) && 0 >= gRlvHandler.camMax(RLV_BHVR_CAMDISTMAX)) return; // [RLVa:LF] - @camdistmax
if (LLViewerJoystick::getInstance()->getOverrideCamera() || !isAgentAvatarValid())
{
return;

View File

@@ -40,6 +40,7 @@
#include "llagent.h"
#include "llagentcamera.h"
#include "llfocusmgr.h"
#include "rlvhandler.h"
#include <boost/regex.hpp>
@@ -1161,7 +1162,8 @@ void LLViewerJoystick::moveFlycam(bool reset)
// -----------------------------------------------------------------------------
bool LLViewerJoystick::toggleFlycam()
{
if (!gSavedSettings.getBOOL("JoystickEnabled") || !gSavedSettings.getBOOL("JoystickFlycamEnabled"))
if (gRlvHandler.hasBehaviour(RLV_BHVR_CAMDISTMAX) // [RLVa:LF] - @camdistmax means no going away!
|| !gSavedSettings.getBOOL("JoystickEnabled") || !gSavedSettings.getBOOL("JoystickFlycamEnabled"))
{
mOverrideCamera = false;
return false;

View File

@@ -1365,11 +1365,30 @@ ERlvCmdRet RlvHandler::processAddRemCommand(const RlvCommand& rlvCmd)
break;
}
case RLV_BHVR_CAMDISTMAX: // @camdistmax:<max_distance>=n|y - Checked: 2015-05-25 (RLVa:LF)
eRet = RLV_RET_FAILED_UNKNOWN; // Singu TODO: Implement
break;
case RLV_BHVR_CAMDISTMIN: // @camdistmin:<min_distance>=n|y - Checked: 2015-05-25 (RLVa:LF)
eRet = RLV_RET_FAILED_UNKNOWN; // Singu TODO: Implement
{
F32 zoom;
LLStringUtil::convertToF32(strOption, zoom);
if (RLV_TYPE_ADD == eType)
addException(rlvCmd.getObjectID(), eBhvr, zoom);
else
removeException(rlvCmd.getObjectID(), eBhvr, zoom);
if (hasBehaviour(eBhvr))
{
if (eBhvr == RLV_BHVR_CAMDISTMAX && zoom <= 0)
{
if (!gAgentCamera.cameraMouselook())
gAgentCamera.changeCameraToMouselook();
}
else
{
if (eBhvr == RLV_BHVR_CAMDISTMIN && zoom > 0 && gAgentCamera.cameraMouselook())
gAgentCamera.changeCameraToDefault();
gAgentCamera.cameraPanUp(0); // Hacky, but meh.
}
}
break;
}
case RLV_BHVR_CAMDRAWMAX: // @camdrawmax:<max_distance>=n|y - Checked: 2015-05-25 (RLVa:LF)
eRet = RLV_RET_FAILED_UNKNOWN; // Singu TODO: Implement
break;