aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewercamera.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llviewercamera.cpp')
-rw-r--r--linden/indra/newview/llviewercamera.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/linden/indra/newview/llviewercamera.cpp b/linden/indra/newview/llviewercamera.cpp
index 72d1494..dade65f 100644
--- a/linden/indra/newview/llviewercamera.cpp
+++ b/linden/indra/newview/llviewercamera.cpp
@@ -102,10 +102,13 @@ LLViewerCamera::LLViewerCamera() : LLCamera()
102{ 102{
103 calcProjection(getFar()); 103 calcProjection(getFar());
104 mCameraFOVDefault = DEFAULT_FIELD_OF_VIEW; 104 mCameraFOVDefault = DEFAULT_FIELD_OF_VIEW;
105 mCosHalfCameraFOV = cosf(mCameraFOVDefault * 0.5f);
105 mPixelMeterRatio = 0.f; 106 mPixelMeterRatio = 0.f;
106 mScreenPixelArea = 0; 107 mScreenPixelArea = 0;
107 mZoomFactor = 1.f; 108 mZoomFactor = 1.f;
108 mZoomSubregion = 1; 109 mZoomSubregion = 1;
110 mAverageSpeed = 0.f;
111 mAverageAngularSpeed = 0.f;
109} 112}
110 113
111void LLViewerCamera::updateCameraLocation(const LLVector3 &center, 114void LLViewerCamera::updateCameraLocation(const LLVector3 &center,
@@ -144,15 +147,22 @@ void LLViewerCamera::updateCameraLocation(const LLVector3 &center,
144 147
145 setOriginAndLookAt(origin, up_direction, point_of_interest); 148 setOriginAndLookAt(origin, up_direction, point_of_interest);
146 149
147 F32 dpos = (center - last_position).magVec(); 150 mVelocityDir = center - last_position ;
151 F32 dpos = mVelocityDir.normVec() ;
148 LLQuaternion rotation; 152 LLQuaternion rotation;
149 rotation.shortestArc(last_axis, getAtAxis()); 153 rotation.shortestArc(last_axis, getAtAxis());
150 154
151 F32 x, y, z; 155 F32 x, y, z;
152 F32 drot; 156 F32 drot;
153 rotation.getAngleAxis(&drot, &x, &y, &z); 157 rotation.getAngleAxis(&drot, &x, &y, &z);
158
154 mVelocityStat.addValue(dpos); 159 mVelocityStat.addValue(dpos);
155 mAngularVelocityStat.addValue(drot); 160 mAngularVelocityStat.addValue(drot);
161
162 mAverageSpeed = mVelocityStat.getMeanPerSec() ;
163 mAverageAngularSpeed = mAngularVelocityStat.getMeanPerSec() ;
164 mCosHalfCameraFOV = cosf(0.5f * getView() * llmax(1.0f, getAspect()));
165
156 // update pixel meter ratio using default fov, not modified one 166 // update pixel meter ratio using default fov, not modified one
157 mPixelMeterRatio = getViewHeightInPixels()/ (2.f*tanf(mCameraFOVDefault*0.5)); 167 mPixelMeterRatio = getViewHeightInPixels()/ (2.f*tanf(mCameraFOVDefault*0.5));
158 // update screen pixel area 168 // update screen pixel area
@@ -759,8 +769,8 @@ BOOL LLViewerCamera::areVertsVisible(LLViewerObject* volumep, BOOL all_verts)
759 769
760 BOOL in_frustum = pointInFrustum(LLVector3(vec)) > 0; 770 BOOL in_frustum = pointInFrustum(LLVector3(vec)) > 0;
761 771
762 if ( !in_frustum && all_verts || 772 if (( !in_frustum && all_verts) ||
763 in_frustum && !all_verts) 773 (in_frustum && !all_verts))
764 { 774 {
765 return !all_verts; 775 return !all_verts;
766 } 776 }
@@ -797,9 +807,11 @@ BOOL LLViewerCamera::areVertsVisible(LLViewerObject* volumep, BOOL all_verts)
797 LLCamera::setView(vertical_fov_rads); // call base implementation 807 LLCamera::setView(vertical_fov_rads); // call base implementation
798} 808}
799 809
800void LLViewerCamera::setDefaultFOV(F32 vertical_fov_rads) { 810void LLViewerCamera::setDefaultFOV(F32 vertical_fov_rads)
811{
801 vertical_fov_rads = llclamp(vertical_fov_rads, getMinView(), getMaxView()); 812 vertical_fov_rads = llclamp(vertical_fov_rads, getMinView(), getMaxView());
802 setView(vertical_fov_rads); 813 setView(vertical_fov_rads);
803 mCameraFOVDefault = vertical_fov_rads; 814 mCameraFOVDefault = vertical_fov_rads;
815 mCosHalfCameraFOV = cosf(mCameraFOVDefault * 0.5f);
804} 816}
805 817