summaryrefslogtreecommitdiff
path: root/core/math/camera_matrix.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2020-12-18 16:19:12 +0100
committerGitHub <noreply@github.com>2020-12-18 16:19:12 +0100
commit7ad29ed64e850fd43ba7ceb1cfaab4e015ef7b97 (patch)
treef1d46d8194f01e56cd3a4d042b9b33ba728c6f62 /core/math/camera_matrix.cpp
parent36b4e035dc7c410c29cda4446f8daa2e00a31da0 (diff)
parentd2302f53d6ad80943e7f4245ac572003f1681d00 (diff)
Merge pull request #44468 from reduz/implement-lod
Implement automatic LOD (Level of Detail)
Diffstat (limited to 'core/math/camera_matrix.cpp')
-rw-r--r--core/math/camera_matrix.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp
index 5e5efb6356..f29cb7a269 100644
--- a/core/math/camera_matrix.cpp
+++ b/core/math/camera_matrix.cpp
@@ -655,6 +655,17 @@ real_t CameraMatrix::get_fov() const {
}
}
+float CameraMatrix::get_lod_multiplier() const {
+ if (is_orthogonal()) {
+ return get_viewport_half_extents().x;
+ } else {
+ float zn = get_z_near();
+ float width = get_viewport_half_extents().x * 2.0;
+ return 1.0 / (zn / width);
+ }
+
+ //usage is lod_size / (lod_distance * multiplier) < threshold
+}
void CameraMatrix::make_scale(const Vector3 &p_scale) {
set_identity();
matrix[0][0] = p_scale.x;