diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-08-13 02:01:37 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-08-13 02:03:31 +0400 |
commit | 1510d0d4417c4ec91b19f06fac6f62ad7df3275b (patch) | |
tree | 1b357467b037bc4dcd265999cceace6fb8d9450f /source/blender/editors | |
parent | b8a23ccac1de3df0ad473e54e607867c91d50ff8 (diff) |
Fix T41164: Knife creates duplicate verts
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/mesh/editmesh_knife.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 96a608a432b..7421acac9b5 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -78,6 +78,7 @@ #define KNIFE_FLT_EPS 0.00001f #define KNIFE_FLT_EPS_SQUARED (KNIFE_FLT_EPS * KNIFE_FLT_EPS) #define KNIFE_FLT_EPSBIG 0.0005f +#define KNIFE_FLT_EPS_PX 0.2f typedef struct KnifeColors { unsigned char line[3]; @@ -1258,6 +1259,7 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) float p[3], p2[3], r1[3], r2[3]; float d, d1, d2, lambda; float vert_tol, vert_tol_sq, line_tol, face_tol; + float eps_scale; int isect_kind; unsigned int tot; int i; @@ -1360,8 +1362,16 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) /* Now go through the candidates and find intersections */ /* These tolerances, in screen space, are for intermediate hits, as ends are already snapped to screen */ - vert_tol = KNIFE_FLT_EPS * 2000.0f; - line_tol = KNIFE_FLT_EPS * 2000.0f; + { + /* Scale the epsilon by the zoom level + * to compensate for projection imprecision, see T41164 */ + float zoom_xy[2] = {kcd->vc.rv3d->winmat[0][0], + kcd->vc.rv3d->winmat[1][1]}; + eps_scale = len_v2(zoom_xy); + } + + vert_tol = KNIFE_FLT_EPS_PX * eps_scale; + line_tol = KNIFE_FLT_EPS_PX * eps_scale; vert_tol_sq = vert_tol * vert_tol; face_tol = max_ff(vert_tol, line_tol); /* Assume these tolerances swamp floating point rounding errors in calculations below */ |