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:
authorHoward Trickey <howard.trickey@gmail.com>2012-10-23 22:17:51 +0400
committerHoward Trickey <howard.trickey@gmail.com>2012-10-23 22:17:51 +0400
commitbe5e2a0dd401afb88009c9ff8b02d5419a753561 (patch)
treef8997e5d9b17369e8bcf70b626a3a434d71cc367 /source/blender/editors/mesh
parent9756c85239bcef5dd61e46a3f40db82a155785ee (diff)
Fix knife sensitivity issue (#30637): better calculation of how
to clamp distances in ortho mode.
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 01ed1a1993e..82447cc0168 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -181,6 +181,7 @@ typedef struct KnifeTool_OpData {
char select_result; /* set on initialization */
short is_ortho;
+ float ortho_extent;
float clipsta, clipend;
enum {
@@ -1311,6 +1312,22 @@ static void knife_bgl_get_mats(KnifeTool_OpData *UNUSED(kcd), bglMats *mats)
//copy_m4_m4(mats->projection, kcd->vc.rv3d->winmat);
}
+/* Calculate maximum excursion (doubled) from (0,0,0) of mesh */
+static void calc_ortho_extent(KnifeTool_OpData *kcd)
+{
+ BMIter iter;
+ BMVert *v;
+ BMesh* bm = kcd->em->bm;
+ float max_xyz = 0.0f;
+ int i;
+
+ BM_ITER_MESH(v, &iter, bm, BM_VERTS_OF_MESH) {
+ for (i = 0; i < 3; i++)
+ max_xyz = max_ff(max_xyz, fabs(v->co[i]));
+ }
+ kcd->ortho_extent = 2 * max_xyz;
+}
+
/* Finds visible (or all, if cutting through) edges that intersects the current screen drag line */
static void knife_find_line_hits(KnifeTool_OpData *kcd)
{
@@ -1353,8 +1370,10 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
* (which may involve using doubles everywhere!),
* limit the distance between these points */
if (kcd->is_ortho) {
- limit_dist_v3(v1, v3, 200.0f);
- limit_dist_v3(v2, v4, 200.0f);
+ if (kcd->ortho_extent == 0.0f)
+ calc_ortho_extent(kcd);
+ limit_dist_v3(v1, v3, kcd->ortho_extent + 10.0f);
+ limit_dist_v3(v2, v4, kcd->ortho_extent + 10.0f);
}
BLI_smallhash_init(ehash);