Curve selection, de-duplicate & cleanup
This commit is contained in:
@@ -539,7 +539,7 @@ static short get_fcurve_end_keyframes(FCurve *fcu, BezTriple **first, BezTriple
|
||||
/* find first selected */
|
||||
bezt = fcu->bezt;
|
||||
for (i = 0; i < fcu->totvert; bezt++, i++) {
|
||||
if (BEZSELECTED(bezt)) {
|
||||
if (BEZT_ISSEL_ANY(bezt)) {
|
||||
*first = bezt;
|
||||
found = true;
|
||||
break;
|
||||
@@ -549,7 +549,7 @@ static short get_fcurve_end_keyframes(FCurve *fcu, BezTriple **first, BezTriple
|
||||
/* find last selected */
|
||||
bezt = ARRAY_LAST_ITEM(fcu->bezt, BezTriple, fcu->totvert);
|
||||
for (i = 0; i < fcu->totvert; bezt--, i++) {
|
||||
if (BEZSELECTED(bezt)) {
|
||||
if (BEZT_ISSEL_ANY(bezt)) {
|
||||
*last = bezt;
|
||||
found = true;
|
||||
break;
|
||||
@@ -603,7 +603,7 @@ bool calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, floa
|
||||
BezTriple *bezt, *prevbezt = NULL;
|
||||
|
||||
for (bezt = fcu->bezt, i = 0; i < fcu->totvert; prevbezt = bezt, bezt++, i++) {
|
||||
if ((do_sel_only == false) || BEZSELECTED(bezt)) {
|
||||
if ((do_sel_only == false) || BEZT_ISSEL_ANY(bezt)) {
|
||||
/* keyframe itself */
|
||||
yminv = min_ff(yminv, bezt->vec[1][1]);
|
||||
ymaxv = max_ff(ymaxv, bezt->vec[1][1]);
|
||||
|
||||
@@ -105,7 +105,7 @@ static DLRBT_Node *nalloc_ak_bezt(void *data)
|
||||
|
||||
/* store settings based on state of BezTriple */
|
||||
ak->cfra = bezt->vec[1][0];
|
||||
ak->sel = BEZSELECTED(bezt) ? SELECT : 0;
|
||||
ak->sel = BEZT_ISSEL_ANY(bezt) ? SELECT : 0;
|
||||
ak->key_type = BEZKEYTYPE(bezt);
|
||||
|
||||
/* set 'modified', since this is used to identify long keyframes */
|
||||
@@ -121,7 +121,7 @@ static void nupdate_ak_bezt(void *node, void *data)
|
||||
BezTriple *bezt = (BezTriple *)data;
|
||||
|
||||
/* set selection status and 'touched' status */
|
||||
if (BEZSELECTED(bezt)) ak->sel = SELECT;
|
||||
if (BEZT_ISSEL_ANY(bezt)) ak->sel = SELECT;
|
||||
ak->modified += 1;
|
||||
|
||||
/* for keyframe type, 'proper' keyframes have priority over breakdowns (and other types for now) */
|
||||
@@ -279,7 +279,7 @@ static ActKeyBlock *bezts_to_new_actkeyblock(BezTriple *prev, BezTriple *beztn)
|
||||
ab->end = beztn->vec[1][0];
|
||||
ab->val = beztn->vec[1][1];
|
||||
|
||||
ab->sel = (BEZSELECTED(prev) || BEZSELECTED(beztn)) ? SELECT : 0;
|
||||
ab->sel = (BEZT_ISSEL_ANY(prev) || BEZT_ISSEL_ANY(beztn)) ? SELECT : 0;
|
||||
ab->modified = 1;
|
||||
|
||||
return ab;
|
||||
@@ -340,7 +340,7 @@ static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, BezTriple *first_bezt
|
||||
*/
|
||||
if (IS_EQT(ab->start, prev->vec[1][0], BEZT_BINARYSEARCH_THRESH)) {
|
||||
/* set selection status and 'touched' status */
|
||||
if (BEZSELECTED(beztn)) ab->sel = SELECT;
|
||||
if (BEZT_ISSEL_ANY(beztn)) ab->sel = SELECT;
|
||||
ab->modified++;
|
||||
|
||||
/* done... no need to insert */
|
||||
|
||||
@@ -455,7 +455,7 @@ static short ok_bezier_selected(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
|
||||
/* this macro checks all beztriple handles for selection...
|
||||
* only one of the verts has to be selected for this to be ok...
|
||||
*/
|
||||
if (BEZSELECTED(bezt))
|
||||
if (BEZT_ISSEL_ANY(bezt))
|
||||
return KEYFRAME_OK_ALL;
|
||||
else
|
||||
return 0;
|
||||
@@ -1181,7 +1181,7 @@ static short select_bezier_add(KeyframeEditData *ked, BezTriple *bezt)
|
||||
bezt->f3 |= SELECT;
|
||||
}
|
||||
else {
|
||||
BEZ_SEL(bezt);
|
||||
BEZT_SEL_ALL(bezt);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1199,7 +1199,7 @@ static short select_bezier_subtract(KeyframeEditData *ked, BezTriple *bezt)
|
||||
bezt->f3 &= ~SELECT;
|
||||
}
|
||||
else {
|
||||
BEZ_DESEL(bezt);
|
||||
BEZT_DESEL_ALL(bezt);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1252,7 +1252,7 @@ static short selmap_build_bezier_more(KeyframeEditData *ked, BezTriple *bezt)
|
||||
int i = ked->curIndex;
|
||||
|
||||
/* if current is selected, just make sure it stays this way */
|
||||
if (BEZSELECTED(bezt)) {
|
||||
if (BEZT_ISSEL_ANY(bezt)) {
|
||||
map[i] = 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -1261,7 +1261,7 @@ static short selmap_build_bezier_more(KeyframeEditData *ked, BezTriple *bezt)
|
||||
if (i > 0) {
|
||||
BezTriple *prev = bezt - 1;
|
||||
|
||||
if (BEZSELECTED(prev)) {
|
||||
if (BEZT_ISSEL_ANY(prev)) {
|
||||
map[i] = 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -1271,7 +1271,7 @@ static short selmap_build_bezier_more(KeyframeEditData *ked, BezTriple *bezt)
|
||||
if (i < (fcu->totvert - 1)) {
|
||||
BezTriple *next = bezt + 1;
|
||||
|
||||
if (BEZSELECTED(next)) {
|
||||
if (BEZT_ISSEL_ANY(next)) {
|
||||
map[i] = 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -1289,12 +1289,12 @@ static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt)
|
||||
/* if current is selected, check the left/right keyframes
|
||||
* since it might need to be deselected (but otherwise no)
|
||||
*/
|
||||
if (BEZSELECTED(bezt)) {
|
||||
if (BEZT_ISSEL_ANY(bezt)) {
|
||||
/* if previous is not selected, we're on the tip of an iceberg */
|
||||
if (i > 0) {
|
||||
BezTriple *prev = bezt - 1;
|
||||
|
||||
if (BEZSELECTED(prev) == 0)
|
||||
if (BEZT_ISSEL_ANY(prev) == 0)
|
||||
return 0;
|
||||
}
|
||||
else if (i == 0) {
|
||||
@@ -1306,7 +1306,7 @@ static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt)
|
||||
if (i < (fcu->totvert - 1)) {
|
||||
BezTriple *next = bezt + 1;
|
||||
|
||||
if (BEZSELECTED(next) == 0)
|
||||
if (BEZT_ISSEL_ANY(next) == 0)
|
||||
return 0;
|
||||
}
|
||||
else if (i == (fcu->totvert - 1)) {
|
||||
@@ -1344,10 +1344,10 @@ short bezt_selmap_flush(KeyframeEditData *ked, BezTriple *bezt)
|
||||
|
||||
/* select or deselect based on whether the map allows it or not */
|
||||
if (on) {
|
||||
BEZ_SEL(bezt);
|
||||
BEZT_SEL_ALL(bezt);
|
||||
}
|
||||
else {
|
||||
BEZ_DESEL(bezt);
|
||||
BEZT_DESEL_ALL(bezt);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -167,11 +167,11 @@ void duplicate_fcurve_keys(FCurve *fcu)
|
||||
fcu->bezt = newbezt;
|
||||
|
||||
/* Unselect the current key */
|
||||
BEZ_DESEL(&fcu->bezt[i]);
|
||||
BEZT_DESEL_ALL(&fcu->bezt[i]);
|
||||
i++;
|
||||
|
||||
/* Select the copied key */
|
||||
BEZ_SEL(&fcu->bezt[i]);
|
||||
BEZT_SEL_ALL(&fcu->bezt[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -308,7 +308,7 @@ void smooth_fcurve(FCurve *fcu)
|
||||
/* first loop through - count how many verts are selected */
|
||||
bezt = fcu->bezt;
|
||||
for (i = 0; i < fcu->totvert; i++, bezt++) {
|
||||
if (BEZSELECTED(bezt))
|
||||
if (BEZT_ISSEL_ANY(bezt))
|
||||
totSel++;
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ void smooth_fcurve(FCurve *fcu)
|
||||
/* populate tarray with data of selected points */
|
||||
bezt = fcu->bezt;
|
||||
for (i = 0, x = 0; (i < fcu->totvert) && (x < totSel); i++, bezt++) {
|
||||
if (BEZSELECTED(bezt)) {
|
||||
if (BEZT_ISSEL_ANY(bezt)) {
|
||||
/* tsb simply needs pointer to vec, and index */
|
||||
tsb->h1 = &bezt->vec[0][1];
|
||||
tsb->h2 = &bezt->vec[1][1];
|
||||
@@ -411,7 +411,7 @@ void sample_fcurve(FCurve *fcu)
|
||||
/* find selected keyframes... once pair has been found, add keyframes */
|
||||
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
|
||||
/* check if selected, and which end this is */
|
||||
if (BEZSELECTED(bezt)) {
|
||||
if (BEZT_ISSEL_ANY(bezt)) {
|
||||
if (start) {
|
||||
/* set end */
|
||||
end = bezt;
|
||||
@@ -576,7 +576,7 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
|
||||
/* TODO: currently, we resize array every time we add a new vert -
|
||||
* this works ok as long as it is assumed only a few keys are copied */
|
||||
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
|
||||
if (BEZSELECTED(bezt)) {
|
||||
if (BEZT_ISSEL_ANY(bezt)) {
|
||||
/* add to buffer */
|
||||
newbuf = MEM_callocN(sizeof(BezTriple) * (aci->totvert + 1), "copybuf beztriple");
|
||||
|
||||
@@ -589,7 +589,7 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
|
||||
*nbezt = *bezt;
|
||||
|
||||
/* ensure copy buffer is selected so pasted keys are selected */
|
||||
BEZ_SEL(nbezt);
|
||||
BEZT_SEL_ALL(nbezt);
|
||||
|
||||
/* free old array and set the new */
|
||||
if (aci->bezt) MEM_freeN(aci->bezt);
|
||||
@@ -776,7 +776,7 @@ static void paste_animedit_keys_fcurve(FCurve *fcu, tAnimCopybufItem *aci, float
|
||||
|
||||
/* First de-select existing FCurve's keyframes */
|
||||
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
|
||||
BEZ_DESEL(bezt);
|
||||
BEZT_DESEL_ALL(bezt);
|
||||
}
|
||||
|
||||
/* mix mode with existing data */
|
||||
|
||||
@@ -1221,7 +1221,7 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu,
|
||||
}
|
||||
else if (mode == POSE_PROPAGATE_SELECTED_KEYS) {
|
||||
/* only allow if this keyframe is already selected - skip otherwise */
|
||||
if (BEZSELECTED(bezt) == 0)
|
||||
if (BEZT_ISSEL_ANY(bezt) == 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,58 +107,6 @@ ListBase *object_editcurve_get(Object *ob)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* ******************* SELECTION FUNCTIONS ********************* */
|
||||
|
||||
int isNurbsel(Nurb *nu)
|
||||
{
|
||||
BezTriple *bezt;
|
||||
BPoint *bp;
|
||||
int a;
|
||||
|
||||
if (nu->type == CU_BEZIER) {
|
||||
bezt = nu->bezt;
|
||||
a = nu->pntsu;
|
||||
while (a--) {
|
||||
if ( (bezt->f1 & SELECT) || (bezt->f2 & SELECT) || (bezt->f3 & SELECT) ) return 1;
|
||||
bezt++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
bp = nu->bp;
|
||||
a = nu->pntsu * nu->pntsv;
|
||||
while (a--) {
|
||||
if (bp->f1 & SELECT) return 1;
|
||||
bp++;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int isNurbsel_count(Curve *cu, Nurb *nu)
|
||||
{
|
||||
BezTriple *bezt;
|
||||
BPoint *bp;
|
||||
int a, sel = 0;
|
||||
|
||||
if (nu->type == CU_BEZIER) {
|
||||
bezt = nu->bezt;
|
||||
a = nu->pntsu;
|
||||
while (a--) {
|
||||
if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) sel++;
|
||||
bezt++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
bp = nu->bp;
|
||||
a = nu->pntsu * nu->pntsv;
|
||||
while (a--) {
|
||||
if ( (bp->f1 & SELECT) ) sel++;
|
||||
bp++;
|
||||
}
|
||||
}
|
||||
return sel;
|
||||
}
|
||||
|
||||
/* ******************* PRINTS ********************* */
|
||||
|
||||
#if 0
|
||||
@@ -169,7 +117,7 @@ void printknots(Object *obedit)
|
||||
int a, num;
|
||||
|
||||
for (nu = editnurb->first; nu; nu = nu->next) {
|
||||
if (isNurbsel(nu) && nu->type == CU_NURBS) {
|
||||
if (ED_curve_nurb_select_check(nu) && nu->type == CU_NURBS) {
|
||||
if (nu->knotsu) {
|
||||
num = KNOTSU(nu);
|
||||
for (a = 0; a < num; a++) printf("knotu %d: %f\n", a, nu->knotsu[a]);
|
||||
@@ -1311,29 +1259,6 @@ void free_editNurb(Object *obedit)
|
||||
BKE_curve_editNurb_free(cu);
|
||||
}
|
||||
|
||||
void ED_curve_deselect_all(EditNurb *editnurb)
|
||||
{
|
||||
Nurb *nu;
|
||||
int a;
|
||||
|
||||
for (nu = editnurb->nurbs.first; nu; nu = nu->next) {
|
||||
if (nu->bezt) {
|
||||
BezTriple *bezt;
|
||||
for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) {
|
||||
bezt->f1 &= ~SELECT;
|
||||
bezt->f2 &= ~SELECT;
|
||||
bezt->f3 &= ~SELECT;
|
||||
}
|
||||
}
|
||||
else if (nu->bp) {
|
||||
BPoint *bp;
|
||||
for (bp = nu->bp, a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) {
|
||||
bp->f1 &= ~SELECT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/******************** separate operator ***********************/
|
||||
|
||||
static int separate_exec(bContext *C, wmOperator *op)
|
||||
@@ -1752,7 +1677,7 @@ static void ed_curve_delete_selected(Object *obedit)
|
||||
a = nu->pntsu;
|
||||
if (a) {
|
||||
while (a) {
|
||||
if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
|
||||
if (BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt)) {
|
||||
/* pass */
|
||||
}
|
||||
else {
|
||||
@@ -1814,7 +1739,7 @@ static void ed_curve_delete_selected(Object *obedit)
|
||||
if (nu->type == CU_BEZIER) {
|
||||
bezt = nu->bezt;
|
||||
for (a = 0; a < nu->pntsu; a++) {
|
||||
if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
|
||||
if (BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt)) {
|
||||
memmove(bezt, bezt + 1, (nu->pntsu - a - 1) * sizeof(BezTriple));
|
||||
keyIndex_delBezt(editnurb, bezt);
|
||||
keyIndex_updateBezt(editnurb, bezt + 1, bezt, nu->pntsu - a - 1);
|
||||
@@ -2103,7 +2028,7 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb,
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isNurbsel(nu)) {
|
||||
if (ED_curve_nurb_select_check(cu, nu)) {
|
||||
/* a rectangular area in nurb has to be selected and if splitting must be in U or V direction */
|
||||
usel = MEM_callocN(nu->pntsu, "adduplicateN3");
|
||||
bp = nu->bp;
|
||||
@@ -2262,7 +2187,7 @@ static int switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
int i;
|
||||
|
||||
for (nu = editnurb->nurbs.first, i = 0; nu; nu = nu->next, i++) {
|
||||
if (isNurbsel(nu)) {
|
||||
if (ED_curve_nurb_select_check(cu, nu)) {
|
||||
BKE_nurb_direction_switch(nu);
|
||||
keyData_switchDirectionNurb(cu, nu);
|
||||
if ((i == cu->actnu) && (cu->actvert != CU_ACT_NONE)) {
|
||||
@@ -2813,11 +2738,11 @@ static int hide_exec(bContext *C, wmOperator *op)
|
||||
a = nu->pntsu;
|
||||
sel = 0;
|
||||
while (a--) {
|
||||
if (invert == 0 && BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
|
||||
if (invert == 0 && BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt)) {
|
||||
select_beztriple(bezt, DESELECT, SELECT, HIDDEN);
|
||||
bezt->hide = 1;
|
||||
}
|
||||
else if (invert && !BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
|
||||
else if (invert && !BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt)) {
|
||||
select_beztriple(bezt, DESELECT, SELECT, HIDDEN);
|
||||
bezt->hide = 1;
|
||||
}
|
||||
@@ -2967,7 +2892,7 @@ static void subdividenurb(Object *obedit, int number_cuts)
|
||||
break;
|
||||
}
|
||||
|
||||
if (BEZSELECTED_HIDDENHANDLES(cu, bezt) && BEZSELECTED_HIDDENHANDLES(cu, nextbezt)) {
|
||||
if (BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt) && BEZT_ISSEL_ANY_HIDDENHANDLES(cu, nextbezt)) {
|
||||
amount += number_cuts;
|
||||
}
|
||||
bezt++;
|
||||
@@ -2989,7 +2914,7 @@ static void subdividenurb(Object *obedit, int number_cuts)
|
||||
break;
|
||||
}
|
||||
|
||||
if (BEZSELECTED_HIDDENHANDLES(cu, bezt) && BEZSELECTED_HIDDENHANDLES(cu, nextbezt)) {
|
||||
if (BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt) && BEZT_ISSEL_ANY_HIDDENHANDLES(cu, nextbezt)) {
|
||||
float prevvec[3][3];
|
||||
|
||||
memcpy(prevvec, bezt->vec, sizeof(float) * 9);
|
||||
@@ -3420,37 +3345,41 @@ bool ED_curve_pick_vert(
|
||||
return (data.bezt || data.bp);
|
||||
}
|
||||
|
||||
static void findselectedNurbvert(ListBase *editnurb, Nurb **nu, BezTriple **bezt, BPoint **bp)
|
||||
static void findselectedNurbvert(
|
||||
Curve *cu,
|
||||
Nurb **r_nu, BezTriple **r_bezt, BPoint **r_bp)
|
||||
{
|
||||
/* in nu and (bezt or bp) selected are written if there's 1 sel. */
|
||||
/* if more points selected in 1 spline: return only nu, bezt and bp are 0 */
|
||||
ListBase *editnurb = &cu->editnurb->nurbs;
|
||||
Nurb *nu1;
|
||||
BezTriple *bezt1;
|
||||
BPoint *bp1;
|
||||
int a;
|
||||
|
||||
*nu = NULL;
|
||||
*bezt = NULL;
|
||||
*bp = NULL;
|
||||
*r_nu = NULL;
|
||||
*r_bezt = NULL;
|
||||
*r_bp = NULL;
|
||||
|
||||
for (nu1 = editnurb->first; nu1; nu1 = nu1->next) {
|
||||
if (nu1->type == CU_BEZIER) {
|
||||
bezt1 = nu1->bezt;
|
||||
a = nu1->pntsu;
|
||||
while (a--) {
|
||||
if ((bezt1->f1 & SELECT) || (bezt1->f2 & SELECT) || (bezt1->f3 & SELECT)) {
|
||||
if (*nu != NULL && *nu != nu1) {
|
||||
*nu = NULL;
|
||||
*bp = NULL;
|
||||
*bezt = NULL;
|
||||
if (BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt1)) {
|
||||
if (*r_nu != NULL && *r_nu != nu1) {
|
||||
*r_nu = NULL;
|
||||
*r_bp = NULL;
|
||||
*r_bezt = NULL;
|
||||
return;
|
||||
}
|
||||
else if (*bezt || *bp) {
|
||||
*bp = NULL;
|
||||
*bezt = NULL;
|
||||
else if (*r_bezt || *r_bp) {
|
||||
*r_bp = NULL;
|
||||
*r_bezt = NULL;
|
||||
}
|
||||
else {
|
||||
*bezt = bezt1;
|
||||
*nu = nu1;
|
||||
*r_bezt = bezt1;
|
||||
*r_nu = nu1;
|
||||
}
|
||||
}
|
||||
bezt1++;
|
||||
@@ -3461,19 +3390,19 @@ static void findselectedNurbvert(ListBase *editnurb, Nurb **nu, BezTriple **bezt
|
||||
a = nu1->pntsu * nu1->pntsv;
|
||||
while (a--) {
|
||||
if (bp1->f1 & SELECT) {
|
||||
if (*nu != NULL && *nu != nu1) {
|
||||
*bp = NULL;
|
||||
*bezt = NULL;
|
||||
*nu = NULL;
|
||||
if (*r_nu != NULL && *r_nu != nu1) {
|
||||
*r_bp = NULL;
|
||||
*r_bezt = NULL;
|
||||
*r_nu = NULL;
|
||||
return;
|
||||
}
|
||||
else if (*bezt || *bp) {
|
||||
*bp = NULL;
|
||||
*bezt = NULL;
|
||||
else if (*r_bezt || *r_bp) {
|
||||
*r_bp = NULL;
|
||||
*r_bezt = NULL;
|
||||
}
|
||||
else {
|
||||
*bp = bp1;
|
||||
*nu = nu1;
|
||||
*r_bp = bp1;
|
||||
*r_nu = nu1;
|
||||
}
|
||||
}
|
||||
bp1++;
|
||||
@@ -3500,7 +3429,7 @@ static int set_spline_type_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
for (nu = editnurb->first; nu; nu = nu->next) {
|
||||
if (isNurbsel(nu)) {
|
||||
if (ED_curve_nurb_select_check(obedit->data, nu)) {
|
||||
const int pntsu_prev = nu->pntsu;
|
||||
if (BKE_nurb_type_convert(nu, type, use_handles)) {
|
||||
changed = true;
|
||||
@@ -3735,7 +3664,7 @@ typedef struct NurbSort {
|
||||
static ListBase nsortbase = {NULL, NULL};
|
||||
/* static NurbSort *nusmain; */ /* this var seems to go unused... at least in this file */
|
||||
|
||||
static void make_selection_list_nurb(ListBase *editnurb)
|
||||
static void make_selection_list_nurb(Curve *cu, ListBase *editnurb)
|
||||
{
|
||||
ListBase nbase = {NULL, NULL};
|
||||
NurbSort *nus, *nustest, *headdo, *taildo;
|
||||
@@ -3745,7 +3674,7 @@ static void make_selection_list_nurb(ListBase *editnurb)
|
||||
int a;
|
||||
|
||||
for (nu = editnurb->first; nu; nu = nu->next) {
|
||||
if (isNurbsel(nu)) {
|
||||
if (ED_curve_nurb_select_check(cu, nu)) {
|
||||
|
||||
nus = (NurbSort *)MEM_callocN(sizeof(NurbSort), "sort");
|
||||
BLI_addhead(&nbase, nus);
|
||||
@@ -3949,7 +3878,7 @@ static int merge_nurb(bContext *C, wmOperator *op)
|
||||
NurbSort *nus1, *nus2;
|
||||
bool ok = true;
|
||||
|
||||
make_selection_list_nurb(editnurb);
|
||||
make_selection_list_nurb(cu, editnurb);
|
||||
|
||||
if (nsortbase.first == nsortbase.last) {
|
||||
BLI_freelistN(&nsortbase);
|
||||
@@ -4024,11 +3953,17 @@ static int make_segment_exec(bContext *C, wmOperator *op)
|
||||
else nu = NULL;
|
||||
|
||||
while (nu) {
|
||||
if (isNurbsel(nu)) {
|
||||
|
||||
if (nu->pntsu > 1 && nu->pntsv > 1) break;
|
||||
if (isNurbsel_count(cu, nu) > 1) break;
|
||||
if (isNurbsel_count(cu, nu) == 1) {
|
||||
const int nu_select_num = ED_curve_nurb_select_count(cu, nu);
|
||||
if (nu_select_num) {
|
||||
|
||||
if (nu->pntsu > 1 && nu->pntsv > 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (nu_select_num > 1) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
/* only 1 selected, not first or last, a little complex, but intuitive */
|
||||
if (nu->pntsv == 1) {
|
||||
if ((nu->bp->f1 & SELECT) || (nu->bp[nu->pntsu - 1].f1 & SELECT)) {
|
||||
@@ -4053,7 +3988,7 @@ static int make_segment_exec(bContext *C, wmOperator *op)
|
||||
|
||||
if ((nu->flagu & CU_NURB_CYCLIC) == 0) { /* not cyclic */
|
||||
if (nu->type == CU_BEZIER) {
|
||||
if (BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu - 1]))) {
|
||||
if (BEZT_ISSEL_ANY_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu - 1]))) {
|
||||
/* Last point is selected, preferred for nu2 */
|
||||
if (nu2 == NULL) {
|
||||
nu2 = nu;
|
||||
@@ -4064,13 +3999,13 @@ static int make_segment_exec(bContext *C, wmOperator *op)
|
||||
/* Just in case both of first/last CV are selected check
|
||||
* whether we really need to switch the direction.
|
||||
*/
|
||||
if (!BEZSELECTED_HIDDENHANDLES(cu, nu1->bezt)) {
|
||||
if (!BEZT_ISSEL_ANY_HIDDENHANDLES(cu, nu1->bezt)) {
|
||||
BKE_nurb_direction_switch(nu1);
|
||||
keyData_switchDirectionNurb(cu, nu1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (BEZSELECTED_HIDDENHANDLES(cu, nu->bezt)) {
|
||||
else if (BEZT_ISSEL_ANY_HIDDENHANDLES(cu, nu->bezt)) {
|
||||
/* First point is selected, preferred for nu1 */
|
||||
if (nu1 == NULL) {
|
||||
nu1 = nu;
|
||||
@@ -4081,7 +4016,7 @@ static int make_segment_exec(bContext *C, wmOperator *op)
|
||||
/* Just in case both of first/last CV are selected check
|
||||
* whether we really need to switch the direction.
|
||||
*/
|
||||
if (!BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu2->pntsu - 1]))) {
|
||||
if (!BEZT_ISSEL_ANY_HIDDENHANDLES(cu, &(nu->bezt[nu2->pntsu - 1]))) {
|
||||
BKE_nurb_direction_switch(nu2);
|
||||
keyData_switchDirectionNurb(cu, nu2);
|
||||
}
|
||||
@@ -4180,8 +4115,8 @@ static int make_segment_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
if (!(nu1->flagu & CU_NURB_CYCLIC) && nu1->pntsu > 1) {
|
||||
if (nu1->type == CU_BEZIER && BEZSELECTED_HIDDENHANDLES(cu, nu1->bezt) &&
|
||||
BEZSELECTED_HIDDENHANDLES(cu, &nu1->bezt[nu1->pntsu - 1]))
|
||||
if (nu1->type == CU_BEZIER && BEZT_ISSEL_ANY_HIDDENHANDLES(cu, nu1->bezt) &&
|
||||
BEZT_ISSEL_ANY_HIDDENHANDLES(cu, &nu1->bezt[nu1->pntsu - 1]))
|
||||
{
|
||||
nu1->flagu |= CU_NURB_CYCLIC;
|
||||
BKE_nurb_handles_calc(nu1);
|
||||
@@ -4415,7 +4350,7 @@ bool ed_editnurb_spin(float viewmat[4][4], Object *obedit, const float axis[3],
|
||||
|
||||
if (ok) {
|
||||
for (nu = editnurb->first; nu; nu = nu->next) {
|
||||
if (isNurbsel(nu)) {
|
||||
if (ED_curve_nurb_select_check(cu, nu)) {
|
||||
nu->orderv = 4;
|
||||
nu->flagv |= CU_NURB_CYCLIC;
|
||||
BKE_nurb_knot_calc_v(nu);
|
||||
@@ -4530,9 +4465,9 @@ static bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb)
|
||||
BezTriple *nu_bezt_old = nu->bezt;
|
||||
BezTriple *bezt = nu->bezt;
|
||||
|
||||
if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
|
||||
if (BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt)) {
|
||||
BezTriple *bezt_new;
|
||||
BEZ_DESEL(bezt);
|
||||
BEZT_DESEL_ALL(bezt);
|
||||
|
||||
bezt_new = MEM_mallocN((nu->pntsu + 1) * sizeof(BezTriple), __func__);
|
||||
ED_curve_beztcpy(editnurb, bezt_new + 1, bezt, nu->pntsu);
|
||||
@@ -4550,7 +4485,7 @@ static bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb)
|
||||
BKE_curve_nurb_vert_active_set(cu, nu, cu_actvert.bezt);
|
||||
}
|
||||
|
||||
BEZ_SEL(bezt_new);
|
||||
BEZT_SEL_ALL(bezt_new);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
@@ -4560,9 +4495,9 @@ static bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb)
|
||||
BezTriple *nu_bezt_old = nu->bezt;
|
||||
BezTriple *bezt = &nu->bezt[nu->pntsu - 1];
|
||||
|
||||
if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
|
||||
if (BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt)) {
|
||||
BezTriple *bezt_new;
|
||||
BEZ_DESEL(bezt);
|
||||
BEZT_DESEL_ALL(bezt);
|
||||
|
||||
bezt_new = MEM_mallocN((nu->pntsu + 1) * sizeof(BezTriple), __func__);
|
||||
ED_curve_beztcpy(editnurb, bezt_new, nu->bezt, nu->pntsu);
|
||||
@@ -4580,7 +4515,7 @@ static bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb)
|
||||
BKE_curve_nurb_vert_active_set(cu, nu, cu_actvert.bezt);
|
||||
}
|
||||
|
||||
BEZ_SEL(bezt_new);
|
||||
BEZT_SEL_ALL(bezt_new);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
@@ -4671,17 +4606,17 @@ static bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb)
|
||||
BezTriple *bezt;
|
||||
|
||||
for (bezt = &nu->bezt[i]; i < i_end; i++, bezt++) {
|
||||
if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
|
||||
if (BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt)) {
|
||||
Nurb *nurb_new;
|
||||
BezTriple *bezt_new;
|
||||
|
||||
BEZ_DESEL(bezt);
|
||||
BEZT_DESEL_ALL(bezt);
|
||||
nurb_new = BKE_nurb_copy(nu, 1, 1);
|
||||
nurb_new->flagu &= ~CU_NURB_CYCLIC;
|
||||
BLI_addtail(&editnurb->nurbs, nurb_new);
|
||||
bezt_new = nurb_new->bezt;
|
||||
ED_curve_beztcpy(editnurb, bezt_new, bezt, 1);
|
||||
BEZ_SEL(bezt_new);
|
||||
BEZT_SEL_ALL(bezt_new);
|
||||
|
||||
if (cu_actvert.bezt == bezt || cu_actnu == NULL) {
|
||||
BKE_curve_nurb_vert_active_set(cu, nurb_new, bezt_new);
|
||||
@@ -4744,7 +4679,7 @@ static int ed_editcurve_addvert(Curve *cu, EditNurb *editnurb, const float locat
|
||||
BezTriple *bezt;
|
||||
|
||||
for (i = 0, bezt = nu->bezt; i < nu->pntsu; i++, bezt++) {
|
||||
if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
|
||||
if (BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt)) {
|
||||
minmax_v3v3_v3(UNPACK2(minmax), bezt->vec[1]);
|
||||
nu_has_select = true;
|
||||
}
|
||||
@@ -4777,7 +4712,7 @@ static int ed_editcurve_addvert(Curve *cu, EditNurb *editnurb, const float locat
|
||||
if (nu->type == CU_BEZIER) {
|
||||
BezTriple *bezt;
|
||||
for (i = 0, bezt = nu->bezt; i < nu->pntsu; i++, bezt++) {
|
||||
if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
|
||||
if (BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt)) {
|
||||
add_v3_v3(bezt->vec[0], ofs);
|
||||
add_v3_v3(bezt->vec[1], ofs);
|
||||
add_v3_v3(bezt->vec[2], ofs);
|
||||
@@ -4825,7 +4760,7 @@ static int ed_editcurve_addvert(Curve *cu, EditNurb *editnurb, const float locat
|
||||
|
||||
bezt_new = nurb_new->bezt;
|
||||
|
||||
BEZ_SEL(bezt_new);
|
||||
BEZT_SEL_ALL(bezt_new);
|
||||
|
||||
bezt_new->h1 = HD_AUTO;
|
||||
bezt_new->h2 = HD_AUTO;
|
||||
@@ -4916,7 +4851,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
|
||||
cu = vc.obedit->data;
|
||||
|
||||
findselectedNurbvert(&cu->editnurb->nurbs, &nu, &bezt, &bp);
|
||||
findselectedNurbvert(cu, &nu, &bezt, &bp);
|
||||
|
||||
if (bezt) {
|
||||
mul_v3_m4v3(location, vc.obedit->obmat, bezt->vec[1]);
|
||||
@@ -4977,7 +4912,9 @@ static int curve_extrude_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
if (obedit->type != OB_CURVE) {
|
||||
Nurb *nu;
|
||||
for (nu = editnurb->nurbs.first; nu; nu = nu->next) {
|
||||
if (nu->pntsv == 1 && isNurbsel_count(cu, nu) == 1) {
|
||||
if ((nu->pntsv == 1) &&
|
||||
(ED_curve_nurb_select_count(cu, nu) == 1))
|
||||
{
|
||||
as_curve = true;
|
||||
break;
|
||||
}
|
||||
@@ -5050,7 +4987,7 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op)
|
||||
a = nu->pntsu;
|
||||
bezt = nu->bezt;
|
||||
while (a--) {
|
||||
if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
|
||||
if (BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt)) {
|
||||
nu->flagu ^= CU_NURB_CYCLIC;
|
||||
break;
|
||||
}
|
||||
@@ -5218,12 +5155,12 @@ static int curve_delete_segments(Object *obedit, const bool split)
|
||||
|
||||
if (nu->type == CU_BEZIER) {
|
||||
for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) {
|
||||
if (!BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
|
||||
if (!BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt)) {
|
||||
enda = a;
|
||||
if (starta == -1) starta = a;
|
||||
if (a < nu->pntsu - 1) continue;
|
||||
}
|
||||
else if (a < nu->pntsu - 1 && !BEZSELECTED_HIDDENHANDLES(cu, bezt + 1)) {
|
||||
else if (a < nu->pntsu - 1 && !BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt + 1)) {
|
||||
/* if just single selected point then continue */
|
||||
continue;
|
||||
}
|
||||
@@ -5247,8 +5184,8 @@ static int curve_delete_segments(Object *obedit, const bool split)
|
||||
bezt2 = &nu->bezt[nu->pntsu - 2];
|
||||
|
||||
if ((nu->flagu & CU_NURB_CYCLIC) &&
|
||||
BEZSELECTED_HIDDENHANDLES(cu, bezt1) &&
|
||||
BEZSELECTED_HIDDENHANDLES(cu, bezt2))
|
||||
BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt1) &&
|
||||
BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt2))
|
||||
{
|
||||
/* check if need to join start of spline to end */
|
||||
nu1 = BKE_nurb_copy(nu, cut + 1, 1);
|
||||
@@ -5269,8 +5206,8 @@ static int curve_delete_segments(Object *obedit, const bool split)
|
||||
bezt2 = &nu->bezt[1];
|
||||
|
||||
if ((nu->flagu & CU_NURB_CYCLIC) &&
|
||||
BEZSELECTED_HIDDENHANDLES(cu, bezt1) &&
|
||||
BEZSELECTED_HIDDENHANDLES(cu, bezt2))
|
||||
BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt1) &&
|
||||
BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt2))
|
||||
{
|
||||
/* check if need to join start of spline to end */
|
||||
nu1 = BKE_nurb_copy(nu, cut + 1, 1);
|
||||
@@ -5310,8 +5247,8 @@ static int curve_delete_segments(Object *obedit, const bool split)
|
||||
bezt1 = nu->bezt;
|
||||
bezt2 = &nu->bezt[1];
|
||||
|
||||
if (BEZSELECTED_HIDDENHANDLES(cu, bezt1) &&
|
||||
BEZSELECTED_HIDDENHANDLES(cu, bezt2))
|
||||
if (BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt1) &&
|
||||
BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt2))
|
||||
{
|
||||
nu1 = BKE_nurb_copy(nu, 1, 1);
|
||||
ED_curve_beztcpy(editnurb, nu1->bezt, bezt1, 1);
|
||||
@@ -5321,8 +5258,8 @@ static int curve_delete_segments(Object *obedit, const bool split)
|
||||
bezt1 = &nu->bezt[nu->pntsu - 1];
|
||||
bezt2 = &nu->bezt[nu->pntsu - 2];
|
||||
|
||||
if (BEZSELECTED_HIDDENHANDLES(cu, bezt1) &&
|
||||
BEZSELECTED_HIDDENHANDLES(cu, bezt2))
|
||||
if (BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt1) &&
|
||||
BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt2))
|
||||
{
|
||||
nu1 = BKE_nurb_copy(nu, 1, 1);
|
||||
ED_curve_beztcpy(editnurb, nu1->bezt, bezt1, 1);
|
||||
@@ -5682,7 +5619,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
for (nu = editnurb->first; nu; nu = nu->next) {
|
||||
if (isNurbsel(nu)) {
|
||||
if (ED_curve_nurb_select_check(obedit->data, nu)) {
|
||||
if (!clear) nu->flag |= CU_SMOOTH;
|
||||
else nu->flag &= ~CU_SMOOTH;
|
||||
}
|
||||
@@ -5840,7 +5777,7 @@ static int clear_tilt_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
bezt = nu->bezt;
|
||||
a = nu->pntsu;
|
||||
while (a--) {
|
||||
if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) bezt->alfa = 0.0;
|
||||
if (BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt)) bezt->alfa = 0.0;
|
||||
bezt++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,32 +113,129 @@ static bool swap_selection_bpoint(BPoint *bp)
|
||||
return select_bpoint(bp, SELECT, SELECT, VISIBLE);
|
||||
}
|
||||
|
||||
bool ED_curve_nurb_select_check(Curve *cu, Nurb *nu)
|
||||
{
|
||||
if (nu->type == CU_BEZIER) {
|
||||
BezTriple *bezt;
|
||||
int i;
|
||||
|
||||
for (i = nu->pntsu, bezt = nu->bezt; i--; bezt++) {
|
||||
if (BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
BPoint *bp;
|
||||
int i;
|
||||
|
||||
for (i = nu->pntsu * nu->pntsv, bp = nu->bp; i--; bp++) {
|
||||
if (bp->f1 & SELECT) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int ED_curve_nurb_select_count(Curve *cu, Nurb *nu)
|
||||
{
|
||||
int sel = 0;
|
||||
|
||||
if (nu->type == CU_BEZIER) {
|
||||
BezTriple *bezt;
|
||||
int i;
|
||||
|
||||
for (i = nu->pntsu, bezt = nu->bezt; i--; bezt++) {
|
||||
if (BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt)) {
|
||||
return sel++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
BPoint *bp;
|
||||
int i;
|
||||
|
||||
for (i = nu->pntsu * nu->pntsv, bp = nu->bp; i--; bp++) {
|
||||
if (bp->f1 & SELECT) {
|
||||
return sel++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sel;
|
||||
}
|
||||
|
||||
void ED_curve_nurb_select_all(Nurb *nu)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (nu->bezt) {
|
||||
BezTriple *bezt;
|
||||
for (i = nu->pntsu, bezt = nu->bezt; i--; bezt++) {
|
||||
if (bezt->hide == 0) {
|
||||
BEZT_SEL_ALL(bezt);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (nu->bp) {
|
||||
BPoint *bp;
|
||||
for (i = nu->pntsu * nu->pntsv, bp = nu->bp; i--; bp++) {
|
||||
if (bp->hide == 0) {
|
||||
bp->f1 |= SELECT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ED_curve_select_all(EditNurb *editnurb)
|
||||
{
|
||||
Nurb *nu;
|
||||
int a;
|
||||
for (nu = editnurb->nurbs.first; nu; nu = nu->next) {
|
||||
if (nu->bezt) {
|
||||
BezTriple *bezt;
|
||||
for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) {
|
||||
if (bezt->hide == 0) {
|
||||
bezt->f1 |= SELECT;
|
||||
bezt->f2 |= SELECT;
|
||||
bezt->f3 |= SELECT;
|
||||
}
|
||||
}
|
||||
ED_curve_nurb_select_all(nu);
|
||||
}
|
||||
}
|
||||
|
||||
void ED_curve_nurb_deselect_all(Nurb *nu)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (nu->bezt) {
|
||||
BezTriple *bezt;
|
||||
for (i = nu->pntsu, bezt = nu->bezt; i--; bezt++) {
|
||||
BEZT_DESEL_ALL(bezt);
|
||||
}
|
||||
else if (nu->bp) {
|
||||
BPoint *bp;
|
||||
for (bp = nu->bp, a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) {
|
||||
if (bp->hide == 0)
|
||||
bp->f1 |= SELECT;
|
||||
}
|
||||
}
|
||||
else if (nu->bp) {
|
||||
BPoint *bp;
|
||||
for (i = nu->pntsu * nu->pntsv, bp = nu->bp; i--; bp++) {
|
||||
bp->f1 &= ~SELECT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ED_curve_select_check(Curve *cu, struct EditNurb *editnurb)
|
||||
{
|
||||
Nurb *nu;
|
||||
|
||||
for (nu = editnurb->nurbs.first; nu; nu = nu->next) {
|
||||
if (ED_curve_nurb_select_check(cu, nu)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ED_curve_deselect_all(EditNurb *editnurb)
|
||||
{
|
||||
Nurb *nu;
|
||||
|
||||
for (nu = editnurb->nurbs.first; nu; nu = nu->next) {
|
||||
ED_curve_nurb_deselect_all(nu);
|
||||
}
|
||||
}
|
||||
|
||||
void ED_curve_select_swap(EditNurb *editnurb, bool hide_handles)
|
||||
{
|
||||
Nurb *nu;
|
||||
@@ -353,55 +450,17 @@ void CURVE_OT_de_select_last(wmOperatorType *ot)
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/******************* de select all operator ***************/
|
||||
|
||||
static bool nurb_has_selected_cps(ListBase *editnurb)
|
||||
{
|
||||
Nurb *nu;
|
||||
BezTriple *bezt;
|
||||
BPoint *bp;
|
||||
int a;
|
||||
|
||||
for (nu = editnurb->first; nu; nu = nu->next) {
|
||||
if (nu->type == CU_BEZIER) {
|
||||
a = nu->pntsu;
|
||||
bezt = nu->bezt;
|
||||
while (a--) {
|
||||
if (bezt->hide == 0) {
|
||||
if ((bezt->f1 & SELECT) ||
|
||||
(bezt->f2 & SELECT) ||
|
||||
(bezt->f3 & SELECT))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
bezt++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
a = nu->pntsu * nu->pntsv;
|
||||
bp = nu->bp;
|
||||
while (a--) {
|
||||
if ((bp->hide == 0) && (bp->f1 & SELECT)) return 1;
|
||||
bp++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int de_select_all_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
Curve *cu = obedit->data;
|
||||
ListBase *editnurb = object_editcurve_get(obedit);
|
||||
int action = RNA_enum_get(op->ptr, "action");
|
||||
|
||||
if (action == SEL_TOGGLE) {
|
||||
action = SEL_SELECT;
|
||||
if (nurb_has_selected_cps(editnurb))
|
||||
if (ED_curve_select_check(cu, cu->editnurb)) {
|
||||
action = SEL_DESELECT;
|
||||
}
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
@@ -451,42 +510,10 @@ static int select_linked_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
EditNurb *editnurb = cu->editnurb;
|
||||
ListBase *nurbs = &editnurb->nurbs;
|
||||
Nurb *nu;
|
||||
BezTriple *bezt;
|
||||
BPoint *bp;
|
||||
int a;
|
||||
|
||||
for (nu = nurbs->first; nu; nu = nu->next) {
|
||||
if (nu->type == CU_BEZIER) {
|
||||
bezt = nu->bezt;
|
||||
a = nu->pntsu;
|
||||
while (a--) {
|
||||
if ((bezt->f1 & SELECT) || (bezt->f2 & SELECT) || (bezt->f3 & SELECT)) {
|
||||
a = nu->pntsu;
|
||||
bezt = nu->bezt;
|
||||
while (a--) {
|
||||
select_beztriple(bezt, SELECT, SELECT, VISIBLE);
|
||||
bezt++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
bezt++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
bp = nu->bp;
|
||||
a = nu->pntsu * nu->pntsv;
|
||||
while (a--) {
|
||||
if (bp->f1 & SELECT) {
|
||||
a = nu->pntsu * nu->pntsv;
|
||||
bp = nu->bp;
|
||||
while (a--) {
|
||||
select_bpoint(bp, SELECT, SELECT, VISIBLE);
|
||||
bp++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
bp++;
|
||||
}
|
||||
if (ED_curve_nurb_select_check(cu, nu)) {
|
||||
ED_curve_nurb_select_all(nu);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1228,7 +1255,7 @@ static void curve_select_similar_direction__bp(Nurb *nu, const float dir_ref[3],
|
||||
BPoint *bp;
|
||||
int i;
|
||||
|
||||
for (i = nu->pntsu, bp = nu->bp; i--; bp++) {
|
||||
for (i = nu->pntsu * nu->pntsv, bp = nu->bp; i--; bp++) {
|
||||
if (!bp->hide) {
|
||||
float dir[3];
|
||||
BKE_nurb_bpoint_calc_normal(nu, bp, dir);
|
||||
@@ -1388,30 +1415,6 @@ static bool curve_select_similar_weight(ListBase *editnurb, Curve *cu, float com
|
||||
return true;
|
||||
}
|
||||
|
||||
static void curve_select_all__bezt(Nurb *nu)
|
||||
{
|
||||
BezTriple *bezt;
|
||||
int i;
|
||||
|
||||
for (i = nu->pntsu, bezt = nu->bezt; i--; bezt++) {
|
||||
if (!bezt->hide) {
|
||||
select_beztriple(bezt, SELECT, SELECT, VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void curve_select_all__bp(Nurb *nu)
|
||||
{
|
||||
BPoint *bp;
|
||||
int i;
|
||||
|
||||
for (i = nu->pntsu * nu->pntsv, bp = nu->bp; i--; bp++) {
|
||||
if (!bp->hide) {
|
||||
select_bpoint(bp, SELECT, SELECT, VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool curve_select_similar_type(ListBase *editnurb, Curve *cu)
|
||||
{
|
||||
Nurb *nu, *act_nu;
|
||||
@@ -1428,12 +1431,7 @@ static bool curve_select_similar_type(ListBase *editnurb, Curve *cu)
|
||||
|
||||
for (nu = editnurb->first; nu; nu = nu->next) {
|
||||
if (nu->type == type_ref) {
|
||||
if (type_ref == CU_BEZIER) {
|
||||
curve_select_all__bezt(nu);
|
||||
}
|
||||
else {
|
||||
curve_select_all__bp(nu);
|
||||
}
|
||||
ED_curve_nurb_select_all(nu);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,11 +59,15 @@ bool mouse_nurb(struct bContext *C, const int mval[2], bool extend, bool dese
|
||||
|
||||
struct Nurb *add_nurbs_primitive(struct bContext *C, struct Object *obedit, float mat[4][4], int type, int newob);
|
||||
|
||||
int isNurbsel(struct Nurb *nu);
|
||||
bool ED_curve_nurb_select_check(struct Curve *cu, struct Nurb *nu);
|
||||
int ED_curve_nurb_select_count(struct Curve *cu, struct Nurb *nu);
|
||||
void ED_curve_nurb_select_all(struct Nurb *nu);
|
||||
void ED_curve_nurb_deselect_all(struct Nurb *nu);
|
||||
|
||||
int join_curve_exec(struct bContext *C, struct wmOperator *op);
|
||||
|
||||
/* editcurve_select.c */
|
||||
bool ED_curve_select_check(struct Curve *cu, struct EditNurb *editnurb);
|
||||
void ED_curve_deselect_all(struct EditNurb *editnurb);
|
||||
void ED_curve_select_all(struct EditNurb *editnurb);
|
||||
void ED_curve_select_swap(struct EditNurb *editnurb, bool hide_handles);
|
||||
|
||||
@@ -41,12 +41,6 @@ struct Scene;
|
||||
/* ************************************************ */
|
||||
/* Common Macros and Defines */
|
||||
|
||||
/* --------- BezTriple Selection ------------- */
|
||||
|
||||
#define BEZ_SEL(bezt) { (bezt)->f1 |= SELECT; (bezt)->f2 |= SELECT; (bezt)->f3 |= SELECT; } (void)0
|
||||
#define BEZ_DESEL(bezt) { (bezt)->f1 &= ~SELECT; (bezt)->f2 &= ~SELECT; (bezt)->f3 &= ~SELECT; } (void)0
|
||||
#define BEZ_INVSEL(bezt) { (bezt)->f1 ^= SELECT; (bezt)->f2 ^= SELECT; (bezt)->f3 ^= SELECT; } (void)0
|
||||
|
||||
/* --------- Tool Flags ------------ */
|
||||
|
||||
/* bezt validation */
|
||||
|
||||
@@ -254,7 +254,7 @@ static int return_editcurve_indexar(
|
||||
}
|
||||
if (totvert == 0) return 0;
|
||||
|
||||
*r_indexar = index = MEM_mallocN(4 * totvert, "hook indexar");
|
||||
*r_indexar = index = MEM_mallocN(sizeof(*index) * totvert, "hook indexar");
|
||||
*r_tot = totvert;
|
||||
nr = 0;
|
||||
zero_v3(r_cent);
|
||||
|
||||
@@ -169,7 +169,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
|
||||
bezt = nu->bezt;
|
||||
a = nu->pntsu;
|
||||
while (a--) {
|
||||
if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
|
||||
if (BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt)) {
|
||||
if (v1 == 0) v1 = nr;
|
||||
else if (v2 == 0) v2 = nr;
|
||||
else if (v3 == 0) v3 = nr;
|
||||
|
||||
@@ -201,9 +201,11 @@ static int material_slot_assign_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
ListBase *nurbs = BKE_curve_editNurbs_get((Curve *)ob->data);
|
||||
|
||||
if (nurbs) {
|
||||
for (nu = nurbs->first; nu; nu = nu->next)
|
||||
if (isNurbsel(nu))
|
||||
for (nu = nurbs->first; nu; nu = nu->next) {
|
||||
if (ED_curve_nurb_select_check(ob->data, nu)) {
|
||||
nu->mat_nr = ob->actcol - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ob->type == OB_FONT) {
|
||||
|
||||
@@ -225,7 +225,7 @@ static int paintcurve_point_co_index(char sel)
|
||||
static char paintcurve_point_side_index(const BezTriple *bezt, const bool is_first, const char fallback)
|
||||
{
|
||||
/* when matching, guess based on endpoint side */
|
||||
if (BEZSELECTED(bezt)) {
|
||||
if (BEZT_ISSEL_ANY(bezt)) {
|
||||
if ((bezt->f1 & SELECT) == (bezt->f3 & SELECT)) {
|
||||
return is_first ? SEL_F1 : SEL_F3;
|
||||
}
|
||||
@@ -395,7 +395,7 @@ static int paintcurve_delete_point_exec(bContext *C, wmOperator *op)
|
||||
#define DELETE_TAG 2
|
||||
|
||||
for (i = 0, pcp = pc->points; i < pc->tot_points; i++, pcp++) {
|
||||
if ((pcp->bez.f1 & SELECT) || (pcp->bez.f2 & SELECT) || (pcp->bez.f3 & SELECT)) {
|
||||
if (BEZT_ISSEL_ANY(&pcp->bez)) {
|
||||
pcp->bez.f2 |= DELETE_TAG;
|
||||
tot_del++;
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ static short get_active_fcurve_keyframe_edit(FCurve *fcu, BezTriple **bezt, BezT
|
||||
* wants to edit numerically, there is likely to only be 1 vert selected
|
||||
*/
|
||||
for (i = 0, b = fcu->bezt; i < fcu->totvert; i++, b++) {
|
||||
if (BEZSELECTED(b)) {
|
||||
if (BEZT_ISSEL_ANY(b)) {
|
||||
/* found
|
||||
* - 'previous' is either the one before, of the keyframe itself (which is still fine)
|
||||
* XXX: we can just make this null instead if needed
|
||||
|
||||
@@ -229,7 +229,7 @@ static void draw_fcurve_vertices_handles(FCurve *fcu, SpaceIpo *sipo, View2D *v2
|
||||
* Also, need to take into account whether the keyframe was selected
|
||||
* if a Graph Editor option to only show handles of selected keys is on.
|
||||
*/
|
||||
if (!sel_handle_only || BEZSELECTED(bezt)) {
|
||||
if (!sel_handle_only || BEZT_ISSEL_ANY(bezt)) {
|
||||
if ((!prevbezt && (bezt->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))) {
|
||||
if ((bezt->f1 & SELECT) == sel) /* && v2d->cur.xmin < bezt->vec[0][0] < v2d->cur.xmax)*/
|
||||
draw_fcurve_handle_control(bezt->vec[0][0], bezt->vec[0][1], xscale, yscale, hsize);
|
||||
@@ -345,7 +345,7 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu)
|
||||
* check that keyframe is selected
|
||||
*/
|
||||
if (sipo->flag & SIPO_SELVHANDLESONLY) {
|
||||
if (BEZSELECTED(bezt) == 0)
|
||||
if (BEZT_ISSEL_ANY(bezt) == 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1112,7 +1112,7 @@ typedef enum eGraphVertIndex {
|
||||
static bool fcurve_handle_sel_check(SpaceIpo *sipo, BezTriple *bezt)
|
||||
{
|
||||
if (sipo->flag & SIPO_NOHANDLES) return 0;
|
||||
if ((sipo->flag & SIPO_SELVHANDLESONLY) && BEZSELECTED(bezt) == 0) return 0;
|
||||
if ((sipo->flag & SIPO_SELVHANDLESONLY) && BEZT_ISSEL_ANY(bezt) == 0) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1143,7 +1143,7 @@ static void nearest_fcurve_vert_store(
|
||||
/* if there is already a point for the F-Curve, check if this point is closer than that was */
|
||||
if ((nvi) && (nvi->fcu == fcu)) {
|
||||
/* replace if we are closer, or if equal and that one wasn't selected but we are... */
|
||||
if ((nvi->dist > dist) || ((nvi->sel == 0) && BEZSELECTED(bezt)))
|
||||
if ((nvi->dist > dist) || ((nvi->sel == 0) && BEZT_ISSEL_ANY(bezt)))
|
||||
replace = 1;
|
||||
}
|
||||
/* add new if not replacing... */
|
||||
@@ -1158,7 +1158,7 @@ static void nearest_fcurve_vert_store(
|
||||
nvi->hpoint = hpoint;
|
||||
nvi->dist = dist;
|
||||
|
||||
nvi->sel = BEZSELECTED(bezt); // XXX... should this use the individual verts instead?
|
||||
nvi->sel = BEZT_ISSEL_ANY(bezt); // XXX... should this use the individual verts instead?
|
||||
|
||||
/* add to list of matches if appropriate... */
|
||||
if (replace == 0)
|
||||
@@ -1338,11 +1338,11 @@ static void mouse_graph_keys(bAnimContext *ac, const int mval[2], short select_m
|
||||
if (select_mode == SELECT_INVERT) {
|
||||
/* keyframe - invert select of all */
|
||||
if (nvi->hpoint == NEAREST_HANDLE_KEY) {
|
||||
if (BEZSELECTED(bezt)) {
|
||||
BEZ_DESEL(bezt);
|
||||
if (BEZT_ISSEL_ANY(bezt)) {
|
||||
BEZT_DESEL_ALL(bezt);
|
||||
}
|
||||
else {
|
||||
BEZ_SEL(bezt);
|
||||
BEZT_SEL_ALL(bezt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1359,7 +1359,7 @@ static void mouse_graph_keys(bAnimContext *ac, const int mval[2], short select_m
|
||||
else {
|
||||
/* if the keyframe was clicked on, select all verts of given beztriple */
|
||||
if (nvi->hpoint == NEAREST_HANDLE_KEY) {
|
||||
BEZ_SEL(bezt);
|
||||
BEZT_SEL_ALL(bezt);
|
||||
}
|
||||
/* otherwise, select the handle that applied */
|
||||
else if (nvi->hpoint == NEAREST_HANDLE_LEFT)
|
||||
@@ -1393,7 +1393,7 @@ static void mouse_graph_keys(bAnimContext *ac, const int mval[2], short select_m
|
||||
/* take selection status from item that got hit, to prevent flip/flop on channel
|
||||
* selection status when shift-selecting (i.e. "SELECT_INVERT") points
|
||||
*/
|
||||
if (BEZSELECTED(bezt))
|
||||
if (BEZT_ISSEL_ANY(bezt))
|
||||
nvi->fcu->flag |= FCURVE_SELECTED;
|
||||
else
|
||||
nvi->fcu->flag &= ~FCURVE_SELECTED;
|
||||
|
||||
@@ -3312,7 +3312,7 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle)
|
||||
for (i = 0; i < fcu->totvert; i++) {
|
||||
BezTriple *bezt = &fcu->bezt[i];
|
||||
|
||||
if (BEZSELECTED(bezt)) {
|
||||
if (BEZT_ISSEL_ANY(bezt)) {
|
||||
selcache[index] = bezt->vec[1][0];
|
||||
index++;
|
||||
len++;
|
||||
@@ -3326,7 +3326,7 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle)
|
||||
for (i = fcu->totvert - 1; i >= 0; i--) {
|
||||
BezTriple *bezt = &fcu->bezt[i];
|
||||
|
||||
if (BEZSELECTED(bezt) == 0) {
|
||||
if (BEZT_ISSEL_ANY(bezt) == 0) {
|
||||
/* check beztriple should be removed according to cache */
|
||||
for (index = 0; index < len; index++) {
|
||||
if (IS_EQF(bezt->vec[1][0], selcache[index])) {
|
||||
@@ -3492,7 +3492,7 @@ static TransData *ActionFCurveToTransData(TransData *td, TransData2D **td2dv, FC
|
||||
|
||||
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
|
||||
/* only add selected keyframes (for now, proportional edit is not enabled) */
|
||||
if (is_prop_edit || (bezt->f2 & SELECT)) { /* note this MUST match count_fcurve_keys(), so can't use BEZSELECTED() macro */
|
||||
if (is_prop_edit || (bezt->f2 & SELECT)) { /* note this MUST match count_fcurve_keys(), so can't use BEZT_ISSEL_ANY() macro */
|
||||
/* only add if on the right 'side' of the current frame */
|
||||
if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) {
|
||||
TimeToTransData(td, bezt->vec[1], adt, ypos);
|
||||
|
||||
@@ -304,7 +304,7 @@ static bool fcu_test_selected(FCurve *fcu)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < fcu->totvert; i++, bezt++) {
|
||||
if (BEZSELECTED(bezt)) return 1;
|
||||
if (BEZT_ISSEL_ANY(bezt)) return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -416,8 +416,13 @@ typedef enum eBezTriple_KeyframeType {
|
||||
} eBezTriple_KeyframeType;
|
||||
|
||||
/* checks if the given BezTriple is selected */
|
||||
#define BEZSELECTED(bezt) (((bezt)->f2 & SELECT) || ((bezt)->f1 & SELECT) || ((bezt)->f3 & SELECT))
|
||||
#define BEZSELECTED_HIDDENHANDLES(cu, bezt) (((cu)->drawflag & CU_HIDE_HANDLES) ? (bezt)->f2 & SELECT : BEZSELECTED(bezt))
|
||||
#define BEZT_ISSEL_ANY(bezt) \
|
||||
(((bezt)->f2 & SELECT) || ((bezt)->f1 & SELECT) || ((bezt)->f3 & SELECT))
|
||||
#define BEZT_ISSEL_ANY_HIDDENHANDLES(cu, bezt) \
|
||||
(((cu)->drawflag & CU_HIDE_HANDLES) ? (bezt)->f2 & SELECT : BEZT_ISSEL_ANY(bezt))
|
||||
|
||||
#define BEZT_SEL_ALL(bezt) { (bezt)->f1 |= SELECT; (bezt)->f2 |= SELECT; (bezt)->f3 |= SELECT; } ((void)0)
|
||||
#define BEZT_DESEL_ALL(bezt) { (bezt)->f1 &= ~SELECT; (bezt)->f2 &= ~SELECT; (bezt)->f3 &= ~SELECT; } ((void)0)
|
||||
|
||||
/* *************** CHARINFO **************** */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user