[Bf-blender-cvs] [61f4a7d1f59] master: Fix T72372: color picker is unreliable with large "clip end" values
mano-wii
noreply at git.blender.org
Wed Dec 18 13:41:24 CET 2019
Commit: 61f4a7d1f593e3870e7a0df4b32e95516b236eef
Author: mano-wii
Date: Wed Dec 18 09:41:03 2019 -0300
Branches: master
https://developer.blender.org/rB61f4a7d1f593e3870e7a0df4b32e95516b236eef
Fix T72372: color picker is unreliable with large "clip end" values
By my tests, `planes_from_projmat` proved to be more accurate than the current solution.
Differential Revision: https://developer.blender.org/D6434
===================================================================
M source/blender/draw/intern/draw_manager_data.c
===================================================================
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index 83b764317a9..98474c81209 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -1416,53 +1416,19 @@ static void draw_frustum_boundbox_calc(const float (*viewinv)[4],
}
}
-static void draw_frustum_culling_planes_calc(const BoundBox *bbox, float (*frustum_planes)[4])
+static void draw_frustum_culling_planes_calc(const float (*persmat)[4], float (*frustum_planes)[4])
{
- /* TODO See if planes_from_projmat cannot do the job. */
+ planes_from_projmat(persmat,
+ frustum_planes[0],
+ frustum_planes[5],
+ frustum_planes[3],
+ frustum_planes[1],
+ frustum_planes[4],
+ frustum_planes[2]);
- /* Compute clip planes using the world space frustum corners. */
+ /* Normalize. */
for (int p = 0; p < 6; p++) {
- int q, r, s;
- switch (p) {
- case 0:
- q = 1;
- r = 2;
- s = 3;
- break; /* -X */
- case 1:
- q = 0;
- r = 4;
- s = 5;
- break; /* -Y */
- case 2:
- q = 1;
- r = 5;
- s = 6;
- break; /* +Z (far) */
- case 3:
- q = 2;
- r = 6;
- s = 7;
- break; /* +Y */
- case 4:
- q = 0;
- r = 3;
- s = 7;
- break; /* -Z (near) */
- default:
- q = 4;
- r = 7;
- s = 6;
- break; /* +X */
- }
-
- normal_quad_v3(frustum_planes[p], bbox->vec[p], bbox->vec[q], bbox->vec[r], bbox->vec[s]);
- /* Increase precision and use the mean of all 4 corners. */
- frustum_planes[p][3] = -dot_v3v3(frustum_planes[p], bbox->vec[p]);
- frustum_planes[p][3] += -dot_v3v3(frustum_planes[p], bbox->vec[q]);
- frustum_planes[p][3] += -dot_v3v3(frustum_planes[p], bbox->vec[r]);
- frustum_planes[p][3] += -dot_v3v3(frustum_planes[p], bbox->vec[s]);
- frustum_planes[p][3] *= 0.25f;
+ frustum_planes[p][3] /= normalize_v3(frustum_planes[p]);
}
}
@@ -1720,7 +1686,7 @@ void DRW_view_update(DRWView *view,
}
draw_frustum_boundbox_calc(viewinv, winmat, &view->frustum_corners);
- draw_frustum_culling_planes_calc(&view->frustum_corners, view->frustum_planes);
+ draw_frustum_culling_planes_calc(view->storage.persmat, view->frustum_planes);
draw_frustum_bound_sphere_calc(
&view->frustum_corners, viewinv, winmat, wininv, &view->frustum_bsphere);
More information about the Bf-blender-cvs
mailing list