Cleanup: style, use braces for editor/curve
This commit is contained in:
@@ -140,7 +140,9 @@ static void init_editNurb_keyIndex(EditNurb *editnurb, ListBase *origBase)
|
||||
CVKeyIndex *keyIndex;
|
||||
int a, key_index = 0, nu_index = 0, pt_index = 0, vertex_index = 0;
|
||||
|
||||
if (editnurb->keyindex) return;
|
||||
if (editnurb->keyindex) {
|
||||
return;
|
||||
}
|
||||
|
||||
gh = BLI_ghash_ptr_new("editNurb keyIndex");
|
||||
|
||||
@@ -346,8 +348,12 @@ static void keyIndex_swap(EditNurb *editnurb, void *a, void *b)
|
||||
CVKeyIndex *index1 = popCVKeyIndex(editnurb, a);
|
||||
CVKeyIndex *index2 = popCVKeyIndex(editnurb, b);
|
||||
|
||||
if (index2) BLI_ghash_insert(editnurb->keyindex, a, index2);
|
||||
if (index1) BLI_ghash_insert(editnurb->keyindex, b, index1);
|
||||
if (index2) {
|
||||
BLI_ghash_insert(editnurb->keyindex, a, index2);
|
||||
}
|
||||
if (index1) {
|
||||
BLI_ghash_insert(editnurb->keyindex, b, index1);
|
||||
}
|
||||
}
|
||||
|
||||
static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu)
|
||||
@@ -363,7 +369,9 @@ static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu)
|
||||
bezt1 = nu->bezt;
|
||||
bezt2 = bezt1 + (a - 1);
|
||||
|
||||
if (a & 1) ++a;
|
||||
if (a & 1) {
|
||||
a++;
|
||||
}
|
||||
|
||||
a /= 2;
|
||||
|
||||
@@ -371,12 +379,16 @@ static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu)
|
||||
index1 = getCVKeyIndex(editnurb, bezt1);
|
||||
index2 = getCVKeyIndex(editnurb, bezt2);
|
||||
|
||||
if (index1) index1->switched = !index1->switched;
|
||||
if (index1) {
|
||||
index1->switched = !index1->switched;
|
||||
}
|
||||
|
||||
if (bezt1 != bezt2) {
|
||||
keyIndex_swap(editnurb, bezt1, bezt2);
|
||||
|
||||
if (index2) index2->switched = !index2->switched;
|
||||
if (index2) {
|
||||
index2->switched = !index2->switched;
|
||||
}
|
||||
}
|
||||
|
||||
bezt1++;
|
||||
@@ -395,10 +407,14 @@ static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu)
|
||||
index1 = getCVKeyIndex(editnurb, bp1);
|
||||
index2 = getCVKeyIndex(editnurb, bp2);
|
||||
|
||||
if (index1) index1->switched = !index1->switched;
|
||||
if (index1) {
|
||||
index1->switched = !index1->switched;
|
||||
}
|
||||
|
||||
if (bp1 != bp2) {
|
||||
if (index2) index2->switched = !index2->switched;
|
||||
if (index2) {
|
||||
index2->switched = !index2->switched;
|
||||
}
|
||||
|
||||
keyIndex_swap(editnurb, bp1, bp2);
|
||||
}
|
||||
@@ -422,10 +438,14 @@ static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu)
|
||||
index1 = getCVKeyIndex(editnurb, bp1);
|
||||
index2 = getCVKeyIndex(editnurb, bp2);
|
||||
|
||||
if (index1) index1->switched = !index1->switched;
|
||||
if (index1) {
|
||||
index1->switched = !index1->switched;
|
||||
}
|
||||
|
||||
if (bp1 != bp2) {
|
||||
if (index2) index2->switched = !index2->switched;
|
||||
if (index2) {
|
||||
index2->switched = !index2->switched;
|
||||
}
|
||||
|
||||
keyIndex_swap(editnurb, bp1, bp2);
|
||||
}
|
||||
@@ -506,8 +526,9 @@ static void keyData_switchDirectionNurb(Curve *cu, Nurb *nu)
|
||||
}
|
||||
|
||||
keyIndex_switchDirection(editnurb, nu);
|
||||
if (cu->key)
|
||||
if (cu->key) {
|
||||
switch_keys_direction(cu, nu);
|
||||
}
|
||||
}
|
||||
|
||||
GHash *ED_curve_keyindex_hash_duplicate(GHash *keyindex)
|
||||
@@ -579,8 +600,12 @@ static void calc_keyHandles(ListBase *nurb, float *key)
|
||||
while (a--) {
|
||||
key_to_bezt(fp, bezt, &cur);
|
||||
|
||||
if (nextp) key_to_bezt(nextfp, nextp, &next);
|
||||
if (prevp) key_to_bezt(prevfp, prevp, &prev);
|
||||
if (nextp) {
|
||||
key_to_bezt(nextfp, nextp, &next);
|
||||
}
|
||||
if (prevp) {
|
||||
key_to_bezt(prevfp, prevp, &prev);
|
||||
}
|
||||
|
||||
BKE_nurb_handle_calc(&cur, prevp ? &prev : NULL, nextp ? &next : NULL, 0, 0);
|
||||
bezt_to_key(&cur, fp);
|
||||
@@ -856,13 +881,17 @@ static void calc_shapeKeys(Object *obedit, ListBase *newnurbs)
|
||||
}
|
||||
|
||||
currkey->totelem = totvert;
|
||||
if (currkey->data) MEM_freeN(currkey->data);
|
||||
if (currkey->data) {
|
||||
MEM_freeN(currkey->data);
|
||||
}
|
||||
currkey->data = newkey;
|
||||
|
||||
currkey = currkey->next;
|
||||
}
|
||||
|
||||
if (ofs) MEM_freeN(ofs);
|
||||
if (ofs) {
|
||||
MEM_freeN(ofs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -894,10 +923,12 @@ static void fcurve_path_rename(AnimData *adt, const char *orig_rna_path, char *r
|
||||
action_groups_remove_channel(adt->action, fcu);
|
||||
action_groups_add_channel(adt->action, fcu->grp, nfcu);
|
||||
}
|
||||
else if ((adt->action) && (&adt->action->curves == orig_curves))
|
||||
else if ((adt->action) && (&adt->action->curves == orig_curves)) {
|
||||
BLI_remlink(&adt->action->curves, fcu);
|
||||
else
|
||||
}
|
||||
else {
|
||||
BLI_remlink(&adt->drivers, fcu);
|
||||
}
|
||||
|
||||
free_fcurve(fcu);
|
||||
|
||||
@@ -908,8 +939,12 @@ static void fcurve_path_rename(AnimData *adt, const char *orig_rna_path, char *r
|
||||
|
||||
static void fcurve_remove(AnimData *adt, ListBase *orig_curves, FCurve *fcu)
|
||||
{
|
||||
if (orig_curves == &adt->drivers) BLI_remlink(&adt->drivers, fcu);
|
||||
else action_groups_remove_channel(adt->action, fcu);
|
||||
if (orig_curves == &adt->drivers) {
|
||||
BLI_remlink(&adt->drivers, fcu);
|
||||
}
|
||||
else {
|
||||
action_groups_remove_channel(adt->action, fcu);
|
||||
}
|
||||
|
||||
free_fcurve(fcu);
|
||||
}
|
||||
@@ -989,16 +1024,21 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves)
|
||||
if (STREQLEN(fcu->rna_path, "splines", 7)) {
|
||||
const char *ch = strchr(fcu->rna_path, '.');
|
||||
|
||||
if (ch && (STREQLEN(ch, ".bezier_points", 14) || STREQLEN(ch, ".points", 7)))
|
||||
if (ch && (STREQLEN(ch, ".bezier_points", 14) || STREQLEN(ch, ".points", 7))) {
|
||||
fcurve_remove(adt, orig_curves, fcu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (nu = editnurb->nurbs.first, nu_index = 0; nu != NULL; nu = nu->next, nu_index++) {
|
||||
keyIndex = NULL;
|
||||
if (nu->pntsu) {
|
||||
if (nu->bezt) keyIndex = getCVKeyIndex(editnurb, &nu->bezt[0]);
|
||||
else keyIndex = getCVKeyIndex(editnurb, &nu->bp[0]);
|
||||
if (nu->bezt) {
|
||||
keyIndex = getCVKeyIndex(editnurb, &nu->bezt[0]);
|
||||
}
|
||||
else {
|
||||
keyIndex = getCVKeyIndex(editnurb, &nu->bp[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if (keyIndex) {
|
||||
@@ -1013,8 +1053,12 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves)
|
||||
for (fcu = orig_curves->first; fcu; fcu = next) {
|
||||
next = fcu->next;
|
||||
|
||||
if (STREQLEN(fcu->rna_path, "splines", 7)) fcurve_remove(adt, orig_curves, fcu);
|
||||
else BLI_addtail(&curves, fcu);
|
||||
if (STREQLEN(fcu->rna_path, "splines", 7)) {
|
||||
fcurve_remove(adt, orig_curves, fcu);
|
||||
}
|
||||
else {
|
||||
BLI_addtail(&curves, fcu);
|
||||
}
|
||||
}
|
||||
|
||||
*orig_curves = curves;
|
||||
@@ -1026,10 +1070,13 @@ int ED_curve_updateAnimPaths(Main *bmain, Curve *cu)
|
||||
AnimData *adt = BKE_animdata_from_id(&cu->id);
|
||||
EditNurb *editnurb = cu->editnurb;
|
||||
|
||||
if (!editnurb->keyindex)
|
||||
if (!editnurb->keyindex) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!curve_is_animated(cu)) return 0;
|
||||
if (!curve_is_animated(cu)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (adt->action != NULL) {
|
||||
curve_rename_fcurves(cu, &adt->action->curves);
|
||||
@@ -1199,7 +1246,9 @@ void ED_curve_editnurb_load(Main *bmain, Object *obedit)
|
||||
{
|
||||
ListBase *editnurb = object_editcurve_get(obedit);
|
||||
|
||||
if (obedit == NULL) return;
|
||||
if (obedit == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
|
||||
Curve *cu = obedit->data;
|
||||
@@ -1509,11 +1558,17 @@ static bool isNurbselUV(
|
||||
for (b = 0; b < nu->pntsv; b++) {
|
||||
sel = 0;
|
||||
for (a = 0; a < nu->pntsu; a++, bp++) {
|
||||
if (bp->f1 & flag) sel++;
|
||||
if (bp->f1 & flag) {
|
||||
sel++;
|
||||
}
|
||||
}
|
||||
if (sel == nu->pntsu) {
|
||||
if (*r_u == -1) *r_u = b;
|
||||
else return 0;
|
||||
if (*r_u == -1) {
|
||||
*r_u = b;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (sel > 1) {
|
||||
return 0; /* because sel == 1 is still ok */
|
||||
@@ -1524,19 +1579,29 @@ static bool isNurbselUV(
|
||||
sel = 0;
|
||||
bp = &nu->bp[a];
|
||||
for (b = 0; b < nu->pntsv; b++, bp += nu->pntsu) {
|
||||
if (bp->f1 & flag) sel++;
|
||||
if (bp->f1 & flag) {
|
||||
sel++;
|
||||
}
|
||||
}
|
||||
if (sel == nu->pntsv) {
|
||||
if (*r_v == -1) *r_v = a;
|
||||
else return 0;
|
||||
if (*r_v == -1) {
|
||||
*r_v = a;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (sel > 1) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (*r_u == -1 && *r_v > -1) return 1;
|
||||
if (*r_v == -1 && *r_u > -1) return 1;
|
||||
if (*r_u == -1 && *r_v > -1) {
|
||||
return 1;
|
||||
}
|
||||
if (*r_v == -1 && *r_u > -1) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1551,7 +1616,9 @@ static bool isNurbselU(Nurb *nu, int *v, int flag)
|
||||
for (b = 0, bp = nu->bp; b < nu->pntsv; b++) {
|
||||
sel = 0;
|
||||
for (a = 0; a < nu->pntsu; a++, bp++) {
|
||||
if (bp->f1 & flag) sel++;
|
||||
if (bp->f1 & flag) {
|
||||
sel++;
|
||||
}
|
||||
}
|
||||
if (sel == nu->pntsu) {
|
||||
(*v)++;
|
||||
@@ -1577,7 +1644,9 @@ static bool isNurbselV(Nurb *nu, int *u, int flag)
|
||||
bp = &nu->bp[a];
|
||||
sel = 0;
|
||||
for (b = 0; b < nu->pntsv; b++, bp += nu->pntsu) {
|
||||
if (bp->f1 & flag) sel++;
|
||||
if (bp->f1 & flag) {
|
||||
sel++;
|
||||
}
|
||||
}
|
||||
if (sel == nu->pntsv) {
|
||||
(*u)++;
|
||||
@@ -1628,9 +1697,9 @@ void ed_editnurb_translate_flag(ListBase *editnurb, short flag, const float vec[
|
||||
a = nu->pntsu;
|
||||
bezt = nu->bezt;
|
||||
while (a--) {
|
||||
if (bezt->f1 & flag) add_v3_v3(bezt->vec[0], vec);
|
||||
if (bezt->f2 & flag) add_v3_v3(bezt->vec[1], vec);
|
||||
if (bezt->f3 & flag) add_v3_v3(bezt->vec[2], vec);
|
||||
if (bezt->f1 & flag) { add_v3_v3(bezt->vec[0], vec); }
|
||||
if (bezt->f2 & flag) { add_v3_v3(bezt->vec[1], vec); }
|
||||
if (bezt->f3 & flag) { add_v3_v3(bezt->vec[2], vec); }
|
||||
bezt++;
|
||||
}
|
||||
}
|
||||
@@ -1638,7 +1707,9 @@ void ed_editnurb_translate_flag(ListBase *editnurb, short flag, const float vec[
|
||||
a = nu->pntsu * nu->pntsv;
|
||||
bp = nu->bp;
|
||||
while (a--) {
|
||||
if (bp->f1 & flag) add_v3_v3(bp->vec, vec);
|
||||
if (bp->f1 & flag) {
|
||||
add_v3_v3(bp->vec, vec);
|
||||
}
|
||||
bp++;
|
||||
}
|
||||
}
|
||||
@@ -1753,7 +1824,9 @@ static void ed_surf_delete_selected(Object *obedit)
|
||||
nu->pntsv = 1;
|
||||
SWAP(short, nu->orderu, nu->orderv);
|
||||
BKE_nurb_order_clamp_u(nu);
|
||||
if (nu->knotsv) MEM_freeN(nu->knotsv);
|
||||
if (nu->knotsv) {
|
||||
MEM_freeN(nu->knotsv);
|
||||
}
|
||||
nu->knotsv = NULL;
|
||||
}
|
||||
else {
|
||||
@@ -1797,8 +1870,9 @@ static void ed_curve_delete_selected(Object *obedit, View3D *v3d)
|
||||
bezt++;
|
||||
}
|
||||
if (a == 0) {
|
||||
if (cu->actnu == nuindex)
|
||||
if (cu->actnu == nuindex) {
|
||||
cu->actnu = CU_ACT_NONE;
|
||||
}
|
||||
|
||||
BLI_remlink(nubase, nu);
|
||||
keyIndex_delNurb(editnurb, nu);
|
||||
@@ -1821,8 +1895,9 @@ static void ed_curve_delete_selected(Object *obedit, View3D *v3d)
|
||||
bp++;
|
||||
}
|
||||
if (a == 0) {
|
||||
if (cu->actnu == nuindex)
|
||||
if (cu->actnu == nuindex) {
|
||||
cu->actnu = CU_ACT_NONE;
|
||||
}
|
||||
|
||||
BLI_remlink(nubase, nu);
|
||||
keyIndex_delNurb(editnurb, nu);
|
||||
@@ -2058,9 +2133,13 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
|
||||
enda = -1;
|
||||
starta = a;
|
||||
while ((bezt->f1 & flag) || (bezt->f2 & flag) || (bezt->f3 & flag)) {
|
||||
if (!split) select_beztriple(bezt, DESELECT, flag, HIDDEN);
|
||||
if (!split) {
|
||||
select_beztriple(bezt, DESELECT, flag, HIDDEN);
|
||||
}
|
||||
enda = a;
|
||||
if (a >= nu->pntsu - 1) break;
|
||||
if (a >= nu->pntsu - 1) {
|
||||
break;
|
||||
}
|
||||
a++;
|
||||
bezt++;
|
||||
}
|
||||
@@ -2071,7 +2150,9 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
|
||||
cyclicu = newu;
|
||||
}
|
||||
else {
|
||||
if (enda == nu->pntsu - 1) newu += cyclicu;
|
||||
if (enda == nu->pntsu - 1) {
|
||||
newu += cyclicu;
|
||||
}
|
||||
if (i == cu->actnu) {
|
||||
calc_duplicate_actvert(
|
||||
editnurb, newnurb, cu,
|
||||
@@ -2090,7 +2171,9 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
|
||||
cyclicu = 0;
|
||||
}
|
||||
|
||||
if (newu != nu->pntsu) newnu->flagu &= ~CU_NURB_CYCLIC;
|
||||
if (newu != nu->pntsu) {
|
||||
newnu->flagu &= ~CU_NURB_CYCLIC;
|
||||
}
|
||||
|
||||
for (b = 0, bezt1 = newnu->bezt; b < newnu->pntsu; b++, bezt1++) {
|
||||
select_beztriple(bezt1, SELECT, flag, HIDDEN);
|
||||
@@ -2124,9 +2207,13 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
|
||||
enda = -1;
|
||||
starta = a;
|
||||
while (bp->f1 & flag) {
|
||||
if (!split) select_bpoint(bp, DESELECT, flag, HIDDEN);
|
||||
if (!split) {
|
||||
select_bpoint(bp, DESELECT, flag, HIDDEN);
|
||||
}
|
||||
enda = a;
|
||||
if (a >= nu->pntsu - 1) break;
|
||||
if (a >= nu->pntsu - 1) {
|
||||
break;
|
||||
}
|
||||
a++;
|
||||
bp++;
|
||||
}
|
||||
@@ -2137,7 +2224,9 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
|
||||
cyclicu = newu;
|
||||
}
|
||||
else {
|
||||
if (enda == nu->pntsu - 1) newu += cyclicu;
|
||||
if (enda == nu->pntsu - 1) {
|
||||
newu += cyclicu;
|
||||
}
|
||||
if (i == cu->actnu) {
|
||||
calc_duplicate_actvert(
|
||||
editnurb, newnurb, cu,
|
||||
@@ -2156,7 +2245,9 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
|
||||
cyclicu = 0;
|
||||
}
|
||||
|
||||
if (newu != nu->pntsu) newnu->flagu &= ~CU_NURB_CYCLIC;
|
||||
if (newu != nu->pntsu) {
|
||||
newnu->flagu &= ~CU_NURB_CYCLIC;
|
||||
}
|
||||
|
||||
for (b = 0, bp1 = newnu->bp; b < newnu->pntsu; b++, bp1++) {
|
||||
select_bpoint(bp1, SELECT, flag, HIDDEN);
|
||||
@@ -2192,7 +2283,9 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
|
||||
bp = nu->bp;
|
||||
for (a = 0; a < nu->pntsv; a++) {
|
||||
for (b = 0; b < nu->pntsu; b++, bp++) {
|
||||
if (bp->f1 & flag) usel[b]++;
|
||||
if (bp->f1 & flag) {
|
||||
usel[b]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
newu = 0;
|
||||
@@ -2214,8 +2307,9 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
|
||||
if ((newu == 0 || newv == 0) ||
|
||||
(split && !isNurbselU(nu, &newv, SELECT) && !isNurbselV(nu, &newu, SELECT)))
|
||||
{
|
||||
if (G.debug & G_DEBUG)
|
||||
if (G.debug & G_DEBUG) {
|
||||
printf("Can't duplicate Nurb\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (a = 0, bp1 = nu->bp; a < nu->pntsu * nu->pntsv; a++, bp1++) {
|
||||
@@ -2230,7 +2324,9 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
|
||||
if (bp3->f1 & flag) {
|
||||
/* flag as seen so skipped on future iterations */
|
||||
bp3->f1 |= SURF_SEEN;
|
||||
if (newu == 1) newv++;
|
||||
if (newu == 1) {
|
||||
newv++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
break;
|
||||
@@ -2247,9 +2343,15 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
|
||||
/* ignore single points */
|
||||
if (a == 0) {
|
||||
/* check if need to save cyclic selection and continue if so */
|
||||
if (newu == nu->pntsu && (nu->flagv & CU_NURB_CYCLIC)) cyclicv = newv;
|
||||
if (newv == nu->pntsv && (nu->flagu & CU_NURB_CYCLIC)) cyclicu = newu;
|
||||
if (cyclicu != 0 || cyclicv != 0) continue;
|
||||
if (newu == nu->pntsu && (nu->flagv & CU_NURB_CYCLIC)) {
|
||||
cyclicv = newv;
|
||||
}
|
||||
if (newv == nu->pntsv && (nu->flagu & CU_NURB_CYCLIC)) {
|
||||
cyclicu = newu;
|
||||
}
|
||||
if (cyclicu != 0 || cyclicv != 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (a + newu == nu->pntsu && cyclicu != 0) {
|
||||
@@ -2320,8 +2422,12 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
|
||||
}
|
||||
BLI_addtail(newnurb, newnu);
|
||||
|
||||
if (newu != nu->pntsu) newnu->flagu &= ~CU_NURB_CYCLIC;
|
||||
if (newv != nu->pntsv) newnu->flagv &= ~CU_NURB_CYCLIC;
|
||||
if (newu != nu->pntsu) {
|
||||
newnu->flagu &= ~CU_NURB_CYCLIC;
|
||||
}
|
||||
if (newv != nu->pntsv) {
|
||||
newnu->flagv &= ~CU_NURB_CYCLIC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2350,13 +2456,19 @@ static void adduplicateflagNurb(Object *obedit, View3D *v3d, ListBase *newnurb,
|
||||
}
|
||||
BLI_addtail(newnurb, newnu);
|
||||
|
||||
if (newu != nu->pntsu) newnu->flagu &= ~CU_NURB_CYCLIC;
|
||||
if (newv != nu->pntsv) newnu->flagv &= ~CU_NURB_CYCLIC;
|
||||
if (newu != nu->pntsu) {
|
||||
newnu->flagu &= ~CU_NURB_CYCLIC;
|
||||
}
|
||||
if (newv != nu->pntsv) {
|
||||
newnu->flagv &= ~CU_NURB_CYCLIC;
|
||||
}
|
||||
}
|
||||
|
||||
for (b = 0, bp1 = nu->bp; b < nu->pntsu * nu->pntsv; b++, bp1++) {
|
||||
bp1->f1 &= ~SURF_SEEN;
|
||||
if (!split) select_bpoint(bp1, DESELECT, flag, HIDDEN);
|
||||
if (!split) {
|
||||
select_bpoint(bp1, DESELECT, flag, HIDDEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2463,14 +2575,16 @@ static int set_goal_weight_exec(bContext *C, wmOperator *op)
|
||||
for (nu = editnurb->first; nu; nu = nu->next) {
|
||||
if (nu->bezt) {
|
||||
for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) {
|
||||
if (bezt->f2 & SELECT)
|
||||
if (bezt->f2 & SELECT) {
|
||||
bezt->weight = weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (nu->bp) {
|
||||
for (bp = nu->bp, a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) {
|
||||
if (bp->f1 & SELECT)
|
||||
if (bp->f1 & SELECT) {
|
||||
bp->weight = weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2515,14 +2629,16 @@ static int set_radius_exec(bContext *C, wmOperator *op)
|
||||
for (nu = editnurb->first; nu; nu = nu->next) {
|
||||
if (nu->bezt) {
|
||||
for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) {
|
||||
if (bezt->f2 & SELECT)
|
||||
if (bezt->f2 & SELECT) {
|
||||
bezt->radius = radius;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (nu->bp) {
|
||||
for (bp = nu->bp, a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) {
|
||||
if (bp->f1 & SELECT)
|
||||
if (bp->f1 & SELECT) {
|
||||
bp->radius = radius;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2756,12 +2872,12 @@ static void curve_smooth_value(ListBase *editnurb,
|
||||
|
||||
if (start_sel == end_sel) {
|
||||
/* simple, only 1 point selected */
|
||||
if (start_sel > 0) start_rad = BEZT_VALUE(&nu->bezt[start_sel - 1]);
|
||||
if (end_sel != -1 && end_sel < nu->pntsu) end_rad = BEZT_VALUE(&nu->bezt[start_sel + 1]);
|
||||
if (start_sel > 0) { start_rad = BEZT_VALUE(&nu->bezt[start_sel - 1]); }
|
||||
if (end_sel != -1 && end_sel < nu->pntsu) { end_rad = BEZT_VALUE(&nu->bezt[start_sel + 1]); }
|
||||
|
||||
if (start_rad != FLT_MAX && end_rad >= FLT_MAX) BEZT_VALUE(&nu->bezt[start_sel]) = (start_rad + end_rad) / 2.0f;
|
||||
else if (start_rad != FLT_MAX) BEZT_VALUE(&nu->bezt[start_sel]) = start_rad;
|
||||
else if (end_rad != FLT_MAX) BEZT_VALUE(&nu->bezt[start_sel]) = end_rad;
|
||||
if (start_rad != FLT_MAX && end_rad >= FLT_MAX) { BEZT_VALUE(&nu->bezt[start_sel]) = (start_rad + end_rad) / 2.0f; }
|
||||
else if (start_rad != FLT_MAX) { BEZT_VALUE(&nu->bezt[start_sel]) = start_rad; }
|
||||
else if (end_rad != FLT_MAX) { BEZT_VALUE(&nu->bezt[start_sel]) = end_rad; }
|
||||
}
|
||||
else {
|
||||
/* if endpoints selected, then use them */
|
||||
@@ -2827,12 +2943,12 @@ static void curve_smooth_value(ListBase *editnurb,
|
||||
|
||||
if (start_sel == end_sel) {
|
||||
/* simple, only 1 point selected */
|
||||
if (start_sel > 0) start_rad = BP_VALUE(&nu->bp[start_sel - 1]);
|
||||
if (end_sel != -1 && end_sel < nu->pntsu) end_rad = BP_VALUE(&nu->bp[start_sel + 1]);
|
||||
if (start_sel > 0) { start_rad = BP_VALUE(&nu->bp[start_sel - 1]); }
|
||||
if (end_sel != -1 && end_sel < nu->pntsu) { end_rad = BP_VALUE(&nu->bp[start_sel + 1]); }
|
||||
|
||||
if (start_rad != FLT_MAX && end_rad != FLT_MAX) BP_VALUE(&nu->bp[start_sel]) = (start_rad + end_rad) / 2;
|
||||
else if (start_rad != FLT_MAX) BP_VALUE(&nu->bp[start_sel]) = start_rad;
|
||||
else if (end_rad != FLT_MAX) BP_VALUE(&nu->bp[start_sel]) = end_rad;
|
||||
if (start_rad != FLT_MAX && end_rad != FLT_MAX) { BP_VALUE(&nu->bp[start_sel]) = (start_rad + end_rad) / 2; }
|
||||
else if (start_rad != FLT_MAX) { BP_VALUE(&nu->bp[start_sel]) = start_rad; }
|
||||
else if (end_rad != FLT_MAX) { BP_VALUE(&nu->bp[start_sel]) = end_rad; }
|
||||
}
|
||||
else {
|
||||
/* if endpoints selected, then use them */
|
||||
@@ -2988,10 +3104,14 @@ static int hide_exec(bContext *C, wmOperator *op)
|
||||
select_beztriple(bezt, DESELECT, SELECT, HIDDEN);
|
||||
bezt->hide = 1;
|
||||
}
|
||||
if (bezt->hide) sel++;
|
||||
if (bezt->hide) {
|
||||
sel++;
|
||||
}
|
||||
bezt++;
|
||||
}
|
||||
if (sel == nu->pntsu) nu->hide = 1;
|
||||
if (sel == nu->pntsu) {
|
||||
nu->hide = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
bp = nu->bp;
|
||||
@@ -3006,10 +3126,14 @@ static int hide_exec(bContext *C, wmOperator *op)
|
||||
select_bpoint(bp, DESELECT, SELECT, HIDDEN);
|
||||
bp->hide = 1;
|
||||
}
|
||||
if (bp->hide) sel++;
|
||||
if (bp->hide) {
|
||||
sel++;
|
||||
}
|
||||
bp++;
|
||||
}
|
||||
if (sel == nu->pntsu * nu->pntsv) nu->hide = 1;
|
||||
if (sel == nu->pntsu * nu->pntsv) {
|
||||
nu->hide = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3409,7 +3533,9 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts)
|
||||
/* subdivide in v direction? */
|
||||
sel = 0;
|
||||
for (a = 0; a < nu->pntsv - 1; a++) {
|
||||
if (vsel[a] == nu->pntsu && vsel[a + 1] == nu->pntsu) sel += number_cuts;
|
||||
if (vsel[a] == nu->pntsu && vsel[a + 1] == nu->pntsu) {
|
||||
sel += number_cuts;
|
||||
}
|
||||
}
|
||||
|
||||
if (sel) { /* V ! */
|
||||
@@ -3454,7 +3580,9 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts)
|
||||
/* or in u direction? */
|
||||
sel = 0;
|
||||
for (a = 0; a < nu->pntsu - 1; a++) {
|
||||
if (usel[a] == nu->pntsv && usel[a + 1] == nu->pntsv) sel += number_cuts;
|
||||
if (usel[a] == nu->pntsv && usel[a + 1] == nu->pntsv) {
|
||||
sel += number_cuts;
|
||||
}
|
||||
}
|
||||
|
||||
if (sel) { /* U ! */
|
||||
@@ -3578,8 +3706,12 @@ static void ED_curve_pick_vert__doClosest(void *userData, Nurb *nu, BPoint *bp,
|
||||
}
|
||||
|
||||
dist_test = len_manhattan_v2v2(data->mval_fl, screen_co);
|
||||
if ((flag & SELECT) == data->select) dist_test += 5.0f;
|
||||
if (bezt && beztindex == 1) dist_test += 3.0f; /* middle points get a small disadvantage */
|
||||
if ((flag & SELECT) == data->select) {
|
||||
dist_test += 5.0f;
|
||||
}
|
||||
if (bezt && beztindex == 1) {
|
||||
dist_test += 3.0f; /* middle points get a small disadvantage */
|
||||
}
|
||||
|
||||
if (dist_test < data->dist) {
|
||||
data->dist = dist_test;
|
||||
@@ -3897,7 +4029,9 @@ static void switchdirection_knots(float *base, int tot)
|
||||
float *fp1, *fp2, *tempf;
|
||||
int a;
|
||||
|
||||
if (base == NULL || tot == 0) return;
|
||||
if (base == NULL || tot == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* reverse knots */
|
||||
a = tot;
|
||||
@@ -4076,7 +4210,9 @@ static bool merge_2_nurb(Curve *cu, ListBase *editnurb, Nurb *nu1, Nurb *nu2)
|
||||
else {
|
||||
/* For 2D curves blender uses (orderv = 0). It doesn't make any sense mathematically. */
|
||||
/* but after rotating (orderu = 0) will be confusing. */
|
||||
if (nu1->orderv == 0) nu1->orderv = 1;
|
||||
if (nu1->orderv == 0) {
|
||||
nu1->orderv = 1;
|
||||
}
|
||||
|
||||
rotate_direction_nurb(nu1);
|
||||
if (is_u_selected(nu1, nu1->pntsu - 1)) {
|
||||
@@ -4094,7 +4230,9 @@ static bool merge_2_nurb(Curve *cu, ListBase *editnurb, Nurb *nu1, Nurb *nu2)
|
||||
}
|
||||
else {
|
||||
/* rotate again, now its OK! */
|
||||
if (nu1->pntsv != 1) rotate_direction_nurb(nu1);
|
||||
if (nu1->pntsv != 1) {
|
||||
rotate_direction_nurb(nu1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -4106,7 +4244,9 @@ static bool merge_2_nurb(Curve *cu, ListBase *editnurb, Nurb *nu1, Nurb *nu2)
|
||||
/* pass */
|
||||
}
|
||||
else {
|
||||
if (nu2->orderv == 0) nu2->orderv = 1;
|
||||
if (nu2->orderv == 0) {
|
||||
nu2->orderv = 1;
|
||||
}
|
||||
rotate_direction_nurb(nu2);
|
||||
if (is_u_selected(nu2, 0)) {
|
||||
/* pass */
|
||||
@@ -4123,8 +4263,12 @@ static bool merge_2_nurb(Curve *cu, ListBase *editnurb, Nurb *nu1, Nurb *nu2)
|
||||
}
|
||||
else {
|
||||
/* rotate again, now its OK! */
|
||||
if (nu1->pntsu == 1) rotate_direction_nurb(nu1);
|
||||
if (nu2->pntsv != 1) rotate_direction_nurb(nu2);
|
||||
if (nu1->pntsu == 1) {
|
||||
rotate_direction_nurb(nu1);
|
||||
}
|
||||
if (nu2->pntsv != 1) {
|
||||
rotate_direction_nurb(nu2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -4157,8 +4301,12 @@ static bool merge_2_nurb(Curve *cu, ListBase *editnurb, Nurb *nu1, Nurb *nu2)
|
||||
/* merge */
|
||||
origu = nu1->pntsu;
|
||||
nu1->pntsu += nu2->pntsu;
|
||||
if (nu1->orderu < 3 && nu1->orderu < nu1->pntsu) nu1->orderu++;
|
||||
if (nu1->orderv < 3 && nu1->orderv < nu1->pntsv) nu1->orderv++;
|
||||
if (nu1->orderu < 3 && nu1->orderu < nu1->pntsu) {
|
||||
nu1->orderu++;
|
||||
}
|
||||
if (nu1->orderv < 3 && nu1->orderv < nu1->pntsv) {
|
||||
nu1->orderv++;
|
||||
}
|
||||
temp = nu1->bp;
|
||||
nu1->bp = MEM_mallocN(nu1->pntsu * nu1->pntsv * sizeof(BPoint), "mergeBP");
|
||||
|
||||
@@ -4168,8 +4316,12 @@ static bool merge_2_nurb(Curve *cu, ListBase *editnurb, Nurb *nu1, Nurb *nu2)
|
||||
for (v = 0; v < nu1->pntsv; v++) {
|
||||
|
||||
/* switch direction? */
|
||||
if (len1 < len2) bp2 = &nu2->bp[v * nu2->pntsu];
|
||||
else bp2 = &nu2->bp[(nu1->pntsv - v - 1) * nu2->pntsu];
|
||||
if (len1 < len2) {
|
||||
bp2 = &nu2->bp[v * nu2->pntsu];
|
||||
}
|
||||
else {
|
||||
bp2 = &nu2->bp[(nu1->pntsv - v - 1) * nu2->pntsu];
|
||||
}
|
||||
|
||||
for (u = 0; u < nu1->pntsu; u++, bp++) {
|
||||
if (u < origu) {
|
||||
@@ -4291,8 +4443,12 @@ static int make_segment_exec(bContext *C, wmOperator *op)
|
||||
bool ok = false;
|
||||
|
||||
/* first decide if this is a surface merge! */
|
||||
if (obedit->type == OB_SURF) nu = nubase->first;
|
||||
else nu = NULL;
|
||||
if (obedit->type == OB_SURF) {
|
||||
nu = nubase->first;
|
||||
}
|
||||
else {
|
||||
nu = NULL;
|
||||
}
|
||||
|
||||
while (nu) {
|
||||
const int nu_select_num = ED_curve_nurb_select_count(v3d, nu);
|
||||
@@ -4341,8 +4497,9 @@ static int make_segment_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* find both nurbs and points, nu1 will be put behind nu2 */
|
||||
for (nu = nubase->first; nu; nu = nu->next) {
|
||||
if (nu->pntsu == 1)
|
||||
if (nu->pntsu == 1) {
|
||||
nu->flagu &= ~CU_NURB_CYCLIC;
|
||||
}
|
||||
|
||||
if ((nu->flagu & CU_NURB_CYCLIC) == 0) { /* not cyclic */
|
||||
if (nu->type == CU_BEZIER) {
|
||||
@@ -4603,8 +4760,12 @@ bool ED_curve_editnurb_select_pick(bContext *C, const int mval[2], bool extend,
|
||||
select_beztriple(bezt, SELECT, SELECT, HIDDEN);
|
||||
}
|
||||
else {
|
||||
if (hand == 0) bezt->f1 |= SELECT;
|
||||
else bezt->f3 |= SELECT;
|
||||
if (hand == 0) {
|
||||
bezt->f1 |= SELECT;
|
||||
}
|
||||
else {
|
||||
bezt->f3 |= SELECT;
|
||||
}
|
||||
}
|
||||
BKE_curve_nurb_vert_active_set(cu, nu, bezt);
|
||||
}
|
||||
@@ -4617,7 +4778,9 @@ bool ED_curve_editnurb_select_pick(bContext *C, const int mval[2], bool extend,
|
||||
if (bezt) {
|
||||
if (hand == 1) {
|
||||
select_beztriple(bezt, DESELECT, SELECT, HIDDEN);
|
||||
if (bezt == vert) cu->actvert = CU_ACT_NONE;
|
||||
if (bezt == vert) {
|
||||
cu->actvert = CU_ACT_NONE;
|
||||
}
|
||||
}
|
||||
else if (hand == 0) {
|
||||
bezt->f1 &= ~SELECT;
|
||||
@@ -4628,7 +4791,9 @@ bool ED_curve_editnurb_select_pick(bContext *C, const int mval[2], bool extend,
|
||||
}
|
||||
else {
|
||||
select_bpoint(bp, DESELECT, SELECT, HIDDEN);
|
||||
if (bp == vert) cu->actvert = CU_ACT_NONE;
|
||||
if (bp == vert) {
|
||||
cu->actvert = CU_ACT_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (toggle) {
|
||||
@@ -4636,7 +4801,9 @@ bool ED_curve_editnurb_select_pick(bContext *C, const int mval[2], bool extend,
|
||||
if (hand == 1) {
|
||||
if (bezt->f2 & SELECT) {
|
||||
select_beztriple(bezt, DESELECT, SELECT, HIDDEN);
|
||||
if (bezt == vert) cu->actvert = CU_ACT_NONE;
|
||||
if (bezt == vert) {
|
||||
cu->actvert = CU_ACT_NONE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
select_beztriple(bezt, SELECT, SELECT, HIDDEN);
|
||||
@@ -4653,7 +4820,9 @@ bool ED_curve_editnurb_select_pick(bContext *C, const int mval[2], bool extend,
|
||||
else {
|
||||
if (bp->f1 & SELECT) {
|
||||
select_bpoint(bp, DESELECT, SELECT, HIDDEN);
|
||||
if (bp == vert) cu->actvert = CU_ACT_NONE;
|
||||
if (bp == vert) {
|
||||
cu->actvert = CU_ACT_NONE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
select_bpoint(bp, SELECT, SELECT, HIDDEN);
|
||||
@@ -4670,8 +4839,12 @@ bool ED_curve_editnurb_select_pick(bContext *C, const int mval[2], bool extend,
|
||||
select_beztriple(bezt, SELECT, SELECT, HIDDEN);
|
||||
}
|
||||
else {
|
||||
if (hand == 0) bezt->f1 |= SELECT;
|
||||
else bezt->f3 |= SELECT;
|
||||
if (hand == 0) {
|
||||
bezt->f1 |= SELECT;
|
||||
}
|
||||
else {
|
||||
bezt->f3 |= SELECT;
|
||||
}
|
||||
}
|
||||
BKE_curve_nurb_vert_active_set(cu, nu, bezt);
|
||||
}
|
||||
@@ -4748,8 +4921,9 @@ bool ed_editnurb_spin(float viewmat[4][4], View3D *v3d, Object *obedit, const fl
|
||||
for (a = 0; a < 7; a++) {
|
||||
ok = ed_editnurb_extrude_flag(cu->editnurb, SELECT);
|
||||
|
||||
if (ok == false)
|
||||
if (ok == false) {
|
||||
return changed;
|
||||
}
|
||||
|
||||
changed = true;
|
||||
|
||||
@@ -4790,10 +4964,12 @@ static int spin_exec(bContext *C, wmOperator *op)
|
||||
RNA_float_get_array(op->ptr, "center", cent);
|
||||
RNA_float_get_array(op->ptr, "axis", axis);
|
||||
|
||||
if (rv3d)
|
||||
if (rv3d) {
|
||||
copy_m4_m4(viewmat, rv3d->viewmat);
|
||||
else
|
||||
}
|
||||
else {
|
||||
unit_m4(viewmat);
|
||||
}
|
||||
|
||||
uint objects_len;
|
||||
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
|
||||
@@ -4835,8 +5011,9 @@ static int spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
|
||||
RegionView3D *rv3d = ED_view3d_context_rv3d(C);
|
||||
float axis[3] = {0.0f, 0.0f, 1.0f};
|
||||
|
||||
if (rv3d)
|
||||
if (rv3d) {
|
||||
copy_v3_v3(axis, rv3d->viewinv[2]);
|
||||
}
|
||||
|
||||
RNA_float_set_array(op->ptr, "center", scene->cursor.location);
|
||||
RNA_float_set_array(op->ptr, "axis", axis);
|
||||
@@ -5718,8 +5895,12 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
|
||||
for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) {
|
||||
if (!BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt)) {
|
||||
enda = a;
|
||||
if (starta == -1) starta = a;
|
||||
if (a < nu->pntsu - 1) continue;
|
||||
if (starta == -1) {
|
||||
starta = a;
|
||||
}
|
||||
if (a < nu->pntsu - 1) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (a < nu->pntsu - 1 && !BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt + 1)) {
|
||||
/* if just single selected point then continue */
|
||||
@@ -5730,7 +5911,9 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
|
||||
/* got selected segment, now check where and copy */
|
||||
if (starta <= 1 && a == nu->pntsu - 1) {
|
||||
/* copying all points in spline */
|
||||
if (starta == 1 && enda != a) nu->flagu &= ~CU_NURB_CYCLIC;
|
||||
if (starta == 1 && enda != a) {
|
||||
nu->flagu &= ~CU_NURB_CYCLIC;
|
||||
}
|
||||
|
||||
starta = 0;
|
||||
enda = a;
|
||||
@@ -5755,8 +5938,12 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
|
||||
cut = 1;
|
||||
}
|
||||
else {
|
||||
if (nu->flagu & CU_NURB_CYCLIC) cyclicut = cut;
|
||||
else nu1 = BKE_nurb_copy(nu, cut, 1);
|
||||
if (nu->flagu & CU_NURB_CYCLIC) {
|
||||
cyclicut = cut;
|
||||
}
|
||||
else {
|
||||
nu1 = BKE_nurb_copy(nu, cut, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (enda == nu->pntsu - 1) {
|
||||
@@ -5796,7 +5983,9 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
|
||||
ED_curve_beztcpy(editnurb, nu1->bezt, &nu->bezt[starta], cut);
|
||||
BLI_addtail(&newnurb, nu1);
|
||||
|
||||
if (starta != 0 || enda != nu->pntsu - 1) nu1->flagu &= ~CU_NURB_CYCLIC;
|
||||
if (starta != 0 || enda != nu->pntsu - 1) {
|
||||
nu1->flagu &= ~CU_NURB_CYCLIC;
|
||||
}
|
||||
nu1 = NULL;
|
||||
}
|
||||
starta = enda = -1;
|
||||
@@ -5835,8 +6024,12 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
|
||||
for (a = 0, bp = nu->bp; a < nu->pntsu; a++, bp++) {
|
||||
if (!(bp->f1 & SELECT)) {
|
||||
enda = a;
|
||||
if (starta == -1) starta = a;
|
||||
if (a < nu->pntsu - 1) continue;
|
||||
if (starta == -1) {
|
||||
starta = a;
|
||||
}
|
||||
if (a < nu->pntsu - 1) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (a < nu->pntsu - 1 && !((bp + 1)->f1 & SELECT)) {
|
||||
/* if just single selected point then continue */
|
||||
@@ -5847,7 +6040,9 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
|
||||
/* got selected segment, now check where and copy */
|
||||
if (starta <= 1 && a == nu->pntsu - 1) {
|
||||
/* copying all points in spline */
|
||||
if (starta == 1 && enda != a) nu->flagu &= ~CU_NURB_CYCLIC;
|
||||
if (starta == 1 && enda != a) {
|
||||
nu->flagu &= ~CU_NURB_CYCLIC;
|
||||
}
|
||||
|
||||
starta = 0;
|
||||
enda = a;
|
||||
@@ -5871,8 +6066,12 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
|
||||
cut = 1;
|
||||
}
|
||||
else {
|
||||
if (nu->flagu & CU_NURB_CYCLIC) cyclicut = cut;
|
||||
else nu1 = BKE_nurb_copy(nu, cut, nu->pntsv);
|
||||
if (nu->flagu & CU_NURB_CYCLIC) {
|
||||
cyclicut = cut;
|
||||
}
|
||||
else {
|
||||
nu1 = BKE_nurb_copy(nu, cut, nu->pntsv);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (enda == nu->pntsu - 1) {
|
||||
@@ -5914,7 +6113,9 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
|
||||
}
|
||||
BLI_addtail(&newnurb, nu1);
|
||||
|
||||
if (starta != 0 || enda != nu->pntsu - 1) nu1->flagu &= ~CU_NURB_CYCLIC;
|
||||
if (starta != 0 || enda != nu->pntsu - 1) {
|
||||
nu1->flagu &= ~CU_NURB_CYCLIC;
|
||||
}
|
||||
nu1 = NULL;
|
||||
}
|
||||
starta = enda = -1;
|
||||
@@ -5950,8 +6151,12 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
|
||||
for (a = 0, bp = nu->bp; a < nu->pntsv; a++, bp += nu->pntsu) {
|
||||
if (!(bp->f1 & SELECT)) {
|
||||
enda = a;
|
||||
if (starta == -1) starta = a;
|
||||
if (a < nu->pntsv - 1) continue;
|
||||
if (starta == -1) {
|
||||
starta = a;
|
||||
}
|
||||
if (a < nu->pntsv - 1) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (a < nu->pntsv - 1 && !((bp + nu->pntsu)->f1 & SELECT)) {
|
||||
/* if just single selected point then continue */
|
||||
@@ -5962,7 +6167,9 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
|
||||
/* got selected segment, now check where and copy */
|
||||
if (starta <= 1 && a == nu->pntsv - 1) {
|
||||
/* copying all points in spline */
|
||||
if (starta == 1 && enda != a) nu->flagv &= ~CU_NURB_CYCLIC;
|
||||
if (starta == 1 && enda != a) {
|
||||
nu->flagv &= ~CU_NURB_CYCLIC;
|
||||
}
|
||||
|
||||
starta = 0;
|
||||
enda = a;
|
||||
@@ -5984,8 +6191,12 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
|
||||
cut = 1;
|
||||
}
|
||||
else {
|
||||
if (nu->flagv & CU_NURB_CYCLIC) cyclicut = cut;
|
||||
else nu1 = BKE_nurb_copy(nu, nu->pntsu, cut);
|
||||
if (nu->flagv & CU_NURB_CYCLIC) {
|
||||
cyclicut = cut;
|
||||
}
|
||||
else {
|
||||
nu1 = BKE_nurb_copy(nu, nu->pntsu, cut);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (enda == nu->pntsv - 1) {
|
||||
@@ -6022,7 +6233,9 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
|
||||
ED_curve_bpcpy(editnurb, nu1->bp, &nu->bp[starta * nu->pntsu], cut * nu->pntsu);
|
||||
BLI_addtail(&newnurb, nu1);
|
||||
|
||||
if (starta != 0 || enda != nu->pntsv - 1) nu1->flagv &= ~CU_NURB_CYCLIC;
|
||||
if (starta != 0 || enda != nu->pntsv - 1) {
|
||||
nu1->flagv &= ~CU_NURB_CYCLIC;
|
||||
}
|
||||
nu1 = NULL;
|
||||
}
|
||||
starta = enda = -1;
|
||||
@@ -6159,8 +6372,9 @@ static const EnumPropertyItem *rna_curve_delete_type_itemf(
|
||||
EnumPropertyItem *item = NULL;
|
||||
int totitem = 0;
|
||||
|
||||
if (!C) /* needed for docs and i18n tools */
|
||||
if (!C) { /* needed for docs and i18n tools */
|
||||
return curve_delete_type_items;
|
||||
}
|
||||
|
||||
RNA_enum_items_add_value(&item, &totitem, curve_delete_type_items, CURVE_VERTEX);
|
||||
RNA_enum_items_add_value(&item, &totitem, curve_delete_type_items, CURVE_SEGMENT);
|
||||
@@ -6417,13 +6631,18 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
|
||||
Nurb *nu;
|
||||
int clear = (STREQ(op->idname, "CURVE_OT_shade_flat"));
|
||||
|
||||
if (obedit->type != OB_CURVE)
|
||||
if (obedit->type != OB_CURVE) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
for (nu = editnurb->first; nu; nu = nu->next) {
|
||||
if (ED_curve_nurb_select_check(v3d, nu)) {
|
||||
if (!clear) nu->flag |= CU_SMOOTH;
|
||||
else nu->flag &= ~CU_SMOOTH;
|
||||
if (!clear) {
|
||||
nu->flag |= CU_SMOOTH;
|
||||
}
|
||||
else {
|
||||
nu->flag &= ~CU_SMOOTH;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6595,7 +6814,9 @@ static int clear_tilt_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
bezt = nu->bezt;
|
||||
a = nu->pntsu;
|
||||
while (a--) {
|
||||
if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt)) bezt->tilt = 0.0;
|
||||
if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt)) {
|
||||
bezt->tilt = 0.0;
|
||||
}
|
||||
bezt++;
|
||||
}
|
||||
}
|
||||
@@ -6603,7 +6824,9 @@ static int clear_tilt_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
bp = nu->bp;
|
||||
a = nu->pntsu * nu->pntsv;
|
||||
while (a--) {
|
||||
if (bp->f1 & SELECT) bp->tilt = 0.0f;
|
||||
if (bp->f1 & SELECT) {
|
||||
bp->tilt = 0.0f;
|
||||
}
|
||||
bp++;
|
||||
}
|
||||
}
|
||||
@@ -6648,8 +6871,9 @@ bool ED_curve_active_center(Curve *cu, float center[3])
|
||||
Nurb *nu = NULL;
|
||||
void *vert = NULL;
|
||||
|
||||
if (!BKE_curve_nurb_vert_active_get(cu, &nu, &vert))
|
||||
if (!BKE_curve_nurb_vert_active_get(cu, &nu, &vert)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (nu->type == CU_BEZIER) {
|
||||
BezTriple *bezt = (BezTriple *)vert;
|
||||
@@ -6695,9 +6919,15 @@ static int match_texture_space_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
size[2] = (max[2] - min[2]) / 2.0f;
|
||||
|
||||
for (a = 0; a < 3; a++) {
|
||||
if (size[a] == 0.0f) size[a] = 1.0f;
|
||||
else if (size[a] > 0.0f && size[a] < 0.00001f) size[a] = 0.00001f;
|
||||
else if (size[a] < 0.0f && size[a] > -0.00001f) size[a] = -0.00001f;
|
||||
if (size[a] == 0.0f) {
|
||||
size[a] = 1.0f;
|
||||
}
|
||||
else if (size[a] > 0.0f && size[a] < 0.00001f) {
|
||||
size[a] = 0.00001f;
|
||||
}
|
||||
else if (size[a] < 0.0f && size[a] > -0.00001f) {
|
||||
size[a] = -0.00001f;
|
||||
}
|
||||
}
|
||||
|
||||
copy_v3_v3(curve->loc, loc);
|
||||
|
||||
@@ -148,7 +148,9 @@ Nurb *ED_curve_add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4],
|
||||
bezt->vec[0][1] += -0.5f * grid;
|
||||
bezt->vec[2][0] += -0.5f * grid;
|
||||
bezt->vec[2][1] += 0.5f * grid;
|
||||
for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]);
|
||||
for (a = 0; a < 3; a++) {
|
||||
mul_m4_v3(mat, bezt->vec[a]);
|
||||
}
|
||||
|
||||
bezt++;
|
||||
bezt->h1 = bezt->h2 = HD_ALIGN;
|
||||
@@ -161,7 +163,9 @@ Nurb *ED_curve_add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4],
|
||||
bezt->vec[1][1] = 0;
|
||||
bezt->vec[2][0] = grid * 2;
|
||||
bezt->vec[2][1] = 0;
|
||||
for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]);
|
||||
for (a = 0; a < 3; a++) {
|
||||
mul_m4_v3(mat, bezt->vec[a]);
|
||||
}
|
||||
|
||||
BKE_nurb_handles_calc(nu);
|
||||
}
|
||||
@@ -191,7 +195,9 @@ Nurb *ED_curve_add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4],
|
||||
bp->vec[0] += 1.5f * grid;
|
||||
|
||||
bp = nu->bp;
|
||||
for (a = 0; a < 4; a++, bp++) mul_m4_v3(mat, bp->vec);
|
||||
for (a = 0; a < 4; a++, bp++) {
|
||||
mul_m4_v3(mat, bp->vec);
|
||||
}
|
||||
|
||||
if (cutype == CU_NURBS) {
|
||||
nu->knotsu = NULL; /* nurbs_knot_calc_u allocates */
|
||||
@@ -225,7 +231,9 @@ Nurb *ED_curve_add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4],
|
||||
bp->vec[0] += 2.0f * grid;
|
||||
|
||||
bp = nu->bp;
|
||||
for (a = 0; a < 5; a++, bp++) mul_m4_v3(mat, bp->vec);
|
||||
for (a = 0; a < 5; a++, bp++) {
|
||||
mul_m4_v3(mat, bp->vec);
|
||||
}
|
||||
|
||||
if (cutype == CU_NURBS) {
|
||||
nu->knotsu = NULL; /* nurbs_knot_calc_u allocates */
|
||||
@@ -245,28 +253,36 @@ Nurb *ED_curve_add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4],
|
||||
bezt->h1 = bezt->h2 = HD_AUTO;
|
||||
bezt->f1 = bezt->f2 = bezt->f3 = SELECT;
|
||||
bezt->vec[1][0] += -grid;
|
||||
for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]);
|
||||
for (a = 0; a < 3; a++) {
|
||||
mul_m4_v3(mat, bezt->vec[a]);
|
||||
}
|
||||
bezt->radius = bezt->weight = 1.0;
|
||||
|
||||
bezt++;
|
||||
bezt->h1 = bezt->h2 = HD_AUTO;
|
||||
bezt->f1 = bezt->f2 = bezt->f3 = SELECT;
|
||||
bezt->vec[1][1] += grid;
|
||||
for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]);
|
||||
for (a = 0; a < 3; a++) {
|
||||
mul_m4_v3(mat, bezt->vec[a]);
|
||||
}
|
||||
bezt->radius = bezt->weight = 1.0;
|
||||
|
||||
bezt++;
|
||||
bezt->h1 = bezt->h2 = HD_AUTO;
|
||||
bezt->f1 = bezt->f2 = bezt->f3 = SELECT;
|
||||
bezt->vec[1][0] += grid;
|
||||
for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]);
|
||||
for (a = 0; a < 3; a++) {
|
||||
mul_m4_v3(mat, bezt->vec[a]);
|
||||
}
|
||||
bezt->radius = bezt->weight = 1.0;
|
||||
|
||||
bezt++;
|
||||
bezt->h1 = bezt->h2 = HD_AUTO;
|
||||
bezt->f1 = bezt->f2 = bezt->f3 = SELECT;
|
||||
bezt->vec[1][1] += -grid;
|
||||
for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]);
|
||||
for (a = 0; a < 3; a++) {
|
||||
mul_m4_v3(mat, bezt->vec[a]);
|
||||
}
|
||||
bezt->radius = bezt->weight = 1.0;
|
||||
|
||||
BKE_nurb_handles_calc(nu);
|
||||
@@ -289,8 +305,12 @@ Nurb *ED_curve_add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4],
|
||||
bp->vec[0] += 0.25f * nurbcircle[a][0] * grid - 0.75f * grid;
|
||||
bp->vec[2] += 0.25f * nurbcircle[a][1] * grid;
|
||||
}
|
||||
if (a & 1) bp->vec[3] = 0.25 * M_SQRT2;
|
||||
else bp->vec[3] = 1.0;
|
||||
if (a & 1) {
|
||||
bp->vec[3] = 0.25 * M_SQRT2;
|
||||
}
|
||||
else {
|
||||
bp->vec[3] = 1.0;
|
||||
}
|
||||
mul_m4_v3(mat, bp->vec);
|
||||
bp->radius = bp->weight = 1.0;
|
||||
|
||||
@@ -378,8 +398,12 @@ Nurb *ED_curve_add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4],
|
||||
bp->f1 = SELECT;
|
||||
bp->vec[0] += nurbcircle[a][0] * grid;
|
||||
bp->vec[2] += nurbcircle[a][1] * grid;
|
||||
if (a & 1) bp->vec[3] = 0.5 * M_SQRT2;
|
||||
else bp->vec[3] = 1.0;
|
||||
if (a & 1) {
|
||||
bp->vec[3] = 0.5 * M_SQRT2;
|
||||
}
|
||||
else {
|
||||
bp->vec[3] = 1.0;
|
||||
}
|
||||
mul_m4_v3(mat, bp->vec);
|
||||
bp++;
|
||||
}
|
||||
@@ -388,12 +412,15 @@ Nurb *ED_curve_add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4],
|
||||
|
||||
BLI_addtail(editnurb, nu); /* temporal for spin */
|
||||
|
||||
if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0)
|
||||
if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) {
|
||||
ed_editnurb_spin(umat, NULL, obedit, tmp_vec, tmp_cent);
|
||||
else if ((U.flag & USER_ADD_VIEWALIGNED))
|
||||
}
|
||||
else if ((U.flag & USER_ADD_VIEWALIGNED)) {
|
||||
ed_editnurb_spin(viewmat, NULL, obedit, zvec, mat[3]);
|
||||
else
|
||||
}
|
||||
else {
|
||||
ed_editnurb_spin(umat, NULL, obedit, tmp_vec, mat[3]);
|
||||
}
|
||||
|
||||
BKE_nurb_knot_calc_v(nu);
|
||||
|
||||
@@ -420,12 +447,15 @@ Nurb *ED_curve_add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4],
|
||||
BLI_addtail(editnurb, nu); /* temporal for spin */
|
||||
|
||||
/* same as above */
|
||||
if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0)
|
||||
if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) {
|
||||
ed_editnurb_spin(umat, NULL, obedit, tmp_vec, tmp_cent);
|
||||
else if ((U.flag & USER_ADD_VIEWALIGNED))
|
||||
}
|
||||
else if ((U.flag & USER_ADD_VIEWALIGNED)) {
|
||||
ed_editnurb_spin(viewmat, NULL, obedit, zvec, mat[3]);
|
||||
else
|
||||
}
|
||||
else {
|
||||
ed_editnurb_spin(umat, NULL, obedit, tmp_vec, mat[3]);
|
||||
}
|
||||
|
||||
|
||||
BLI_remlink(editnurb, nu);
|
||||
@@ -476,8 +506,9 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
|
||||
|
||||
WM_operator_view3d_unit_defaults(C, op);
|
||||
|
||||
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, NULL))
|
||||
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, NULL)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if (!isSurf) { /* adding curve */
|
||||
if (obedit == NULL || obedit->type != OB_CURVE) {
|
||||
@@ -490,8 +521,9 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
|
||||
cu = (Curve *)obedit->data;
|
||||
cu->flag |= CU_DEFORM_FILL;
|
||||
|
||||
if (type & CU_PRIM_PATH)
|
||||
if (type & CU_PRIM_PATH) {
|
||||
cu->flag |= CU_PATH | CU_3D;
|
||||
}
|
||||
}
|
||||
else {
|
||||
DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
|
||||
|
||||
@@ -96,18 +96,22 @@ bool select_bpoint(BPoint *bp, bool selstatus, short flag, bool hidden)
|
||||
|
||||
static bool swap_selection_beztriple(BezTriple *bezt)
|
||||
{
|
||||
if (bezt->f2 & SELECT)
|
||||
if (bezt->f2 & SELECT) {
|
||||
return select_beztriple(bezt, DESELECT, SELECT, VISIBLE);
|
||||
else
|
||||
}
|
||||
else {
|
||||
return select_beztriple(bezt, SELECT, SELECT, VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
static bool swap_selection_bpoint(BPoint *bp)
|
||||
{
|
||||
if (bp->f1 & SELECT)
|
||||
if (bp->f1 & SELECT) {
|
||||
return select_bpoint(bp, DESELECT, SELECT, VISIBLE);
|
||||
else
|
||||
}
|
||||
else {
|
||||
return select_bpoint(bp, SELECT, SELECT, VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
bool ED_curve_nurb_select_check(View3D *v3d, Nurb *nu)
|
||||
@@ -337,21 +341,29 @@ static void select_adjacent_cp(
|
||||
int a;
|
||||
bool lastsel = false;
|
||||
|
||||
if (next == 0) return;
|
||||
if (next == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (nu = editnurb->first; nu; nu = nu->next) {
|
||||
lastsel = false;
|
||||
if (nu->type == CU_BEZIER) {
|
||||
a = nu->pntsu;
|
||||
bezt = nu->bezt;
|
||||
if (next < 0) bezt = &nu->bezt[a - 1];
|
||||
if (next < 0) {
|
||||
bezt = &nu->bezt[a - 1];
|
||||
}
|
||||
while (a--) {
|
||||
if (a - abs(next) < 0) break;
|
||||
if (a - abs(next) < 0) {
|
||||
break;
|
||||
}
|
||||
if ((lastsel == false) && (bezt->hide == 0) && ((bezt->f2 & SELECT) || (selstatus == DESELECT))) {
|
||||
bezt += next;
|
||||
if (!(bezt->f2 & SELECT) || (selstatus == DESELECT)) {
|
||||
bool sel = select_beztriple(bezt, selstatus, SELECT, VISIBLE);
|
||||
if (sel && !cont) lastsel = true;
|
||||
if (sel && !cont) {
|
||||
lastsel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -365,14 +377,20 @@ static void select_adjacent_cp(
|
||||
else {
|
||||
a = nu->pntsu * nu->pntsv;
|
||||
bp = nu->bp;
|
||||
if (next < 0) bp = &nu->bp[a - 1];
|
||||
if (next < 0) {
|
||||
bp = &nu->bp[a - 1];
|
||||
}
|
||||
while (a--) {
|
||||
if (a - abs(next) < 0) break;
|
||||
if (a - abs(next) < 0) {
|
||||
break;
|
||||
}
|
||||
if ((lastsel == false) && (bp->hide == 0) && ((bp->f1 & SELECT) || (selstatus == DESELECT))) {
|
||||
bp += next;
|
||||
if (!(bp->f1 & SELECT) || (selstatus == DESELECT)) {
|
||||
bool sel = select_bpoint(bp, selstatus, SELECT, VISIBLE);
|
||||
if (sel && !cont) lastsel = true;
|
||||
if (sel && !cont) {
|
||||
lastsel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -402,7 +420,9 @@ static void selectend_nurb(Object *obedit, eEndPoint_Types selfirst, bool doswap
|
||||
Curve *cu;
|
||||
int a;
|
||||
|
||||
if (obedit == NULL) return;
|
||||
if (obedit == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
cu = (Curve *)obedit->data;
|
||||
cu->actvert = CU_ACT_NONE;
|
||||
@@ -421,10 +441,16 @@ static void selectend_nurb(Object *obedit, eEndPoint_Types selfirst, bool doswap
|
||||
|
||||
while (a--) {
|
||||
bool sel;
|
||||
if (doswap) sel = swap_selection_beztriple(bezt);
|
||||
else sel = select_beztriple(bezt, selstatus, SELECT, VISIBLE);
|
||||
if (doswap) {
|
||||
sel = swap_selection_beztriple(bezt);
|
||||
}
|
||||
else {
|
||||
sel = select_beztriple(bezt, selstatus, SELECT, VISIBLE);
|
||||
}
|
||||
|
||||
if (sel == true) break;
|
||||
if (sel == true) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -441,10 +467,16 @@ static void selectend_nurb(Object *obedit, eEndPoint_Types selfirst, bool doswap
|
||||
while (a--) {
|
||||
if (bp->hide == 0) {
|
||||
bool sel;
|
||||
if (doswap) sel = swap_selection_bpoint(bp);
|
||||
else sel = select_bpoint(bp, selstatus, SELECT, VISIBLE);
|
||||
if (doswap) {
|
||||
sel = swap_selection_bpoint(bp);
|
||||
}
|
||||
else {
|
||||
sel = select_bpoint(bp, selstatus, SELECT, VISIBLE);
|
||||
}
|
||||
|
||||
if (sel == true) break;
|
||||
if (sel == true) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -722,8 +754,9 @@ static int select_row_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
BPoint *bp = NULL;
|
||||
int u = 0, v = 0, a, b;
|
||||
|
||||
if (!BKE_curve_nurb_vert_active_get(cu, &nu, (void *)&bp))
|
||||
if (!BKE_curve_nurb_vert_active_get(cu, &nu, (void *)&bp)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if (last == bp) {
|
||||
direction = 1 - direction;
|
||||
@@ -737,10 +770,14 @@ static int select_row_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
for (a = 0; a < nu->pntsv; a++) {
|
||||
for (b = 0; b < nu->pntsu; b++, bp++) {
|
||||
if (direction) {
|
||||
if (a == v) select_bpoint(bp, SELECT, SELECT, VISIBLE);
|
||||
if (a == v) {
|
||||
select_bpoint(bp, SELECT, SELECT, VISIBLE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (b == u) select_bpoint(bp, SELECT, SELECT, VISIBLE);
|
||||
if (b == u) {
|
||||
select_bpoint(bp, SELECT, SELECT, VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -859,29 +896,39 @@ static void curve_select_more(Object *obedit)
|
||||
/* upper control point */
|
||||
if (a % nu->pntsu != 0) {
|
||||
tempbp = bp - 1;
|
||||
if (!(tempbp->f1 & SELECT)) select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
|
||||
if (!(tempbp->f1 & SELECT)) {
|
||||
select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
/* left control point. select only if it is not selected already */
|
||||
if (a - nu->pntsu > 0) {
|
||||
sel = 0;
|
||||
tempbp = bp + nu->pntsu;
|
||||
if (!(tempbp->f1 & SELECT)) sel = select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
|
||||
if (!(tempbp->f1 & SELECT)) {
|
||||
sel = select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
|
||||
}
|
||||
/* make sure selected bpoint is discarded */
|
||||
if (sel == 1) BLI_BITMAP_ENABLE(selbpoints, a - nu->pntsu);
|
||||
if (sel == 1) {
|
||||
BLI_BITMAP_ENABLE(selbpoints, a - nu->pntsu);
|
||||
}
|
||||
}
|
||||
|
||||
/* right control point */
|
||||
if (a + nu->pntsu < nu->pntsu * nu->pntsv) {
|
||||
tempbp = bp - nu->pntsu;
|
||||
if (!(tempbp->f1 & SELECT)) select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
|
||||
if (!(tempbp->f1 & SELECT)) {
|
||||
select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
/* lower control point. skip next bp in case selection was made */
|
||||
if (a % nu->pntsu != 1) {
|
||||
sel = 0;
|
||||
tempbp = bp + 1;
|
||||
if (!(tempbp->f1 & SELECT)) sel = select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
|
||||
if (!(tempbp->f1 & SELECT)) {
|
||||
sel = select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
|
||||
}
|
||||
if (sel) {
|
||||
bp++;
|
||||
a--;
|
||||
@@ -962,7 +1009,9 @@ static void curve_select_less(Object *obedit)
|
||||
}
|
||||
else {
|
||||
bp--;
|
||||
if (BLI_BITMAP_TEST(selbpoints, a + 1) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++;
|
||||
if (BLI_BITMAP_TEST(selbpoints, a + 1) || ((bp->hide == 0) && (bp->f1 & SELECT))) {
|
||||
sel++;
|
||||
}
|
||||
bp++;
|
||||
}
|
||||
|
||||
@@ -971,7 +1020,9 @@ static void curve_select_less(Object *obedit)
|
||||
}
|
||||
else {
|
||||
bp++;
|
||||
if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++;
|
||||
if ((bp->hide == 0) && (bp->f1 & SELECT)) {
|
||||
sel++;
|
||||
}
|
||||
bp--;
|
||||
}
|
||||
|
||||
@@ -980,7 +1031,9 @@ static void curve_select_less(Object *obedit)
|
||||
}
|
||||
else {
|
||||
bp -= nu->pntsu;
|
||||
if (BLI_BITMAP_TEST(selbpoints, a + nu->pntsu) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++;
|
||||
if (BLI_BITMAP_TEST(selbpoints, a + nu->pntsu) || ((bp->hide == 0) && (bp->f1 & SELECT))) {
|
||||
sel++;
|
||||
}
|
||||
bp += nu->pntsu;
|
||||
}
|
||||
|
||||
@@ -989,7 +1042,9 @@ static void curve_select_less(Object *obedit)
|
||||
}
|
||||
else {
|
||||
bp += nu->pntsu;
|
||||
if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++;
|
||||
if ((bp->hide == 0) && (bp->f1 & SELECT)) {
|
||||
sel++;
|
||||
}
|
||||
bp -= nu->pntsu;
|
||||
}
|
||||
|
||||
@@ -1026,7 +1081,9 @@ static void curve_select_less(Object *obedit)
|
||||
}
|
||||
else {
|
||||
bezt--;
|
||||
if ((bezt->hide == 0) && (bezt->f2 & SELECT)) sel++;
|
||||
if ((bezt->hide == 0) && (bezt->f2 & SELECT)) {
|
||||
sel++;
|
||||
}
|
||||
bezt++;
|
||||
}
|
||||
|
||||
@@ -1035,7 +1092,9 @@ static void curve_select_less(Object *obedit)
|
||||
}
|
||||
else {
|
||||
bezt++;
|
||||
if ((bezt->hide == 0) && (bezt->f2 & SELECT)) sel++;
|
||||
if ((bezt->hide == 0) && (bezt->f2 & SELECT)) {
|
||||
sel++;
|
||||
}
|
||||
bezt--;
|
||||
}
|
||||
|
||||
@@ -1067,7 +1126,9 @@ static void curve_select_less(Object *obedit)
|
||||
}
|
||||
else {
|
||||
bp--;
|
||||
if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++;
|
||||
if ((bp->hide == 0) && (bp->f1 & SELECT)) {
|
||||
sel++;
|
||||
}
|
||||
bp++;
|
||||
}
|
||||
|
||||
@@ -1076,7 +1137,9 @@ static void curve_select_less(Object *obedit)
|
||||
}
|
||||
else {
|
||||
bp++;
|
||||
if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++;
|
||||
if ((bp->hide == 0) && (bp->f1 & SELECT)) {
|
||||
sel++;
|
||||
}
|
||||
bp--;
|
||||
}
|
||||
|
||||
@@ -1274,8 +1337,9 @@ static bool ed_curve_select_nth(Curve *cu, const struct CheckerIntervalParams *p
|
||||
Nurb *nu = NULL;
|
||||
void *vert = NULL;
|
||||
|
||||
if (!BKE_curve_nurb_vert_active_get(cu, &nu, &vert))
|
||||
if (!BKE_curve_nurb_vert_active_get(cu, &nu, &vert)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (nu->bezt) {
|
||||
select_nth_bezt(nu, vert, params);
|
||||
|
||||
@@ -133,8 +133,9 @@ static void undocurve_from_editcurve(UndoCurve *ucu, Curve *cu, const short shap
|
||||
}
|
||||
|
||||
if (ad) {
|
||||
if (ad->action)
|
||||
if (ad->action) {
|
||||
copy_fcurves(&ucu->fcurves, &ad->action->curves);
|
||||
}
|
||||
|
||||
copy_fcurves(&ucu->drivers, &ad->drivers);
|
||||
}
|
||||
|
||||
@@ -79,139 +79,143 @@ static char findaccent(char char1, unsigned int code)
|
||||
char new = 0;
|
||||
|
||||
if (char1 == 'a') {
|
||||
if (code == '`') new = 224;
|
||||
else if (code == 39) new = 225;
|
||||
else if (code == '^') new = 226;
|
||||
else if (code == '~') new = 227;
|
||||
else if (code == '"') new = 228;
|
||||
else if (code == 'o') new = 229;
|
||||
else if (code == 'e') new = 230;
|
||||
else if (code == '-') new = 170;
|
||||
if (code == '`') { new = 224; }
|
||||
else if (code == 39) { new = 225; }
|
||||
else if (code == '^') { new = 226; }
|
||||
else if (code == '~') { new = 227; }
|
||||
else if (code == '"') { new = 228; }
|
||||
else if (code == 'o') { new = 229; }
|
||||
else if (code == 'e') { new = 230; }
|
||||
else if (code == '-') { new = 170; }
|
||||
}
|
||||
else if (char1 == 'c') {
|
||||
if (code == ',') new = 231;
|
||||
else if (code == '|') new = 162;
|
||||
else if (code == 'o') new = 169;
|
||||
if (code == ',') { new = 231; }
|
||||
else if (code == '|') { new = 162; }
|
||||
else if (code == 'o') { new = 169; }
|
||||
}
|
||||
else if (char1 == 'e') {
|
||||
if (code == '`') new = 232;
|
||||
else if (code == 39) new = 233;
|
||||
else if (code == '^') new = 234;
|
||||
else if (code == '"') new = 235;
|
||||
if (code == '`') { new = 232; }
|
||||
else if (code == 39) { new = 233; }
|
||||
else if (code == '^') { new = 234; }
|
||||
else if (code == '"') { new = 235; }
|
||||
}
|
||||
else if (char1 == 'i') {
|
||||
if (code == '`') new = 236;
|
||||
else if (code == 39) new = 237;
|
||||
else if (code == '^') new = 238;
|
||||
else if (code == '"') new = 239;
|
||||
if (code == '`') { new = 236; }
|
||||
else if (code == 39) { new = 237; }
|
||||
else if (code == '^') { new = 238; }
|
||||
else if (code == '"') { new = 239; }
|
||||
}
|
||||
else if (char1 == 'n') {
|
||||
if (code == '~') new = 241;
|
||||
if (code == '~') { new = 241; }
|
||||
}
|
||||
else if (char1 == 'o') {
|
||||
if (code == '`') new = 242;
|
||||
else if (code == 39) new = 243;
|
||||
else if (code == '^') new = 244;
|
||||
else if (code == '~') new = 245;
|
||||
else if (code == '"') new = 246;
|
||||
else if (code == '/') new = 248;
|
||||
else if (code == '-') new = 186;
|
||||
else if (code == 'e') new = 143;
|
||||
else if (code == 'c') new = 169;
|
||||
else if (code == 'r') new = 174;
|
||||
if (code == '`') { new = 242; }
|
||||
else if (code == 39) { new = 243; }
|
||||
else if (code == '^') { new = 244; }
|
||||
else if (code == '~') { new = 245; }
|
||||
else if (code == '"') { new = 246; }
|
||||
else if (code == '/') { new = 248; }
|
||||
else if (code == '-') { new = 186; }
|
||||
else if (code == 'e') { new = 143; }
|
||||
else if (code == 'c') { new = 169; }
|
||||
else if (code == 'r') { new = 174; }
|
||||
}
|
||||
else if (char1 == 'r') {
|
||||
if (code == 'o') new = 174;
|
||||
if (code == 'o') { new = 174; }
|
||||
}
|
||||
else if (char1 == 's') {
|
||||
if (code == 's') new = 167;
|
||||
if (code == 's') { new = 167; }
|
||||
}
|
||||
else if (char1 == 't') {
|
||||
if (code == 'm') new = 153;
|
||||
if (code == 'm') { new = 153; }
|
||||
}
|
||||
else if (char1 == 'u') {
|
||||
if (code == '`') new = 249;
|
||||
else if (code == 39) new = 250;
|
||||
else if (code == '^') new = 251;
|
||||
else if (code == '"') new = 252;
|
||||
if (code == '`') { new = 249; }
|
||||
else if (code == 39) { new = 250; }
|
||||
else if (code == '^') { new = 251; }
|
||||
else if (code == '"') { new = 252; }
|
||||
}
|
||||
else if (char1 == 'y') {
|
||||
if (code == 39) new = 253;
|
||||
else if (code == '"') new = 255;
|
||||
if (code == 39) { new = 253; }
|
||||
else if (code == '"') { new = 255; }
|
||||
}
|
||||
else if (char1 == 'A') {
|
||||
if (code == '`') new = 192;
|
||||
else if (code == 39) new = 193;
|
||||
else if (code == '^') new = 194;
|
||||
else if (code == '~') new = 195;
|
||||
else if (code == '"') new = 196;
|
||||
else if (code == 'o') new = 197;
|
||||
else if (code == 'e') new = 198;
|
||||
if (code == '`') { new = 192; }
|
||||
else if (code == 39) { new = 193; }
|
||||
else if (code == '^') { new = 194; }
|
||||
else if (code == '~') { new = 195; }
|
||||
else if (code == '"') { new = 196; }
|
||||
else if (code == 'o') { new = 197; }
|
||||
else if (code == 'e') { new = 198; }
|
||||
}
|
||||
else if (char1 == 'C') {
|
||||
if (code == ',') new = 199;
|
||||
if (code == ',') { new = 199; }
|
||||
}
|
||||
else if (char1 == 'E') {
|
||||
if (code == '`') new = 200;
|
||||
else if (code == 39) new = 201;
|
||||
else if (code == '^') new = 202;
|
||||
else if (code == '"') new = 203;
|
||||
if (code == '`') { new = 200; }
|
||||
else if (code == 39) { new = 201; }
|
||||
else if (code == '^') { new = 202; }
|
||||
else if (code == '"') { new = 203; }
|
||||
}
|
||||
else if (char1 == 'I') {
|
||||
if (code == '`') new = 204;
|
||||
else if (code == 39) new = 205;
|
||||
else if (code == '^') new = 206;
|
||||
else if (code == '"') new = 207;
|
||||
if (code == '`') { new = 204; }
|
||||
else if (code == 39) { new = 205; }
|
||||
else if (code == '^') { new = 206; }
|
||||
else if (code == '"') { new = 207; }
|
||||
}
|
||||
else if (char1 == 'N') {
|
||||
if (code == '~') new = 209;
|
||||
if (code == '~') { new = 209; }
|
||||
}
|
||||
else if (char1 == 'O') {
|
||||
if (code == '`') new = 210;
|
||||
else if (code == 39) new = 211;
|
||||
else if (code == '^') new = 212;
|
||||
else if (code == '~') new = 213;
|
||||
else if (code == '"') new = 214;
|
||||
else if (code == '/') new = 216;
|
||||
else if (code == 'e') new = 141;
|
||||
if (code == '`') { new = 210; }
|
||||
else if (code == 39) { new = 211; }
|
||||
else if (code == '^') { new = 212; }
|
||||
else if (code == '~') { new = 213; }
|
||||
else if (code == '"') { new = 214; }
|
||||
else if (code == '/') { new = 216; }
|
||||
else if (code == 'e') { new = 141; }
|
||||
}
|
||||
else if (char1 == 'U') {
|
||||
if (code == '`') new = 217;
|
||||
else if (code == 39) new = 218;
|
||||
else if (code == '^') new = 219;
|
||||
else if (code == '"') new = 220;
|
||||
if (code == '`') { new = 217; }
|
||||
else if (code == 39) { new = 218; }
|
||||
else if (code == '^') { new = 219; }
|
||||
else if (code == '"') { new = 220; }
|
||||
}
|
||||
else if (char1 == 'Y') {
|
||||
if (code == 39) new = 221;
|
||||
if (code == 39) { new = 221; }
|
||||
}
|
||||
else if (char1 == '1') {
|
||||
if (code == '4') new = 188;
|
||||
if (code == '2') new = 189;
|
||||
if (code == '4') { new = 188; }
|
||||
if (code == '2') { new = 189; }
|
||||
}
|
||||
else if (char1 == '3') {
|
||||
if (code == '4') new = 190;
|
||||
if (code == '4') { new = 190; }
|
||||
}
|
||||
else if (char1 == ':') {
|
||||
if (code == '-') new = 247;
|
||||
if (code == '-') { new = 247; }
|
||||
}
|
||||
else if (char1 == '-') {
|
||||
if (code == ':') new = 247;
|
||||
if (code == '|') new = 135;
|
||||
if (code == '+') new = 177;
|
||||
if (code == ':') { new = 247; }
|
||||
if (code == '|') { new = 135; }
|
||||
if (code == '+') { new = 177; }
|
||||
}
|
||||
else if (char1 == '|') {
|
||||
if (code == '-') new = 135;
|
||||
if (code == '=') new = 136;
|
||||
if (code == '-') { new = 135; }
|
||||
if (code == '=') { new = 136; }
|
||||
}
|
||||
else if (char1 == '=') {
|
||||
if (code == '|') new = 136;
|
||||
if (code == '|') { new = 136; }
|
||||
}
|
||||
else if (char1 == '+') {
|
||||
if (code == '-') new = 177;
|
||||
if (code == '-') { new = 177; }
|
||||
}
|
||||
|
||||
if (new) return new;
|
||||
else return char1;
|
||||
if (new) {
|
||||
return new;
|
||||
}
|
||||
else {
|
||||
return char1;
|
||||
}
|
||||
}
|
||||
|
||||
static int insert_into_textbuf(Object *obedit, uintptr_t c)
|
||||
@@ -222,8 +226,12 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c)
|
||||
if (ef->len < MAXTEXT - 1) {
|
||||
int x;
|
||||
|
||||
for (x = ef->len; x > ef->pos; x--) ef->textbuf[x] = ef->textbuf[x - 1];
|
||||
for (x = ef->len; x > ef->pos; x--) ef->textbufinfo[x] = ef->textbufinfo[x - 1];
|
||||
for (x = ef->len; x > ef->pos; x--) {
|
||||
ef->textbuf[x] = ef->textbuf[x - 1];
|
||||
}
|
||||
for (x = ef->len; x > ef->pos; x--) {
|
||||
ef->textbufinfo[x] = ef->textbufinfo[x - 1];
|
||||
}
|
||||
ef->textbuf[ef->pos] = c;
|
||||
ef->textbufinfo[ef->pos] = cu->curinfo;
|
||||
ef->textbufinfo[ef->pos].kern = 0;
|
||||
@@ -235,8 +243,9 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c)
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void text_update_edited(bContext *C, Object *obedit, int mode)
|
||||
@@ -383,8 +392,9 @@ static int paste_from_file_exec(bContext *C, wmOperator *op)
|
||||
|
||||
static int paste_from_file_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
{
|
||||
if (RNA_struct_property_is_set(op->ptr, "filepath"))
|
||||
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
|
||||
return paste_from_file_exec(C, op);
|
||||
}
|
||||
|
||||
WM_event_add_fileselect(C, op);
|
||||
|
||||
@@ -450,8 +460,12 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, const
|
||||
nbytes += nbytes_line + 1;
|
||||
}
|
||||
|
||||
if (cu->str) MEM_freeN(cu->str);
|
||||
if (cu->strinfo) MEM_freeN(cu->strinfo);
|
||||
if (cu->str) {
|
||||
MEM_freeN(cu->str);
|
||||
}
|
||||
if (cu->strinfo) {
|
||||
MEM_freeN(cu->strinfo);
|
||||
}
|
||||
|
||||
cu->str = MEM_mallocN(nbytes + 4, "str");
|
||||
cu->strinfo = MEM_callocN((nchars + 4) * sizeof(CharInfo), "strinfo");
|
||||
@@ -492,7 +506,9 @@ void ED_text_to_object(bContext *C, Text *text, const bool split_lines)
|
||||
float offset[3];
|
||||
int linenum = 0;
|
||||
|
||||
if (!text || !text->lines.first) return;
|
||||
if (!text || !text->lines.first) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (split_lines) {
|
||||
for (line = text->lines.first; line; line = line->next) {
|
||||
@@ -507,8 +523,9 @@ void ED_text_to_object(bContext *C, Text *text, const bool split_lines)
|
||||
offset[1] = -linenum;
|
||||
offset[2] = 0;
|
||||
|
||||
if (rv3d)
|
||||
if (rv3d) {
|
||||
mul_mat3_m4_v3(rv3d->viewinv, offset);
|
||||
}
|
||||
|
||||
txt_add_object(C, line, 1, offset);
|
||||
|
||||
@@ -537,14 +554,20 @@ static int kill_selection(Object *obedit, int ins) /* 1 == new character */
|
||||
direction = BKE_vfont_select_get(obedit, &selstart, &selend);
|
||||
if (direction) {
|
||||
int size;
|
||||
if (ins) offset = 1;
|
||||
if (ef->pos >= selstart) ef->pos = selstart + offset;
|
||||
if (ins) {
|
||||
offset = 1;
|
||||
}
|
||||
if (ef->pos >= selstart) {
|
||||
ef->pos = selstart + offset;
|
||||
}
|
||||
if ((direction == -1) && ins) {
|
||||
selstart++;
|
||||
selend++;
|
||||
}
|
||||
getfrom = selend + offset;
|
||||
if (ins == 0) getfrom++;
|
||||
if (ins == 0) {
|
||||
getfrom++;
|
||||
}
|
||||
size = (ef->len * sizeof(wchar_t)) - (selstart * sizeof(wchar_t)) + (offset * sizeof(wchar_t));
|
||||
memmove(ef->textbuf + selstart, ef->textbuf + getfrom, size);
|
||||
memmove(ef->textbufinfo + selstart, ef->textbufinfo + getfrom, ((ef->len - selstart) + offset) * sizeof(CharInfo));
|
||||
@@ -572,14 +595,17 @@ static int set_style(bContext *C, const int style, const bool clear)
|
||||
EditFont *ef = cu->editfont;
|
||||
int i, selstart, selend;
|
||||
|
||||
if (!BKE_vfont_select_get(obedit, &selstart, &selend))
|
||||
if (!BKE_vfont_select_get(obedit, &selstart, &selend)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
for (i = selstart; i <= selend; i++) {
|
||||
if (clear)
|
||||
if (clear) {
|
||||
ef->textbufinfo[i].flag &= ~style;
|
||||
else
|
||||
}
|
||||
else {
|
||||
ef->textbufinfo[i].flag |= style;
|
||||
}
|
||||
}
|
||||
|
||||
DEG_id_tag_update(obedit->data, 0);
|
||||
@@ -623,8 +649,9 @@ static int toggle_style_exec(bContext *C, wmOperator *op)
|
||||
Curve *cu = obedit->data;
|
||||
int style, clear, selstart, selend;
|
||||
|
||||
if (!BKE_vfont_select_get(obedit, &selstart, &selend))
|
||||
if (!BKE_vfont_select_get(obedit, &selstart, &selend)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
style = RNA_enum_get(op->ptr, "style");
|
||||
|
||||
@@ -748,8 +775,9 @@ static int cut_text_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
int selstart, selend;
|
||||
|
||||
if (!BKE_vfont_select_get(obedit, &selstart, &selend))
|
||||
if (!BKE_vfont_select_get(obedit, &selstart, &selend)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
copy_selection(obedit);
|
||||
kill_selection(obedit, 0);
|
||||
@@ -906,8 +934,12 @@ static int move_cursor(bContext *C, int type, const bool select)
|
||||
switch (type) {
|
||||
case LINE_BEGIN:
|
||||
while (ef->pos > 0) {
|
||||
if (ef->textbuf[ef->pos - 1] == '\n') break;
|
||||
if (ef->textbufinfo[ef->pos - 1].flag & CU_CHINFO_WRAP) break;
|
||||
if (ef->textbuf[ef->pos - 1] == '\n') {
|
||||
break;
|
||||
}
|
||||
if (ef->textbufinfo[ef->pos - 1].flag & CU_CHINFO_WRAP) {
|
||||
break;
|
||||
}
|
||||
ef->pos--;
|
||||
}
|
||||
cursmove = FO_CURS;
|
||||
@@ -915,9 +947,15 @@ static int move_cursor(bContext *C, int type, const bool select)
|
||||
|
||||
case LINE_END:
|
||||
while (ef->pos < ef->len) {
|
||||
if (ef->textbuf[ef->pos] == 0) break;
|
||||
if (ef->textbuf[ef->pos] == '\n') break;
|
||||
if (ef->textbufinfo[ef->pos].flag & CU_CHINFO_WRAP) break;
|
||||
if (ef->textbuf[ef->pos] == 0) {
|
||||
break;
|
||||
}
|
||||
if (ef->textbuf[ef->pos] == '\n') {
|
||||
break;
|
||||
}
|
||||
if (ef->textbufinfo[ef->pos].flag & CU_CHINFO_WRAP) {
|
||||
break;
|
||||
}
|
||||
ef->pos++;
|
||||
}
|
||||
cursmove = FO_CURS;
|
||||
@@ -969,12 +1007,13 @@ static int move_cursor(bContext *C, int type, const bool select)
|
||||
break;
|
||||
}
|
||||
|
||||
if (cursmove == -1)
|
||||
if (cursmove == -1) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if (ef->pos > ef->len) ef->pos = ef->len;
|
||||
else if (ef->pos >= MAXTEXT) ef->pos = MAXTEXT;
|
||||
else if (ef->pos < 0) ef->pos = 0;
|
||||
if (ef->pos > ef->len) { ef->pos = ef->len; }
|
||||
else if (ef->pos >= MAXTEXT) { ef->pos = MAXTEXT; }
|
||||
else if (ef->pos < 0) { ef->pos = 0; }
|
||||
|
||||
/* apply vertical cursor motion to position immediately
|
||||
* otherwise the selection will lag behind */
|
||||
@@ -990,8 +1029,9 @@ static int move_cursor(bContext *C, int type, const bool select)
|
||||
}
|
||||
}
|
||||
|
||||
if (select)
|
||||
if (select) {
|
||||
ef->selend = ef->pos;
|
||||
}
|
||||
|
||||
text_update_edited(C, obedit, cursmove);
|
||||
|
||||
@@ -1063,8 +1103,9 @@ static int change_spacing_exec(bContext *C, wmOperator *op)
|
||||
kern += delta;
|
||||
CLAMP(kern, -20, 20);
|
||||
|
||||
if (ef->textbufinfo[ef->pos - 1].kern == kern)
|
||||
if (ef->textbufinfo[ef->pos - 1].kern == kern) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
ef->textbufinfo[ef->pos - 1].kern = kern;
|
||||
|
||||
@@ -1100,15 +1141,17 @@ static int change_character_exec(bContext *C, wmOperator *op)
|
||||
EditFont *ef = cu->editfont;
|
||||
int character, delta = RNA_int_get(op->ptr, "delta");
|
||||
|
||||
if (ef->pos <= 0)
|
||||
if (ef->pos <= 0) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
character = ef->textbuf[ef->pos - 1];
|
||||
character += delta;
|
||||
CLAMP(character, 0, 255);
|
||||
|
||||
if (character == ef->textbuf[ef->pos - 1])
|
||||
if (character == ef->textbuf[ef->pos - 1]) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
ef->textbuf[ef->pos - 1] = character;
|
||||
|
||||
@@ -1189,27 +1232,38 @@ static int delete_exec(bContext *C, wmOperator *op)
|
||||
int range[2] = {0, 0};
|
||||
bool has_select = false;
|
||||
|
||||
if (ef->len == 0)
|
||||
if (ef->len == 0) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if (BKE_vfont_select_get(obedit, &selstart, &selend)) {
|
||||
if (type == DEL_NEXT_SEL) type = DEL_SELECTION;
|
||||
else if (type == DEL_PREV_SEL) type = DEL_SELECTION;
|
||||
if (type == DEL_NEXT_SEL) {
|
||||
type = DEL_SELECTION;
|
||||
}
|
||||
else if (type == DEL_PREV_SEL) {
|
||||
type = DEL_SELECTION;
|
||||
}
|
||||
has_select = true;
|
||||
}
|
||||
else {
|
||||
if (type == DEL_NEXT_SEL) type = DEL_NEXT_CHAR;
|
||||
else if (type == DEL_PREV_SEL) type = DEL_PREV_CHAR;
|
||||
if (type == DEL_NEXT_SEL) {
|
||||
type = DEL_NEXT_CHAR;
|
||||
}
|
||||
else if (type == DEL_PREV_SEL) {
|
||||
type = DEL_PREV_CHAR;
|
||||
}
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case DEL_SELECTION:
|
||||
if (!kill_selection(obedit, 0))
|
||||
if (!kill_selection(obedit, 0)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
break;
|
||||
case DEL_PREV_CHAR:
|
||||
if (ef->pos <= 0)
|
||||
if (ef->pos <= 0) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
range[0] = ef->pos - 1;
|
||||
range[1] = ef->pos;
|
||||
@@ -1217,8 +1271,9 @@ static int delete_exec(bContext *C, wmOperator *op)
|
||||
ef->pos--;
|
||||
break;
|
||||
case DEL_NEXT_CHAR:
|
||||
if (ef->pos >= ef->len)
|
||||
if (ef->pos >= ef->len) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
range[0] = ef->pos;
|
||||
range[1] = ef->pos + 1;
|
||||
@@ -1306,8 +1361,9 @@ static int insert_text_exec(bContext *C, wmOperator *op)
|
||||
wchar_t *inserted_text;
|
||||
int a, len;
|
||||
|
||||
if (!RNA_struct_property_is_set(op->ptr, "text"))
|
||||
if (!RNA_struct_property_is_set(op->ptr, "text")) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
inserted_utf8 = RNA_string_get_alloc(op->ptr, "text", NULL, 0);
|
||||
len = BLI_strlen_utf8(inserted_utf8);
|
||||
@@ -1315,8 +1371,9 @@ static int insert_text_exec(bContext *C, wmOperator *op)
|
||||
inserted_text = MEM_callocN(sizeof(wchar_t) * (len + 1), "FONT_insert_text");
|
||||
BLI_strncpy_wchar_from_utf8(inserted_text, inserted_utf8, len + 1);
|
||||
|
||||
for (a = 0; a < len; a++)
|
||||
for (a = 0; a < len; a++) {
|
||||
insert_into_textbuf(obedit, inserted_text[a]);
|
||||
}
|
||||
|
||||
MEM_freeN(inserted_text);
|
||||
MEM_freeN(inserted_utf8);
|
||||
@@ -1338,26 +1395,31 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
int event_type = event->type, event_val = event->val;
|
||||
wchar_t inserted_text[2] = {0};
|
||||
|
||||
if (RNA_struct_property_is_set(op->ptr, "text"))
|
||||
if (RNA_struct_property_is_set(op->ptr, "text")) {
|
||||
return insert_text_exec(C, op);
|
||||
}
|
||||
|
||||
if (RNA_struct_property_is_set(op->ptr, "accent")) {
|
||||
if (ef->len != 0 && ef->pos > 0)
|
||||
if (ef->len != 0 && ef->pos > 0) {
|
||||
accentcode = 1;
|
||||
}
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
/* tab should exit editmode, but we allow it to be typed using modifier keys */
|
||||
if (event_type == TABKEY) {
|
||||
if ((alt || ctrl || shift) == 0)
|
||||
if ((alt || ctrl || shift) == 0) {
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
else
|
||||
}
|
||||
else {
|
||||
ascii = 9;
|
||||
}
|
||||
}
|
||||
|
||||
if (event_type == BACKSPACEKEY) {
|
||||
if (alt && ef->len != 0 && ef->pos > 0)
|
||||
if (alt && ef->len != 0 && ef->pos > 0) {
|
||||
accentcode = 1;
|
||||
}
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
@@ -1400,8 +1462,9 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
text_update_edited(C, obedit, FO_EDIT);
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
if (inserted_text[0]) {
|
||||
/* store as utf8 in RNA string */
|
||||
@@ -1412,8 +1475,9 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
}
|
||||
|
||||
/* reset property? */
|
||||
if (event_val == 0)
|
||||
if (event_val == 0) {
|
||||
accentcode = 0;
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1447,7 +1511,9 @@ static int textbox_add_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
int i;
|
||||
|
||||
if (cu->totbox < 256) {
|
||||
for (i = cu->totbox; i > cu->actbox; i--) cu->tb[i] = cu->tb[i - 1];
|
||||
for (i = cu->totbox; i > cu->actbox; i--) {
|
||||
cu->tb[i] = cu->tb[i - 1];
|
||||
}
|
||||
cu->tb[cu->actbox] = cu->tb[cu->actbox - 1];
|
||||
cu->actbox++;
|
||||
cu->totbox++;
|
||||
@@ -1490,10 +1556,13 @@ static int textbox_remove_exec(bContext *C, wmOperator *op)
|
||||
|
||||
|
||||
if (cu->totbox > 1) {
|
||||
for (i = index; i < cu->totbox; i++) cu->tb[i] = cu->tb[i + 1];
|
||||
for (i = index; i < cu->totbox; i++) {
|
||||
cu->tb[i] = cu->tb[i + 1];
|
||||
}
|
||||
cu->totbox--;
|
||||
if (cu->actbox >= index)
|
||||
if (cu->actbox >= index) {
|
||||
cu->actbox--;
|
||||
}
|
||||
}
|
||||
|
||||
DEG_id_tag_update(obedit->data, 0);
|
||||
@@ -1544,7 +1613,9 @@ void ED_curve_editfont_make(Object *obedit)
|
||||
|
||||
memcpy(ef->textbufinfo, cu->strinfo, ef->len * sizeof(CharInfo));
|
||||
|
||||
if (ef->pos > ef->len) ef->pos = ef->len;
|
||||
if (ef->pos > ef->len) {
|
||||
ef->pos = ef->len;
|
||||
}
|
||||
|
||||
cu->curinfo = ef->textbufinfo[ef->pos ? ef->pos - 1 : 0];
|
||||
|
||||
@@ -1575,8 +1646,9 @@ void ED_curve_editfont_load(Object *obedit)
|
||||
/* Copy the wchar to UTF-8 */
|
||||
BLI_strncpy_wchar_as_utf8(cu->str, ef->textbuf, cu->len + 1);
|
||||
|
||||
if (cu->strinfo)
|
||||
if (cu->strinfo) {
|
||||
MEM_freeN(cu->strinfo);
|
||||
}
|
||||
cu->strinfo = MEM_callocN((cu->len_wchar + 4) * sizeof(CharInfo), "texteditinfo");
|
||||
memcpy(cu->strinfo, ef->textbufinfo, cu->len_wchar * sizeof(CharInfo));
|
||||
|
||||
@@ -1612,8 +1684,9 @@ static int set_case(bContext *C, int ccase)
|
||||
len = (selend - selstart) + 1;
|
||||
str = &ef->textbuf[selstart];
|
||||
while (len) {
|
||||
if (*str >= 'a' && *str <= 'z')
|
||||
if (*str >= 'a' && *str <= 'z') {
|
||||
*str -= 32;
|
||||
}
|
||||
len--;
|
||||
str++;
|
||||
}
|
||||
@@ -1727,12 +1800,15 @@ static int font_open_exec(bContext *C, wmOperator *op)
|
||||
font = BKE_vfont_load(bmain, filepath);
|
||||
|
||||
if (!font) {
|
||||
if (op->customdata) MEM_freeN(op->customdata);
|
||||
if (op->customdata) {
|
||||
MEM_freeN(op->customdata);
|
||||
}
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if (!op->customdata)
|
||||
if (!op->customdata) {
|
||||
font_ui_template_init(C, op);
|
||||
}
|
||||
|
||||
/* hook into UI */
|
||||
pprop = op->customdata;
|
||||
@@ -1772,8 +1848,9 @@ static int open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
|
||||
|
||||
path = (vfont && !BKE_vfont_is_builtin(vfont)) ? vfont->name : U.fontdir;
|
||||
|
||||
if (RNA_struct_property_is_set(op->ptr, "filepath"))
|
||||
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
|
||||
return font_open_exec(C, op);
|
||||
}
|
||||
|
||||
RNA_string_set(op->ptr, "filepath", path);
|
||||
WM_event_add_fileselect(C, op);
|
||||
|
||||
Reference in New Issue
Block a user