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:
authorBastien Montagne <montagne29@wanadoo.fr>2018-11-20 20:01:13 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-11-20 20:01:13 +0300
commit23656d01d8439006ccda12e19d34d1f537604d77 (patch)
tree45fb7d39813b6839033f961803558dca0313d868 /source/blender/bmesh/intern/bmesh_mesh.c
parentd2e473f01c5db04d0e77ac911c9e34a1acb6aeb6 (diff)
parentec851efda93ed19c9f7063c6167ae9437ed6803c (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_mesh.c')
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index 7bea0363a04..50aa3f08fbc 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -371,6 +371,8 @@ typedef struct BMVertsCalcNormalsData {
static void mesh_verts_calc_normals_accum_cb(void *userdata, MempoolIterData *mp_f)
{
+#define FLT_EQ_NONAN(_fa, _fb) (*((const uint32_t *)&_fa) == *((const uint32_t *)&_fb))
+
BMVertsCalcNormalsData *data = userdata;
BMFace *f = (BMFace *)mp_f;
@@ -398,6 +400,11 @@ static void mesh_verts_calc_normals_accum_cb(void *userdata, MempoolIterData *mp
fac = saacos(-dotprod);
+ if (fac != fac) { /* NAN detection. */
+ /* Degenerated case, nothing to do here, just ignore that vertex. */
+ continue;
+ }
+
/* accumulate weighted face normal into the vertex's normal */
float *v_no = data->vnos ? data->vnos[BM_elem_index_get(l_iter->v)] : l_iter->v->no;
@@ -413,7 +420,7 @@ static void mesh_verts_calc_normals_accum_cb(void *userdata, MempoolIterData *mp
* - v_no[0] was not FLT_MAX, i.e. it was not locked by another thread.
*/
const float vl = atomic_cas_float(&v_no[0], virtual_lock, FLT_MAX);
- if (vl == virtual_lock && vl != FLT_MAX) {
+ if (FLT_EQ_NONAN(vl, virtual_lock) && vl != FLT_MAX) {
break;
}
virtual_lock = vl;
@@ -431,6 +438,8 @@ static void mesh_verts_calc_normals_accum_cb(void *userdata, MempoolIterData *mp
BLI_assert(virtual_lock == FLT_MAX);
} while ((l_iter = l_iter->next) != l_first);
+
+#undef FLT_EQ_NONAN
}
static void mesh_verts_calc_normals_normalize_cb(void *userdata, MempoolIterData *mp_v)