Subversion Repository Public Repository

Divide-Framework

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

Diff Revisions 1020 vs 1021 for /trunk/Source Code/Rendering/Camera/Frustum.cpp

Diff revisions: vs.
  @@ -139,9 +139,7 @@
139 139 }
140 140
141 141 void Frustum::Extract(const mat4<F32>& viewMatrix, const mat4<F32>& projectionMatrix) {
142 - mat4<F32>::Multiply(viewMatrix, projectionMatrix, _viewProjectionMatrixCache);
143 -
144 - computePlanes(_viewProjectionMatrixCache);
142 + computePlanes(viewMatrix * projectionMatrix);
145 143 }
146 144
147 145 void Frustum::intersectionPoint(const Plane<F32>& a, const Plane<F32>& b,
  @@ -193,9 +191,9 @@
193 191 });
194 192 }
195 193
196 - void Frustum::computePlanes(const mat4<F32>& invViewProj) {
194 + void Frustum::computePlanes(const mat4<F32>& viewProjMatrix) {
197 195 #if 0
198 - computeFrustumPlanes(invViewProj.getInverse(), _frustumPlanes);
196 + computeFrustumPlanes(viewProjMatrix, _frustumPlanes);
199 197 #else
200 198 Plane<F32>& leftPlane = _frustumPlanes[to_base(FrustPlane::PLANE_LEFT)];
201 199 Plane<F32>& rightPlane = _frustumPlanes[to_base(FrustPlane::PLANE_RIGHT)];
  @@ -204,7 +202,7 @@
204 202 Plane<F32>& topPlane = _frustumPlanes[to_base(FrustPlane::PLANE_TOP)];
205 203 Plane<F32>& bottomPlane = _frustumPlanes[to_base(FrustPlane::PLANE_BOTTOM)];
206 204
207 - F32 const* mat = &invViewProj.mat[0];
205 + F32 const* mat = &viewProjMatrix.mat[0];
208 206
209 207 leftPlane.set( mat[3] + mat[0], mat[7] + mat[4], mat[11] + mat[8], mat[15] + mat[12]);
210 208 rightPlane.set( mat[3] - mat[0], mat[7] - mat[4], mat[11] - mat[8], mat[15] - mat[12]);
  @@ -221,16 +219,18 @@
221 219 _pointsDirty = true;
222 220 }
223 221
224 - void Frustum::computePlanes(const mat4<F32>& invViewProj, Plane<F32>* planesOut) {
222 + void Frustum::computePlanes(const mat4<F32>& viewProjMatrix, Plane<F32>* planesOut) {
225 223 std::array<vec4<F32>, to_base(Frustum::FrustPlane::COUNT)> planesTemp;
226 224
227 - computePlanes(invViewProj, planesTemp.data());
225 + computePlanes(viewProjMatrix, planesTemp.data());
228 226 for (U8 i = 0; i < to_U8(Frustum::FrustPoints::COUNT); ++i) {
229 227 planesOut[i].set(planesTemp[i]);
230 228 }
231 229 }
232 230
233 - void Frustum::computePlanes(const mat4<F32>& invViewProj, vec4<F32>* planesOut) {
231 + void Frustum::computePlanes(const mat4<F32>& viewProjMatrix, vec4<F32>* planesOut) {
232 + const mat4<F32> invViewProj(viewProjMatrix.getInverse());
233 +
234 234 static const vec4<F32> unitVecs[] = { vec4<F32>(-1, -1, -1, 1),
235 235 vec4<F32>(-1 , 1, -1, 1),
236 236 vec4<F32>(-1, -1, 1, 1),