Fix T51665: No orientation for nurbs, polygons
This commit is contained in:
@@ -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_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_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,
|
void BKE_nurb_handle_calc(struct BezTriple *bezt, struct BezTriple *prev, struct BezTriple *next,
|
||||||
const bool is_fcurve);
|
const bool is_fcurve);
|
||||||
|
|||||||
@@ -856,6 +856,34 @@ void BKE_nurb_bpoint_calc_normal(struct Nurb *nu, struct BPoint *bp, float r_nor
|
|||||||
normalize_v3(r_normal);
|
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 ~~~~~~~~~~~ */
|
/* ~~~~~~~~~~~~~~~~~~~~Non Uniform Rational B Spline calculations ~~~~~~~~~~~ */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1775,6 +1775,26 @@ static void createTransCurveVerts(TransInfo *t)
|
|||||||
for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a > 0; a--, bp++) {
|
for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a > 0; a--, bp++) {
|
||||||
if (bp->hide == 0) {
|
if (bp->hide == 0) {
|
||||||
if (is_prop_edit || (bp->f1 & SELECT)) {
|
if (is_prop_edit || (bp->f1 & SELECT)) {
|
||||||
|
float axismtx[3][3];
|
||||||
|
|
||||||
|
if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
|
||||||
|
if (nu->pntsv == 1) {
|
||||||
|
float normal[3], plane[3];
|
||||||
|
|
||||||
|
BKE_nurb_bpoint_calc_normal(nu, bp, normal);
|
||||||
|
BKE_nurb_bpoint_calc_plane(nu, bp, plane);
|
||||||
|
|
||||||
|
if (createSpaceNormalTangent(axismtx, normal, plane)) {
|
||||||
|
/* pass */
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
normalize_v3(normal);
|
||||||
|
axis_dominant_v3_to_m3(axismtx, normal);
|
||||||
|
invert_m3(axismtx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
copy_v3_v3(td->iloc, bp->vec);
|
copy_v3_v3(td->iloc, bp->vec);
|
||||||
td->loc = bp->vec;
|
td->loc = bp->vec;
|
||||||
copy_v3_v3(td->center, td->loc);
|
copy_v3_v3(td->center, td->loc);
|
||||||
@@ -1793,6 +1813,11 @@ static void createTransCurveVerts(TransInfo *t)
|
|||||||
|
|
||||||
copy_m3_m3(td->smtx, smtx);
|
copy_m3_m3(td->smtx, smtx);
|
||||||
copy_m3_m3(td->mtx, mtx);
|
copy_m3_m3(td->mtx, mtx);
|
||||||
|
if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
|
||||||
|
if (nu->pntsv == 1) {
|
||||||
|
copy_m3_m3(td->axismtx, axismtx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
td++;
|
td++;
|
||||||
count++;
|
count++;
|
||||||
|
|||||||
@@ -817,15 +817,21 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
|
|||||||
else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
|
else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
|
||||||
Curve *cu = obedit->data;
|
Curve *cu = obedit->data;
|
||||||
Nurb *nu = NULL;
|
Nurb *nu = NULL;
|
||||||
BezTriple *bezt = NULL;
|
|
||||||
int a;
|
int a;
|
||||||
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
|
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
|
||||||
|
|
||||||
if (activeOnly && BKE_curve_nurb_vert_active_get(cu, &nu, (void *)&bezt)) {
|
void *vert_act = NULL;
|
||||||
|
if (activeOnly && BKE_curve_nurb_vert_active_get(cu, &nu, &vert_act)) {
|
||||||
if (nu->type == CU_BEZIER) {
|
if (nu->type == CU_BEZIER) {
|
||||||
|
BezTriple *bezt = vert_act;
|
||||||
BKE_nurb_bezt_calc_normal(nu, bezt, normal);
|
BKE_nurb_bezt_calc_normal(nu, bezt, normal);
|
||||||
BKE_nurb_bezt_calc_plane(nu, bezt, plane);
|
BKE_nurb_bezt_calc_plane(nu, bezt, plane);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
BPoint *bp = vert_act;
|
||||||
|
BKE_nurb_bpoint_calc_normal(nu, bp, normal);
|
||||||
|
BKE_nurb_bpoint_calc_plane(nu, bp, plane);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const bool use_handle = (cu->drawflag & CU_HIDE_HANDLES) == 0;
|
const bool use_handle = (cu->drawflag & CU_HIDE_HANDLES) == 0;
|
||||||
@@ -833,7 +839,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
|
|||||||
for (nu = nurbs->first; nu; nu = nu->next) {
|
for (nu = nurbs->first; nu; nu = nu->next) {
|
||||||
/* only bezier has a normal */
|
/* only bezier has a normal */
|
||||||
if (nu->type == CU_BEZIER) {
|
if (nu->type == CU_BEZIER) {
|
||||||
bezt = nu->bezt;
|
BezTriple *bezt = nu->bezt;
|
||||||
a = nu->pntsu;
|
a = nu->pntsu;
|
||||||
while (a--) {
|
while (a--) {
|
||||||
short flag = 0;
|
short flag = 0;
|
||||||
@@ -885,6 +891,36 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
|
|||||||
bezt++;
|
bezt++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (nu->bp && (nu->pntsv == 1)) {
|
||||||
|
BPoint *bp = nu->bp;
|
||||||
|
a = nu->pntsu;
|
||||||
|
while (a--) {
|
||||||
|
if (bp->f1 & SELECT) {
|
||||||
|
float tvec[3];
|
||||||
|
|
||||||
|
BPoint *bp_prev = BKE_nurb_bpoint_get_prev(nu, bp);
|
||||||
|
BPoint *bp_next = BKE_nurb_bpoint_get_next(nu, bp);
|
||||||
|
|
||||||
|
const bool is_prev_sel = bp_prev && (bp_prev->f1 & SELECT);
|
||||||
|
const bool is_next_sel = bp_next && (bp_next->f1 & SELECT);
|
||||||
|
if (is_prev_sel == false && is_next_sel == false) {
|
||||||
|
/* Isolated, add based on surrounding */
|
||||||
|
BKE_nurb_bpoint_calc_normal(nu, bp, tvec);
|
||||||
|
add_v3_v3(normal, tvec);
|
||||||
|
}
|
||||||
|
else if (is_next_sel) {
|
||||||
|
/* A segment, add the edge normal */
|
||||||
|
sub_v3_v3v3(tvec, bp->vec, bp_next->vec );
|
||||||
|
normalize_v3(tvec);
|
||||||
|
add_v3_v3(normal, tvec);
|
||||||
|
}
|
||||||
|
|
||||||
|
BKE_nurb_bpoint_calc_plane(nu, bp, tvec);
|
||||||
|
add_v3_v3(plane, tvec);
|
||||||
|
}
|
||||||
|
bp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user