Some cleanup. Using gAgentAvatarp in many places. Incl other misc small changes.
This commit is contained in:
@@ -1111,29 +1111,27 @@ void LLAgentCamera::cameraPanUp(F32 meters)
|
||||
//-----------------------------------------------------------------------------
|
||||
void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y)
|
||||
{
|
||||
LLVOAvatar *pAvatar = gAgentAvatarp; // bleh
|
||||
|
||||
static LLVector3 last_at_axis;
|
||||
|
||||
if (!isAgentAvatarValid()) return;
|
||||
|
||||
LLQuaternion av_inv_rot = ~pAvatar->mRoot.getWorldRotation();
|
||||
LLVector3 root_at = LLVector3::x_axis * pAvatar->mRoot.getWorldRotation();
|
||||
LLQuaternion av_inv_rot = ~gAgentAvatarp->mRoot.getWorldRotation();
|
||||
LLVector3 root_at = LLVector3::x_axis * gAgentAvatarp->mRoot.getWorldRotation();
|
||||
|
||||
if ((gViewerWindow->getMouseVelocityStat()->getCurrent() < 0.01f) &&
|
||||
(root_at * last_at_axis > 0.95f))
|
||||
{
|
||||
LLVector3 vel = pAvatar->getVelocity();
|
||||
LLVector3 vel = gAgentAvatarp->getVelocity();
|
||||
if (vel.magVecSquared() > 4.f)
|
||||
{
|
||||
setLookAt(LOOKAT_TARGET_IDLE, pAvatar, vel * av_inv_rot);
|
||||
setLookAt(LOOKAT_TARGET_IDLE, gAgentAvatarp, vel * av_inv_rot);
|
||||
}
|
||||
else
|
||||
{
|
||||
// *FIX: rotate mframeagent by sit object's rotation?
|
||||
LLQuaternion look_rotation = pAvatar->isSitting() ? pAvatar->getRenderRotation() : gAgent.getFrameAgent().getQuaternion(); // use camera's current rotation
|
||||
LLQuaternion look_rotation = gAgentAvatarp->isSitting() ? gAgentAvatarp->getRenderRotation() : gAgent.getFrameAgent().getQuaternion(); // use camera's current rotation
|
||||
LLVector3 look_offset = LLVector3(2.f, 0.f, 0.f) * look_rotation * av_inv_rot;
|
||||
setLookAt(LOOKAT_TARGET_IDLE, pAvatar, look_offset);
|
||||
setLookAt(LOOKAT_TARGET_IDLE, gAgentAvatarp, look_offset);
|
||||
}
|
||||
last_at_axis = root_at;
|
||||
return;
|
||||
@@ -1143,7 +1141,7 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y)
|
||||
|
||||
if (CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode())
|
||||
{
|
||||
setLookAt(LOOKAT_TARGET_NONE, pAvatar, LLVector3(-2.f, 0.f, 0.f));
|
||||
setLookAt(LOOKAT_TARGET_NONE, gAgentAvatarp, LLVector3(-2.f, 0.f, 0.f));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1160,9 +1158,9 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y)
|
||||
{
|
||||
// range from -.5 to .5
|
||||
F32 x_from_center =
|
||||
((F32) mouse_x / (F32) gViewerWindow->getWindowWidth() ) - 0.5f;
|
||||
((F32) mouse_x / (F32) gViewerWindow->getWorldViewWidthScaled() ) - 0.5f;
|
||||
F32 y_from_center =
|
||||
((F32) mouse_y / (F32) gViewerWindow->getWindowHeight() ) - 0.5f;
|
||||
((F32) mouse_y / (F32) gViewerWindow->getWorldViewHeightScaled() ) - 0.5f;
|
||||
|
||||
frameCamera.yaw( - x_from_center * gSavedSettings.getF32("YawFromMousePosition") * DEG_TO_RAD);
|
||||
frameCamera.pitch( - y_from_center * gSavedSettings.getF32("PitchFromMousePosition") * DEG_TO_RAD);
|
||||
@@ -1172,7 +1170,7 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y)
|
||||
headLookAxis = frameCamera.getAtAxis();
|
||||
// RN: we use world-space offset for mouselook and freelook
|
||||
//headLookAxis = headLookAxis * av_inv_rot;
|
||||
setLookAt(lookAtType, pAvatar, headLookAxis);
|
||||
setLookAt(lookAtType, gAgentAvatarp, headLookAxis);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1183,8 +1181,6 @@ void LLAgentCamera::updateCamera()
|
||||
{
|
||||
//static LLFastTimer::DeclareTimer ftm("Camera");
|
||||
//LLFastTimer t(ftm);
|
||||
|
||||
LLVOAvatar *pAvatar = gAgentAvatarp;
|
||||
|
||||
// - changed camera_skyward to the new global "mCameraUpVector"
|
||||
mCameraUpVector = LLVector3::z_axis;
|
||||
@@ -1195,11 +1191,11 @@ void LLAgentCamera::updateCamera()
|
||||
validateFocusObject();
|
||||
|
||||
if (isAgentAvatarValid() &&
|
||||
pAvatar->isSitting() &&
|
||||
gAgentAvatarp->isSitting() &&
|
||||
camera_mode == CAMERA_MODE_MOUSELOOK)
|
||||
{
|
||||
//changed camera_skyward to the new global "mCameraUpVector"
|
||||
mCameraUpVector = mCameraUpVector * pAvatar->getRenderRotation();
|
||||
mCameraUpVector = mCameraUpVector * gAgentAvatarp->getRenderRotation();
|
||||
}
|
||||
|
||||
if (cameraThirdPerson() && mFocusOnAvatar && LLFollowCamMgr::getActiveFollowCamParams())
|
||||
@@ -1298,13 +1294,13 @@ void LLAgentCamera::updateCamera()
|
||||
// (2) focus, and (3) upvector. They can then be queried elsewhere in llAgent.
|
||||
//--------------------------------------------------------------------------------
|
||||
// *TODO: use combined rotation of frameagent and sit object
|
||||
LLQuaternion avatarRotationForFollowCam = pAvatar->isSitting() ? pAvatar->getRenderRotation() : gAgent.getFrameAgent().getQuaternion();
|
||||
LLQuaternion avatarRotationForFollowCam = gAgentAvatarp->isSitting() ? gAgentAvatarp->getRenderRotation() : gAgent.getFrameAgent().getQuaternion();
|
||||
|
||||
LLFollowCamParams* current_cam = LLFollowCamMgr::getActiveFollowCamParams();
|
||||
if (current_cam)
|
||||
{
|
||||
mFollowCam.copyParams(*current_cam);
|
||||
mFollowCam.setSubjectPositionAndRotation( pAvatar->getRenderPosition(), avatarRotationForFollowCam );
|
||||
mFollowCam.setSubjectPositionAndRotation( gAgentAvatarp->getRenderPosition(), avatarRotationForFollowCam );
|
||||
mFollowCam.update();
|
||||
LLViewerJoystick::getInstance()->setCameraNeedsUpdate(true);
|
||||
}
|
||||
@@ -1380,7 +1376,7 @@ void LLAgentCamera::updateCamera()
|
||||
|
||||
if (isAgentAvatarValid() && (mCameraMode != CAMERA_MODE_MOUSELOOK))
|
||||
{
|
||||
pAvatar->updateAttachmentVisibility(mCameraMode);
|
||||
gAgentAvatarp->updateAttachmentVisibility(mCameraMode);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1476,40 +1472,40 @@ void LLAgentCamera::updateCamera()
|
||||
}
|
||||
gAgent.setLastPositionGlobal(global_pos);
|
||||
|
||||
if (LLVOAvatar::sVisibleInFirstPerson && isAgentAvatarValid() && !pAvatar->isSitting() && cameraMouselook())
|
||||
if (LLVOAvatar::sVisibleInFirstPerson && isAgentAvatarValid() && !gAgentAvatarp->isSitting() && cameraMouselook())
|
||||
{
|
||||
LLVector3 head_pos = pAvatar->mHeadp->getWorldPosition() +
|
||||
LLVector3(0.08f, 0.f, 0.05f) * pAvatar->mHeadp->getWorldRotation() +
|
||||
LLVector3(0.1f, 0.f, 0.f) * pAvatar->mPelvisp->getWorldRotation();
|
||||
LLVector3 head_pos = gAgentAvatarp->mHeadp->getWorldPosition() +
|
||||
LLVector3(0.08f, 0.f, 0.05f) * gAgentAvatarp->mHeadp->getWorldRotation() +
|
||||
LLVector3(0.1f, 0.f, 0.f) * gAgentAvatarp->mPelvisp->getWorldRotation();
|
||||
LLVector3 diff = mCameraPositionAgent - head_pos;
|
||||
diff = diff * ~pAvatar->mRoot.getWorldRotation();
|
||||
diff = diff * ~gAgentAvatarp->mRoot.getWorldRotation();
|
||||
|
||||
LLJoint* torso_joint = pAvatar->mTorsop;
|
||||
LLJoint* chest_joint = pAvatar->mChestp;
|
||||
LLJoint* torso_joint = gAgentAvatarp->mTorsop;
|
||||
LLJoint* chest_joint = gAgentAvatarp->mChestp;
|
||||
LLVector3 torso_scale = torso_joint->getScale();
|
||||
LLVector3 chest_scale = chest_joint->getScale();
|
||||
|
||||
// shorten avatar skeleton to avoid foot interpenetration
|
||||
if (!pAvatar->mInAir)
|
||||
if (!gAgentAvatarp->mInAir)
|
||||
{
|
||||
LLVector3 chest_offset = LLVector3(0.f, 0.f, chest_joint->getPosition().mV[VZ]) * torso_joint->getWorldRotation();
|
||||
F32 z_compensate = llclamp(-diff.mV[VZ], -0.2f, 1.f);
|
||||
F32 scale_factor = llclamp(1.f - ((z_compensate * 0.5f) / chest_offset.mV[VZ]), 0.5f, 1.2f);
|
||||
torso_joint->setScale(LLVector3(1.f, 1.f, scale_factor));
|
||||
|
||||
LLJoint* neck_joint = pAvatar->mNeckp;
|
||||
LLJoint* neck_joint = gAgentAvatarp->mNeckp;
|
||||
LLVector3 neck_offset = LLVector3(0.f, 0.f, neck_joint->getPosition().mV[VZ]) * chest_joint->getWorldRotation();
|
||||
scale_factor = llclamp(1.f - ((z_compensate * 0.5f) / neck_offset.mV[VZ]), 0.5f, 1.2f);
|
||||
chest_joint->setScale(LLVector3(1.f, 1.f, scale_factor));
|
||||
diff.mV[VZ] = 0.f;
|
||||
}
|
||||
|
||||
pAvatar->mPelvisp->setPosition(pAvatar->mPelvisp->getPosition() + diff);
|
||||
gAgentAvatarp->mPelvisp->setPosition(gAgentAvatarp->mPelvisp->getPosition() + diff);
|
||||
|
||||
pAvatar->mRoot.updateWorldMatrixChildren();
|
||||
gAgentAvatarp->mRoot.updateWorldMatrixChildren();
|
||||
|
||||
for (LLVOAvatar::attachment_map_t::iterator iter = pAvatar->mAttachmentPoints.begin();
|
||||
iter != pAvatar->mAttachmentPoints.end(); )
|
||||
for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin();
|
||||
iter != gAgentAvatarp->mAttachmentPoints.end(); )
|
||||
{
|
||||
LLVOAvatar::attachment_map_t::iterator curiter = iter++;
|
||||
LLViewerJointAttachment* attachment = curiter->second;
|
||||
@@ -1770,7 +1766,6 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
|
||||
gAgent.getPositionGlobal() :
|
||||
gAgent.getPosGlobalFromAgent(gAgentAvatarp->mRoot.getWorldPosition());
|
||||
|
||||
LLVOAvatar *pAvatar = gAgentAvatarp;
|
||||
BOOL isConstrained = FALSE;
|
||||
LLVector3d head_offset;
|
||||
head_offset.setVec(mThirdPersonHeadOffset);
|
||||
@@ -1783,32 +1778,32 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
|
||||
}
|
||||
else if (mCameraMode == CAMERA_MODE_MOUSELOOK)
|
||||
{
|
||||
if (!isAgentAvatarValid() || pAvatar->mDrawable.isNull())
|
||||
if (!isAgentAvatarValid() || gAgentAvatarp->mDrawable.isNull())
|
||||
{
|
||||
llwarns << "Null avatar drawable!" << llendl;
|
||||
return LLVector3d::zero;
|
||||
}
|
||||
head_offset.clearVec();
|
||||
if (pAvatar->isSitting() && pAvatar->getParent())
|
||||
if (gAgentAvatarp->isSitting() && gAgentAvatarp->getParent())
|
||||
{
|
||||
pAvatar->updateHeadOffset();
|
||||
head_offset.mdV[VX] = pAvatar->mHeadOffset.mV[VX];
|
||||
head_offset.mdV[VY] = pAvatar->mHeadOffset.mV[VY];
|
||||
head_offset.mdV[VZ] = pAvatar->mHeadOffset.mV[VZ] + 0.1f;
|
||||
const LLMatrix4& mat = ((LLViewerObject*) pAvatar->getParent())->getRenderMatrix();
|
||||
gAgentAvatarp->updateHeadOffset();
|
||||
head_offset.mdV[VX] = gAgentAvatarp->mHeadOffset.mV[VX];
|
||||
head_offset.mdV[VY] = gAgentAvatarp->mHeadOffset.mV[VY];
|
||||
head_offset.mdV[VZ] = gAgentAvatarp->mHeadOffset.mV[VZ] + 0.1f;
|
||||
const LLMatrix4& mat = ((LLViewerObject*) gAgentAvatarp->getParent())->getRenderMatrix();
|
||||
camera_position_global = gAgent.getPosGlobalFromAgent
|
||||
((gAgentAvatarp->getPosition()+
|
||||
LLVector3(head_offset)*pAvatar->getRotation()) * mat);
|
||||
LLVector3(head_offset)*gAgentAvatarp->getRotation()) * mat);
|
||||
}
|
||||
else
|
||||
{
|
||||
head_offset.mdV[VZ] = pAvatar->mHeadOffset.mV[VZ];
|
||||
if (pAvatar->isSitting())
|
||||
head_offset.mdV[VZ] = gAgentAvatarp->mHeadOffset.mV[VZ];
|
||||
if (gAgentAvatarp->isSitting())
|
||||
{
|
||||
head_offset.mdV[VZ] += 0.1;
|
||||
}
|
||||
camera_position_global = gAgent.getPosGlobalFromAgent(pAvatar->getRenderPosition());//frame_center_global;
|
||||
head_offset = head_offset * pAvatar->getRenderRotation();
|
||||
camera_position_global = gAgent.getPosGlobalFromAgent(gAgentAvatarp->getRenderPosition());//frame_center_global;
|
||||
head_offset = head_offset * gAgentAvatarp->getRenderRotation();
|
||||
camera_position_global = camera_position_global + head_offset;
|
||||
}
|
||||
}
|
||||
@@ -1819,7 +1814,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
|
||||
|
||||
if (mSitCameraEnabled
|
||||
&& isAgentAvatarValid()
|
||||
&& pAvatar->isSitting()
|
||||
&& gAgentAvatarp->isSitting()
|
||||
&& mSitCameraReferenceObject.notNull())
|
||||
{
|
||||
// sit camera
|
||||
@@ -1835,7 +1830,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
|
||||
local_camera_offset = mCameraZoomFraction * getCameraOffsetInitial() * gSavedSettings.getF32("CameraOffsetScale");
|
||||
|
||||
// are we sitting down?
|
||||
if (isAgentAvatarValid() && pAvatar->getParent())
|
||||
if (isAgentAvatarValid() && gAgentAvatarp->getParent())
|
||||
{
|
||||
LLQuaternion parent_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
|
||||
// slam agent coordinate frame to proper parent local version
|
||||
@@ -1851,7 +1846,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
|
||||
local_camera_offset = gAgent.getFrameAgent().rotateToAbsolute( local_camera_offset );
|
||||
}
|
||||
|
||||
if (!mCameraCollidePlane.isExactlyZero() && (!isAgentAvatarValid() || !pAvatar->isSitting()))
|
||||
if (!mCameraCollidePlane.isExactlyZero() && (!isAgentAvatarValid() || !gAgentAvatarp->isSitting()))
|
||||
{
|
||||
LLVector3 plane_normal;
|
||||
plane_normal.setVec(mCameraCollidePlane.mV);
|
||||
@@ -1904,7 +1899,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
|
||||
// set the global camera position
|
||||
LLVector3d camera_offset;
|
||||
|
||||
LLVector3 av_pos = !isAgentAvatarValid() ? LLVector3::zero : pAvatar->getRenderPosition();
|
||||
LLVector3 av_pos = !isAgentAvatarValid() ? LLVector3::zero : gAgentAvatarp->getRenderPosition();
|
||||
camera_offset.setVec( local_camera_offset );
|
||||
camera_position_global = frame_center_global + head_offset + camera_offset;
|
||||
|
||||
@@ -1916,8 +1911,8 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
|
||||
LLVector3 vel = gAgent.getVelocity();
|
||||
|
||||
// lag by appropriate amount for flying
|
||||
F32 time_in_air = pAvatar->mTimeInAir.getElapsedTimeF32();
|
||||
if(!mCameraAnimating && pAvatar->mInAir && time_in_air > GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME)
|
||||
F32 time_in_air = gAgentAvatarp->mTimeInAir.getElapsedTimeF32();
|
||||
if(!mCameraAnimating && gAgentAvatarp->mInAir && time_in_air > GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME)
|
||||
{
|
||||
LLVector3 frame_at_axis = gAgent.getFrameAgent().getAtAxis();
|
||||
frame_at_axis -= projected_vec(frame_at_axis, gAgent.getReferenceUpVector());
|
||||
@@ -1929,7 +1924,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
|
||||
|
||||
lag_interp *= u;
|
||||
|
||||
if (gViewerWindow->getLeftMouseDown() && gViewerWindow->getLastPick().mObjectID == pAvatar->getID())
|
||||
if (gViewerWindow->getLeftMouseDown() && gViewerWindow->getLastPick().mObjectID == gAgentAvatarp->getID())
|
||||
{
|
||||
// disable camera lag when using mouse-directed steering
|
||||
target_lag.clearVec();
|
||||
|
||||
Reference in New Issue
Block a user