forked from bartvdbraak/blender
Fix knife sensitivity issue (#30637): better calculation of how
to clamp distances in ortho mode.
This commit is contained in:
parent
9756c85239
commit
be5e2a0dd4
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user