diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-06-28 08:44:16 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-06-28 08:46:16 +0300 |
commit | 6f42e69b58ce4b9a2f0370d22b41f1c76bf21f89 (patch) | |
tree | 7c20860e70c7ea09433e860a5485c8044152b3ad /source/blender/editors/space_view3d | |
parent | 7efc87dcd2162b9294cb84512b7445fe1565f058 (diff) |
Cleanup: de-duplicate 3D-view depth calculation function
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_project.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c index 49da1764660..8a900a4e898 100644 --- a/source/blender/editors/space_view3d/view3d_project.c +++ b/source/blender/editors/space_view3d/view3d_project.c @@ -330,6 +330,17 @@ float ED_view3d_calc_zfac(const RegionView3D *rv3d, const float co[3], bool *r_f return zfac; } +/** + * Calculate a depth value from `co` (result should only be used for comparison). + */ +float ED_view3d_calc_depth_for_comparison(const RegionView3D *rv3d, const float co[3]) +{ + if (rv3d->is_persp) { + return ED_view3d_calc_zfac(rv3d, co, NULL); + } + return -dot_v3v3(rv3d->viewinv[2], co); +} + static void view3d_win_to_ray_segment(struct Depsgraph *depsgraph, const ARegion *region, const View3D *v3d, |