Fix T65141 Bevel did not curve.

The previous fix to the spike bug T64582 was not really right.
This fixes that one properly and restores the desired curving
profile in the bug's example.
This commit is contained in:
2019-05-28 07:56:56 -04:00
parent b2b1aa2f8e
commit 2e211d099f
4 changed files with 17 additions and 17 deletions

View File

@@ -1377,31 +1377,31 @@ static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv)
}
}
/* Move the profile plane for bndv to the plane containing e1 and e2, which share a vert */
static void move_profile_plane(BoundVert *bndv, EdgeHalf *e1, EdgeHalf *e2)
/* Maybe move the profile plane for bndv->ebev to the plane its profile's coa, cob and the
* original beveled vert, bmv. This will usually be the plane containing its adjacent
* non-beveled edges, but sometimes coa and cob are not on those edges.
*/
static void move_profile_plane(BoundVert *bndv, BMVert *bmv)
{
float d1[3], d2[3], no[3], no2[3], no3[3], dot2, dot3;
Profile *pro = &bndv->profile;
/* only do this if projecting, and e1, e2, and proj_dir are not coplanar */
if (is_zero_v3(bndv->profile.proj_dir)) {
/* only do this if projecting, and coa, cob, and proj_dir are not coplanar */
if (is_zero_v3(pro->proj_dir)) {
return;
}
sub_v3_v3v3(d1, e1->e->v1->co, e1->e->v2->co);
if (e1->is_rev)
negate_v3(d1);
sub_v3_v3v3(d1, bmv->co, pro->coa);
normalize_v3(d1);
sub_v3_v3v3(d2, e2->e->v1->co, e2->e->v2->co);
if (e2->is_rev)
negate_v3(d2);
sub_v3_v3v3(d2, bmv->co, pro->cob);
normalize_v3(d2);
cross_v3_v3v3(no, d1, d2);
cross_v3_v3v3(no2, d1, bndv->profile.proj_dir);
cross_v3_v3v3(no3, d2, bndv->profile.proj_dir);
cross_v3_v3v3(no2, d1, pro->proj_dir);
cross_v3_v3v3(no3, d2, pro->proj_dir);
if (normalize_v3(no) > BEVEL_EPSILON_BIG && normalize_v3(no2) > BEVEL_EPSILON_BIG &&
normalize_v3(no3) > BEVEL_EPSILON_BIG) {
dot2 = dot_v3v3(no, no2);
dot3 = dot_v3v3(no, no3);
if (fabsf(dot2) < 0.95f && fabsf(dot3) < 0.95f) {
if (fabsf(dot2) < (1 - BEVEL_EPSILON_BIG) && fabsf(dot3) < (1 - BEVEL_EPSILON_BIG)) {
copy_v3_v3(bndv->profile.plane_no, no);
}
}
@@ -2354,7 +2354,7 @@ static void build_boundary_terminal_edge(BevelParams *bp,
/* special case: snap profile to plane of adjacent two edges */
v = vm->boundstart;
BLI_assert(v->ebev != NULL);
move_profile_plane(v, v->next->elast, v->efirst);
move_profile_plane(v, bv->v);
calculate_profile(bp, v);
}