diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-10-08 23:47:35 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-10-08 23:49:54 +0300 |
commit | da39f10eb75cd6b8d14525c1c50463e6e76bda81 (patch) | |
tree | 47e223473ee6e7f1889b3b6ef9ceeb6cf21a885f /source/blender/bmesh/operators | |
parent | 7aaeb06fb6f020cae4c19e51a63b963d3f5c54f7 (diff) |
Fix T57103: Subdivide smooth results in NAN verts
Diffstat (limited to 'source/blender/bmesh/operators')
-rw-r--r-- | source/blender/bmesh/operators/bmo_subdivide.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index c8ba2134a73..66730f8c837 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -182,15 +182,12 @@ static void interp_slerp_co_no_v3( /* calculate sphere 'center' */ { /* use point on plane to */ - float plane_a[4], plane_b[4], plane_c[4]; float no_mid[3], no_ortho[3]; /* pass this as an arg instead */ #if 0 float no_dir[3]; #endif - float v_a_no_ortho[3], v_b_no_ortho[3]; - add_v3_v3v3(no_mid, no_a, no_b); normalize_v3(no_mid); @@ -200,24 +197,28 @@ static void interp_slerp_co_no_v3( #endif /* axis of slerp */ + bool center_ok = false; cross_v3_v3v3(no_ortho, no_mid, no_dir); - normalize_v3(no_ortho); - - /* create planes */ - cross_v3_v3v3(v_a_no_ortho, no_ortho, no_a); - cross_v3_v3v3(v_b_no_ortho, no_ortho, no_b); - project_v3_plane(v_a_no_ortho, no_ortho, v_a_no_ortho); - project_v3_plane(v_b_no_ortho, no_ortho, v_b_no_ortho); - - plane_from_point_normal_v3(plane_a, co_a, v_a_no_ortho); - plane_from_point_normal_v3(plane_b, co_b, v_b_no_ortho); - plane_from_point_normal_v3(plane_c, co_b, no_ortho); - - /* find the sphere center from 3 planes */ - if (isect_plane_plane_plane_v3(plane_a, plane_b, plane_c, center)) { - /* pass */ + if (normalize_v3(no_ortho) != 0.0f) { + float plane_a[4], plane_b[4], plane_c[4]; + float v_a_no_ortho[3], v_b_no_ortho[3]; + + /* create planes */ + cross_v3_v3v3(v_a_no_ortho, no_ortho, no_a); + cross_v3_v3v3(v_b_no_ortho, no_ortho, no_b); + project_v3_plane(v_a_no_ortho, no_ortho, v_a_no_ortho); + project_v3_plane(v_b_no_ortho, no_ortho, v_b_no_ortho); + + plane_from_point_normal_v3(plane_a, co_a, v_a_no_ortho); + plane_from_point_normal_v3(plane_b, co_b, v_b_no_ortho); + plane_from_point_normal_v3(plane_c, co_b, no_ortho); + + /* find the sphere center from 3 planes */ + if (isect_plane_plane_plane_v3(plane_a, plane_b, plane_c, center)) { + center_ok = true; + } } - else { + if (center_ok == false) { mid_v3_v3v3(center, co_a, co_b); } } |