Skip to content

Commit 4ffdce1

Browse files
committed
Updates chapter25/chapter25.md
Auto commit by GitBook Editor
1 parent da98822 commit 4ffdce1

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

chapter25/chapter25.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,43 @@ You can play with activating and deactivating the filtering and can check the in
150150

151151
# Optimizations - Frustum Culling \(II\)
152152

153-
Once the basis of frustum culling has been explained, we can get advatange of more refined methods that the [JOML](https://github.com/JOML-CI/JOML "JOML")library provides. In particular, it provdies a class named `FrustumIntersection `which extracts the planes of the veiw frustum in a more efficient way as described in this [paper](http://gamedevs.org/uploads/fast-extraction-viewing-frustum-planes-from-world-view-projection-matrix.pdf "paper").
153+
Once the basis of frustum culling has been explained, we can get advatange of more refined methods that the [JOML](https://github.com/JOML-CI/JOML "JOML")library provides. In particular, it provdies a class named `FrustumIntersection`which extracts the planes of the veiw frustum in a more efficient way as described in this [paper](http://gamedevs.org/uploads/fast-extraction-viewing-frustum-planes-from-world-view-projection-matrix.pdf "paper"). Besides that, this class also provides methods for testing bounding boxes, points and spheres.
154154

155+
So, let's change the `FrustumCullingFilter` class. The attributes and constructor are simplified like this:
155156

157+
```
158+
public class FrustumCullingFilter {
159+
160+
private final Matrix4f prjViewMatrix;
161+
162+
private FrustumIntersection frustumInt;
163+
164+
public FrustumCullingFilter() {
165+
prjViewMatrix = new Matrix4f();
166+
frustumInt = new FrustumIntersection();
167+
}
168+
```
169+
170+
The updateFrustum method just delegates the plane extraction to the `FrustumIntersection`instance.
171+
172+
```
173+
public void updateFrustum(Matrix4f projMatrix, Matrix4f viewMatrix) {
174+
// Calculate projection view matrix
175+
prjViewMatrix.set(projMatrix);
176+
prjViewMatrix.mul(viewMatrix);
177+
// Update frustum intersection class
178+
frustumInt.set(prjViewMatrix);
179+
}
180+
181+
```
182+
183+
And the method that `insideFrustum `method is vene more simple:
184+
185+
```
186+
public boolean insideFrustum(float x0, float y0, float z0, float boundingRadius) {
187+
return frustumInt.testSphere(x0, y0, z0, boundingRadius);
188+
}
189+
```
190+
191+
With this approach you will be able to vene get a few more FPS.
156192

0 commit comments

Comments
 (0)