Skip to content

Commit 9b5f2fa

Browse files
committed
Added camera info.
1 parent fa7a073 commit 9b5f2fa

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/main/java/engine/debug/DebugInfoUpdater.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import engine.input.Input;
1010
import engine.input.Key;
1111
import engine.scene.Scene;
12+
import engine.scene.camera.Camera;
13+
import math.Mathf;
1214

1315
/**
1416
* The {@code DebugInfoUpdater} class is responsible for updating debug information displayed by a
@@ -24,9 +26,11 @@ public class DebugInfoUpdater {
2426
private static final String CATEGORY_SCENE = "Scene";
2527

2628
private static final String CATEGORY_SYSTEM = "System";
27-
29+
2830
private static final String CATEGORY_OS = "OS";
2931

32+
private static final String CATEGORY_CAMERA = "Camera";
33+
3034
private final DebugOverlay debugOverlay;
3135

3236
private final PerformanceMetrics performanceMetrics = new PerformanceMetrics();
@@ -80,6 +84,7 @@ public void update(Timer timer, Scene activeScene, Input input) {
8084
updateInputMetrics(input);
8185
if (activeScene != null) {
8286
updateSceneMetrics(activeScene);
87+
updateCameraInfo(activeScene.getActiveCamera());
8388
}
8489
updateOsMetrics();
8590
}
@@ -91,12 +96,20 @@ private String keysToString(Collection<Key> keys) {
9196
}
9297
return pressedKeys;
9398
}
94-
99+
100+
private void updateCameraInfo(Camera camera) {
101+
if (camera == null) return;
102+
setInfo(CATEGORY_CAMERA, "Aspect", camera.getAspectRatio());
103+
setInfo(CATEGORY_CAMERA, "FOV", Mathf.toDegrees(camera.getFieldOfView()));
104+
setInfo(CATEGORY_CAMERA, "Near", Mathf.toDegrees(camera.getNearPlane()));
105+
setInfo(CATEGORY_CAMERA, "Far", Mathf.toDegrees(camera.getFarPlane()));
106+
}
107+
95108
private void updateOsMetrics() {
96-
setInfo(CATEGORY_OS, "Name", osBean.getName());
97-
setInfo(CATEGORY_OS, "Arch", osBean.getArch());
98-
setInfo(CATEGORY_OS, "Processors", osBean.getAvailableProcessors());
99-
setInfo(CATEGORY_OS, "Version", osBean.getVersion());
109+
setInfo(CATEGORY_OS, "Name", osBean.getName());
110+
setInfo(CATEGORY_OS, "Arch", osBean.getArch());
111+
setInfo(CATEGORY_OS, "Processors", osBean.getAvailableProcessors());
112+
setInfo(CATEGORY_OS, "Version", osBean.getVersion());
100113
}
101114

102115
private void updateInputMetrics(Input input) {

0 commit comments

Comments
 (0)