Subversion Repository Public Repository

Divide-Framework

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

Diff Revisions 716 vs 744 for /trunk/Source Code/Rendering/Camera/Camera.cpp

Diff revisions: vs.
  @@ -73,29 +73,54 @@
73 73 _cameraZoomSpeed = _zoomSpeedFactor * timeFactor;
74 74 }
75 75
76 - void Camera::updateProjection(bool force) {
76 + void Camera::updateProjection(bool updateGPU) {
77 77 assert(_isActive);
78 78
79 - if (_projectionDirty || force) {
79 + if (updateGPU) {
80 + GFXDevice& gfx = GFX_DEVICE;
81 +
82 + F32* projectionMatrixData = nullptr;
83 + projectionMatrixData = _isOrthoCamera ? gfx.setProjection(_orthoRect,
84 + _zPlanes)
85 +
86 + : gfx.setProjection(_verticalFoV,
87 + _aspectRatio,
88 + _zPlanes);
80 89 if (_projectionDirty) {
81 - _projectionMatrix.set(
82 - _isOrthoCamera ? GFX_DEVICE.setProjection(_orthoRect, _zPlanes)
83 - : GFX_DEVICE.setProjection(_verticalFoV, _aspectRatio, _zPlanes));
90 + _projectionMatrix.set(projectionMatrixData);
91 + _frustumDirty = true;
84 92 _projectionDirty = false;
93 + }
94 +
95 + } else {
96 + if (_projectionDirty) {
97 + if (_isOrthoCamera) {
98 + _projectionMatrix.ortho(_orthoRect.x,
99 + _orthoRect.y,
100 + _orthoRect.z,
101 + _orthoRect.w,
102 + _zPlanes.x,
103 + _zPlanes.y);
104 + } else {
105 + _projectionMatrix.perspective(Angle::DegreesToRadians(_verticalFoV),
106 + _aspectRatio,
107 + _zPlanes.x,
108 + _zPlanes.y);
109 + }
85 110 _frustumDirty = true;
86 - } else {
87 - _isOrthoCamera ? GFX_DEVICE.setProjection(_orthoRect, _zPlanes)
88 - : GFX_DEVICE.setProjection(_verticalFoV,_aspectRatio, _zPlanes);
111 + _projectionDirty = false;
89 112 }
90 113 }
91 114 }
92 115
93 116 void Camera::onActivate() {
94 117 _isActive = true;
95 - updateProjection(true);
118 + updateProjection(false);
96 119 }
97 120
98 - void Camera::onDeactivate() { _isActive = false; }
121 + void Camera::onDeactivate() {
122 + _isActive = false;
123 + }
99 124
100 125 void Camera::setGlobalRotation(F32 yaw, F32 pitch, F32 roll) {
101 126 if (_rotationLocked) {
  @@ -263,7 +288,8 @@
263 288 void Camera::lookAtInternal() {
264 289 assert(_isActive);
265 290
266 - updateMatrices();
291 + updateViewMatrix();
292 + updateProjection();
267 293
268 294 // Tell the Rendering API to draw from our desired PoV
269 295 GFX_DEVICE.lookAt(_reflectionRendering