Fix #114596: Face Nearest with steps sometimes breaks
When multiple steps are tested, we cannot depend on the distance calculated for `nearest.dist_sq`, as it reduces with each step.
This commit is contained in:
@@ -723,6 +723,12 @@ bool nearest_world_tree(SnapObjectContext *sctx,
|
||||
if (sctx->runtime.params.keep_on_same_target) {
|
||||
r_nearest->dist_sq = original_distance;
|
||||
}
|
||||
else if (sctx->runtime.params.face_nearest_steps > 1) {
|
||||
/* Recalculate the distance.
|
||||
* When multiple steps are tested, we cannot depend on the distance calculated for
|
||||
* `nearest.dist_sq`, as it reduces with each step. */
|
||||
r_nearest->dist_sq = math::distance_squared(sctx->runtime.curr_co, co);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ static bool nearest_world_mesh(SnapObjectContext *sctx,
|
||||
}
|
||||
|
||||
BVHTreeNearest nearest{};
|
||||
nearest.dist_sq = sctx->ret.dist_px_sq;
|
||||
nearest.dist_sq = sctx->ret.dist_nearest_sq;
|
||||
if (nearest_world_tree(
|
||||
sctx, treedata.tree, treedata.nearest_callback, obmat, &treedata, &nearest)) {
|
||||
SnapData::register_result(sctx, ob_eval, &me_eval->id, obmat, &nearest);
|
||||
|
||||
Reference in New Issue
Block a user