diff options
author | Jacek Antonelli | 2009-11-19 04:19:06 -0600 |
---|---|---|
committer | Jacek Antonelli | 2009-11-19 04:19:06 -0600 |
commit | 1d443b7a94ed6f9ef1d408caef72fcbc0b1ee427 (patch) | |
tree | e09ccbc010e326a48fd91ba15b58afd7fb836b3f /linden/indra/newview/llviewercamera.cpp | |
parent | Fixed minor formatting issue in MANIFESTO.txt. (diff) | |
parent | Fixed CMake setting errors (diff) | |
download | meta-impy-1d443b7a94ed6f9ef1d408caef72fcbc0b1ee427.zip meta-impy-1d443b7a94ed6f9ef1d408caef72fcbc0b1ee427.tar.gz meta-impy-1d443b7a94ed6f9ef1d408caef72fcbc0b1ee427.tar.bz2 meta-impy-1d443b7a94ed6f9ef1d408caef72fcbc0b1ee427.tar.xz |
Merge remote branch 'mccabe/1.3.0-next' into next
Conflicts:
linden/indra/cmake/00-Common.cmake
linden/indra/newview/skins/default/xui/de/floater_about.xml
linden/indra/newview/skins/default/xui/fr/floater_about.xml
linden/indra/newview/skins/default/xui/ja/floater_about.xml
linden/indra/newview/skins/default/xui/ko/floater_about.xml
linden/indra/newview/skins/default/xui/zh/floater_about.xml
linden/install.xml
Diffstat (limited to 'linden/indra/newview/llviewercamera.cpp')
-rw-r--r-- | linden/indra/newview/llviewercamera.cpp | 87 |
1 files changed, 79 insertions, 8 deletions
diff --git a/linden/indra/newview/llviewercamera.cpp b/linden/indra/newview/llviewercamera.cpp index 36cce35..72d1494 100644 --- a/linden/indra/newview/llviewercamera.cpp +++ b/linden/indra/newview/llviewercamera.cpp | |||
@@ -17,7 +17,8 @@ | |||
17 | * There are special exceptions to the terms and conditions of the GPL as | 17 | * There are special exceptions to the terms and conditions of the GPL as |
18 | * it is applied to this Source Code. View the full text of the exception | 18 | * it is applied to this Source Code. View the full text of the exception |
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | 19 | * in the file doc/FLOSS-exception.txt in this software distribution, or |
20 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | 20 | * online at |
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
21 | * | 22 | * |
22 | * By copying, modifying or distributing this software, you acknowledge | 23 | * By copying, modifying or distributing this software, you acknowledge |
23 | * that you have read and understood your obligations described above, | 24 | * that you have read and understood your obligations described above, |
@@ -82,6 +83,21 @@ glh::matrix4f gl_perspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloa | |||
82 | 0, 0, -1.f, 0); | 83 | 0, 0, -1.f, 0); |
83 | } | 84 | } |
84 | 85 | ||
86 | glh::matrix4f gl_lookat(LLVector3 eye, LLVector3 center, LLVector3 up) | ||
87 | { | ||
88 | LLVector3 f = center-eye; | ||
89 | f.normVec(); | ||
90 | up.normVec(); | ||
91 | LLVector3 s = f % up; | ||
92 | LLVector3 u = s % f; | ||
93 | |||
94 | return glh::matrix4f(s[0], s[1], s[2], 0, | ||
95 | u[0], u[1], u[2], 0, | ||
96 | -f[0], -f[1], -f[2], 0, | ||
97 | 0, 0, 0, 1); | ||
98 | |||
99 | } | ||
100 | |||
85 | LLViewerCamera::LLViewerCamera() : LLCamera() | 101 | LLViewerCamera::LLViewerCamera() : LLCamera() |
86 | { | 102 | { |
87 | calcProjection(getFar()); | 103 | calcProjection(getFar()); |
@@ -138,9 +154,9 @@ void LLViewerCamera::updateCameraLocation(const LLVector3 ¢er, | |||
138 | mVelocityStat.addValue(dpos); | 154 | mVelocityStat.addValue(dpos); |
139 | mAngularVelocityStat.addValue(drot); | 155 | mAngularVelocityStat.addValue(drot); |
140 | // update pixel meter ratio using default fov, not modified one | 156 | // update pixel meter ratio using default fov, not modified one |
141 | mPixelMeterRatio = mViewHeightInPixels / (2.f*tanf(mCameraFOVDefault*0.5)); | 157 | mPixelMeterRatio = getViewHeightInPixels()/ (2.f*tanf(mCameraFOVDefault*0.5)); |
142 | // update screen pixel area | 158 | // update screen pixel area |
143 | mScreenPixelArea =(S32)((F32)mViewHeightInPixels * ((F32)mViewHeightInPixels * mAspect)); | 159 | mScreenPixelArea =(S32)((F32)getViewHeightInPixels() * ((F32)getViewHeightInPixels() * getAspect())); |
144 | } | 160 | } |
145 | 161 | ||
146 | const LLMatrix4 &LLViewerCamera::getProjection() const | 162 | const LLMatrix4 &LLViewerCamera::getProjection() const |
@@ -182,7 +198,7 @@ void LLViewerCamera::calcProjection(const F32 far_distance) const | |||
182 | // height. | 198 | // height. |
183 | 199 | ||
184 | //static | 200 | //static |
185 | void LLViewerCamera::updateFrustumPlanes(LLCamera& camera, BOOL ortho, BOOL zflip) | 201 | void LLViewerCamera::updateFrustumPlanes(LLCamera& camera, BOOL ortho, BOOL zflip, BOOL no_hacks) |
186 | { | 202 | { |
187 | GLint* viewport = (GLint*) gGLViewport; | 203 | GLint* viewport = (GLint*) gGLViewport; |
188 | GLdouble* model = gGLModelView; | 204 | GLdouble* model = gGLModelView; |
@@ -191,7 +207,27 @@ void LLViewerCamera::updateFrustumPlanes(LLCamera& camera, BOOL ortho, BOOL zfli | |||
191 | 207 | ||
192 | LLVector3 frust[8]; | 208 | LLVector3 frust[8]; |
193 | 209 | ||
194 | if (zflip) | 210 | if (no_hacks) |
211 | { | ||
212 | gluUnProject(viewport[0],viewport[1],0,model,proj,viewport,&objX,&objY,&objZ); | ||
213 | frust[0].setVec((F32)objX,(F32)objY,(F32)objZ); | ||
214 | gluUnProject(viewport[0]+viewport[2],viewport[1],0,model,proj,viewport,&objX,&objY,&objZ); | ||
215 | frust[1].setVec((F32)objX,(F32)objY,(F32)objZ); | ||
216 | gluUnProject(viewport[0]+viewport[2],viewport[1]+viewport[3],0,model,proj,viewport,&objX,&objY,&objZ); | ||
217 | frust[2].setVec((F32)objX,(F32)objY,(F32)objZ); | ||
218 | gluUnProject(viewport[0],viewport[1]+viewport[3],0,model,proj,viewport,&objX,&objY,&objZ); | ||
219 | frust[3].setVec((F32)objX,(F32)objY,(F32)objZ); | ||
220 | |||
221 | gluUnProject(viewport[0],viewport[1],1,model,proj,viewport,&objX,&objY,&objZ); | ||
222 | frust[4].setVec((F32)objX,(F32)objY,(F32)objZ); | ||
223 | gluUnProject(viewport[0]+viewport[2],viewport[1],1,model,proj,viewport,&objX,&objY,&objZ); | ||
224 | frust[5].setVec((F32)objX,(F32)objY,(F32)objZ); | ||
225 | gluUnProject(viewport[0]+viewport[2],viewport[1]+viewport[3],1,model,proj,viewport,&objX,&objY,&objZ); | ||
226 | frust[6].setVec((F32)objX,(F32)objY,(F32)objZ); | ||
227 | gluUnProject(viewport[0],viewport[1]+viewport[3],1,model,proj,viewport,&objX,&objY,&objZ); | ||
228 | frust[7].setVec((F32)objX,(F32)objY,(F32)objZ); | ||
229 | } | ||
230 | else if (zflip) | ||
195 | { | 231 | { |
196 | gluUnProject(viewport[0],viewport[1]+viewport[3],0,model,proj,viewport,&objX,&objY,&objZ); | 232 | gluUnProject(viewport[0],viewport[1]+viewport[3],0,model,proj,viewport,&objX,&objY,&objZ); |
197 | frust[0].setVec((F32)objX,(F32)objY,(F32)objZ); | 233 | frust[0].setVec((F32)objX,(F32)objY,(F32)objZ); |
@@ -231,7 +267,7 @@ void LLViewerCamera::updateFrustumPlanes(LLCamera& camera, BOOL ortho, BOOL zfli | |||
231 | 267 | ||
232 | if (ortho) | 268 | if (ortho) |
233 | { | 269 | { |
234 | LLVector3 far_shift = LLVector3(camera.getFar()*2.0f,0,0); | 270 | LLVector3 far_shift = camera.getAtAxis()*camera.getFar()*2.f; |
235 | for (U32 i = 0; i < 4; i++) | 271 | for (U32 i = 0; i < 4; i++) |
236 | { | 272 | { |
237 | frust[i+4] = frust[i] + far_shift; | 273 | frust[i+4] = frust[i] + far_shift; |
@@ -368,13 +404,13 @@ void LLViewerCamera::setPerspective(BOOL for_selection, | |||
368 | 404 | ||
369 | updateFrustumPlanes(*this); | 405 | updateFrustumPlanes(*this); |
370 | 406 | ||
371 | if (gSavedSettings.getBOOL("CameraOffset")) | 407 | /*if (gSavedSettings.getBOOL("CameraOffset")) |
372 | { | 408 | { |
373 | glMatrixMode(GL_PROJECTION); | 409 | glMatrixMode(GL_PROJECTION); |
374 | glTranslatef(0,0,-50); | 410 | glTranslatef(0,0,-50); |
375 | glRotatef(20.0,1,0,0); | 411 | glRotatef(20.0,1,0,0); |
376 | glMatrixMode(GL_MODELVIEW); | 412 | glMatrixMode(GL_MODELVIEW); |
377 | } | 413 | }*/ |
378 | } | 414 | } |
379 | 415 | ||
380 | 416 | ||
@@ -732,3 +768,38 @@ BOOL LLViewerCamera::areVertsVisible(LLViewerObject* volumep, BOOL all_verts) | |||
732 | } | 768 | } |
733 | return all_verts; | 769 | return all_verts; |
734 | } | 770 | } |
771 | |||
772 | // changes local camera and broadcasts change | ||
773 | /* virtual */ void LLViewerCamera::setView(F32 vertical_fov_rads) | ||
774 | { | ||
775 | F32 old_fov = LLViewerCamera::getInstance()->getView(); | ||
776 | |||
777 | // cap the FoV | ||
778 | vertical_fov_rads = llclamp(vertical_fov_rads, getMinView(), getMaxView()); | ||
779 | |||
780 | if (vertical_fov_rads == old_fov) return; | ||
781 | |||
782 | // send the new value to the simulator | ||
783 | LLMessageSystem* msg = gMessageSystem; | ||
784 | msg->newMessageFast(_PREHASH_AgentFOV); | ||
785 | msg->nextBlockFast(_PREHASH_AgentData); | ||
786 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | ||
787 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | ||
788 | msg->addU32Fast(_PREHASH_CircuitCode, gMessageSystem->mOurCircuitCode); | ||
789 | |||
790 | msg->nextBlockFast(_PREHASH_FOVBlock); | ||
791 | msg->addU32Fast(_PREHASH_GenCounter, 0); | ||
792 | msg->addF32Fast(_PREHASH_VerticalAngle, vertical_fov_rads); | ||
793 | |||
794 | gAgent.sendReliableMessage(); | ||
795 | |||
796 | // sync the camera with the new value | ||
797 | LLCamera::setView(vertical_fov_rads); // call base implementation | ||
798 | } | ||
799 | |||
800 | void LLViewerCamera::setDefaultFOV(F32 vertical_fov_rads) { | ||
801 | vertical_fov_rads = llclamp(vertical_fov_rads, getMinView(), getMaxView()); | ||
802 | setView(vertical_fov_rads); | ||
803 | mCameraFOVDefault = vertical_fov_rads; | ||
804 | } | ||
805 | |||