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:
authorCampbell Barton <ideasman42@gmail.com>2019-06-22 06:19:11 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-06-22 06:21:30 +0300
commit2642ba13b4639fc524bc77e30c112942cd3f5355 (patch)
tree527842604fdd299328256700ae51b1f2f0c1496c /source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
parent1b2b9c6b1f203048d5abf88083823614b405a790 (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/windowmanager/gizmo/intern/wm_gizmo_map.c')
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
index 6915ea91c8e..f57760cdc2b 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
@@ -571,8 +571,11 @@ static int gizmo_find_intersected_3d_intern(wmGizmo **visible_gizmos,
const int viewport[4] = {0, 0, ar->winx, ar->winy};
float co_3d_origin[3];
- GPU_matrix_unproject_model_inverted(
- co_screen, rv3d->viewinv, rv3d->winmat, viewport, co_3d_origin);
+ /* Avoid multiple calculations. */
+ struct GPUMatrixUnproject_Precalc unproj_precalc;
+ GPU_matrix_unproject_precalc(&unproj_precalc, rv3d->viewmat, rv3d->winmat, viewport);
+
+ GPU_matrix_unproject_with_precalc(&unproj_precalc, co_screen, co_3d_origin);
GLuint *buf_iter = buffer;
int hit_found = -1;
@@ -583,7 +586,7 @@ static int gizmo_find_intersected_3d_intern(wmGizmo **visible_gizmos,
wmGizmo *gz = visible_gizmos[buf_iter[3] >> 8];
float co_3d[3];
co_screen[2] = int_as_float(buf_iter[1]);
- GPU_matrix_unproject_model_inverted(co_screen, rv3d->viewinv, rv3d->winmat, viewport, co_3d);
+ GPU_matrix_unproject_with_precalc(&unproj_precalc, co_screen, co_3d);
float select_bias = gz->select_bias;
if ((gz->flag & WM_GIZMO_DRAW_NO_SCALE) == 0) {
select_bias *= gz->scale_final;