Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 850 vs 853 for /trunk/Source Code/Rendering/Camera/Camera.cpp

Diff revisions: vs.
  @@ -72,6 +72,7 @@
72 72
73 73 setEye(camera.getEye());
74 74 setRotation(camera._orientation);
75 + updateLookAt();
75 76 }
76 77
77 78 void Camera::updateInternal(const U64 deltaTime) {
  @@ -193,38 +194,12 @@
193 194 const mat4<F32>& Camera::lookAt(const vec3<F32>& eye,
194 195 const vec3<F32>& target,
195 196 const vec3<F32>& up) {
196 - vec3<F32> xAxis, yAxis, zAxis;
197 -
198 197 _eye.set(eye);
199 198 _target.set(target);
200 -
201 - zAxis.set(eye - target);
202 -
203 - zAxis.normalize();
204 - xAxis.cross(up, zAxis);
205 - xAxis.normalize();
206 - yAxis.cross(zAxis, xAxis);
207 - yAxis.normalize();
208 -
209 - _viewMatrix.m[0][0] = xAxis.x;
210 - _viewMatrix.m[1][0] = xAxis.y;
211 - _viewMatrix.m[2][0] = xAxis.z;
212 - _viewMatrix.m[3][0] = xAxis.dot(eye);
213 -
214 - _viewMatrix.m[0][1] = yAxis.x;
215 - _viewMatrix.m[1][1] = yAxis.y;
216 - _viewMatrix.m[2][1] = yAxis.z;
217 - _viewMatrix.m[3][1] = yAxis.dot(eye);
218 -
219 - _viewMatrix.m[0][2] = zAxis.x;
220 - _viewMatrix.m[1][2] = zAxis.y;
221 - _viewMatrix.m[2][2] = zAxis.z;
222 - _viewMatrix.m[3][2] = zAxis.dot(eye);
223 -
199 + _viewMatrix.lookAt(_eye, _target, up);
224 200 // Extract the pitch angle from the view matrix.
225 - _accumPitchDegrees = Angle::RadiansToDegrees(asinf(zAxis.y));
226 -
227 - _orientation.fromMatrix(_viewMatrix);
201 + _accumPitchDegrees = Angle::RadiansToDegrees(std::asinf(getForwardDir().y));
202 + _orientation.fromLookAt(_eye - _target, up);
228 203
229 204 _viewMatrixDirty = false;
230 205 _frustumDirty = true;
  @@ -243,11 +218,12 @@
243 218 }
244 219
245 220 void Camera::reflect(const Plane<F32>& reflectionPlane) {
246 - updateLookAt();
247 -
248 - mat4<F32> reflectedMatrix(getViewMatrix());
221 + mat4<F32> reflectedMatrix;
249 222 reflectedMatrix.reflect(reflectionPlane);
250 - lookAt(reflectedMatrix * getEye(), getTarget(), reflectedMatrix * getUpDir());
223 +
224 + lookAt(reflectedMatrix * getEye(),
225 + getTarget(),
226 + reflectedMatrix * getUpDir());
251 227 }
252 228
253 229 bool Camera::updateProjection() {