diff options
Diffstat (limited to 'indra/newview/llagentcamera.cpp')
-rw-r--r-- | indra/newview/llagentcamera.cpp | 145 |
1 files changed, 72 insertions, 73 deletions
diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 282b41b2f1..6bdc8752d9 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -123,14 +123,14 @@ LLAgentCamera::LLAgentCamera() : mHUDTargetZoom(1.f), mHUDCurZoom(1.f), - mForceMouselook(FALSE), + mForceMouselook(false), mCameraMode( CAMERA_MODE_THIRD_PERSON ), mLastCameraMode( CAMERA_MODE_THIRD_PERSON ), mCameraPreset(CAMERA_PRESET_REAR_VIEW), - mCameraAnimating( FALSE ), + mCameraAnimating( false ), mAnimationCameraStartGlobal(), mAnimationFocusStartGlobal(), mAnimationTimer(), @@ -146,21 +146,21 @@ LLAgentCamera::LLAgentCamera() : mTargetCameraDistance(2.f), mCameraZoomFraction(1.f), // deprecated mThirdPersonHeadOffset(0.f, 0.f, 1.f), - mSitCameraEnabled(FALSE), + mSitCameraEnabled(false), mCameraSmoothingLastPositionGlobal(), mCameraSmoothingLastPositionAgent(), mCameraSmoothingStop(false), mCameraUpVector(LLVector3::z_axis), // default is straight up - mFocusOnAvatar(TRUE), - mAllowChangeToFollow(FALSE), + mFocusOnAvatar(true), + mAllowChangeToFollow(false), mFocusGlobal(), mFocusTargetGlobal(), mFocusObject(NULL), mFocusObjectDist(0.f), mFocusObjectOffset(), - mTrackFocusObject(TRUE), + mTrackFocusObject(true), mAtKey(0), // Either 1, 0, or -1... indicates that movement-key is pressed mWalkKey(0), // like AtKey, but causes less forward thrust @@ -279,7 +279,7 @@ LLAgentCamera::~LLAgentCamera() //----------------------------------------------------------------------------- // resetView() //----------------------------------------------------------------------------- -void LLAgentCamera::resetView(BOOL reset_camera, BOOL change_camera) +void LLAgentCamera::resetView(bool reset_camera, bool change_camera) { if (gDisconnected) { @@ -288,7 +288,7 @@ void LLAgentCamera::resetView(BOOL reset_camera, BOOL change_camera) if (gAgent.getAutoPilot()) { - gAgent.stopAutoPilot(TRUE); + gAgent.stopAutoPilot(true); } LLSelectMgr::getInstance()->unhighlightAll(); @@ -348,7 +348,7 @@ void LLAgentCamera::resetView(BOOL reset_camera, BOOL change_camera) gAgent.resetAxes(lerp(gAgent.getAtAxis(), agent_at_axis, LLSmoothInterpolation::getInterpolant(0.3f))); } - setFocusOnAvatar(TRUE, ANIMATE); + setFocusOnAvatar(true, ANIMATE); mCameraFOVZoomFactor = 0.f; } @@ -381,7 +381,7 @@ void LLAgentCamera::unlockView() { setFocusGlobal(LLVector3d::zero, gAgentAvatarp->mID); } - setFocusOnAvatar(FALSE, FALSE); // no animation + setFocusOnAvatar(false, false); // no animation } } @@ -572,16 +572,16 @@ LLVector3 LLAgentCamera::calcFocusOffset(LLViewerObject *object, LLVector3 origi //----------------------------------------------------------------------------- // calcCameraMinDistance() //----------------------------------------------------------------------------- -BOOL LLAgentCamera::calcCameraMinDistance(F32 &obj_min_distance) +bool LLAgentCamera::calcCameraMinDistance(F32 &obj_min_distance) { - BOOL soft_limit = FALSE; // is the bounding box to be treated literally (volumes) or as an approximation (avatars) + bool soft_limit = false; // is the bounding box to be treated literally (volumes) or as an approximation (avatars) if (!mFocusObject || mFocusObject->isDead() || mFocusObject->isMesh() || isDisableCameraConstraints()) { obj_min_distance = 0.f; - return TRUE; + return true; } if (mFocusObject->mDrawable.isNull()) @@ -593,7 +593,7 @@ BOOL LLAgentCamera::calcCameraMinDistance(F32 &obj_min_distance) LL_ERRS() << "Focus object with no drawable!" << LL_ENDL; #endif obj_min_distance = 0.f; - return TRUE; + return true; } LLQuaternion inv_object_rot = ~mFocusObject->getRenderRotation(); @@ -612,20 +612,20 @@ BOOL LLAgentCamera::calcCameraMinDistance(F32 &obj_min_distance) object_extents.mV[VX] *= AVATAR_ZOOM_MIN_X_FACTOR; object_extents.mV[VY] *= AVATAR_ZOOM_MIN_Y_FACTOR; object_extents.mV[VZ] *= AVATAR_ZOOM_MIN_Z_FACTOR; - soft_limit = TRUE; + soft_limit = true; } LLVector3 abs_target_offset = target_offset_origin; abs_target_offset.abs(); LLVector3 target_offset_dir = target_offset_origin; - BOOL target_outside_object_extents = FALSE; + bool target_outside_object_extents = false; for (U32 i = VX; i <= VZ; i++) { if (abs_target_offset.mV[i] * 2.f > object_extents.mV[i] + OBJECT_EXTENTS_PADDING) { - target_outside_object_extents = TRUE; + target_outside_object_extents = true; } if (camera_offset_target.mV[i] > 0.f) { @@ -722,11 +722,11 @@ BOOL LLAgentCamera::calcCameraMinDistance(F32 &obj_min_distance) { if (camera_offset_clip > 0.f && target_offset_clip > 0.f) { - return FALSE; + return false; } else if (camera_offset_clip < 0.f && target_offset_clip < 0.f) { - return FALSE; + return false; } } @@ -735,7 +735,7 @@ BOOL LLAgentCamera::calcCameraMinDistance(F32 &obj_min_distance) obj_min_distance += LLViewerCamera::getInstance()->getNear() + (soft_limit ? 0.1f : 0.2f); - return TRUE; + return true; } F32 LLAgentCamera::getCameraZoomFraction(bool get_third_person) @@ -749,11 +749,6 @@ F32 LLAgentCamera::getCameraZoomFraction(bool get_third_person) return mHUDTargetZoom; } - if (isDisableCameraConstraints()) - { - return mCameraZoomFraction; - } - if (get_third_person || (mFocusOnAvatar && cameraThirdPerson())) { return clamp_rescale(mCameraZoomFraction, MIN_ZOOM_FRACTION, MAX_ZOOM_FRACTION, 1.f, 0.f); @@ -767,6 +762,10 @@ F32 LLAgentCamera::getCameraZoomFraction(bool get_third_person) F32 min_zoom; F32 max_zoom = getCameraMaxZoomDistance(); + if (isDisableCameraConstraints()) + { + max_zoom = MAX_CAMERA_DISTANCE_FROM_OBJECT; + } F32 distance = (F32)mCameraFocusOffsetTarget.magVec(); if (mFocusObject.notNull()) @@ -798,10 +797,6 @@ void LLAgentCamera::setCameraZoomFraction(F32 fraction) { mHUDTargetZoom = fraction; } - else if (isDisableCameraConstraints()) - { - mCameraZoomFraction = fraction; - } else if (mFocusOnAvatar && cameraThirdPerson()) { mCameraZoomFraction = rescale(fraction, 0.f, 1.f, MAX_ZOOM_FRACTION, MIN_ZOOM_FRACTION); @@ -816,6 +811,10 @@ void LLAgentCamera::setCameraZoomFraction(F32 fraction) { F32 min_zoom = LAND_MIN_ZOOM; F32 max_zoom = getCameraMaxZoomDistance(); + if (isDisableCameraConstraints()) + { + max_zoom = MAX_CAMERA_DISTANCE_FROM_OBJECT; + } if (mFocusObject.notNull()) { @@ -994,7 +993,7 @@ void LLAgentCamera::cameraOrbitIn(const F32 meters) if (!gSavedSettings.getBOOL("FreezeTime") && mCameraZoomFraction < MIN_ZOOM_FRACTION && meters > 0.f) { // No need to animate, camera is already there. - changeCameraToMouselook(FALSE); + changeCameraToMouselook(false); } if (!isDisableCameraConstraints()) @@ -1195,7 +1194,7 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y) static LLTrace::BlockTimerStatHandle FTM_UPDATE_CAMERA("Camera"); -extern BOOL gCubeSnapshot; +extern bool gCubeSnapshot; //----------------------------------------------------------------------------- // updateCamera() @@ -1226,8 +1225,8 @@ void LLAgentCamera::updateCamera() if (cameraThirdPerson() && (mFocusOnAvatar || mAllowChangeToFollow) && LLFollowCamMgr::getInstance()->getActiveFollowCamParams()) { - mAllowChangeToFollow = FALSE; - mFocusOnAvatar = TRUE; + mAllowChangeToFollow = false; + mFocusOnAvatar = true; changeCameraToFollow(); } @@ -1334,12 +1333,12 @@ void LLAgentCamera::updateCamera() } else { - changeCameraToThirdPerson(TRUE); + changeCameraToThirdPerson(true); } } } - BOOL hit_limit; + bool hit_limit; LLVector3d camera_pos_global; LLVector3d camera_target_global = calcCameraPositionTargetGlobal(&hit_limit); mCameraVirtualPositionAgent = gAgent.getPosAgentFromGlobal(camera_target_global); @@ -1349,7 +1348,7 @@ void LLAgentCamera::updateCamera() mCameraFOVZoomFactor = calcCameraFOVZoomFactor(); camera_target_global = focus_target_global + (camera_target_global - focus_target_global) * (1.f + mCameraFOVZoomFactor); - gAgent.setShowAvatar(TRUE); // can see avatar by default + gAgent.setShowAvatar(true); // can see avatar by default // Adjust position for animation if (mCameraAnimating) @@ -1362,8 +1361,8 @@ void LLAgentCamera::updateCamera() // linear interpolation F32 fraction_of_animation = time / mAnimationDuration; - BOOL isfirstPerson = mCameraMode == CAMERA_MODE_MOUSELOOK; - BOOL wasfirstPerson = mLastCameraMode == CAMERA_MODE_MOUSELOOK; + bool isfirstPerson = mCameraMode == CAMERA_MODE_MOUSELOOK; + bool wasfirstPerson = mLastCameraMode == CAMERA_MODE_MOUSELOOK; F32 fraction_animation_to_skip; if (mAnimationCameraStartGlobal == camera_target_global) @@ -1382,7 +1381,7 @@ void LLAgentCamera::updateCamera() { if (fraction_of_animation < animation_start_fraction || fraction_of_animation > animation_finish_fraction ) { - gAgent.setShowAvatar(FALSE); + gAgent.setShowAvatar(false); } // ...adjust position for animation @@ -1393,13 +1392,13 @@ void LLAgentCamera::updateCamera() else { // ...animation complete - mCameraAnimating = FALSE; + mCameraAnimating = false; camera_pos_global = camera_target_global; mFocusGlobal = focus_target_global; gAgent.endAnimationUpdateUI(); - gAgent.setShowAvatar(TRUE); + gAgent.setShowAvatar(true); } if (isAgentAvatarValid() && (mCameraMode != CAMERA_MODE_MOUSELOOK)) @@ -1411,11 +1410,11 @@ void LLAgentCamera::updateCamera() { camera_pos_global = camera_target_global; mFocusGlobal = focus_target_global; - gAgent.setShowAvatar(TRUE); + gAgent.setShowAvatar(true); } // smoothing - if (TRUE) + if (true) { LLVector3d agent_pos = gAgent.getPositionGlobal(); LLVector3d camera_pos_agent = camera_pos_global - agent_pos; @@ -1428,7 +1427,7 @@ void LLAgentCamera::updateCamera() { const F32 SMOOTHING_HALF_LIFE = 0.02f; - F32 smoothing = LLSmoothInterpolation::getInterpolant(gSavedSettings.getF32("CameraPositionSmoothing") * SMOOTHING_HALF_LIFE, FALSE); + F32 smoothing = LLSmoothInterpolation::getInterpolant(gSavedSettings.getF32("CameraPositionSmoothing") * SMOOTHING_HALF_LIFE, false); if (mFocusOnAvatar && !mFocusObject) // we differentiate on avatar mode { @@ -1751,7 +1750,7 @@ F32 LLAgentCamera::calcCameraFOVZoomFactor() //----------------------------------------------------------------------------- // calcCameraPositionTargetGlobal() //----------------------------------------------------------------------------- -LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) +LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(bool *hit_limit) { // Compute base camera position and look-at points. F32 camera_land_height; @@ -1759,7 +1758,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) gAgent.getPositionGlobal() : gAgent.getPosGlobalFromAgent(getAvatarRootPosition()); - BOOL isConstrained = FALSE; + bool isConstrained = false; LLVector3d head_offset; head_offset.setVec(mThirdPersonHeadOffset); @@ -1986,7 +1985,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) if(camera_distance > max_dist) { camera_position_global = gAgent.getPositionGlobal() + (max_dist/camera_distance)*camera_offset; - isConstrained = TRUE; + isConstrained = true; } } @@ -1997,7 +1996,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) // { // camera_position_global = last_position_global; // -// isConstrained = TRUE; +// isConstrained = true; // } } @@ -2008,7 +2007,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) if (camera_position_global.mdV[VZ] < minZ) { camera_position_global.mdV[VZ] = minZ; - isConstrained = TRUE; + isConstrained = true; } if (hit_limit) @@ -2090,7 +2089,7 @@ void LLAgentCamera::handleScrollWheel(S32 clicks) mFollowCam.zoom(clicks); if (mFollowCam.isZoomedToMinimumDistance()) { - changeCameraToMouselook(FALSE); + changeCameraToMouselook(false); } } } @@ -2166,7 +2165,7 @@ void LLAgentCamera::resetCamera() //----------------------------------------------------------------------------- // changeCameraToMouselook() //----------------------------------------------------------------------------- -void LLAgentCamera::changeCameraToMouselook(BOOL animate) +void LLAgentCamera::changeCameraToMouselook(bool animate) { if (!gSavedSettings.getBOOL("EnableMouselook") || LLViewerJoystick::getInstance()->getOverrideCamera()) @@ -2216,7 +2215,7 @@ void LLAgentCamera::changeCameraToMouselook(BOOL animate) } else { - mCameraAnimating = FALSE; + mCameraAnimating = false; gAgent.endAnimationUpdateUI(); } } @@ -2252,7 +2251,7 @@ void LLAgentCamera::changeCameraToDefault() //----------------------------------------------------------------------------- // changeCameraToFollow() //----------------------------------------------------------------------------- -void LLAgentCamera::changeCameraToFollow(BOOL animate) +void LLAgentCamera::changeCameraToFollow(bool animate) { if (LLViewerJoystick::getInstance()->getOverrideCamera()) { @@ -2263,7 +2262,7 @@ void LLAgentCamera::changeCameraToFollow(BOOL animate) { if (mCameraMode == CAMERA_MODE_MOUSELOOK) { - animate = FALSE; + animate = false; } startCameraAnimation(); @@ -2297,7 +2296,7 @@ void LLAgentCamera::changeCameraToFollow(BOOL animate) } else { - mCameraAnimating = FALSE; + mCameraAnimating = false; gAgent.endAnimationUpdateUI(); } } @@ -2306,7 +2305,7 @@ void LLAgentCamera::changeCameraToFollow(BOOL animate) //----------------------------------------------------------------------------- // changeCameraToThirdPerson() //----------------------------------------------------------------------------- -void LLAgentCamera::changeCameraToThirdPerson(BOOL animate) +void LLAgentCamera::changeCameraToThirdPerson(bool animate) { if (LLViewerJoystick::getInstance()->getOverrideCamera()) { @@ -2345,7 +2344,7 @@ void LLAgentCamera::changeCameraToThirdPerson(BOOL animate) { mCurrentCameraDistance = MIN_CAMERA_DISTANCE; mTargetCameraDistance = MIN_CAMERA_DISTANCE; - animate = FALSE; + animate = false; } updateLastCamera(); mCameraMode = CAMERA_MODE_THIRD_PERSON; @@ -2368,7 +2367,7 @@ void LLAgentCamera::changeCameraToThirdPerson(BOOL animate) } else { - mCameraAnimating = FALSE; + mCameraAnimating = false; gAgent.endAnimationUpdateUI(); } } @@ -2408,7 +2407,7 @@ void LLAgentCamera::changeCameraToCustomizeAvatar() gFocusMgr.setMouseCapture( NULL ); if( gMorphView ) { - gMorphView->setVisible( TRUE ); + gMorphView->setVisible( true ); } // Remove any pitch or rotation from the avatar LLVector3 at = gAgent.getAtAxis(); @@ -2417,7 +2416,7 @@ void LLAgentCamera::changeCameraToCustomizeAvatar() gAgent.resetAxes(at); gAgent.sendAnimationRequest(ANIM_AGENT_CUSTOMIZE, ANIM_REQUEST_START); - gAgent.setCustomAnim(TRUE); + gAgent.setCustomAnim(true); gAgentAvatarp->startMotion(ANIM_AGENT_CUSTOMIZE); LLMotion* turn_motion = gAgentAvatarp->findMotion(ANIM_AGENT_CUSTOMIZE); @@ -2453,7 +2452,7 @@ void LLAgentCamera::switchCameraPreset(ECameraPreset preset) mCameraZoomFraction = 1.f; //focusing on avatar in that case means following him on movements - mFocusOnAvatar = TRUE; + mFocusOnAvatar = true; mCameraPreset = preset; @@ -2491,7 +2490,7 @@ void LLAgentCamera::startCameraAnimation() mAnimationFocusStartGlobal = mFocusGlobal; setAnimationDuration(gSavedSettings.getF32("ZoomTime")); mAnimationTimer.reset(); - mCameraAnimating = TRUE; + mCameraAnimating = true; } //----------------------------------------------------------------------------- @@ -2499,7 +2498,7 @@ void LLAgentCamera::startCameraAnimation() //----------------------------------------------------------------------------- void LLAgentCamera::stopCameraAnimation() { - mCameraAnimating = FALSE; + mCameraAnimating = false; } void LLAgentCamera::clearFocusObject() @@ -2679,7 +2678,7 @@ void LLAgentCamera::setCameraPosAndFocusGlobal(const LLVector3d& camera_pos, con //----------------------------------------------------------------------------- void LLAgentCamera::setSitCamera(const LLUUID &object_id, const LLVector3 &camera_pos, const LLVector3 &camera_focus) { - BOOL camera_enabled = !object_id.isNull(); + bool camera_enabled = !object_id.isNull(); if (camera_enabled) { @@ -2690,7 +2689,7 @@ void LLAgentCamera::setSitCamera(const LLUUID &object_id, const LLVector3 &camer mSitCameraPos = camera_pos; mSitCameraFocus = camera_focus; mSitCameraReferenceObject = reference_object; - mSitCameraEnabled = TRUE; + mSitCameraEnabled = true; } } else @@ -2698,14 +2697,14 @@ void LLAgentCamera::setSitCamera(const LLUUID &object_id, const LLVector3 &camer mSitCameraPos.clearVec(); mSitCameraFocus.clearVec(); mSitCameraReferenceObject = NULL; - mSitCameraEnabled = FALSE; + mSitCameraEnabled = false; } } //----------------------------------------------------------------------------- // setFocusOnAvatar() //----------------------------------------------------------------------------- -void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate, BOOL reset_axes) +void LLAgentCamera::setFocusOnAvatar(bool focus_on_avatar, bool animate, bool reset_axes) { if (focus_on_avatar != mFocusOnAvatar) { @@ -2752,14 +2751,14 @@ void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate, BOOL re { // keep camera focus point consistent, even though it is now unlocked setFocusGlobal(gAgent.getPositionGlobal() + calcThirdPersonFocusOffset(), gAgent.getID()); - mAllowChangeToFollow = FALSE; + mAllowChangeToFollow = false; } mFocusOnAvatar = focus_on_avatar; } -BOOL LLAgentCamera::setLookAt(ELookAtType target_type, LLViewerObject *object, LLVector3 position) +bool LLAgentCamera::setLookAt(ELookAtType target_type, LLViewerObject *object, LLVector3 position) { if(object && object->isAttachment()) { @@ -2828,7 +2827,7 @@ void LLAgentCamera::lookAtLastChat() new_camera_pos += left * 0.3f; new_camera_pos += up * 0.2f; - setFocusOnAvatar(FALSE, FALSE); + setFocusOnAvatar(false, false); if (chatter_av->mHeadp) { @@ -2859,7 +2858,7 @@ void LLAgentCamera::lookAtLastChat() new_camera_pos += left * 0.3f; new_camera_pos += up * 0.2f; - setFocusOnAvatar(FALSE, FALSE); + setFocusOnAvatar(false, false); setFocusGlobal(chatter->getPositionGlobal(), gAgent.getLastChatter()); mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(new_camera_pos) - chatter->getPositionGlobal(); @@ -2871,12 +2870,12 @@ bool LLAgentCamera::isfollowCamLocked() return mFollowCam.getPositionLocked(); } -BOOL LLAgentCamera::setPointAt(EPointAtType target_type, LLViewerObject *object, LLVector3 position) +bool LLAgentCamera::setPointAt(EPointAtType target_type, LLViewerObject *object, LLVector3 position) { // disallow pointing at attachments and avatars if (object && (object->isAttachment() || object->isAvatar())) { - return FALSE; + return false; } if (!mPointAt || mPointAt->isDead()) { |