[Bf-blender-cvs] [26e4f4a8c47] master: Fix T71795: Unproject with high clipping range sometimes results in nans

mano-wii noreply at git.blender.org
Thu Dec 19 15:45:38 CET 2019


Commit: 26e4f4a8c475049e9600d466bb95eed341202f57
Author: mano-wii
Date:   Thu Dec 19 11:44:50 2019 -0300
Branches: master
https://developer.blender.org/rB26e4f4a8c475049e9600d466bb95eed341202f57

Fix T71795: Unproject with high clipping range sometimes results in nans

Differential Revision: https://developer.blender.org/D6311

===================================================================

M	source/blender/gpu/intern/gpu_matrix.c

===================================================================

diff --git a/source/blender/gpu/intern/gpu_matrix.c b/source/blender/gpu/intern/gpu_matrix.c
index fb0dffb58d1..5e44a950ba7 100644
--- a/source/blender/gpu/intern/gpu_matrix.c
+++ b/source/blender/gpu/intern/gpu_matrix.c
@@ -535,6 +535,11 @@ bool GPU_matrix_unproject_precalc(struct GPUMatrixUnproject_Precalc *precalc,
                      &precalc->dims.ymax,
                      &precalc->dims.zmin,
                      &precalc->dims.zmax);
+  if (isinf(precalc->dims.zmax)) {
+    /* We cannot retrieve the actual value of the clip_end.
+     * Use `FLT_MAX` to avoid nans. */
+    precalc->dims.zmax = FLT_MAX;
+  }
   for (int i = 0; i < 4; i++) {
     precalc->view[i] = (float)view[i];
   }



More information about the Bf-blender-cvs mailing list