diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-06-22 06:19:11 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-06-22 06:21:30 +0300 |
commit | 2642ba13b4639fc524bc77e30c112942cd3f5355 (patch) | |
tree | 527842604fdd299328256700ae51b1f2f0c1496c /source/blender/gpu/GPU_matrix.h | |
parent | 1b2b9c6b1f203048d5abf88083823614b405a790 (diff) |
GPU_matrix: Add GPU_matrix_unproject_precalc
Pre-calculates values needed for unprojecting to avoid
a matrix invert and extracting projection matrix dimensions for
every call to GPU_matrix_unproject.
Use for gizmo selection drawing.
Diffstat (limited to 'source/blender/gpu/GPU_matrix.h')
-rw-r--r-- | source/blender/gpu/GPU_matrix.h | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/source/blender/gpu/GPU_matrix.h b/source/blender/gpu/GPU_matrix.h index 6f7d25dafa7..61622c40ff0 100644 --- a/source/blender/gpu/GPU_matrix.h +++ b/source/blender/gpu/GPU_matrix.h @@ -96,21 +96,38 @@ void GPU_matrix_perspective_set(float fovy, float aspect, float near, float far) /* 3D Projection between Window and World Space */ +struct GPUMatrixUnproject_Precalc { + float model_inverted[4][4]; + float view[4]; + bool is_persp; + /** Result of 'projmat_dimensions'. */ + struct { + float xmin, xmax; + float ymin, ymax; + float zmin, zmax; + } dims; +}; + +bool GPU_matrix_unproject_precalc(struct GPUMatrixUnproject_Precalc *unproj_precalc, + const float model[4][4], + const float proj[4][4], + const int view[4]); + void GPU_matrix_project(const float world[3], const float model[4][4], const float proj[4][4], const int view[4], - float win[3]); + float r_win[3]); + bool GPU_matrix_unproject(const float win[3], const float model[4][4], const float proj[4][4], const int view[4], - float world[3]); -void GPU_matrix_unproject_model_inverted(const float win[3], - const float model_inverted[4][4], - const float proj[4][4], - const int view[4], - float world[3]); + float r_world[3]); + +void GPU_matrix_unproject_with_precalc(const struct GPUMatrixUnproject_Precalc *unproj_precalc, + const float win[3], + float r_world[3]); /* 2D Projection Matrix */ |