Commit: 62dba60e49e79e77ecb11027e723823767c13854
Author: Campbell Barton
Date:   Tue Feb 4 21:55:57 2020 +1100
Branches: blender-v2.82-release
https://developer.blender.org/rB62dba60e49e79e77ecb11027e723823767c13854

GPU: add projection matrix function to set only near/far clipping

Useful when UI code needs to extend the clipping range.

===================================================================

M       source/blender/gpu/GPU_matrix.h
M       source/blender/gpu/intern/gpu_matrix.c

===================================================================

diff --git a/source/blender/gpu/GPU_matrix.h b/source/blender/gpu/GPU_matrix.h
index a424f3180de..1dcb83be11f 100644
--- a/source/blender/gpu/GPU_matrix.h
+++ b/source/blender/gpu/GPU_matrix.h
@@ -90,6 +90,8 @@ void GPU_matrix_identity_projection_set(void);
 void GPU_matrix_projection_set(const float m[4][4]);
 
 void GPU_matrix_ortho_set(float left, float right, float bottom, float top, 
float near, float far);
+void GPU_matrix_ortho_set_z(float near, float far);
+
 void GPU_matrix_frustum_set(
     float left, float right, float bottom, float top, float near, float far);
 void GPU_matrix_perspective_set(float fovy, float aspect, float near, float 
far);
diff --git a/source/blender/gpu/intern/gpu_matrix.c 
b/source/blender/gpu/intern/gpu_matrix.c
index 5e44a950ba7..8260e1496ff 100644
--- a/source/blender/gpu/intern/gpu_matrix.c
+++ b/source/blender/gpu/intern/gpu_matrix.c
@@ -421,6 +421,14 @@ void GPU_matrix_ortho_set(float left, float right, float 
bottom, float top, floa
   gpu_matrix_state_active_set_dirty(true);
 }
 
+void GPU_matrix_ortho_set_z(float near, float far)
+{
+  CHECKMAT(Projection);
+  Projection[2][2] = -2.0f / (far - near);
+  Projection[3][2] = -(far + near) / (far - near);
+  gpu_matrix_state_active_set_dirty(true);
+}
+
 void GPU_matrix_ortho_2d_set(float left, float right, float bottom, float top)
 {
   Mat4 m;

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to