diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-03-08 17:06:50 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-03-10 04:18:25 +0300 |
commit | f043365c38cb75443d22c3d4c66e15852b4846f6 (patch) | |
tree | 355e1c9ce8b627dace7cd7a377260458b161e7fe /source/blender | |
parent | 9cd09fee6ae57c194c73faecae0ab01674f52475 (diff) |
DRW: Culling: Fix precision error.
This was triggering the BLI_assert(fac >= 0.0f);.
Clamp fac to ensure correct value for release builds.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/draw/intern/draw_manager_exec.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index 896525a10eb..1c149330005 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -387,7 +387,6 @@ static void draw_clipping_setup_from_view(void) if (DST.clipping.updated) return; - float (*viewprojinv)[4] = DST.view_data.matstate.mat[DRW_MAT_PERSINV]; float (*viewinv)[4] = DST.view_data.matstate.mat[DRW_MAT_VIEWINV]; float (*projmat)[4] = DST.view_data.matstate.mat[DRW_MAT_WIN]; float (*projinv)[4] = DST.view_data.matstate.mat[DRW_MAT_WININV]; @@ -399,7 +398,9 @@ static void draw_clipping_setup_from_view(void) /* Extract the 8 corners (world space). */ for (int i = 0; i < 8; i++) { - mul_project_m4_v3(viewprojinv, bbox.vec[i]); + /* Use separate matrix mul for more precision. */ + mul_project_m4_v3(projinv, bbox.vec[i]); + mul_m4_v3(viewinv, bbox.vec[i]); } /* Compute clip planes using the world space frustum corners. */ @@ -458,9 +459,7 @@ static void draw_clipping_setup_from_view(void) /* The goal is to get the smallest sphere, * not the sphere that passes through each corner */ - if (fac > 1.0f) { - fac = 1.0f; - } + CLAMP(fac, 0.0f, 1.0f); interp_v3_v3v3(bsphere->center, mid_min, mid_max, fac); |