Fix #113111: Connect Vertex Pair precision issue on large models #113246
|
@ -40,7 +40,7 @@
|
|||
* - run the standard connect operator.
|
||||
*/
|
||||
|
||||
#define CONNECT_EPS 0.0001f
|
||||
#define CONNECT_EPS 0.00001f
|
||||
|
||||
#define VERT_OUT 1
|
||||
#define VERT_EXCLUDE 2
|
||||
|
||||
|
@ -82,6 +82,7 @@ struct PathContext {
|
|||
HeapSimple *states;
|
||||
float matrix[3][3];
|
||||
float axis_sep;
|
||||
float connect_eps;
|
||||
Campbell Barton
commented
Worth adding a doc-string (CONNECT_EPS_BASIS scaled by geometry). Worth adding a doc-string (CONNECT_EPS_BASIS scaled by geometry).
|
||||
|
||||
/* only to access BMO flags */
|
||||
BMesh *bm_bmoflag;
|
||||
|
@ -171,8 +172,8 @@ static int state_isect_co_pair(const PathContext *pc, const float co_a[3], const
|
|||
const float diff_a = dot_m3_v3_row_x(pc->matrix, co_a) - pc->axis_sep;
|
||||
const float diff_b = dot_m3_v3_row_x(pc->matrix, co_b) - pc->axis_sep;
|
||||
|
||||
const int test_a = (fabsf(diff_a) < CONNECT_EPS) ? 0 : (diff_a < 0.0f) ? -1 : 1;
|
||||
const int test_b = (fabsf(diff_b) < CONNECT_EPS) ? 0 : (diff_b < 0.0f) ? -1 : 1;
|
||||
const int test_a = (fabsf(diff_a) < pc->connect_eps) ? 0 : (diff_a < 0.0f) ? -1 : 1;
|
||||
const int test_b = (fabsf(diff_b) < pc->connect_eps) ? 0 : (diff_b < 0.0f) ? -1 : 1;
|
||||
|
||||
if ((test_a && test_b) && (test_a != test_b)) {
|
||||
return 1; /* on either side */
|
||||
|
@ -183,7 +184,7 @@ static int state_isect_co_pair(const PathContext *pc, const float co_a[3], const
|
|||
static int state_isect_co_exact(const PathContext *pc, const float co[3])
|
||||
{
|
||||
const float diff = dot_m3_v3_row_x(pc->matrix, co) - pc->axis_sep;
|
||||
return (fabsf(diff) <= CONNECT_EPS);
|
||||
return (fabsf(diff) <= pc->connect_eps);
|
||||
}
|
||||
|
||||
static float state_calc_co_pair_fac(const PathContext *pc,
|
||||
|
@ -617,6 +618,8 @@ void bmo_connect_vert_pair_exec(BMesh *bm, BMOperator *op)
|
|||
{
|
||||
pc.states = BLI_heapsimple_new();
|
||||
pc.link_pool = BLI_mempool_create(sizeof(PathLink), 0, 512, BLI_MEMPOOL_NOP);
|
||||
pc.connect_eps = CONNECT_EPS *
|
||||
Campbell Barton
commented
The logic behind this scaling should be mentioned, with a reference to #113111. The logic behind this scaling should be mentioned, with a reference to #113111.
|
||||
std::max(1.0f, std::max(len_v3(pc.v_pair[0]->co), len_v3(pc.v_pair[1]->co)));
|
||||
Campbell Barton
commented
Can sqrtf the max: Can sqrtf the max: `sqrtf(std::max(len_squared_v3(pc.v_pair[0]->co), len_squared_v3(pc.v_pair[1]->co)))`
|
||||
}
|
||||
|
||||
/* calculate matrix */
|
||||
|
|
Loading…
Reference in New Issue
Better call this
CONNECT_EPS_BASIS
since it's potentially scaled up.