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:
Diffstat (limited to 'source/blender/editors/mesh/editmesh_knife.c')
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 65bb7879867..f6f226ec614 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -182,6 +182,7 @@ typedef struct KnifeTool_OpData {
char select_result; /* set on initialization */
short is_ortho;
+ float ortho_extent;
float clipsta, clipend;
enum {
@@ -1169,7 +1170,7 @@ static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree,
/* for comparing distances, error of intersection depends on triangle scale.
* need to scale down before squaring for accurate comparison */
- const float depsilon = (KNIFE_FLT_EPS / 2.0f) * len_v3_tri_side_max(v1, v2, v3);
+ const float depsilon = (FLT_EPSILON / 2.0f) * len_v3_tri_side_max(v1, v2, v3);
const float depsilon_squared = depsilon * depsilon;
copy_v3_v3(cos + 0, v1);
@@ -1316,6 +1317,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)
{
@@ -1358,8 +1375,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);
@@ -1423,7 +1442,7 @@ static void knife_input_ray_cast(KnifeTool_OpData *kcd, const int mval_i[2],
static BMFace *knife_find_closest_face(KnifeTool_OpData *kcd, float co[3], float cageco[3], int *is_space)
{
BMFace *f;
- int dist = KMAXDIST;
+ float dist = KMAXDIST;
float origin[3];
float ray[3];
@@ -1511,7 +1530,7 @@ static float knife_snap_size(KnifeTool_OpData *kcd, float maxsize)
if (density < 1.0f)
density = 1.0f;
- return minf(maxsize / (density * 0.5f), maxsize);
+ return min_ff(maxsize / (density * 0.5f), maxsize);
}
/* p is closest point on edge to the mouse cursor */