Fix T51665: No orientation for nurbs, polygons

This commit is contained in:
2017-07-10 14:37:20 +10:00
parent 2acd05b24c
commit 004a143760
4 changed files with 93 additions and 3 deletions

View File

@@ -198,6 +198,7 @@ void BKE_nurb_bezt_calc_normal(struct Nurb *nu, struct BezTriple *bezt, float r_
void BKE_nurb_bezt_calc_plane(struct Nurb *nu, struct BezTriple *bezt, float r_plane[3]);
void BKE_nurb_bpoint_calc_normal(struct Nurb *nu, struct BPoint *bp, float r_normal[3]);
void BKE_nurb_bpoint_calc_plane(struct Nurb *nu, struct BPoint *bp, float r_plane[3]);
void BKE_nurb_handle_calc(struct BezTriple *bezt, struct BezTriple *prev, struct BezTriple *next,
const bool is_fcurve);

View File

@@ -856,6 +856,34 @@ void BKE_nurb_bpoint_calc_normal(struct Nurb *nu, struct BPoint *bp, float r_nor
normalize_v3(r_normal);
}
void BKE_nurb_bpoint_calc_plane(struct Nurb *nu, BPoint *bp, float r_plane[3])
{
BPoint *bp_prev = BKE_nurb_bpoint_get_prev(nu, bp);
BPoint *bp_next = BKE_nurb_bpoint_get_next(nu, bp);
float dir_prev[3] = {0.0f}, dir_next[3] = {0.0f};
if (bp_prev) {
sub_v3_v3v3(dir_prev, bp_prev->vec, bp->vec);
normalize_v3(dir_prev);
}
if (bp_next) {
sub_v3_v3v3(dir_next, bp->vec, bp_next->vec);
normalize_v3(dir_next);
}
cross_v3_v3v3(r_plane, dir_prev, dir_next);
/* matches with bones more closely */
{
float dir_mid[3], tvec[3];
add_v3_v3v3(dir_mid, dir_prev, dir_next);
cross_v3_v3v3(tvec, r_plane, dir_mid);
copy_v3_v3(r_plane, tvec);
}
normalize_v3(r_plane);
}
/* ~~~~~~~~~~~~~~~~~~~~Non Uniform Rational B Spline calculations ~~~~~~~~~~~ */