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 19:52:21 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-11-20 19:52:21 +0300
commitc9c6433a59549dbdf56298ae81a0b890639a6e0b (patch)
tree0924389f640aae7865d8d9326c536eeb88f9aaae /source/blender/bmesh/intern/bmesh_mesh.c
parent01e8e7dc6d9dd3710e0e3872b2d70196ac654d14 (diff)
Fix T57923: Freeze in mesh vnors computation code with some degenerated geometry.
Fix first part of it, the freeze itself being caused by float NAN values never comparing equal to anything, not even themselves.
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_mesh.c')
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index 95e667004fe..7a63fa3c64f 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -363,6 +363,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;
@@ -405,7 +407,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;
@@ -423,6 +425,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)