diff options
author | Hein-Pieter van Braam <hp@tmm.cx> | 2019-04-23 06:20:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-23 06:20:13 +0300 |
commit | 5d33f241f0f9330105a511a4450ffd5137850609 (patch) | |
tree | d8ad457c419ab3cc9637e1f7b3869094b513f553 /core/math | |
parent | 01f7166d09662889ae8e3a827ef95c2004ec3e53 (diff) | |
parent | 54b95b6c5ab476707a5ec3a210266716dfbcd3fe (diff) |
Merge pull request #26064 from JFonS/add_frustum_camera_mode
Add FRUSTUM camera mode, allowing tilted frustums
Diffstat (limited to 'core/math')
-rw-r--r-- | core/math/camera_matrix.cpp | 8 | ||||
-rw-r--r-- | core/math/camera_matrix.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp index caf08c7379..f615cc8c65 100644 --- a/core/math/camera_matrix.cpp +++ b/core/math/camera_matrix.cpp @@ -210,6 +210,14 @@ void CameraMatrix::set_frustum(real_t p_left, real_t p_right, real_t p_bottom, r te[15] = 0; } +void CameraMatrix::set_frustum(real_t p_size, real_t p_aspect, Vector2 p_offset, real_t p_near, real_t p_far, bool p_flip_fov) { + if (!p_flip_fov) { + p_size *= p_aspect; + } + + set_frustum(-p_size / 2 + p_offset.x, +p_size / 2 + p_offset.x, -p_size / p_aspect / 2 + p_offset.y, +p_size / p_aspect / 2 + p_offset.y, p_near, p_far); +} + real_t CameraMatrix::get_z_far() const { const real_t *matrix = (const real_t *)this->matrix; diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h index 015588a8cb..3bcf48f5da 100644 --- a/core/math/camera_matrix.h +++ b/core/math/camera_matrix.h @@ -61,6 +61,7 @@ struct CameraMatrix { void set_orthogonal(real_t p_left, real_t p_right, real_t p_bottom, real_t p_top, real_t p_znear, real_t p_zfar); void set_orthogonal(real_t p_size, real_t p_aspect, real_t p_znear, real_t p_zfar, bool p_flip_fov = false); void set_frustum(real_t p_left, real_t p_right, real_t p_bottom, real_t p_top, real_t p_near, real_t p_far); + void set_frustum(real_t p_size, real_t p_aspect, Vector2 p_offset, real_t p_near, real_t p_far, bool p_flip_fov = false); static real_t get_fovy(real_t p_fovx, real_t p_aspect) { |