[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42356] branches/bmesh/blender/source/ blender/editors/mesh/knifetool.c: fix for own error - r42200, broke knife tool edge/triangle intersection.
Campbell Barton
ideasman42 at gmail.com
Fri Dec 2 21:45:26 CET 2011
Revision: 42356
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42356
Author: campbellbarton
Date: 2011-12-02 20:45:20 +0000 (Fri, 02 Dec 2011)
Log Message:
-----------
fix for own error - r42200, broke knife tool edge/triangle intersection.
Revision Links:
--------------
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42200
Modified Paths:
--------------
branches/bmesh/blender/source/blender/editors/mesh/knifetool.c
Modified: branches/bmesh/blender/source/blender/editors/mesh/knifetool.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/knifetool.c 2011-12-02 20:36:13 UTC (rev 42355)
+++ branches/bmesh/blender/source/blender/editors/mesh/knifetool.c 2011-12-02 20:45:20 UTC (rev 42356)
@@ -770,9 +770,19 @@
return 0;
}
-static BMEdgeHit *knife_edge_tri_isect(knifetool_opdata *kcd, BMBVHTree *bmtree, float v1[3],
- float v2[3], float v3[3], SmallHash *ehash, bglMats *mats, int *count)
+static float len_v3_tri_side_max(const float v1[3], const float v2[3], const float v3[3])
{
+ const float s1= len_v3v3(v1, v2);
+ const float s2= len_v3v3(v2, v3);
+ const float s3= len_v3v3(v3, v1);
+
+ return MAX3(s1, s2, s3);
+}
+
+static BMEdgeHit *knife_edge_tri_isect(knifetool_opdata *kcd, BMBVHTree *bmtree,
+ const float v1[3], const float v2[3], const float v3[3],
+ SmallHash *ehash, bglMats *mats, int *count)
+{
BVHTree *tree2 = BLI_bvhtree_new(3, FLT_EPSILON*4, 8, 8), *tree = BMBVH_BVHTree(bmtree);
BMEdgeHit *edges = NULL;
BLI_array_declare(edges);
@@ -781,11 +791,12 @@
float cos[9], uv[3], lambda;
unsigned int tot=0;
int i, j;
+
+ /* for comparing distances, error of intersection depends on triangle scale.
+ * need to scale down before squaring for accurate comparison */
+ const float depsilon= 50*FLT_EPSILON * len_v3_tri_side_max(v1, v2, v3);
+ const float depsilon_squared = depsilon * depsilon;
- /* for comparing distances, error of intersection depends on triangle scale */
- const float depsilon_squared= 50 * FLT_EPSILON * maxf(maxf(len_squared_v3v3(v1, v2), len_squared_v3v3(v1, v3)), len_squared_v3v3(v2, v3));
- /* const float depsilon= sqrtf(depsilon_squared); */ /* UNUSED */
-
copy_v3_v3(cos, v1);
copy_v3_v3(cos+3, v2);
copy_v3_v3(cos+6, v3);
More information about the Bf-blender-cvs
mailing list