Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib/intern/math_geom.c')
-rw-r--r--source/blender/blenlib/intern/math_geom.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index d54ec0f1ac1..fa50bf202a8 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -4709,6 +4709,25 @@ void perspective_m4(float mat[4][4],
mat[3][3] = 0.0f;
}
+void perspective_m4_fov(float mat[4][4],
+ const float angle_left,
+ const float angle_right,
+ const float angle_up,
+ const float angle_down,
+ const float nearClip,
+ const float farClip)
+{
+ const float tan_angle_left = tanf(angle_left);
+ const float tan_angle_right = tanf(angle_right);
+ const float tan_angle_bottom = tanf(angle_up);
+ const float tan_angle_top = tanf(angle_down);
+
+ perspective_m4(
+ mat, tan_angle_left, tan_angle_right, tan_angle_top, tan_angle_bottom, nearClip, farClip);
+ mat[0][0] /= nearClip;
+ mat[1][1] /= nearClip;
+}
+
/* translate a matrix created by orthographic_m4 or perspective_m4 in XY coords
* (used to jitter the view) */
void window_translate_m4(float winmat[4][4], float perspmat[4][4], const float x, const float y)