Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/curve')
-rw-r--r--source/blender/editors/curve/editcurve.c1622
-rw-r--r--source/blender/editors/curve/editfont.c478
2 files changed, 1075 insertions, 1025 deletions
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 7b855398802..fbcda86eb75 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -117,7 +117,7 @@ static float nurbcircle[8][2]= {
ListBase *object_editcurve_get(Object *ob)
{
- if(ob && ELEM(ob->type, OB_CURVE, OB_SURF)) {
+ if (ob && ELEM(ob->type, OB_CURVE, OB_SURF)) {
Curve *cu= ob->data;
return &cu->editnurb->nurbs;
}
@@ -129,7 +129,7 @@ static void set_actNurb(Object *obedit, Nurb *nu)
{
Curve *cu= obedit->data;
- if(nu==NULL)
+ if (nu==NULL)
cu->actnu = -1;
else {
ListBase *nurbs= curve_editnurbs(cu);
@@ -157,9 +157,9 @@ static Nurb *get_actNurb(Object *obedit)
/* returns 1 in case (de)selection was successful */
static short select_beztriple(BezTriple *bezt, short selstatus, short flag, short hidden)
{
- if(bezt) {
- if((bezt->hide==0) || (hidden==1)) {
- if(selstatus==1) { /* selects */
+ if (bezt) {
+ if ((bezt->hide==0) || (hidden==1)) {
+ if (selstatus==1) { /* selects */
bezt->f1 |= flag;
bezt->f2 |= flag;
bezt->f3 |= flag;
@@ -180,9 +180,9 @@ static short select_beztriple(BezTriple *bezt, short selstatus, short flag, shor
/* returns 1 in case (de)selection was successful */
static short select_bpoint(BPoint *bp, short selstatus, short flag, short hidden)
{
- if(bp) {
- if((bp->hide==0) || (hidden==1)) {
- if(selstatus==1) {
+ if (bp) {
+ if ((bp->hide==0) || (hidden==1)) {
+ if (selstatus==1) {
bp->f1 |= flag;
return 1;
}
@@ -198,7 +198,7 @@ static short select_bpoint(BPoint *bp, short selstatus, short flag, short hidden
static short swap_selection_beztriple(BezTriple *bezt)
{
- if(bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT)
return select_beztriple(bezt, DESELECT, 1, VISIBLE);
else
return select_beztriple(bezt, SELECT, 1, VISIBLE);
@@ -206,7 +206,7 @@ static short swap_selection_beztriple(BezTriple *bezt)
static short swap_selection_bpoint(BPoint *bp)
{
- if(bp->f1 & SELECT)
+ if (bp->f1 & SELECT)
return select_bpoint(bp, DESELECT, 1, VISIBLE);
else
return select_bpoint(bp, SELECT, 1, VISIBLE);
@@ -218,19 +218,19 @@ int isNurbsel(Nurb *nu)
BPoint *bp;
int a;
- if(nu->type == CU_BEZIER) {
+ 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;
+ 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;
+ while (a--) {
+ if ( (bp->f1 & SELECT) ) return 1;
bp++;
}
}
@@ -243,10 +243,10 @@ static int isNurbsel_count(Curve *cu, Nurb *nu)
BPoint *bp;
int a, sel=0;
- if(nu->type == CU_BEZIER) {
+ if (nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
- while(a--) {
+ while (a--) {
if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) sel++;
bezt++;
}
@@ -254,8 +254,8 @@ static int isNurbsel_count(Curve *cu, Nurb *nu)
else {
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
- while(a--) {
- if( (bp->f1 & SELECT) ) sel++;
+ while (a--) {
+ if ( (bp->f1 & SELECT) ) sel++;
bp++;
}
}
@@ -270,15 +270,15 @@ void printknots(Object *obedit)
Nurb *nu;
int a, num;
- for(nu= editnurb->first; nu; nu= nu->next) {
- if(isNurbsel(nu) && nu->type == CU_NURBS) {
- if(nu->knotsu) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
+ if (isNurbsel(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]);
+ for (a=0;a<num;a++) printf("knotu %d: %f\n", a, nu->knotsu[a]);
}
- if(nu->knotsv) {
+ if (nu->knotsv) {
num= KNOTSV(nu);
- for(a=0;a<num;a++) printf("knotv %d: %f\n", a, nu->knotsv[a]);
+ for (a=0;a<num;a++) printf("knotv %d: %f\n", a, nu->knotsv[a]);
}
}
}
@@ -310,7 +310,7 @@ static void init_editNurb_keyIndex(EditNurb *editnurb, ListBase *origBase)
CVKeyIndex *keyIndex;
int a, key_index= 0, nu_index= 0, pt_index= 0;
- if(editnurb->keyindex) return;
+ if (editnurb->keyindex) return;
gh= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "editNurb keyIndex");
@@ -328,7 +328,8 @@ static void init_editNurb_keyIndex(EditNurb *editnurb, ListBase *origBase)
origbezt++;
pt_index++;
}
- } else {
+ }
+ else {
a= orignu->pntsu * orignu->pntsv;
bp= nu->bp;
origbp= orignu->bp;
@@ -424,7 +425,8 @@ static void keyIndex_delNurb(EditNurb *editnurb, Nurb *nu)
BLI_ghash_remove(editnurb->keyindex, bezt, NULL, (GHashValFreeFP)MEM_freeN);
++bezt;
}
- } else {
+ }
+ else {
BPoint *bp= nu->bp;
a= nu->pntsu * nu->pntsv;
@@ -487,7 +489,8 @@ static void keyIndex_updateNurb(EditNurb *editnurb, Nurb *nu, Nurb *newnu)
{
if (nu->bezt) {
keyIndex_updateBezt(editnurb, nu->bezt, newnu->bezt, newnu->pntsu);
- } else {
+ }
+ else {
keyIndex_updateBP(editnurb, nu->bp, newnu->bp, newnu->pntsu * newnu->pntsv);
}
}
@@ -500,8 +503,8 @@ static void keyIndex_swap(EditNurb *editnurb, void *a, void *b)
BLI_ghash_remove(editnurb->keyindex, a, NULL, NULL);
BLI_ghash_remove(editnurb->keyindex, b, NULL, NULL);
- 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)
@@ -525,18 +528,19 @@ 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++;
bezt2--;
}
- } else {
+ }
+ else {
BPoint *bp1, *bp2;
if (nu->pntsv == 1) {
@@ -544,14 +548,14 @@ static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu)
bp1= nu->bp;
bp2= bp1+(a-1);
a/= 2;
- while(bp1!=bp2 && a>0) {
+ while (bp1!=bp2 && a>0) {
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);
}
@@ -560,24 +564,25 @@ static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu)
bp1++;
bp2--;
}
- } else {
+ }
+ else {
int b;
- for(b=0; b<nu->pntsv; b++) {
+ for (b=0; b<nu->pntsv; b++) {
bp1= nu->bp+b*nu->pntsu;
a= nu->pntsu;
bp2= bp1+(a-1);
a/= 2;
- while(bp1!=bp2 && a>0) {
+ while (bp1!=bp2 && a>0) {
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);
}
@@ -602,7 +607,7 @@ static void switch_keys_direction(Curve *cu, Nurb *actnu)
int a;
currkey = cu->key->block.first;
- while(currkey) {
+ while (currkey) {
fp= currkey->data;
nu= nubase->first;
@@ -612,26 +617,29 @@ static void switch_keys_direction(Curve *cu, Nurb *actnu)
a= nu->pntsu;
if (nu == actnu) {
while (a--) {
- if(getKeyIndexOrig_bezt(editnurb, bezt)) {
+ if (getKeyIndexOrig_bezt(editnurb, bezt)) {
swap_v3_v3(fp, fp + 6);
*(fp+9) = -*(fp+9);
fp += 12;
}
bezt++;
}
- } else fp += a * 12;
- } else {
+ }
+ else fp += a * 12;
+ }
+ else {
BPoint *bp= nu->bp;
a= nu->pntsu * nu->pntsv;
if (nu == actnu) {
while (a--) {
- if(getKeyIndexOrig_bp(editnurb, bp)) {
+ if (getKeyIndexOrig_bp(editnurb, bp)) {
*(fp+3) = -*(fp+3);
fp += 4;
}
bp++;
}
- } else fp += a * 4;
+ }
+ else fp += a * 4;
}
nu= nu->next;
@@ -651,7 +659,7 @@ static void keyData_switchDirectionNurb(Curve *cu, Nurb *nu)
}
keyIndex_switchDirection(editnurb, nu);
- if(cu->key)
+ if (cu->key)
switch_keys_direction(cu, nu);
}
@@ -662,7 +670,7 @@ static GHash *dupli_keyIndexHash(GHash *keyindex)
gh= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dupli_keyIndex gh");
- for(hashIter = BLI_ghashIterator_new(keyindex);
+ for (hashIter = BLI_ghashIterator_new(keyindex);
!BLI_ghashIterator_isDone(hashIter);
BLI_ghashIterator_step(hashIter)) {
void *cv = BLI_ghashIterator_getKey(hashIter);
@@ -710,10 +718,11 @@ static void calc_keyHandles(ListBase *nurb, float *key)
a= nu->pntsu;
startfp= fp;
- if(nu->flagu & CU_NURB_CYCLIC) {
+ if (nu->flagu & CU_NURB_CYCLIC) {
prevp= bezt+(a-1);
prevfp= fp+(12 * (a-1));
- } else {
+ }
+ else {
prevp= NULL;
prevfp= NULL;
}
@@ -732,11 +741,12 @@ static void calc_keyHandles(ListBase *nurb, float *key)
prevp= bezt;
prevfp= fp;
- if(a==1) {
- if(nu->flagu & CU_NURB_CYCLIC) {
+ if (a==1) {
+ if (nu->flagu & CU_NURB_CYCLIC) {
nextp= nu->bezt;
nextfp= startfp;
- } else {
+ }
+ else {
nextp= NULL;
nextfp= NULL;
}
@@ -749,7 +759,8 @@ static void calc_keyHandles(ListBase *nurb, float *key)
++bezt;
fp += 12;
}
- } else {
+ }
+ else {
a= nu->pntsu * nu->pntsv;
fp += a * 4;
}
@@ -763,7 +774,7 @@ static void calc_shapeKeys(Object *obedit)
Curve *cu= (Curve*)obedit->data;
/* are there keys? */
- if(cu->key) {
+ if (cu->key) {
int a, i;
EditNurb *editnurb= cu->editnurb;
KeyBlock *currkey;
@@ -777,26 +788,27 @@ static void calc_shapeKeys(Object *obedit)
float *oldkey, *newkey, *ofp;
/* editing the base key should update others */
- if(cu->key->type==KEY_RELATIVE) {
+ if (cu->key->type==KEY_RELATIVE) {
int act_is_basis = 0;
/* find if this key is a basis for any others */
- for(currkey = cu->key->block.first; currkey; currkey= currkey->next) {
- if(editnurb->shapenr-1 == currkey->relative) {
+ for (currkey = cu->key->block.first; currkey; currkey= currkey->next) {
+ if (editnurb->shapenr-1 == currkey->relative) {
act_is_basis = 1;
break;
}
}
- if(act_is_basis) { /* active key is a base */
+ if (act_is_basis) { /* active key is a base */
int totvec= 0;
/* Calculate needed memory to store offset */
nu= editnurb->nurbs.first;
- while(nu) {
+ while (nu) {
if (nu->bezt) {
/* Three vects to store handles and one for alfa */
totvec+= nu->pntsu * 4;
- } else {
+ }
+ else {
totvec+= 2 * nu->pntsu * nu->pntsv;
}
@@ -806,11 +818,11 @@ static void calc_shapeKeys(Object *obedit)
ofs= MEM_callocN(sizeof(float) * 3 * totvec, "currkey->data");
nu= editnurb->nurbs.first;
i= 0;
- while(nu) {
- if(nu->bezt) {
+ while (nu) {
+ if (nu->bezt) {
bezt= nu->bezt;
a= nu->pntsu;
- while(a--) {
+ while (a--) {
oldbezt= getKeyIndexOrig_bezt(editnurb, bezt);
if (oldbezt) {
@@ -820,7 +832,8 @@ static void calc_shapeKeys(Object *obedit)
i++;
}
ofs[i++][0]= bezt->alfa - oldbezt->alfa;
- } else {
+ }
+ else {
i += 4;
}
bezt++;
@@ -829,7 +842,7 @@ static void calc_shapeKeys(Object *obedit)
else {
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
- while(a--) {
+ while (a--) {
oldbp= getKeyIndexOrig_bp(editnurb, bp);
if (oldbp) {
sub_v3_v3v3(ofs[i], bp->vec, oldbp->vec);
@@ -846,7 +859,7 @@ static void calc_shapeKeys(Object *obedit)
}
currkey = cu->key->block.first;
- while(currkey) {
+ while (currkey) {
int apply_offset = (ofs && (currkey != actkey) && (editnurb->shapenr-1 == currkey->relative));
float *fp= newkey= MEM_callocN(cu->key->elemsize * totvert, "currkey->data");
@@ -854,14 +867,14 @@ static void calc_shapeKeys(Object *obedit)
nu= editnurb->nurbs.first;
i = 0;
- while(nu) {
- if(currkey == actkey) {
+ while (nu) {
+ if (currkey == actkey) {
int restore= actkey != cu->key->refkey;
- if(nu->bezt) {
+ if (nu->bezt) {
bezt= nu->bezt;
a= nu->pntsu;
- while(a--) {
+ while (a--) {
int j;
oldbezt= getKeyIndexOrig_bezt(editnurb, bezt);
@@ -876,7 +889,7 @@ static void calc_shapeKeys(Object *obedit)
}
fp[0]= bezt->alfa;
- if(restore && oldbezt) {
+ if (restore && oldbezt) {
bezt->alfa= oldbezt->alfa;
}
@@ -887,14 +900,14 @@ static void calc_shapeKeys(Object *obedit)
else {
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
- while(a--) {
+ while (a--) {
oldbp= getKeyIndexOrig_bp(editnurb, bp);
copy_v3_v3(fp, bp->vec);
fp[3]= bp->alfa;
- if(restore && oldbp) {
+ if (restore && oldbp) {
copy_v3_v3(bp->vec, oldbp->vec);
bp->alfa= oldbp->alfa;
}
@@ -909,12 +922,12 @@ static void calc_shapeKeys(Object *obedit)
int index;
float *curofp;
- if(oldkey) {
- if(nu->bezt) {
+ if (oldkey) {
+ if (nu->bezt) {
bezt= nu->bezt;
a= nu->pntsu;
- while(a--) {
+ while (a--) {
index= getKeyIndexOrig_keyIndex(editnurb, bezt);
if (index >= 0) {
int j;
@@ -923,7 +936,7 @@ static void calc_shapeKeys(Object *obedit)
for (j= 0; j < 3; ++j, ++i) {
copy_v3_v3(fp, curofp);
- if(apply_offset) {
+ if (apply_offset) {
add_v3_v3(fp, ofs[i]);
}
@@ -931,14 +944,15 @@ static void calc_shapeKeys(Object *obedit)
}
fp[0]= curofp[0];
- if(apply_offset) {
+ if (apply_offset) {
/* apply alfa offsets */
add_v3_v3(fp, ofs[i]);
++i;
}
fp+= 3; /* alphas */
- } else {
+ }
+ else {
int j;
for (j= 0; j < 3; ++j, ++i) {
copy_v3_v3(fp, bezt->vec[j]);
@@ -954,7 +968,7 @@ static void calc_shapeKeys(Object *obedit)
else {
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
- while(a--) {
+ while (a--) {
index= getKeyIndexOrig_keyIndex(editnurb, bp);
if (index >= 0) {
@@ -962,11 +976,12 @@ static void calc_shapeKeys(Object *obedit)
copy_v3_v3(fp, curofp);
fp[3]= curofp[3];
- if(apply_offset) {
+ if (apply_offset) {
add_v3_v3(fp, ofs[i]);
fp[3]+=ofs[i+1][0];
}
- } else {
+ }
+ else {
copy_v3_v3(fp, bp->vec);
fp[3]= bp->alfa;
}
@@ -988,13 +1003,13 @@ static void calc_shapeKeys(Object *obedit)
}
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);
}
}
@@ -1016,7 +1031,7 @@ static void fcurve_path_rename(AnimData *ad, char *orig_rna_path, char *rna_path
fcu= orig_curves->first;
while (fcu) {
nextfcu= fcu->next;
- if(!strncmp(fcu->rna_path, orig_rna_path, len)) {
+ if (!strncmp(fcu->rna_path, orig_rna_path, len)) {
char *spath, *suffix= fcu->rna_path + len;
nfcu= copy_fcurve(fcu);
spath= nfcu->rna_path;
@@ -1042,7 +1057,7 @@ static void fcurve_path_rename(AnimData *ad, char *orig_rna_path, char *rna_path
static void fcurve_remove(AnimData *ad, ListBase *orig_curves, FCurve *fcu)
{
- if(orig_curves==&ad->drivers) BLI_remlink(&ad->drivers, fcu);
+ if (orig_curves==&ad->drivers) BLI_remlink(&ad->drivers, fcu);
else action_groups_remove_channel(ad->action, fcu);
free_fcurve(fcu);
@@ -1060,19 +1075,19 @@ static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves)
ListBase curves= {NULL, NULL};
FCurve *fcu, *next;
- while(nu) {
- if(nu->bezt) {
+ while (nu) {
+ if (nu->bezt) {
BezTriple *bezt= nu->bezt;
a= nu->pntsu;
pt_index= 0;
while (a--) {
keyIndex= getCVKeyIndex(editnurb, bezt);
- if(keyIndex) {
+ if (keyIndex) {
BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d].bezier_points[%d]", nu_index, pt_index);
BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d].bezier_points[%d]", keyIndex->nu_index, keyIndex->pt_index);
- if(keyIndex->switched) {
+ if (keyIndex->switched) {
char handle_path[64], orig_handle_path[64];
BLI_snprintf(orig_handle_path, sizeof(orig_rna_path), "%s.handle_left", orig_rna_path);
BLI_snprintf(handle_path, sizeof(rna_path), "%s.handle_right", rna_path);
@@ -1092,14 +1107,15 @@ static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves)
bezt++;
pt_index++;
}
- } else {
+ }
+ else {
BPoint *bp= nu->bp;
a= nu->pntsu * nu->pntsv;
pt_index= 0;
while (a--) {
keyIndex= getCVKeyIndex(editnurb, bp);
- if(keyIndex) {
+ if (keyIndex) {
BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d].points[%d]", nu_index, pt_index);
BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d].points[%d]", keyIndex->nu_index, keyIndex->pt_index);
fcurve_path_rename(ad, orig_rna_path, rna_path, orig_curves, &curves);
@@ -1119,10 +1135,10 @@ static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves)
/* remove paths for removed control points
* need this to make further step with copying non-cv related curves copying
* not touching cv's f-curves */
- for(fcu= orig_curves->first; fcu; fcu= next) {
+ for (fcu= orig_curves->first; fcu; fcu= next) {
next= fcu->next;
- if(!strncmp(fcu->rna_path, "splines", 7)) {
+ if (!strncmp(fcu->rna_path, "splines", 7)) {
char *ch= strchr(fcu->rna_path, '.');
if (ch && (!strncmp(ch, ".bezier_points", 14) || !strncmp(ch, ".points", 7)))
@@ -1132,14 +1148,14 @@ static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves)
nu_index= 0;
nu= editnurb->nurbs.first;
- while(nu) {
+ while (nu) {
keyIndex= NULL;
- if(nu->pntsu) {
- if(nu->bezt) keyIndex= getCVKeyIndex(editnurb, &nu->bezt[0]);
+ if (nu->pntsu) {
+ if (nu->bezt) keyIndex= getCVKeyIndex(editnurb, &nu->bezt[0]);
else keyIndex= getCVKeyIndex(editnurb, &nu->bp[0]);
}
- if(keyIndex) {
+ if (keyIndex) {
BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d]", nu_index);
BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d]", keyIndex->nu_index);
fcurve_path_rename(ad, orig_rna_path, rna_path, orig_curves, &curves);
@@ -1151,10 +1167,10 @@ static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves)
/* the remainders in orig_curves can be copied back (like follow path) */
/* (if it's not path to spline) */
- for(fcu= orig_curves->first; fcu; fcu= next) {
+ for (fcu= orig_curves->first; fcu; fcu= next) {
next= fcu->next;
- if(!strncmp(fcu->rna_path, "splines", 7)) fcurve_remove(ad, orig_curves, fcu);
+ if (!strncmp(fcu->rna_path, "splines", 7)) fcurve_remove(ad, orig_curves, fcu);
else BLI_addtail(&curves, fcu);
}
@@ -1167,9 +1183,9 @@ int ED_curve_updateAnimPaths(Object *obedit)
Curve *cu= (Curve*)obedit->data;
AnimData *ad= BKE_animdata_from_id(&cu->id);
- if(!curve_is_animated(obedit)) return 0;
+ if (!curve_is_animated(obedit)) return 0;
- if(ad->action)
+ if (ad->action)
curve_rename_fcurves(obedit, &ad->action->curves);
curve_rename_fcurves(obedit, &ad->drivers);
@@ -1184,7 +1200,7 @@ void load_editNurb(Object *obedit)
{
ListBase *editnurb= object_editcurve_get(obedit);
- if(obedit==NULL) return;
+ if (obedit==NULL) return;
set_actNurb(obedit, NULL);
@@ -1193,11 +1209,11 @@ void load_editNurb(Object *obedit)
Nurb *nu, *newnu;
ListBase newnurb= {NULL, NULL}, oldnurb= cu->nurb;
- for(nu= editnurb->first; nu; nu= nu->next) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
newnu= duplicateNurb(nu);
BLI_addtail(&newnurb, newnu);
- if(nu->type == CU_NURBS) {
+ if (nu->type == CU_NURBS) {
clamp_nurb_order_u(nu);
}
}
@@ -1227,17 +1243,18 @@ void make_editNurb(Object *obedit)
if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
actkey= ob_get_keyblock(obedit);
- if(actkey) {
+ if (actkey) {
// XXX strcpy(G.editModeTitleExtra, "(Key) ");
undo_editmode_clear();
key_to_curve(actkey, cu, &cu->nurb);
}
- if(editnurb) {
+ if (editnurb) {
freeNurblist(&editnurb->nurbs);
free_curve_editNurb_keyIndex(editnurb);
editnurb->keyindex= NULL;
- } else {
+ }
+ else {
editnurb= MEM_callocN(sizeof(EditNurb), "editnurb");
cu->editnurb= editnurb;
}
@@ -1245,7 +1262,7 @@ void make_editNurb(Object *obedit)
nu= cu->nurb.first;
cu->lastsel= NULL; /* for select row */
- while(nu) {
+ while (nu) {
newnu= duplicateNurb(nu);
test2DNurb(newnu); // after join, or any other creation of curve
BLI_addtail(&editnurb->nurbs, newnu);
@@ -1258,7 +1275,7 @@ void make_editNurb(Object *obedit)
nu= nu->next;
}
- if(actkey)
+ if (actkey)
editnurb->shapenr= obedit->shapenr;
/* animation could be added in editmode even if there was no animdata i
@@ -1307,14 +1324,14 @@ void CU_select_swap(Object *obedit)
cu->lastsel= NULL;
- for(nu= editnurb->first; nu; nu= nu->next) {
- if(nu->type == CU_BEZIER) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
+ if (nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
- while(a--) {
- if(bezt->hide==0) {
+ while (a--) {
+ if (bezt->hide==0) {
bezt->f2 ^= SELECT; /* always do the center point */
- if((cu->drawflag & CU_HIDE_HANDLES)==0) {
+ if ((cu->drawflag & CU_HIDE_HANDLES)==0) {
bezt->f1 ^= SELECT;
bezt->f3 ^= SELECT;
}
@@ -1325,7 +1342,7 @@ void CU_select_swap(Object *obedit)
else {
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
- while(a--) {
+ while (a--) {
swap_selection_bpoint(bp);
bp++;
}
@@ -1351,7 +1368,7 @@ static int separate_exec(bContext *C, wmOperator *op)
oldcu= oldob->data;
oldedit= oldcu->editnurb;
- if(oldcu->key) {
+ if (oldcu->key) {
BKE_report(op->reports, RPT_ERROR, "Can't separate a curve with vertex keys");
return OPERATOR_CANCELLED;
}
@@ -1374,10 +1391,10 @@ static int separate_exec(bContext *C, wmOperator *op)
free_curve_editNurb_keyIndex(newedit);
/* 3. move over parts from old object */
- for(nu= oldedit->nurbs.first; nu; nu=nu1) {
+ for (nu= oldedit->nurbs.first; nu; nu=nu1) {
nu1= nu->next;
- if(isNurbsel(nu)) {
+ if (isNurbsel(nu)) {
BLI_remlink(&oldedit->nurbs, nu);
BLI_addtail(&newedit->nurbs, nu);
}
@@ -1424,33 +1441,33 @@ static short isNurbselUV(Nurb *nu, int *u, int *v, int flag)
*u= *v= -1;
bp= nu->bp;
- for(b=0; b<nu->pntsv; b++) {
+ for (b=0; b<nu->pntsv; b++) {
sel= 0;
- for(a=0; a<nu->pntsu; a++, bp++) {
- if(bp->f1 & flag) sel++;
+ for (a=0; a<nu->pntsu; a++, bp++) {
+ if (bp->f1 & flag) sel++;
}
- if(sel==nu->pntsu) {
- if(*u== -1) *u= b;
+ if (sel==nu->pntsu) {
+ if (*u== -1) *u= b;
else return 0;
}
- else if(sel>1) return 0; /* because sel==1 is still ok */
+ else if (sel>1) return 0; /* because sel==1 is still ok */
}
- for(a=0; a<nu->pntsu; a++) {
+ for (a=0; a<nu->pntsu; a++) {
sel= 0;
bp= nu->bp+a;
- for(b=0; b<nu->pntsv; b++, bp+=nu->pntsu) {
- if(bp->f1 & flag) sel++;
+ for (b=0; b<nu->pntsv; b++, bp+=nu->pntsu) {
+ if (bp->f1 & flag) sel++;
}
- if(sel==nu->pntsv) {
- if(*v== -1) *v= a;
+ if (sel==nu->pntsv) {
+ if (*v== -1) *v= a;
else return 0;
}
- else if(sel>1) return 0;
+ else if (sel>1) return 0;
}
- if(*u==-1 && *v>-1) return 1;
- if(*v==-1 && *u>-1) return 1;
+ if (*u==-1 && *v>-1) return 1;
+ if (*v==-1 && *u>-1) return 1;
return 0;
}
@@ -1461,11 +1478,11 @@ static void setflagsNurb(ListBase *editnurb, short flag)
BPoint *bp;
int a;
- for(nu= editnurb->first; nu; nu= nu->next) {
- if(nu->type == CU_BEZIER) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
+ if (nu->type == CU_BEZIER) {
a= nu->pntsu;
bezt= nu->bezt;
- while(a--) {
+ while (a--) {
bezt->f1= bezt->f2= bezt->f3= flag;
bezt++;
}
@@ -1473,7 +1490,7 @@ static void setflagsNurb(ListBase *editnurb, short flag)
else {
a= nu->pntsu*nu->pntsv;
bp= nu->bp;
- while(a--) {
+ while (a--) {
bp->f1= flag;
bp++;
}
@@ -1488,13 +1505,13 @@ static void rotateflagNurb(ListBase *editnurb, short flag, float *cent, float ro
BPoint *bp;
int a;
- for(nu= editnurb->first; nu; nu= nu->next) {
- if(nu->type == CU_NURBS) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
+ if (nu->type == CU_NURBS) {
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
- while(a--) {
- if(bp->f1 & flag) {
+ while (a--) {
+ if (bp->f1 & flag) {
sub_v3_v3(bp->vec, cent);
mul_m3_v3(rotmat, bp->vec);
add_v3_v3(bp->vec, cent);
@@ -1513,22 +1530,22 @@ static void translateflagNurb(ListBase *editnurb, short flag, const float vec[3]
BPoint *bp;
int a;
- for(nu= editnurb->first; nu; nu= nu->next) {
- if(nu->type == CU_BEZIER) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
+ if (nu->type == CU_BEZIER) {
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);
+ 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);
bezt++;
}
}
else {
a= nu->pntsu*nu->pntsv;
bp= nu->bp;
- while(a--) {
- if(bp->f1 & flag) add_v3_v3(bp->vec, vec);
+ while (a--) {
+ if (bp->f1 & flag) add_v3_v3(bp->vec, vec);
bp++;
}
}
@@ -1543,12 +1560,12 @@ static void weightflagNurb(ListBase *editnurb, short flag, float w)
BPoint *bp;
int a;
- for(nu= editnurb->first; nu; nu= nu->next) {
- if(nu->type == CU_NURBS) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
+ if (nu->type == CU_NURBS) {
a= nu->pntsu*nu->pntsv;
bp= nu->bp;
- while(a--) {
- if(bp->f1 & flag) {
+ while (a--) {
+ if (bp->f1 & flag) {
/* a mode used to exist for replace/multiple but is was unused */
bp->vec[3]*= w;
}
@@ -1567,25 +1584,25 @@ static int deleteflagNurb(bContext *C, wmOperator *UNUSED(op), int flag)
BPoint *bp, *bpn, *newbp;
int a, b, newu, newv, sel;
- if(obedit->type==OB_SURF);
+ if (obedit->type==OB_SURF);
else return OPERATOR_CANCELLED;
cu->lastsel= NULL;
nu= editnurb->first;
- while(nu) {
+ while (nu) {
next= nu->next;
/* is entire nurb selected */
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
- while(a) {
+ while (a) {
a--;
- if(bp->f1 & flag);
+ if (bp->f1 & flag);
else break;
bp++;
}
- if(a==0) {
+ if (a==0) {
BLI_remlink(editnurb, nu);
keyIndex_delNurb(cu->editnurb, nu);
freeNurb(nu); nu=NULL;
@@ -1594,30 +1611,31 @@ static int deleteflagNurb(bContext *C, wmOperator *UNUSED(op), int flag)
/* is nurb in U direction selected */
newv= nu->pntsv;
bp= nu->bp;
- for(b=0; b<nu->pntsv; b++) {
+ for (b=0; b<nu->pntsv; b++) {
sel= 0;
- for(a=0; a<nu->pntsu; a++, bp++) {
- if(bp->f1 & flag) sel++;
+ for (a=0; a<nu->pntsu; a++, bp++) {
+ if (bp->f1 & flag) sel++;
}
- if(sel==nu->pntsu) {
+ if (sel==nu->pntsu) {
newv--;
}
- else if(sel>=1) {
+ else if (sel>=1) {
/* don't delete */
break;
}
}
- if(newv!=nu->pntsv && b==nu->pntsv) {
+ if (newv!=nu->pntsv && b==nu->pntsv) {
/* delete */
bp= nu->bp;
bpn = newbp =
(BPoint*) MEM_mallocN(newv * nu->pntsu * sizeof(BPoint), "deleteNurb");
- for(b=0; b<nu->pntsv; b++) {
- if((bp->f1 & flag)==0) {
+ for (b=0; b<nu->pntsv; b++) {
+ if ((bp->f1 & flag)==0) {
memcpy(bpn, bp, nu->pntsu*sizeof(BPoint));
keyIndex_updateBP(cu->editnurb, bp, bpn, nu->pntsu);
bpn+= nu->pntsu;
- } else {
+ }
+ else {
keyIndex_delBP(cu->editnurb, bp);
}
bp+= nu->pntsu;
@@ -1632,44 +1650,45 @@ static int deleteflagNurb(bContext *C, wmOperator *UNUSED(op), int flag)
else {
/* is the nurb in V direction selected */
newu= nu->pntsu;
- for(a=0; a<nu->pntsu; a++) {
+ for (a=0; a<nu->pntsu; a++) {
bp= nu->bp+a;
sel= 0;
- for(b=0; b<nu->pntsv; b++, bp+=nu->pntsu) {
- if(bp->f1 & flag) sel++;
+ for (b=0; b<nu->pntsv; b++, bp+=nu->pntsu) {
+ if (bp->f1 & flag) sel++;
}
- if(sel==nu->pntsv) {
+ if (sel==nu->pntsv) {
newu--;
}
- else if(sel>=1) {
+ else if (sel>=1) {
/* don't delete */
break;
}
}
- if(newu!=nu->pntsu && a==nu->pntsu) {
+ if (newu!=nu->pntsu && a==nu->pntsu) {
/* delete */
bp= nu->bp;
bpn = newbp =
(BPoint*) MEM_mallocN(newu * nu->pntsv * sizeof(BPoint), "deleteNurb");
- for(b=0; b<nu->pntsv; b++) {
- for(a=0; a<nu->pntsu; a++, bp++) {
- if((bp->f1 & flag)==0) {
+ for (b=0; b<nu->pntsv; b++) {
+ for (a=0; a<nu->pntsu; a++, bp++) {
+ if ((bp->f1 & flag)==0) {
*bpn= *bp;
keyIndex_updateBP(cu->editnurb, bp, bpn, 1);
bpn++;
- } else {
+ }
+ else {
keyIndex_delBP(cu->editnurb, bp);
}
}
}
MEM_freeN(nu->bp);
nu->bp= newbp;
- if(newu==1 && nu->pntsv>1) { /* make a U spline */
+ if (newu==1 && nu->pntsv>1) { /* make a U spline */
nu->pntsu= nu->pntsv;
nu->pntsv= 1;
SWAP(short, nu->orderu, nu->orderv);
clamp_nurb_order_u(nu);
- if(nu->knotsv) MEM_freeN(nu->knotsv);
+ if (nu->knotsv) MEM_freeN(nu->knotsv);
nu->knotsv= NULL;
}
else {
@@ -1683,7 +1702,7 @@ static int deleteflagNurb(bContext *C, wmOperator *UNUSED(op), int flag)
nu= next;
}
- if(ED_curve_updateAnimPaths(obedit))
+ if (ED_curve_updateAnimPaths(obedit))
WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit);
return OPERATOR_FINISHED;
@@ -1697,18 +1716,18 @@ static short extrudeflagNurb(EditNurb *editnurb, int flag)
int ok= 0, a, u, v, len;
nu= editnurb->nurbs.first;
- while(nu) {
+ while (nu) {
- if(nu->pntsv==1) {
+ if (nu->pntsv==1) {
bp= nu->bp;
a= nu->pntsu;
- while(a) {
- if(bp->f1 & flag);
+ while (a) {
+ if (bp->f1 & flag);
else break;
bp++;
a--;
}
- if(a==0) {
+ if (a==0) {
ok= 1;
newbp =
(BPoint*)MEM_mallocN(2 * nu->pntsu * sizeof(BPoint), "extrudeNurb1");
@@ -1718,7 +1737,7 @@ static short extrudeflagNurb(EditNurb *editnurb, int flag)
MEM_freeN(nu->bp);
nu->bp= newbp;
a= nu->pntsu;
- while(a--) {
+ while (a--) {
select_bpoint(bp, SELECT, flag, HIDDEN);
select_bpoint(newbp, DESELECT, flag, HIDDEN);
bp++;
@@ -1733,22 +1752,22 @@ static short extrudeflagNurb(EditNurb *editnurb, int flag)
else {
/* which row or column is selected */
- if( isNurbselUV(nu, &u, &v, flag) ) {
+ if ( isNurbselUV(nu, &u, &v, flag) ) {
/* deselect all */
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
- while(a--) {
+ while (a--) {
select_bpoint(bp, DESELECT, flag, HIDDEN);
bp++;
}
- if(u==0 || u== nu->pntsv-1) { /* row in u-direction selected */
+ if (u==0 || u== nu->pntsv-1) { /* row in u-direction selected */
ok= 1;
newbp =
(BPoint*) MEM_mallocN(nu->pntsu*(nu->pntsv + 1)
* sizeof(BPoint), "extrudeNurb1");
- if(u==0) {
+ if (u==0) {
len= nu->pntsv*nu->pntsu;
ED_curve_bpcpy(editnurb, newbp+nu->pntsu, nu->bp, len);
ED_curve_bpcpy(editnurb, newbp, nu->bp, nu->pntsu);
@@ -1762,7 +1781,7 @@ static short extrudeflagNurb(EditNurb *editnurb, int flag)
}
a= nu->pntsu;
- while(a--) {
+ while (a--) {
select_bpoint(bp, SELECT, flag, HIDDEN);
bp++;
}
@@ -1772,14 +1791,14 @@ static short extrudeflagNurb(EditNurb *editnurb, int flag)
nu->pntsv++;
nurbs_knot_calc_v(nu);
}
- else if(v==0 || v== nu->pntsu-1) { /* column in v-direction selected */
+ else if (v==0 || v== nu->pntsu-1) { /* column in v-direction selected */
ok= 1;
bpn = newbp =
(BPoint*) MEM_mallocN((nu->pntsu + 1) * nu->pntsv * sizeof(BPoint), "extrudeNurb1");
bp= nu->bp;
- for(a=0; a<nu->pntsv; a++) {
- if(v==0) {
+ for (a=0; a<nu->pntsv; a++) {
+ if (v==0) {
*bpn= *bp;
bpn->f1 |= flag;
bpn++;
@@ -1787,7 +1806,7 @@ static short extrudeflagNurb(EditNurb *editnurb, int flag)
ED_curve_bpcpy(editnurb, bpn, bp, nu->pntsu);
bp+= nu->pntsu;
bpn+= nu->pntsu;
- if(v== nu->pntsu-1) {
+ if (v== nu->pntsu-1) {
*bpn= *(bp-1);
bpn->f1 |= flag;
bpn++;
@@ -1820,20 +1839,20 @@ static void adduplicateflagNurb(Object *obedit, short flag)
cu->lastsel= NULL;
nu= editnurb->last;
- while(nu) {
- if(nu->type == CU_BEZIER) {
+ while (nu) {
+ if (nu->type == CU_BEZIER) {
bezt= nu->bezt;
- for(a=0; a<nu->pntsu; a++) {
+ for (a=0; a<nu->pntsu; a++) {
enda= -1;
starta= a;
- while( (bezt->f1 & flag) || (bezt->f2 & flag) || (bezt->f3 & flag) ) {
+ while ( (bezt->f1 & flag) || (bezt->f2 & flag) || (bezt->f3 & flag) ) {
select_beztriple(bezt, DESELECT, flag, HIDDEN);
enda=a;
- if(a>=nu->pntsu-1) break;
+ if (a>=nu->pntsu-1) break;
a++;
bezt++;
}
- if(enda>=starta) {
+ if (enda>=starta) {
newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN");
memcpy(newnu, nu, sizeof(Nurb));
BLI_addtail(editnurb, newnu);
@@ -1845,13 +1864,13 @@ static void adduplicateflagNurb(Object *obedit, short flag)
b= newnu->pntsu;
bezt1= newnu->bezt;
- while(b--) {
+ while (b--) {
select_beztriple(bezt1, SELECT, flag, HIDDEN);
bezt1++;
}
- if(nu->flagu & CU_NURB_CYCLIC) {
- if(starta!=0 || enda!=nu->pntsu-1) {
+ if (nu->flagu & CU_NURB_CYCLIC) {
+ if (starta!=0 || enda!=nu->pntsu-1) {
newnu->flagu &= ~CU_NURB_CYCLIC;
}
}
@@ -1859,19 +1878,19 @@ static void adduplicateflagNurb(Object *obedit, short flag)
bezt++;
}
}
- else if(nu->pntsv==1) { /* because UV Nurb has a different method for dupli */
+ else if (nu->pntsv==1) { /* because UV Nurb has a different method for dupli */
bp= nu->bp;
- for(a=0; a<nu->pntsu; a++) {
+ for (a=0; a<nu->pntsu; a++) {
enda= -1;
starta= a;
- while(bp->f1 & flag) {
+ while (bp->f1 & flag) {
select_bpoint(bp, DESELECT, flag, HIDDEN);
enda= a;
- if(a>=nu->pntsu-1) break;
+ if (a>=nu->pntsu-1) break;
a++;
bp++;
}
- if(enda>=starta) {
+ if (enda>=starta) {
newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN3");
memcpy(newnu, nu, sizeof(Nurb));
set_actNurb(obedit, newnu);
@@ -1882,13 +1901,13 @@ static void adduplicateflagNurb(Object *obedit, short flag)
b= newnu->pntsu;
bp1= newnu->bp;
- while(b--) {
+ while (b--) {
select_bpoint(bp1, SELECT, flag, HIDDEN);
bp1++;
}
- if(nu->flagu & CU_NURB_CYCLIC) {
- if(starta!=0 || enda!=nu->pntsu-1) {
+ if (nu->flagu & CU_NURB_CYCLIC) {
+ if (starta!=0 || enda!=nu->pntsu-1) {
newnu->flagu &= ~CU_NURB_CYCLIC;
}
}
@@ -1902,19 +1921,19 @@ static void adduplicateflagNurb(Object *obedit, short flag)
}
else {
/* a rectangular area in nurb has to be selected */
- if(isNurbsel(nu)) {
+ if (isNurbsel(nu)) {
usel= MEM_callocN(nu->pntsu, "adduplicateN4");
bp= nu->bp;
- for(a=0; a<nu->pntsv; a++) {
- for(b=0; b<nu->pntsu; b++, bp++) {
- if(bp->f1 & flag) usel[b]++;
+ for (a=0; a<nu->pntsv; a++) {
+ for (b=0; b<nu->pntsu; b++, bp++) {
+ if (bp->f1 & flag) usel[b]++;
}
}
newu= 0;
newv= 0;
- for(a=0; a<nu->pntsu; a++) {
- if(usel[a]) {
- if(newv==0 || usel[a]==newv) {
+ for (a=0; a<nu->pntsu; a++) {
+ if (usel[a]) {
+ if (newv==0 || usel[a]==newv) {
newv= usel[a];
newu++;
}
@@ -1924,13 +1943,13 @@ static void adduplicateflagNurb(Object *obedit, short flag)
}
}
}
- if(newu==0 || newv==0) {
+ if (newu==0 || newv==0) {
if (G.f & G_DEBUG)
printf("Can't duplicate Nurb\n");
}
else {
- if(newu==1) SWAP(short, newu, newv);
+ if (newu==1) SWAP(short, newu, newv);
newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN5");
memcpy(newnu, nu, sizeof(Nurb));
@@ -1947,9 +1966,9 @@ static void adduplicateflagNurb(Object *obedit, short flag)
bp= newnu->bp;
bp1= nu->bp;
- for(a=0; a<nu->pntsv; a++) {
- for(b=0; b<nu->pntsu; b++, bp1++) {
- if(bp1->f1 & flag) {
+ for (a=0; a<nu->pntsv; a++) {
+ for (b=0; b<nu->pntsu; b++, bp1++) {
+ if (bp1->f1 & flag) {
memcpy(bp, bp1, sizeof(BPoint));
select_bpoint(bp1, DESELECT, flag, HIDDEN);
bp++;
@@ -1957,16 +1976,18 @@ static void adduplicateflagNurb(Object *obedit, short flag)
}
}
if (check_valid_nurb_u(newnu)) {
- if(nu->pntsu==newnu->pntsu && nu->knotsu) {
+ if (nu->pntsu==newnu->pntsu && nu->knotsu) {
newnu->knotsu= MEM_dupallocN( nu->knotsu );
- } else {
+ }
+ else {
nurbs_knot_calc_u(newnu);
}
}
if (check_valid_nurb_v(newnu)) {
- if(nu->pntsv==newnu->pntsv && nu->knotsv) {
+ if (nu->pntsv==newnu->pntsv && nu->knotsv) {
newnu->knotsv= MEM_dupallocN( nu->knotsv );
- } else {
+ }
+ else {
nurbs_knot_calc_v(newnu);
}
}
@@ -1990,13 +2011,13 @@ static int switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
EditNurb *editnurb= cu->editnurb;
Nurb *nu;
- for(nu= editnurb->nurbs.first; nu; nu= nu->next)
- if(isNurbsel(nu)) {
+ for (nu= editnurb->nurbs.first; nu; nu= nu->next)
+ if (isNurbsel(nu)) {
switchdirectionNurb(nu);
keyData_switchDirectionNurb(cu, nu);
}
- if(ED_curve_updateAnimPaths(obedit))
+ if (ED_curve_updateAnimPaths(obedit))
WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit);
DAG_id_tag_update(obedit->data, 0);
@@ -2032,16 +2053,16 @@ static int set_goal_weight_exec(bContext *C, wmOperator *op)
float weight= RNA_float_get(op->ptr, "weight");
int a;
- 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)
+ 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)
bezt->weight= weight;
}
}
- else if(nu->bp) {
- for(bp=nu->bp, a=0; a<nu->pntsu*nu->pntsv; a++, bp++) {
- if(bp->f1 & SELECT)
+ else if (nu->bp) {
+ for (bp=nu->bp, a=0; a<nu->pntsu*nu->pntsv; a++, bp++) {
+ if (bp->f1 & SELECT)
bp->weight= weight;
}
}
@@ -2084,16 +2105,16 @@ static int set_radius_exec(bContext *C, wmOperator *op)
float radius= RNA_float_get(op->ptr, "radius");
int a;
- 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)
+ 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)
bezt->radius= radius;
}
}
- else if(nu->bp) {
- for(bp=nu->bp, a=0; a<nu->pntsu*nu->pntsv; a++, bp++) {
- if(bp->f1 & SELECT)
+ else if (nu->bp) {
+ for (bp=nu->bp, a=0; a<nu->pntsu*nu->pntsv; a++, bp++) {
+ if (bp->f1 & SELECT)
bp->radius= radius;
}
}
@@ -2136,13 +2157,13 @@ static int smooth_exec(bContext *C, wmOperator *UNUSED(op))
float val, newval, offset;
int a, i, change = 0;
- for(nu= editnurb->first; nu; nu= nu->next) {
- if(nu->bezt) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
+ if (nu->bezt) {
change = 0;
beztOrig = MEM_dupallocN( nu->bezt );
- for(bezt=nu->bezt+1, a=1; a<nu->pntsu-1; a++, bezt++) {
- if(bezt->f2 & SELECT) {
- for(i=0; i<3; i++) {
+ for (bezt=nu->bezt+1, a=1; a<nu->pntsu-1; a++, bezt++) {
+ if (bezt->f2 & SELECT) {
+ for (i=0; i<3; i++) {
val = bezt->vec[1][i];
newval = ((beztOrig+(a-1))->vec[1][i] * 0.5f) + ((beztOrig+(a+1))->vec[1][i] * 0.5f);
offset = (val*((1.0f/6.0f)*5.0f)) + (newval*(1.0f/6.0f)) - val;
@@ -2157,12 +2178,13 @@ static int smooth_exec(bContext *C, wmOperator *UNUSED(op))
MEM_freeN(beztOrig);
if (change)
calchandlesNurb(nu);
- } else if (nu->bp) {
+ }
+ else if (nu->bp) {
bpOrig = MEM_dupallocN( nu->bp );
/* Same as above, keep these the same! */
- for(bp=nu->bp+1, a=1; a<nu->pntsu-1; a++, bp++) {
- if(bp->f1 & SELECT) {
- for(i=0; i<3; i++) {
+ for (bp=nu->bp+1, a=1; a<nu->pntsu-1; a++, bp++) {
+ if (bp->f1 & SELECT) {
+ for (i=0; i<3; i++) {
val = bp->vec[i];
newval = ((bpOrig+(a-1))->vec[i] * 0.5f) + ((bpOrig+(a+1))->vec[i] * 0.5f);
offset = (val*((1.0f/6.0f)*5.0f)) + (newval*(1.0f/6.0f)) - val;
@@ -2213,24 +2235,24 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op))
int start_sel, end_sel; /* selection indices, inclusive */
float start_rad, end_rad, fac, range;
- for(nu= editnurb->first; nu; nu= nu->next) {
- if(nu->bezt) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
+ if (nu->bezt) {
for (last_sel=0; last_sel < nu->pntsu; last_sel++) {
/* loop over selection segments of a curve, smooth each */
/* Start BezTriple code, this is duplicated below for points, make sure these functions stay in sync */
start_sel = -1;
- for(bezt=nu->bezt+last_sel, a=last_sel; a<nu->pntsu; a++, bezt++) {
- if(bezt->f2 & SELECT) {
+ for (bezt=nu->bezt+last_sel, a=last_sel; a<nu->pntsu; a++, bezt++) {
+ if (bezt->f2 & SELECT) {
start_sel = a;
break;
}
}
/* in case there are no other selected verts */
end_sel = start_sel;
- for(bezt=nu->bezt+(start_sel+1), a=start_sel+1; a<nu->pntsu; a++, bezt++) {
- if((bezt->f2 & SELECT)==0) {
+ for (bezt=nu->bezt+(start_sel+1), a=start_sel+1; a<nu->pntsu; a++, bezt++) {
+ if ((bezt->f2 & SELECT)==0) {
break;
}
end_sel = a;
@@ -2238,7 +2260,8 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op))
if (start_sel == -1) {
last_sel = nu->pntsu; /* next... */
- } else {
+ }
+ else {
last_sel = end_sel; /* before we modify it */
/* now blend between start and end sel */
@@ -2252,47 +2275,51 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op))
if (start_rad >= 0.0f && end_rad >= 0.0f) (nu->bezt+start_sel)->radius = (start_rad + end_rad)/2;
else if (start_rad >= 0.0f) (nu->bezt+start_sel)->radius = start_rad;
else if (end_rad >= 0.0f) (nu->bezt+start_sel)->radius = end_rad;
- } else {
+ }
+ else {
/* if endpoints selected, then use them */
if (start_sel==0) {
start_rad = (nu->bezt+start_sel)->radius;
start_sel++; /* we don't want to edit the selected endpoint */
- } else {
+ }
+ else {
start_rad = (nu->bezt+start_sel-1)->radius;
}
if (end_sel==nu->pntsu-1) {
end_rad = (nu->bezt+end_sel)->radius;
end_sel--; /* we don't want to edit the selected endpoint */
- } else {
+ }
+ else {
end_rad = (nu->bezt+end_sel+1)->radius;
}
/* Now Blend between the points */
range = (float)(end_sel - start_sel) + 2.0f;
- for(bezt=nu->bezt+start_sel, a=start_sel; a<=end_sel; a++, bezt++) {
+ for (bezt=nu->bezt+start_sel, a=start_sel; a<=end_sel; a++, bezt++) {
fac = (float)(1+a-start_sel) / range;
bezt->radius = start_rad*(1.0f-fac) + end_rad*fac;
}
}
}
}
- } else if (nu->bp) {
+ }
+ else if (nu->bp) {
/* Same as above, keep these the same! */
for (last_sel=0; last_sel < nu->pntsu; last_sel++) {
/* loop over selection segments of a curve, smooth each */
/* Start BezTriple code, this is duplicated below for points, make sure these functions stay in sync */
start_sel = -1;
- for(bp=nu->bp+last_sel, a=last_sel; a<nu->pntsu; a++, bp++) {
- if(bp->f1 & SELECT) {
+ for (bp=nu->bp+last_sel, a=last_sel; a<nu->pntsu; a++, bp++) {
+ if (bp->f1 & SELECT) {
start_sel = a;
break;
}
}
/* in case there are no other selected verts */
end_sel = start_sel;
- for(bp=nu->bp+(start_sel+1), a=start_sel+1; a<nu->pntsu; a++, bp++) {
- if((bp->f1 & SELECT)==0) {
+ for (bp=nu->bp+(start_sel+1), a=start_sel+1; a<nu->pntsu; a++, bp++) {
+ if ((bp->f1 & SELECT)==0) {
break;
}
end_sel = a;
@@ -2300,7 +2327,8 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op))
if (start_sel == -1) {
last_sel = nu->pntsu; /* next... */
- } else {
+ }
+ else {
last_sel = end_sel; /* before we modify it */
/* now blend between start and end sel */
@@ -2314,24 +2342,27 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op))
if (start_rad >= 0.0f && end_rad >= 0.0f) (nu->bp+start_sel)->radius = (start_rad + end_rad)/2;
else if (start_rad >= 0.0f) (nu->bp+start_sel)->radius = start_rad;
else if (end_rad >= 0.0f) (nu->bp+start_sel)->radius = end_rad;
- } else {
+ }
+ else {
/* if endpoints selected, then use them */
if (start_sel==0) {
start_rad = (nu->bp+start_sel)->radius;
start_sel++; /* we don't want to edit the selected endpoint */
- } else {
+ }
+ else {
start_rad = (nu->bp+start_sel-1)->radius;
}
if (end_sel==nu->pntsu-1) {
end_rad = (nu->bp+end_sel)->radius;
end_sel--; /* we don't want to edit the selected endpoint */
- } else {
+ }
+ else {
end_rad = (nu->bp+end_sel+1)->radius;
}
/* Now Blend between the points */
range = (float)(end_sel - start_sel) + 2.0f;
- for(bp=nu->bp+start_sel, a=start_sel; a<=end_sel; a++, bp++) {
+ for (bp=nu->bp+start_sel, a=start_sel; a<=end_sel; a++, bp++) {
fac = (float)(1+a-start_sel) / range;
bp->radius = start_rad*(1.0f-fac) + end_rad*fac;
}
@@ -2376,21 +2407,21 @@ static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short
int a;
short lastsel= 0;
- if(next==0) return;
+ if (next==0) return;
- for(nu= editnurb->first; nu; nu= nu->next) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
lastsel=0;
- if(nu->type == CU_BEZIER) {
+ if (nu->type == CU_BEZIER) {
a= nu->pntsu;
bezt= nu->bezt;
- if(next < 0) bezt= (nu->bezt + (a-1));
- while(a--) {
- if(a-abs(next) < 0) break;
- if((lastsel==0) && (bezt->hide==0) && ((bezt->f2 & SELECT) || (selstatus==0))) {
+ if (next < 0) bezt= (nu->bezt + (a-1));
+ while (a--) {
+ if (a-abs(next) < 0) break;
+ if ((lastsel==0) && (bezt->hide==0) && ((bezt->f2 & SELECT) || (selstatus==0))) {
bezt+=next;
- if(!(bezt->f2 & SELECT) || (selstatus==0)) {
+ if (!(bezt->f2 & SELECT) || (selstatus==0)) {
short sel= select_beztriple(bezt, selstatus, 1, VISIBLE);
- if((sel==1) && (cont==0)) lastsel= 1;
+ if ((sel==1) && (cont==0)) lastsel= 1;
}
}
else {
@@ -2404,14 +2435,14 @@ static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short
else {
a= nu->pntsu*nu->pntsv;
bp= nu->bp;
- if(next < 0) bp= (nu->bp + (a-1));
- while(a--) {
- if(a-abs(next) < 0) break;
- if((lastsel==0) && (bp->hide==0) && ((bp->f1 & SELECT) || (selstatus==0))) {
+ if (next < 0) bp= (nu->bp + (a-1));
+ while (a--) {
+ if (a-abs(next) < 0) break;
+ if ((lastsel==0) && (bp->hide==0) && ((bp->f1 & SELECT) || (selstatus==0))) {
bp+=next;
- if(!(bp->f1 & SELECT) || (selstatus==0)) {
+ if (!(bp->f1 & SELECT) || (selstatus==0)) {
short sel= select_bpoint(bp, selstatus, 1, VISIBLE);
- if((sel==1) && (cont==0)) lastsel= 1;
+ if ((sel==1) && (cont==0)) lastsel= 1;
}
}
else {
@@ -2440,49 +2471,49 @@ void selectend_nurb(Object *obedit, short selfirst, short doswap, short selstatu
Curve *cu;
int a;
- if(obedit==NULL) return;
+ if (obedit==NULL) return;
cu= (Curve*)obedit->data;
cu->lastsel= NULL;
- for(nu= editnurb->first; nu; nu= nu->next) {
- if(nu->type == CU_BEZIER) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
+ if (nu->type == CU_BEZIER) {
a= nu->pntsu;
/* which point? */
- if(selfirst==0) { /* select last */
+ if (selfirst==0) { /* select last */
bezt= (nu->bezt + (a-1));
}
else { /* select first */
bezt= nu->bezt;
}
- while(a--) {
+ while (a--) {
short sel;
- if(doswap) sel= swap_selection_beztriple(bezt);
+ if (doswap) sel= swap_selection_beztriple(bezt);
else sel= select_beztriple(bezt, selstatus, 1, VISIBLE);
- if(sel==1) break;
+ if (sel==1) break;
}
}
else {
a= nu->pntsu*nu->pntsv;
/* which point? */
- if(selfirst==0) { /* select last */
+ if (selfirst==0) { /* select last */
bp= (nu->bp + (a-1));
}
- else{ /* select first */
+ else { /* select first */
bp= nu->bp;
}
- while(a--) {
+ while (a--) {
if (bp->hide == 0) {
short sel;
- if(doswap) sel= swap_selection_bpoint(bp);
+ if (doswap) sel= swap_selection_bpoint(bp);
else sel= select_bpoint(bp, selstatus, 1, VISIBLE);
- if(sel==1) break;
+ if (sel==1) break;
}
}
}
@@ -2546,13 +2577,13 @@ static short nurb_has_selected_cps(ListBase *editnurb)
BPoint *bp;
int a;
- for(nu= editnurb->first; nu; nu= nu->next) {
- if(nu->type == CU_BEZIER) {
+ 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)
+ while (a--) {
+ if (bezt->hide==0) {
+ if ((bezt->f1 & SELECT)
|| (bezt->f2 & SELECT)
|| (bezt->f3 & SELECT)) return 1;
}
@@ -2562,8 +2593,8 @@ static short nurb_has_selected_cps(ListBase *editnurb)
else {
a= nu->pntsu*nu->pntsv;
bp= nu->bp;
- while(a--) {
- if((bp->hide==0) && (bp->f1 & SELECT)) return 1;
+ while (a--) {
+ if ((bp->hide==0) && (bp->f1 & SELECT)) return 1;
bp++;
}
}
@@ -2580,7 +2611,7 @@ static int de_select_all_exec(bContext *C, wmOperator *op)
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
- if(nurb_has_selected_cps(editnurb))
+ if (nurb_has_selected_cps(editnurb))
action = SEL_DESELECT;
}
@@ -2630,42 +2661,42 @@ static int hide_exec(bContext *C, wmOperator *op)
BezTriple *bezt;
int a, sel, invert= RNA_boolean_get(op->ptr, "unselected");
- for(nu= editnurb->first; nu; nu= nu->next) {
- if(nu->type == CU_BEZIER) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
+ if (nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
sel= 0;
- while(a--) {
- if(invert == 0 && BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
+ while (a--) {
+ if (invert == 0 && BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
select_beztriple(bezt, DESELECT, 1, HIDDEN);
bezt->hide= 1;
}
- else if(invert && !BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
+ else if (invert && !BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
select_beztriple(bezt, DESELECT, 1, 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;
a= nu->pntsu*nu->pntsv;
sel= 0;
- while(a--) {
- if(invert==0 && (bp->f1 & SELECT)) {
+ while (a--) {
+ if (invert==0 && (bp->f1 & SELECT)) {
select_bpoint(bp, DESELECT, 1, HIDDEN);
bp->hide= 1;
}
- else if(invert && (bp->f1 & SELECT)==0) {
+ else if (invert && (bp->f1 & SELECT)==0) {
select_bpoint(bp, DESELECT, 1, 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;
}
}
@@ -2703,13 +2734,13 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op))
BezTriple *bezt;
int a;
- for(nu= editnurb->first; nu; nu= nu->next) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
nu->hide= 0;
- if(nu->type == CU_BEZIER) {
+ if (nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
- while(a--) {
- if(bezt->hide) {
+ while (a--) {
+ if (bezt->hide) {
select_beztriple(bezt, SELECT, 1, HIDDEN);
bezt->hide= 0;
}
@@ -2719,8 +2750,8 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op))
else {
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
- while(a--) {
- if(bp->hide) {
+ while (a--) {
+ if (bp->hide) {
select_bpoint(bp, SELECT, 1, HIDDEN);
bp->hide= 0;
}
@@ -2768,16 +2799,16 @@ static void subdividenurb(Object *obedit, int number_cuts)
// printf("*** subdivideNurb: entering subdivide\n");
- for(nu= editnurb->nurbs.first; nu; nu= nu->next) {
+ for (nu= editnurb->nurbs.first; nu; nu= nu->next) {
amount= 0;
- if(nu->type == CU_BEZIER) {
+ if (nu->type == CU_BEZIER) {
/*
* Insert a point into a 2D Bezier curve.
* Endpoints are preserved. Otherwise, all selected and inserted points are
* newly created. Old points are discarded.
*/
/* count */
- if(nu->flagu & CU_NURB_CYCLIC) {
+ if (nu->flagu & CU_NURB_CYCLIC) {
a= nu->pntsu;
bezt= nu->bezt;
prevbezt= bezt+(a-1);
@@ -2787,18 +2818,18 @@ static void subdividenurb(Object *obedit, int number_cuts)
prevbezt= nu->bezt;
bezt= prevbezt+1;
}
- while(a--) {
- if( BEZSELECTED_HIDDENHANDLES(cu, prevbezt) && BEZSELECTED_HIDDENHANDLES(cu, bezt) ) amount+=number_cuts;
+ while (a--) {
+ if ( BEZSELECTED_HIDDENHANDLES(cu, prevbezt) && BEZSELECTED_HIDDENHANDLES(cu, bezt) ) amount+=number_cuts;
prevbezt= bezt;
bezt++;
}
- if(amount) {
+ if (amount) {
/* insert */
beztnew =
(BezTriple*)MEM_mallocN((amount + nu->pntsu) * sizeof(BezTriple), "subdivNurb");
beztn= beztnew;
- if(nu->flagu & CU_NURB_CYCLIC) {
+ if (nu->flagu & CU_NURB_CYCLIC) {
a= nu->pntsu;
bezt= nu->bezt;
prevbezt= bezt+(a-1);
@@ -2808,12 +2839,12 @@ static void subdividenurb(Object *obedit, int number_cuts)
prevbezt= nu->bezt;
bezt= prevbezt+1;
}
- while(a--) {
+ while (a--) {
memcpy(beztn, prevbezt, sizeof(BezTriple));
keyIndex_updateBezt(editnurb, prevbezt, beztn, 1);
beztn++;
- if( BEZSELECTED_HIDDENHANDLES(cu, prevbezt) && BEZSELECTED_HIDDENHANDLES(cu, bezt) ) {
+ if ( BEZSELECTED_HIDDENHANDLES(cu, prevbezt) && BEZSELECTED_HIDDENHANDLES(cu, bezt) ) {
float prevvec[3][3];
memcpy(prevvec, prevbezt->vec, sizeof(float) * 9);
@@ -2838,7 +2869,7 @@ static void subdividenurb(Object *obedit, int number_cuts)
interp_v3_v3v3(beztn->vec[1], vec+9, vec+12, factor);
copy_v3_v3(beztn->vec[2], vec+12);
/* handle of next bezt */
- if(a==0 && i == number_cuts - 1 && (nu->flagu & CU_NURB_CYCLIC)) {copy_v3_v3(beztnew->vec[0], vec+6);}
+ if (a==0 && i == number_cuts - 1 && (nu->flagu & CU_NURB_CYCLIC)) {copy_v3_v3(beztnew->vec[0], vec+6);}
else {copy_v3_v3(bezt->vec[0], vec+6);}
beztn->radius = (prevbezt->radius + bezt->radius)/2;
@@ -2853,7 +2884,7 @@ static void subdividenurb(Object *obedit, int number_cuts)
bezt++;
}
/* last point */
- if((nu->flagu & CU_NURB_CYCLIC)==0) {
+ if ((nu->flagu & CU_NURB_CYCLIC)==0) {
memcpy(beztn, prevbezt, sizeof(BezTriple));
keyIndex_updateBezt(editnurb, prevbezt, beztn, 1);
}
@@ -2873,7 +2904,7 @@ static void subdividenurb(Object *obedit, int number_cuts)
* stable... nzc 30-5-'00
*/
/* count */
- if(nu->flagu & CU_NURB_CYCLIC) {
+ if (nu->flagu & CU_NURB_CYCLIC) {
a= nu->pntsu;
bp= nu->bp;
prevbp= bp+(a-1);
@@ -2883,19 +2914,19 @@ static void subdividenurb(Object *obedit, int number_cuts)
prevbp= nu->bp;
bp= prevbp+1;
}
- while(a--) {
- if( (bp->f1 & SELECT) && (prevbp->f1 & SELECT) ) amount+=number_cuts;
+ while (a--) {
+ if ( (bp->f1 & SELECT) && (prevbp->f1 & SELECT) ) amount+=number_cuts;
prevbp= bp;
bp++;
}
- if(amount) {
+ if (amount) {
/* insert */
bpnew =
(BPoint*)MEM_mallocN((amount + nu->pntsu) * sizeof(BPoint), "subdivNurb2");
bpn= bpnew;
- if(nu->flagu & CU_NURB_CYCLIC) {
+ if (nu->flagu & CU_NURB_CYCLIC) {
a= nu->pntsu;
bp= nu->bp;
prevbp= bp+(a-1);
@@ -2905,12 +2936,12 @@ static void subdividenurb(Object *obedit, int number_cuts)
prevbp= nu->bp;
bp= prevbp+1;
}
- while(a--) {
+ while (a--) {
memcpy(bpn, prevbp, sizeof(BPoint));
keyIndex_updateBP(editnurb, prevbp, bpn, 1);
bpn++;
- if( (bp->f1 & SELECT) && (prevbp->f1 & SELECT) ) {
+ if ( (bp->f1 & SELECT) && (prevbp->f1 & SELECT) ) {
// printf("*** subdivideNurb: insert 'linear' point\n");
for (i = 0; i < number_cuts; i++) {
factor = (float)(i + 1) / (number_cuts + 1);
@@ -2924,7 +2955,7 @@ static void subdividenurb(Object *obedit, int number_cuts)
prevbp= bp;
bp++;
}
- if((nu->flagu & CU_NURB_CYCLIC)==0) { /* last point */
+ if ((nu->flagu & CU_NURB_CYCLIC)==0) { /* last point */
memcpy(bpn, prevbp, sizeof(BPoint));
keyIndex_updateBP(editnurb, prevbp, bpn, 1);
}
@@ -2933,12 +2964,12 @@ static void subdividenurb(Object *obedit, int number_cuts)
nu->bp= bpnew;
nu->pntsu+= amount;
- if(nu->type & CU_NURBS) {
+ if (nu->type & CU_NURBS) {
nurbs_knot_calc_u(nu);
}
}
- } /* End of 'else if(nu->pntsv==1)' */
- else if(nu->type == CU_NURBS) {
+ } /* End of 'else if (nu->pntsv==1)' */
+ else if (nu->type == CU_NURBS) {
/* This is a very strange test ... */
/**
* Subdivide NURB surfaces - nzc 30-5-'00 -
@@ -2988,9 +3019,9 @@ static void subdividenurb(Object *obedit, int number_cuts)
/* Count the number of selected points. */
bp= nu->bp;
- for(a=0; a<nu->pntsv; a++) {
- for(b=0; b<nu->pntsu; b++) {
- if(bp->f1 & SELECT) {
+ for (a=0; a<nu->pntsv; a++) {
+ for (b=0; b<nu->pntsu; b++) {
+ if (bp->f1 & SELECT) {
usel[b]++;
vsel[a]++;
sel++;
@@ -2998,7 +3029,7 @@ static void subdividenurb(Object *obedit, int number_cuts)
bp++;
}
}
- if( sel == (nu->pntsu*nu->pntsv) ) { /* subdivide entire nurb */
+ if ( sel == (nu->pntsu*nu->pntsv) ) { /* subdivide entire nurb */
/* Global subdivision is a special case of partial
* subdivision. Strange it is considered separately... */
@@ -3011,13 +3042,13 @@ static void subdividenurb(Object *obedit, int number_cuts)
bpn=bpnew= MEM_mallocN( tot*sizeof(BPoint), "subdivideNurb4");
bp= nu->bp;
/* first subdivide rows */
- for(a=0; a<nu->pntsv; a++) {
- for(b=0; b<nu->pntsu; b++) {
+ for (a=0; a<nu->pntsv; a++) {
+ for (b=0; b<nu->pntsu; b++) {
*bpn= *bp;
keyIndex_updateBP(editnurb, bp, bpn, 1);
bpn++;
bp++;
- if(b<nu->pntsu-1) {
+ if (b<nu->pntsu-1) {
prevbp= bp-1;
for (i = 0; i < number_cuts; i++) {
factor = (float)(i + 1) / (number_cuts + 1);
@@ -3033,9 +3064,9 @@ static void subdividenurb(Object *obedit, int number_cuts)
bpn= bpnew+((number_cuts+1)*nu->pntsu - number_cuts);
bp= bpnew+(number_cuts+1)*((number_cuts+1)*nu->pntsu-number_cuts);
prevbp= bpnew;
- for(a=1; a<nu->pntsv; a++) {
+ for (a=1; a<nu->pntsv; a++) {
- for(b=0; b<(number_cuts+1)*nu->pntsu-number_cuts; b++) {
+ for (b=0; b<(number_cuts+1)*nu->pntsu-number_cuts; b++) {
BPoint *tmp= bpn;
for (i = 0; i < number_cuts; i++) {
factor = (float)(i + 1) / (number_cuts + 1);
@@ -3061,25 +3092,25 @@ static void subdividenurb(Object *obedit, int number_cuts)
else {
/* 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;
+ for (a=0; a<nu->pntsv-1; a++) {
+ if (vsel[a]==nu->pntsu && vsel[a+1]==nu->pntsu) sel+=number_cuts;
}
- if(sel) { /* V ! */
+ if (sel) { /* V ! */
bpn=bpnew= MEM_mallocN( (sel+nu->pntsv)*nu->pntsu*sizeof(BPoint), "subdivideNurb4");
bp= nu->bp;
- for(a=0; a<nu->pntsv; a++) {
- for(b=0; b<nu->pntsu; b++) {
+ for (a=0; a<nu->pntsv; a++) {
+ for (b=0; b<nu->pntsu; b++) {
*bpn= *bp;
keyIndex_updateBP(editnurb, bp, bpn, 1);
bpn++;
bp++;
}
- if( (a<nu->pntsv-1) && vsel[a]==nu->pntsu && vsel[a+1]==nu->pntsu ) {
+ if ( (a<nu->pntsv-1) && vsel[a]==nu->pntsu && vsel[a+1]==nu->pntsu ) {
for (i = 0; i < number_cuts; i++) {
factor = (float)(i + 1) / (number_cuts + 1);
prevbp= bp- nu->pntsu;
- for(b=0; b<nu->pntsu; b++) {
+ for (b=0; b<nu->pntsu; b++) {
/*
* This simple bisection must be replaces by a
* subtle resampling of a number of points. Our
@@ -3106,22 +3137,22 @@ static void subdividenurb(Object *obedit, int number_cuts)
else {
/* 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;
+ for (a=0; a<nu->pntsu-1; a++) {
+ if (usel[a]==nu->pntsv && usel[a+1]==nu->pntsv) sel+=number_cuts;
}
- if(sel) { /* U ! */
+ if (sel) { /* U ! */
/* Inserting U points is sort of 'default' Flat curves only get */
/* U points inserted in them. */
bpn=bpnew= MEM_mallocN( (sel+nu->pntsu)*nu->pntsv*sizeof(BPoint), "subdivideNurb4");
bp= nu->bp;
- for(a=0; a<nu->pntsv; a++) {
- for(b=0; b<nu->pntsu; b++) {
+ for (a=0; a<nu->pntsv; a++) {
+ for (b=0; b<nu->pntsu; b++) {
*bpn= *bp;
keyIndex_updateBP(editnurb, bp, bpn, 1);
bpn++;
bp++;
- if( (b<nu->pntsu-1) && usel[b]==nu->pntsv && usel[b+1]==nu->pntsv ) {
+ if ( (b<nu->pntsu-1) && usel[b]==nu->pntsv && usel[b+1]==nu->pntsv ) {
/*
* One thing that bugs me here is that the
* orders of things are not the same as in
@@ -3160,7 +3191,7 @@ static int subdivide_exec(bContext *C, wmOperator *op)
subdividenurb(obedit, number_cuts);
- if(ED_curve_updateAnimPaths(obedit))
+ if (ED_curve_updateAnimPaths(obedit))
WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
@@ -3201,12 +3232,15 @@ static void findnearestNurbvert__doClosest(void *userData, Nurb *nu, BPoint *bp,
if (bp) {
flag = bp->f1;
- } else {
+ }
+ else {
if (beztindex==0) {
flag = bezt->f1;
- } else if (beztindex==1) {
+ }
+ else if (beztindex==1) {
flag = bezt->f2;
- } else {
+ }
+ else {
flag = bezt->f3;
}
}
@@ -3260,19 +3294,19 @@ static void findselectedNurbvert(ListBase *editnurb, Nurb **nu, BezTriple **bezt
*nu= NULL;
*bezt= NULL;
*bp= NULL;
- for(nu1= editnurb->first; nu1; nu1= nu1->next) {
- if(nu1->type == CU_BEZIER) {
+ 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) {
+ while (a--) {
+ if ( (bezt1->f1 & SELECT) || (bezt1->f2 & SELECT) || (bezt1->f3 & SELECT) ) {
+ if (*nu != NULL && *nu != nu1) {
*nu= NULL;
*bp= NULL;
*bezt= NULL;
return;
}
- else if(*bezt || *bp) {
+ else if (*bezt || *bp) {
*bp= NULL;
*bezt= NULL;
}
@@ -3287,15 +3321,15 @@ static void findselectedNurbvert(ListBase *editnurb, Nurb **nu, BezTriple **bezt
else {
bp1= nu1->bp;
a= nu1->pntsu*nu1->pntsv;
- while(a--) {
- if( bp1->f1 & 1 ) {
- if(*nu != NULL && *nu != nu1) {
+ while (a--) {
+ if ( bp1->f1 & 1 ) {
+ if (*nu != NULL && *nu != nu1) {
*bp= NULL;
*bezt= NULL;
*nu= NULL;
return;
}
- else if(*bezt || *bp) {
+ else if (*bezt || *bp) {
*bp= NULL;
*bezt= NULL;
}
@@ -3318,15 +3352,15 @@ static int convertspline(short type, Nurb *nu)
BPoint *bp;
int a, c, nr;
- if(nu->type == CU_POLY) {
- if(type==CU_BEZIER) { /* to Bezier with vecthandles */
+ if (nu->type == CU_POLY) {
+ if (type==CU_BEZIER) { /* to Bezier with vecthandles */
nr= nu->pntsu;
bezt =
(BezTriple*)MEM_callocN(nr * sizeof(BezTriple), "setsplinetype2");
nu->bezt= bezt;
a= nr;
bp= nu->bp;
- while(a--) {
+ while (a--) {
copy_v3_v3(bezt->vec[1], bp->vec);
bezt->f1=bezt->f2=bezt->f3= bp->f1;
bezt->h1= bezt->h2= HD_VECT;
@@ -3341,28 +3375,28 @@ static int convertspline(short type, Nurb *nu)
nu->type = CU_BEZIER;
calchandlesNurb(nu);
}
- else if(type==CU_NURBS) {
+ else if (type==CU_NURBS) {
nu->type = CU_NURBS;
nu->orderu= 4;
nu->flagu &= CU_NURB_CYCLIC; /* disable all flags except for cyclic */
nurbs_knot_calc_u(nu);
a= nu->pntsu*nu->pntsv;
bp= nu->bp;
- while(a--) {
+ while (a--) {
bp->vec[3]= 1.0;
bp++;
}
}
}
- else if(nu->type == CU_BEZIER) { /* Bezier */
- if(type==CU_POLY || type==CU_NURBS) {
+ else if (nu->type == CU_BEZIER) { /* Bezier */
+ if (type==CU_POLY || type==CU_NURBS) {
nr= 3*nu->pntsu;
nu->bp = MEM_callocN(nr * sizeof(BPoint), "setsplinetype");
a= nu->pntsu;
bezt= nu->bezt;
bp= nu->bp;
- while(a--) {
- if(type==CU_POLY && bezt->h1==HD_VECT && bezt->h2==HD_VECT) {
+ while (a--) {
+ if (type==CU_POLY && bezt->h1==HD_VECT && bezt->h2==HD_VECT) {
/* vector handle becomes 1 poly vertice */
copy_v3_v3(bp->vec, bezt->vec[1]);
bp->vec[3]= 1.0;
@@ -3373,11 +3407,11 @@ static int convertspline(short type, Nurb *nu)
bp++;
}
else {
- for(c=0;c<3;c++) {
+ for (c=0;c<3;c++) {
copy_v3_v3(bp->vec, bezt->vec[c]);
bp->vec[3]= 1.0;
- if(c==0) bp->f1= bezt->f1;
- else if(c==1) bp->f1= bezt->f2;
+ if (c==0) bp->f1= bezt->f1;
+ else if (c==1) bp->f1= bezt->f2;
else bp->f1= bezt->f3;
bp->radius= bezt->radius;
bp->weight= bezt->weight;
@@ -3395,36 +3429,36 @@ static int convertspline(short type, Nurb *nu)
nu->type = type;
#if 0 /* UNUSED */
- if(nu->flagu & CU_NURB_CYCLIC) c= nu->orderu-1;
+ if (nu->flagu & CU_NURB_CYCLIC) c= nu->orderu-1;
else c= 0;
#endif
- if(type== CU_NURBS) {
+ if (type== CU_NURBS) {
nu->flagu &= CU_NURB_CYCLIC; /* disable all flags except for cyclic */
nu->flagu |= CU_NURB_BEZIER;
nurbs_knot_calc_u(nu);
}
}
}
- else if(nu->type == CU_NURBS) {
- if(type==CU_POLY) {
+ else if (nu->type == CU_NURBS) {
+ if (type==CU_POLY) {
nu->type = CU_POLY;
- if(nu->knotsu) MEM_freeN(nu->knotsu); /* python created nurbs have a knotsu of zero */
+ if (nu->knotsu) MEM_freeN(nu->knotsu); /* python created nurbs have a knotsu of zero */
nu->knotsu= NULL;
- if(nu->knotsv) MEM_freeN(nu->knotsv);
+ if (nu->knotsv) MEM_freeN(nu->knotsv);
nu->knotsv= NULL;
}
- else if(type==CU_BEZIER) { /* to Bezier */
+ else if (type==CU_BEZIER) { /* to Bezier */
nr= nu->pntsu/3;
- if(nr<2)
+ if (nr<2)
return 1; /* conversion impossible */
else {
bezt = MEM_callocN(nr * sizeof(BezTriple), "setsplinetype2");
nu->bezt= bezt;
a= nr;
bp= nu->bp;
- while(a--) {
+ while (a--) {
copy_v3_v3(bezt->vec[0], bp->vec);
bezt->f1= bp->f1;
bp++;
@@ -3463,22 +3497,22 @@ static int set_spline_type_exec(bContext *C, wmOperator *op)
Nurb *nu;
int changed=0, type= RNA_enum_get(op->ptr, "type");
- if(type==CU_CARDINAL || type==CU_BSPLINE) {
+ if (type==CU_CARDINAL || type==CU_BSPLINE) {
BKE_report(op->reports, RPT_ERROR, "Not implemented yet");
return OPERATOR_CANCELLED;
}
- for(nu= editnurb->first; nu; nu= nu->next) {
- if(isNurbsel(nu)) {
- if(convertspline(type, nu))
+ for (nu= editnurb->first; nu; nu= nu->next) {
+ if (isNurbsel(nu)) {
+ if (convertspline(type, nu))
BKE_report(op->reports, RPT_ERROR, "No conversion possible");
else
changed= 1;
}
}
- if(changed) {
- if(ED_curve_updateAnimPaths(obedit))
+ if (changed) {
+ if (ED_curve_updateAnimPaths(obedit))
WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit);
DAG_id_tag_update(obedit->data, 0);
@@ -3570,14 +3604,14 @@ 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;
fp1= base;
fp2= fp1+(a-1);
a/= 2;
- while(fp1!=fp2 && a>0) {
+ while (fp1!=fp2 && a>0) {
SWAP(float, *fp1, *fp2);
a--;
fp1++;
@@ -3587,7 +3621,7 @@ static void switchdirection_knots(float *base, int tot)
a= tot;
fp1= base;
fp2=tempf= MEM_mallocN(sizeof(float)*a, "switchdirect");
- while(a--) {
+ while (a--) {
fp2[0]= fabs(fp1[1]-fp1[0]);
fp1++;
fp2++;
@@ -3598,7 +3632,7 @@ static void switchdirection_knots(float *base, int tot)
fp2= tempf;
fp1[0]= 0.0;
fp1++;
- while(a--) {
+ while (a--) {
fp1[0]= fp1[-1]+fp2[0];
fp1++;
fp2++;
@@ -3621,8 +3655,8 @@ static void rotate_direction_nurb(Nurb *nu)
temp= MEM_dupallocN(nu->bp);
bp1= nu->bp;
- for(v=0; v<nu->pntsv; v++) {
- for(u=0; u<nu->pntsu; u++, bp1++) {
+ for (v=0; v<nu->pntsv; v++) {
+ for (u=0; u<nu->pntsu; u++, bp1++) {
bp2= temp + (nu->pntsu-u-1)*(nu->pntsv) + v;
*bp1= *bp2;
}
@@ -3638,8 +3672,8 @@ static int is_u_selected(Nurb *nu, int u)
/* what about resolu == 2? */
bp= nu->bp+u;
- for(v=0; v<nu->pntsv-1; v++, bp+=nu->pntsu) {
- if(v) if(bp->f1 & SELECT) return 1;
+ for (v=0; v<nu->pntsv-1; v++, bp+=nu->pntsu) {
+ if (v) if(bp->f1 & SELECT) return 1;
}
return 0;
@@ -3663,8 +3697,8 @@ static void make_selection_list_nurb(ListBase *editnurb)
float dist, headdist, taildist;
int a;
- for(nu= editnurb->first; nu; nu= nu->next) {
- if( isNurbsel(nu) ) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
+ if ( isNurbsel(nu) ) {
nus = (NurbSort*)MEM_callocN(sizeof(NurbSort), "sort");
BLI_addhead(&nbase, nus);
@@ -3672,7 +3706,7 @@ static void make_selection_list_nurb(ListBase *editnurb)
bp= nu->bp;
a= nu->pntsu;
- while(a--) {
+ while (a--) {
add_v3_v3(nus->vec, bp->vec);
bp++;
}
@@ -3688,29 +3722,29 @@ static void make_selection_list_nurb(ListBase *editnurb)
BLI_addtail( &nsortbase, nus);
/* now add, either at head or tail, the closest one */
- while(nbase.first) {
+ while (nbase.first) {
headdist= taildist= 1.0e30;
headdo= taildo= NULL;
nustest= nbase.first;
- while(nustest) {
+ while (nustest) {
dist= len_v3v3(nustest->vec, ((NurbSort *)nsortbase.first)->vec);
- if(dist<headdist) {
+ if (dist<headdist) {
headdist= dist;
headdo= nustest;
}
dist= len_v3v3(nustest->vec, ((NurbSort *)nsortbase.last)->vec);
- if(dist<taildist) {
+ if (dist<taildist) {
taildist= dist;
taildo= nustest;
}
nustest= nustest->next;
}
- if(headdist<taildist) {
+ if (headdist<taildist) {
BLI_remlink(&nbase, headdo);
BLI_addhead(&nsortbase, headdo);
}
@@ -3732,23 +3766,23 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu
/* first nurbs: u = resolu-1 selected */
- if( is_u_selected(nu1, nu1->pntsu-1) );
+ if ( is_u_selected(nu1, nu1->pntsu-1) );
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;
rotate_direction_nurb(nu1);
- if( is_u_selected(nu1, nu1->pntsu-1) );
+ if ( is_u_selected(nu1, nu1->pntsu-1) );
else {
rotate_direction_nurb(nu1);
- if( is_u_selected(nu1, nu1->pntsu-1) );
+ if ( is_u_selected(nu1, nu1->pntsu-1) );
else {
rotate_direction_nurb(nu1);
- if( is_u_selected(nu1, nu1->pntsu-1) );
+ if ( is_u_selected(nu1, nu1->pntsu-1) );
else {
/* rotate again, now its OK! */
- if(nu1->pntsv!=1) rotate_direction_nurb(nu1);
+ if (nu1->pntsv!=1) rotate_direction_nurb(nu1);
return;
}
}
@@ -3756,28 +3790,28 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu
}
/* 2nd nurbs: u = 0 selected */
- if( is_u_selected(nu2, 0) );
+ if ( is_u_selected(nu2, 0) );
else {
if (nu2->orderv == 0) nu2->orderv= 1;
rotate_direction_nurb(nu2);
- if( is_u_selected(nu2, 0) );
+ if ( is_u_selected(nu2, 0) );
else {
rotate_direction_nurb(nu2);
- if( is_u_selected(nu2, 0) );
+ if ( is_u_selected(nu2, 0) );
else {
rotate_direction_nurb(nu2);
- if( is_u_selected(nu2, 0) );
+ if ( is_u_selected(nu2, 0) );
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;
}
}
}
}
- if( nu1->pntsv != nu2->pntsv ) {
+ if ( nu1->pntsv != nu2->pntsv ) {
BKE_report(op->reports, RPT_ERROR, "Resolution doesn't match");
return;
}
@@ -3789,7 +3823,7 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu
bp2= nu2->bp;
len1= 0.0;
- for(v=0; v<nu1->pntsv; v++, bp1+=nu1->pntsu, bp2+=nu2->pntsu) {
+ for (v=0; v<nu1->pntsv; v++, bp1+=nu1->pntsu, bp2+=nu2->pntsu) {
len1+= len_v3v3(bp1->vec, bp2->vec);
}
@@ -3797,29 +3831,29 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu
bp2= nu2->bp + nu2->pntsu*(nu2->pntsv-1);
len2= 0.0;
- for(v=0; v<nu1->pntsv; v++, bp1+=nu1->pntsu, bp2-=nu2->pntsu) {
+ for (v=0; v<nu1->pntsv; v++, bp1+=nu1->pntsu, bp2-=nu2->pntsu) {
len2+= len_v3v3(bp1->vec, bp2->vec);
}
/* 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");
bp= nu1->bp;
bp1= temp;
- for(v=0; v<nu1->pntsv; v++) {
+ for (v=0; v<nu1->pntsv; v++) {
/* switch direction? */
- if(len1<len2) bp2= nu2->bp + v*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) {
+ for (u=0; u<nu1->pntsu; u++, bp++) {
+ if (u<origu) {
*bp= *bp1; bp1++;
select_bpoint(bp, SELECT, 1, HIDDEN);
}
@@ -3829,7 +3863,7 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu
}
}
- if(nu1->type == CU_NURBS) {
+ if (nu1->type == CU_NURBS) {
/* merge knots */
nurbs_knot_calc_u(nu1);
@@ -3851,7 +3885,7 @@ static int merge_nurb(bContext *C, wmOperator *op)
make_selection_list_nurb(editnurb);
- if(nsortbase.first == nsortbase.last) {
+ if (nsortbase.first == nsortbase.last) {
BLI_freelistN(&nsortbase);
BKE_report(op->reports, RPT_ERROR, "Too few selections to merge");
return OPERATOR_CANCELLED;
@@ -3861,27 +3895,27 @@ static int merge_nurb(bContext *C, wmOperator *op)
nus2= nus1->next;
/* resolution match, to avoid uv rotations */
- if(nus1->nu->pntsv==1) {
- if(nus1->nu->pntsu==nus2->nu->pntsu || nus1->nu->pntsu==nus2->nu->pntsv);
+ if (nus1->nu->pntsv==1) {
+ if (nus1->nu->pntsu==nus2->nu->pntsu || nus1->nu->pntsu==nus2->nu->pntsv);
else ok= 0;
}
- else if(nus2->nu->pntsv==1) {
- if(nus2->nu->pntsu==nus1->nu->pntsu || nus2->nu->pntsu==nus1->nu->pntsv);
+ else if (nus2->nu->pntsv==1) {
+ if (nus2->nu->pntsu==nus1->nu->pntsu || nus2->nu->pntsu==nus1->nu->pntsv);
else ok= 0;
}
- else if( nus1->nu->pntsu==nus2->nu->pntsu || nus1->nu->pntsv==nus2->nu->pntsv);
- else if( nus1->nu->pntsu==nus2->nu->pntsv || nus1->nu->pntsv==nus2->nu->pntsu);
+ else if ( nus1->nu->pntsu==nus2->nu->pntsu || nus1->nu->pntsv==nus2->nu->pntsv);
+ else if ( nus1->nu->pntsu==nus2->nu->pntsv || nus1->nu->pntsv==nus2->nu->pntsu);
else {
ok= 0;
}
- if(ok==0) {
+ if (ok==0) {
BKE_report(op->reports, RPT_ERROR, "Resolution doesn't match");
BLI_freelistN(&nsortbase);
return OPERATOR_CANCELLED;
}
- while(nus2) {
+ while (nus2) {
merge_2_nurb(op, editnurb, nus1->nu, nus2->nu);
nus2= nus2->next;
}
@@ -3908,18 +3942,18 @@ static int make_segment_exec(bContext *C, wmOperator *op)
int a, ok= 0;
/* first decide if this is a surface merge! */
- if(obedit->type==OB_SURF) nu= nubase->first;
+ if (obedit->type==OB_SURF) nu= nubase->first;
else nu= NULL;
- while(nu) {
- if( isNurbsel(nu) ) {
+ 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) {
+ if (nu->pntsu>1 && nu->pntsv>1) break;
+ if (isNurbsel_count(cu, nu)>1) break;
+ if (isNurbsel_count(cu, nu)==1) {
/* 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));
+ if (nu->pntsv==1) {
+ if ( (nu->bp->f1 & SELECT) || ((nu->bp+nu->pntsu-1)->f1 & SELECT));
else break;
}
}
@@ -3927,62 +3961,62 @@ static int make_segment_exec(bContext *C, wmOperator *op)
nu= nu->next;
}
- if(nu)
+ if (nu)
return merge_nurb(C, op);
/* find both nurbs and points, nu1 will be put behind nu2 */
- for(nu= nubase->first; nu; nu= nu->next) {
- if(nu->pntsu == 1)
+ for (nu= nubase->first; nu; nu= nu->next) {
+ if (nu->pntsu == 1)
nu->flagu&= ~CU_NURB_CYCLIC;
- if((nu->flagu & CU_NURB_CYCLIC)==0) { /* not cyclic */
- if(nu->type == CU_BEZIER) {
- if(nu1==NULL) {
- if( BEZSELECTED_HIDDENHANDLES(cu, nu->bezt) ) nu1= nu;
+ if ((nu->flagu & CU_NURB_CYCLIC)==0) { /* not cyclic */
+ if (nu->type == CU_BEZIER) {
+ if (nu1==NULL) {
+ if ( BEZSELECTED_HIDDENHANDLES(cu, nu->bezt) ) nu1= nu;
else {
- if( BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu-1])) ) {
+ if ( BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu-1])) ) {
nu1= nu;
switchdirectionNurb(nu);
keyData_switchDirectionNurb(cu, nu);
}
}
}
- else if(nu2==NULL) {
- if( BEZSELECTED_HIDDENHANDLES(cu, nu->bezt) ) {
+ else if (nu2==NULL) {
+ if ( BEZSELECTED_HIDDENHANDLES(cu, nu->bezt) ) {
nu2= nu;
switchdirectionNurb(nu);
keyData_switchDirectionNurb(cu, nu);
}
else {
- if( BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu-1])) ) {
+ if ( BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu-1])) ) {
nu2= nu;
}
}
}
else break;
}
- else if(nu->pntsv==1) {
+ else if (nu->pntsv==1) {
bp= nu->bp;
- if(nu1==NULL) {
- if( bp->f1 & SELECT) nu1= nu;
+ if (nu1==NULL) {
+ if ( bp->f1 & SELECT) nu1= nu;
else {
bp= bp+(nu->pntsu-1);
- if( bp->f1 & SELECT ) {
+ if ( bp->f1 & SELECT ) {
nu1= nu;
switchdirectionNurb(nu);
keyData_switchDirectionNurb(cu, nu);
}
}
}
- else if(nu2==NULL) {
- if( bp->f1 & SELECT ) {
+ else if (nu2==NULL) {
+ if ( bp->f1 & SELECT ) {
nu2= nu;
switchdirectionNurb(nu);
keyData_switchDirectionNurb(cu, nu);
}
else {
bp= bp+(nu->pntsu-1);
- if( bp->f1 & SELECT ) {
+ if ( bp->f1 & SELECT ) {
nu2= nu;
}
}
@@ -3992,9 +4026,9 @@ static int make_segment_exec(bContext *C, wmOperator *op)
}
}
- if((nu1 && nu2) && (nu1!=nu2)) {
- if( nu1->type==nu2->type) {
- if(nu1->type == CU_BEZIER) {
+ if ((nu1 && nu2) && (nu1!=nu2)) {
+ if ( nu1->type==nu2->type) {
+ if (nu1->type == CU_BEZIER) {
BezTriple *bezt =
(BezTriple*)MEM_mallocN((nu1->pntsu+nu2->pntsu) * sizeof(BezTriple), "addsegmentN");
ED_curve_beztcpy(cu->editnurb, bezt, nu2->bezt, nu2->pntsu);
@@ -4021,8 +4055,8 @@ static int make_segment_exec(bContext *C, wmOperator *op)
BLI_remlink(nubase, nu2);
/* now join the knots */
- if(nu1->type == CU_NURBS) {
- if(nu1->knotsu==NULL) {
+ if (nu1->type == CU_NURBS) {
+ if (nu1->knotsu==NULL) {
nurbs_knot_calc_u(nu1);
}
else {
@@ -4034,8 +4068,8 @@ static int make_segment_exec(bContext *C, wmOperator *op)
offset= nu1->knotsu[a-1] + 1.0f;
fp= nu1->knotsu+a;
- for(a=0; a<nu2->pntsu; a++, fp++) {
- if(nu2->knotsu)
+ for (a=0; a<nu2->pntsu; a++, fp++) {
+ if (nu2->knotsu)
*fp= offset+nu2->knotsu[a+1];
else
*fp = offset;
@@ -4048,14 +4082,16 @@ static int make_segment_exec(bContext *C, wmOperator *op)
set_actNurb(obedit, nu1); /* for selected */
ok= 1;
}
- } else if(nu1 && !nu2) {
- if(!(nu1->flagu & CU_NURB_CYCLIC) && nu1->pntsu>1) {
+ }
+ else if (nu1 && !nu2) {
+ 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))) {
nu1->flagu|= CU_NURB_CYCLIC;
calchandlesNurb(nu1);
ok= 1;
- } else if (nu1->type == CU_NURBS && nu1->bp->f1&SELECT && (nu1->bp+(nu1->pntsu-1))->f1&SELECT) {
+ }
+ else if (nu1->type == CU_NURBS && nu1->bp->f1&SELECT && (nu1->bp+(nu1->pntsu-1))->f1&SELECT) {
nu1->flagu|= CU_NURB_CYCLIC;
nurbs_knot_calc_u(nu1);
ok= 1;
@@ -4063,12 +4099,12 @@ static int make_segment_exec(bContext *C, wmOperator *op)
}
}
- if(!ok) {
+ if (!ok) {
BKE_report(op->reports, RPT_ERROR, "Can't make segment");
return OPERATOR_CANCELLED;
}
- if(ED_curve_updateAnimPaths(obedit))
+ if (ED_curve_updateAnimPaths(obedit))
WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
@@ -4112,18 +4148,19 @@ int mouse_nurb(bContext *C, const int mval[2], int extend)
location[1]= mval[1];
hand= findnearestNurbvert(&vc, 1, location, &nu, &bezt, &bp);
- if(bezt || bp) {
- if(extend==0) {
+ if (bezt || bp) {
+ if (extend==0) {
setflagsNurb(editnurb, 0);
- if(bezt) {
+ if (bezt) {
- if(hand==1) {
+ if (hand==1) {
select_beztriple(bezt, SELECT, 1, HIDDEN);
cu->lastsel= bezt;
- } else {
- if(hand==0) bezt->f1|= SELECT;
+ }
+ else {
+ if (hand==0) bezt->f1|= SELECT;
else bezt->f3|= SELECT;
cu->lastsel= NULL;
@@ -4136,26 +4173,30 @@ int mouse_nurb(bContext *C, const int mval[2], int extend)
}
else {
- if(bezt) {
- if(hand==1) {
- if(bezt->f2 & SELECT) {
+ if (bezt) {
+ if (hand==1) {
+ if (bezt->f2 & SELECT) {
select_beztriple(bezt, DESELECT, 1, HIDDEN);
if (bezt == cu->lastsel) cu->lastsel = NULL;
- } else {
+ }
+ else {
select_beztriple(bezt, SELECT, 1, HIDDEN);
cu->lastsel= bezt;
}
- } else if(hand==0) {
+ }
+ else if (hand==0) {
bezt->f1 ^= SELECT;
- } else {
+ }
+ else {
bezt->f3 ^= SELECT;
}
}
else {
- if(bp->f1 & SELECT) {
+ if (bp->f1 & SELECT) {
select_bpoint(bp, DESELECT, 1, HIDDEN);
if (cu->lastsel == bp) cu->lastsel = NULL;
- } else {
+ }
+ else {
select_bpoint(bp, SELECT, 1, HIDDEN);
cu->lastsel= bp;
}
@@ -4163,7 +4204,7 @@ int mouse_nurb(bContext *C, const int mval[2], int extend)
}
- if(nu!=get_actNurb(obedit))
+ if (nu!=get_actNurb(obedit))
set_actNurb(obedit, nu);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
@@ -4227,17 +4268,17 @@ static int spin_nurb(float viewmat[][4], Object *obedit, float *axis, float *cen
ok= 1;
- for(a=0;a<7;a++) {
+ for (a=0;a<7;a++) {
ok= extrudeflagNurb(cu->editnurb, 1);
- if(ok==0)
+ if (ok==0)
return changed;
changed= 1;
rotateflagNurb(editnurb, SELECT, cent, rotmat);
- if( (a & SELECT)==0 ) {
+ if ( (a & SELECT)==0 ) {
rotateflagNurb(editnurb, SELECT, cent, scalemat1);
weightflagNurb(editnurb, SELECT, 0.25*M_SQRT2);
}
@@ -4247,9 +4288,9 @@ static int spin_nurb(float viewmat[][4], Object *obedit, float *axis, float *cen
}
}
- if(ok) {
- for(nu= editnurb->first; nu; nu= nu->next) {
- if(isNurbsel(nu)) {
+ if (ok) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
+ if (isNurbsel(nu)) {
nu->orderv= 4;
nu->flagv |= CU_NURB_CYCLIC;
nurbs_knot_calc_v(nu);
@@ -4272,17 +4313,17 @@ static int spin_exec(bContext *C, wmOperator *op)
invert_m4_m4(obedit->imat, obedit->obmat);
mul_m4_v3(obedit->imat, cent);
- if(rv3d)
+ if (rv3d)
copy_m4_m4(viewmat, rv3d->viewmat);
else
unit_m4(viewmat);
- if(!spin_nurb(viewmat, obedit, axis, cent)) {
+ if (!spin_nurb(viewmat, obedit, axis, cent)) {
BKE_report(op->reports, RPT_ERROR, "Can't spin");
return OPERATOR_CANCELLED;
}
- if(ED_curve_updateAnimPaths(obedit))
+ if (ED_curve_updateAnimPaths(obedit))
WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
@@ -4298,7 +4339,7 @@ static int spin_invoke(bContext *C, wmOperator *op, 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", give_cursor(scene, v3d));
@@ -4343,11 +4384,11 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
findselectedNurbvert(&editnurb->nurbs, &nu, &bezt, &bp);
if ((nu == NULL) || (nu->type==CU_BEZIER && bezt==NULL) || (nu->type!=CU_BEZIER && bp==NULL)) {
- if(mode!='e') {
- if(cu->actnu >= 0)
+ if (mode!='e') {
+ if (cu->actnu >= 0)
nu= BLI_findlink(&editnurb->nurbs, cu->actnu);
- if(!nu || nu->type==CU_BEZIER) {
+ if (!nu || nu->type==CU_BEZIER) {
newbezt= (BezTriple*)MEM_callocN(sizeof(BezTriple), "addvert_Nurb");
newbezt->radius= 1;
newbezt->alfa= 0;
@@ -4355,14 +4396,15 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
newbezt->h2= newbezt->h1= HD_AUTO;
newnu= (Nurb*)MEM_callocN(sizeof(Nurb), "addvert_Nurb newnu");
- if(!nu) {
+ if (!nu) {
/* no selected sement -- create new one which is BEZIER tpye
* type couldn't be determined from Curve bt could be changed
* in the future, so shouldn't make much headache */
newnu->type= CU_BEZIER;
newnu->resolu= cu->resolu;
newnu->flag |= CU_SMOOTH;
- } else memcpy(newnu, nu, sizeof(Nurb));
+ }
+ else memcpy(newnu, nu, sizeof(Nurb));
BLI_addtail(&editnurb->nurbs, newnu);
set_actNurb(obedit, newnu);
@@ -4383,7 +4425,8 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
ok= 1;
nu= newnu;
- } else if(nu->pntsv == 1) {
+ }
+ else if (nu->pntsv == 1) {
newbp= (BPoint*)MEM_callocN(sizeof(BPoint), "addvert_Nurb5");
newbp->radius= 1;
newbp->alfa= 0;
@@ -4410,13 +4453,13 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
}
- if(!ok)
+ if (!ok)
return OPERATOR_CANCELLED;
}
- if(!ok && nu->type == CU_BEZIER) {
+ if (!ok && nu->type == CU_BEZIER) {
/* which bezpoint? */
- if(bezt== (nu->bezt+nu->pntsu-1)) { /* last */
+ if (bezt== (nu->bezt+nu->pntsu-1)) { /* last */
BEZ_DESEL(bezt);
newbezt =
(BezTriple*)MEM_callocN((nu->pntsu+1) * sizeof(BezTriple), "addvert_Nurb");
@@ -4432,7 +4475,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
bezt= nu->bezt+nu->pntsu-1;
ok= 1;
}
- else if(bezt== nu->bezt) { /* first */
+ else if (bezt== nu->bezt) { /* first */
BEZ_DESEL(bezt);
newbezt =
(BezTriple*)MEM_callocN((nu->pntsu+1) * sizeof(BezTriple), "addvert_Nurb");
@@ -4447,7 +4490,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
bezt= newbezt+1;
ok= 1;
}
- else if(mode!='e') {
+ else if (mode!='e') {
BEZ_DESEL(bezt);
newbezt= (BezTriple*)MEM_callocN(sizeof(BezTriple), "addvert_Nurb");
*newbezt= *bezt;
@@ -4469,10 +4512,10 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
}
else bezt= NULL;
- if(bezt) {
- if(!newnu) nu->pntsu++;
+ if (bezt) {
+ if (!newnu) nu->pntsu++;
- if(mode=='e') {
+ if (mode=='e') {
copy_v3_v3(newbezt->vec[0], bezt->vec[0]);
copy_v3_v3(newbezt->vec[1], bezt->vec[1]);
copy_v3_v3(newbezt->vec[2], bezt->vec[2]);
@@ -4483,14 +4526,14 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
add_v3_v3v3(newbezt->vec[0], bezt->vec[0],temp);
add_v3_v3v3(newbezt->vec[2], bezt->vec[2],temp);
- if(newnu) calchandlesNurb(newnu);
+ if (newnu) calchandlesNurb(newnu);
else calchandlesNurb(nu);
}
}
}
- else if(!ok && nu->pntsv==1) {
+ else if (!ok && nu->pntsv==1) {
/* which b-point? */
- if(bp== (nu->bp+nu->pntsu-1)) { /* last */
+ if (bp== (nu->bp+nu->pntsu-1)) { /* last */
bp->f1= 0;
newbp =
(BPoint*)MEM_callocN((nu->pntsu+1) * sizeof(BPoint), "addvert_Nurb4");
@@ -4504,7 +4547,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
bp= newbp - 1;
ok= 1;
}
- else if(bp== nu->bp) { /* first */
+ else if (bp== nu->bp) { /* first */
bp->f1= 0;
newbp =
(BPoint*)MEM_callocN((nu->pntsu+1) * sizeof(BPoint), "addvert_Nurb3");
@@ -4517,7 +4560,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
bp= newbp + 1;
ok= 1;
}
- else if(mode!='e') {
+ else if (mode!='e') {
bp->f1= 0;
newbp= (BPoint*)MEM_callocN(sizeof(BPoint), "addvert_Nurb5");
*newbp= *bp;
@@ -4538,29 +4581,30 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
}
else bp= NULL;
- if(bp) {
- if(mode=='e') {
+ if (bp) {
+ if (mode=='e') {
copy_v3_v3(newbp->vec, bp->vec);
}
else {
mul_v3_m4v3(newbp->vec, imat, location);
newbp->vec[3]= 1.0;
- if(!newnu && nu->orderu<4 && nu->orderu<=nu->pntsu)
+ if (!newnu && nu->orderu<4 && nu->orderu<=nu->pntsu)
nu->orderu++;
}
- if(!newnu) {
+ if (!newnu) {
nu->pntsu++;
nurbs_knot_calc_u(nu);
- } else nurbs_knot_calc_u(newnu);
+ }
+ else nurbs_knot_calc_u(newnu);
}
}
- if(ok) {
+ if (ok) {
test2DNurb(nu);
- if(ED_curve_updateAnimPaths(obedit))
+ if (ED_curve_updateAnimPaths(obedit))
WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
@@ -4584,7 +4628,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
RegionView3D *rv3d= CTX_wm_region_view3d(C);
- if(rv3d && !RNA_struct_property_is_set(op->ptr, "location")) {
+ if (rv3d && !RNA_struct_property_is_set(op->ptr, "location")) {
Curve *cu;
ViewContext vc;
float location[3];
@@ -4599,7 +4643,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event)
findselectedNurbvert(&cu->editnurb->nurbs, &nu, &bezt, &bp);
- if(bezt) {
+ if (bezt) {
mul_v3_m4v3(location, vc.obedit->obmat, bezt->vec[1]);
}
else if (bp) {
@@ -4644,16 +4688,16 @@ static int extrude_exec(bContext *C, wmOperator *UNUSED(op))
Nurb *nu;
/* first test: curve? */
- for(nu= editnurb->nurbs.first; nu; nu= nu->next)
- if(nu->pntsv==1 && isNurbsel_count(cu, nu)==1)
+ for (nu= editnurb->nurbs.first; nu; nu= nu->next)
+ if (nu->pntsv==1 && isNurbsel_count(cu, nu)==1)
break;
- if(obedit->type==OB_CURVE || nu) {
+ if (obedit->type==OB_CURVE || nu) {
addvert_Nurb(C, 'e', NULL);
}
else {
- if(extrudeflagNurb(editnurb, 1)) { /* '1'= flag */
- if(ED_curve_updateAnimPaths(obedit))
+ if (extrudeflagNurb(editnurb, 1)) { /* '1'= flag */
+ if (ED_curve_updateAnimPaths(obedit))
WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
@@ -4694,24 +4738,24 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op)
BPoint *bp;
int a, direction= RNA_enum_get(op->ptr, "direction");
- for(nu= editnurb->first; nu; nu= nu->next) {
- if( nu->pntsu>1 || nu->pntsv>1) {
- if(nu->type == CU_POLY) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
+ if ( nu->pntsu>1 || nu->pntsv>1) {
+ if (nu->type == CU_POLY) {
a= nu->pntsu;
bp= nu->bp;
- while(a--) {
- if( bp->f1 & SELECT ) {
+ while (a--) {
+ if ( bp->f1 & SELECT ) {
nu->flagu ^= CU_NURB_CYCLIC;
break;
}
bp++;
}
}
- else if(nu->type == CU_BEZIER) {
+ else if (nu->type == CU_BEZIER) {
a= nu->pntsu;
bezt= nu->bezt;
- while(a--) {
- if( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) {
+ while (a--) {
+ if ( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) {
nu->flagu ^= CU_NURB_CYCLIC;
break;
}
@@ -4719,12 +4763,12 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op)
}
calchandlesNurb(nu);
}
- else if(nu->pntsv==1 && nu->type == CU_NURBS) {
+ else if (nu->pntsv==1 && nu->type == CU_NURBS) {
if (nu->knotsu) { /* if check_valid_nurb_u fails the knotsu can be NULL */
a= nu->pntsu;
bp= nu->bp;
- while(a--) {
- if( bp->f1 & SELECT ) {
+ while (a--) {
+ if ( bp->f1 & SELECT ) {
nu->flagu ^= CU_NURB_CYCLIC;
nurbs_knot_calc_u(nu); /* 1==u type is ignored for cyclic curves */
break;
@@ -4733,17 +4777,17 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op)
}
}
}
- else if(nu->type==CU_NURBS) {
+ else if (nu->type==CU_NURBS) {
a= nu->pntsu*nu->pntsv;
bp= nu->bp;
- while(a--) {
+ while (a--) {
- if( bp->f1 & SELECT) {
- if(direction==0 && nu->pntsu>1) {
+ if ( bp->f1 & SELECT) {
+ if (direction==0 && nu->pntsu>1) {
nu->flagu ^= CU_NURB_CYCLIC;
nurbs_knot_calc_u(nu); /* 1==u type is ignored for cyclic curves */
}
- if(direction==1 && nu->pntsv>1) {
+ if (direction==1 && nu->pntsv>1) {
nu->flagv ^= CU_NURB_CYCLIC;
nurbs_knot_calc_v(nu); /* 2==v type is ignored for cyclic curves */
}
@@ -4770,10 +4814,10 @@ static int toggle_cyclic_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve
uiLayout *layout;
Nurb *nu;
- if(obedit->type == OB_SURF) {
- for(nu= editnurb->first; nu; nu= nu->next) {
- if(nu->pntsu>1 || nu->pntsv>1) {
- if(nu->type==CU_NURBS) {
+ if (obedit->type == OB_SURF) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
+ if (nu->pntsu>1 || nu->pntsv>1) {
+ if (nu->type==CU_NURBS) {
pup= uiPupMenuBegin(C, "Direction", ICON_NONE);
layout= uiPupMenuLayout(pup);
uiItemsEnumO(layout, op->type->idname, "direction");
@@ -4824,15 +4868,15 @@ static int select_linked_exec(bContext *C, wmOperator *UNUSED(op))
BPoint *bp;
int a;
- for(nu= nurbs->first; nu; nu= nu->next) {
- if(nu->type == CU_BEZIER) {
+ 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) ) {
+ while (a--) {
+ if ( (bezt->f1 & SELECT) || (bezt->f2 & SELECT) || (bezt->f3 & SELECT) ) {
a= nu->pntsu;
bezt= nu->bezt;
- while(a--) {
+ while (a--) {
select_beztriple(bezt, SELECT, 1, VISIBLE);
bezt++;
}
@@ -4844,11 +4888,11 @@ static int select_linked_exec(bContext *C, wmOperator *UNUSED(op))
else {
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
- while(a--) {
- if( bp->f1 & 1 ) {
+ while (a--) {
+ if ( bp->f1 & 1 ) {
a= nu->pntsu*nu->pntsv;
bp= nu->bp;
- while(a--) {
+ while (a--) {
select_bpoint(bp, SELECT, 1, VISIBLE);
bp++;
}
@@ -4905,20 +4949,20 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event
findnearestNurbvert(&vc, 1, event->mval, &nu, &bezt, &bp);
- if(bezt) {
+ if (bezt) {
a= nu->pntsu;
bezt= nu->bezt;
- while(a--) {
- if(deselect) select_beztriple(bezt, DESELECT, 1, VISIBLE);
+ while (a--) {
+ if (deselect) select_beztriple(bezt, DESELECT, 1, VISIBLE);
else select_beztriple(bezt, SELECT, 1, VISIBLE);
bezt++;
}
}
- else if(bp) {
+ else if (bp) {
a= nu->pntsu*nu->pntsv;
bp= nu->bp;
- while(a--) {
- if(deselect) select_bpoint(bp, DESELECT, 1, VISIBLE);
+ while (a--) {
+ if (deselect) select_bpoint(bp, DESELECT, 1, VISIBLE);
else select_bpoint(bp, SELECT, 1, VISIBLE);
bp++;
}
@@ -4959,41 +5003,41 @@ static int select_row_exec(bContext *C, wmOperator *UNUSED(op))
BPoint *bp;
int u = 0, v = 0, a, b, ok=0;
- if(editnurb->first == NULL)
+ if (editnurb->first == NULL)
return OPERATOR_CANCELLED;
- if(cu->lastsel==NULL)
+ if (cu->lastsel==NULL)
return OPERATOR_CANCELLED;
/* find the correct nurb and toggle with u of v */
- for(nu= editnurb->first; nu; nu= nu->next) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
bp= nu->bp;
- for(v=0; v<nu->pntsv; v++) {
- for(u=0; u<nu->pntsu; u++, bp++) {
- if(bp==cu->lastsel) {
- if(bp->f1 & SELECT) {
+ for (v=0; v<nu->pntsv; v++) {
+ for (u=0; u<nu->pntsu; u++, bp++) {
+ if (bp==cu->lastsel) {
+ if (bp->f1 & SELECT) {
ok= 1;
break;
}
}
}
- if(ok) break;
+ if (ok) break;
}
- if(ok) {
- if(last==cu->lastsel) {
+ if (ok) {
+ if (last==cu->lastsel) {
direction= 1-direction;
setflagsNurb(editnurb, 0);
}
last= cu->lastsel;
bp= nu->bp;
- for(a=0; a<nu->pntsv; a++) {
- for(b=0; b<nu->pntsu; b++, bp++) {
- if(direction) {
- if(a==v) select_bpoint(bp, SELECT, 1, VISIBLE);
+ for (a=0; a<nu->pntsv; a++) {
+ for (b=0; b<nu->pntsu; b++, bp++) {
+ if (direction) {
+ if (a==v) select_bpoint(bp, SELECT, 1, VISIBLE);
}
else {
- if(b==u) select_bpoint(bp, SELECT, 1, VISIBLE);
+ if (b==u) select_bpoint(bp, SELECT, 1, VISIBLE);
}
}
}
@@ -5091,40 +5135,40 @@ static int select_more_exec(bContext *C, wmOperator *UNUSED(op))
/* the behavior of "select more" of mesh tools. */
/* The algorithm is designed to work in planar cases so it */
/* may not be optimal always (example: end of NURBS sphere) */
- if(obedit->type==OB_SURF) {
- for(nu= editnurb->first; nu; nu= nu->next) {
+ if (obedit->type==OB_SURF) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
a= nu->pntsu*nu->pntsv;
bp= nu->bp;
selbpoints= MEM_callocN(sizeof(short)*a-nu->pntsu, "selectlist");
- while(a > 0) {
- if((selbpoints[a]!=1) && (bp->hide==0) && (bp->f1 & SELECT)) {
+ while (a > 0) {
+ if ((selbpoints[a]!=1) && (bp->hide==0) && (bp->f1 & SELECT)) {
/* upper control point */
- if(a%nu->pntsu != 0) {
+ if (a%nu->pntsu != 0) {
tempbp= bp-1;
- if(!(tempbp->f1 & SELECT)) select_bpoint(tempbp, SELECT, 1, VISIBLE);
+ if (!(tempbp->f1 & SELECT)) select_bpoint(tempbp, SELECT, 1, VISIBLE);
}
/* left control point. select only if it is not selected already */
- if(a-nu->pntsu > 0) {
+ if (a-nu->pntsu > 0) {
sel= 0;
tempbp= bp+nu->pntsu;
- if(!(tempbp->f1 & SELECT)) sel= select_bpoint(tempbp, SELECT, 1, VISIBLE);
+ if (!(tempbp->f1 & SELECT)) sel= select_bpoint(tempbp, SELECT, 1, VISIBLE);
/* make sure selected bpoint is discarded */
- if(sel == 1) selbpoints[a-nu->pntsu]= 1;
+ if (sel == 1) selbpoints[a-nu->pntsu]= 1;
}
/* right control point */
- if(a+nu->pntsu < nu->pntsu*nu->pntsv) {
+ if (a+nu->pntsu < nu->pntsu*nu->pntsv) {
tempbp= bp-nu->pntsu;
- if(!(tempbp->f1 & SELECT)) select_bpoint(tempbp, SELECT, 1, VISIBLE);
+ if (!(tempbp->f1 & SELECT)) select_bpoint(tempbp, SELECT, 1, VISIBLE);
}
/* lower control point. skip next bp in case selection was made */
- if(a%nu->pntsu != 1) {
+ if (a%nu->pntsu != 1) {
sel= 0;
tempbp= bp+1;
- if(!(tempbp->f1 & 1)) sel= select_bpoint(tempbp, SELECT, 1, VISIBLE);
- if(sel) {
+ if (!(tempbp->f1 & 1)) sel= select_bpoint(tempbp, SELECT, 1, VISIBLE);
+ if (sel) {
bp++;
a--;
}
@@ -5176,46 +5220,46 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op))
short sel= 0, lastsel= 0;
short *selbpoints;
- if(obedit->type==OB_SURF) {
- for(nu= editnurb->first; nu; nu= nu->next) {
+ if (obedit->type==OB_SURF) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
a= nu->pntsu*nu->pntsv;
bp= nu->bp;
selbpoints= MEM_callocN(sizeof(short)*a, "selectlist");
- while(a--) {
- if((bp->hide==0) && (bp->f1 & SELECT)) {
+ while (a--) {
+ if ((bp->hide==0) && (bp->f1 & SELECT)) {
sel= 0;
/* check if neighbors have been selected */
/* edges of surface are an exception */
- if((a+1)%nu->pntsu==0) sel++;
+ if ((a+1)%nu->pntsu==0) sel++;
else {
bp--;
- if((selbpoints[a+1]==1) || ((bp->hide==0) && (bp->f1 & SELECT))) sel++;
+ if ((selbpoints[a+1]==1) || ((bp->hide==0) && (bp->f1 & SELECT))) sel++;
bp++;
}
- if((a+1)%nu->pntsu==1) sel++;
+ if ((a+1)%nu->pntsu==1) sel++;
else {
bp++;
- if((bp->hide==0) && (bp->f1 & SELECT)) sel++;
+ if ((bp->hide==0) && (bp->f1 & SELECT)) sel++;
bp--;
}
- if(a+1 > nu->pntsu*nu->pntsv-nu->pntsu) sel++;
+ if (a+1 > nu->pntsu*nu->pntsv-nu->pntsu) sel++;
else {
bp-=nu->pntsu;
- if((selbpoints[a+nu->pntsu]==1) || ((bp->hide==0) && (bp->f1 & SELECT))) sel++;
+ if ((selbpoints[a+nu->pntsu]==1) || ((bp->hide==0) && (bp->f1 & SELECT))) sel++;
bp+=nu->pntsu;
}
- if(a < nu->pntsu) sel++;
+ if (a < nu->pntsu) sel++;
else {
bp+=nu->pntsu;
- if((bp->hide==0) && (bp->f1 & SELECT)) sel++;
+ if ((bp->hide==0) && (bp->f1 & SELECT)) sel++;
bp-=nu->pntsu;
}
- if(sel!=4) {
+ if (sel!=4) {
select_bpoint(bp, DESELECT, 1, VISIBLE);
selbpoints[a]= 1;
}
@@ -5229,34 +5273,34 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op))
}
}
else {
- for(nu= editnurb->first; nu; nu= nu->next) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
lastsel=0;
/* check what type of curve/nurb it is */
- if(nu->type == CU_BEZIER) {
+ if (nu->type == CU_BEZIER) {
a= nu->pntsu;
bezt= nu->bezt;
- while(a--) {
- if((bezt->hide==0) && (bezt->f2 & SELECT)) {
- if(lastsel==1) sel= 1;
+ while (a--) {
+ if ((bezt->hide==0) && (bezt->f2 & SELECT)) {
+ if (lastsel==1) sel= 1;
else sel= 0;
/* check if neighbors have been selected */
/* first and last are exceptions */
- if(a==nu->pntsu-1) sel++;
+ if (a==nu->pntsu-1) sel++;
else {
bezt--;
- if((bezt->hide==0) && (bezt->f2 & SELECT)) sel++;
+ if ((bezt->hide==0) && (bezt->f2 & SELECT)) sel++;
bezt++;
}
- if(a==0) sel++;
+ if (a==0) sel++;
else {
bezt++;
- if((bezt->hide==0) && (bezt->f2 & SELECT)) sel++;
+ if ((bezt->hide==0) && (bezt->f2 & SELECT)) sel++;
bezt--;
}
- if(sel!=2) {
+ if (sel!=2) {
select_beztriple(bezt, DESELECT, 1, VISIBLE);
lastsel= 1;
}
@@ -5270,27 +5314,27 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op))
else {
a= nu->pntsu*nu->pntsv;
bp= nu->bp;
- while(a--) {
- if((lastsel==0) && (bp->hide==0) && (bp->f1 & SELECT)) {
- if(lastsel!=0) sel= 1;
+ while (a--) {
+ if ((lastsel==0) && (bp->hide==0) && (bp->f1 & SELECT)) {
+ if (lastsel!=0) sel= 1;
else sel= 0;
/* first and last are exceptions */
- if(a==nu->pntsu*nu->pntsv-1) sel++;
+ if (a==nu->pntsu*nu->pntsv-1) sel++;
else {
bp--;
- if((bp->hide==0) && (bp->f1 & SELECT)) sel++;
+ if ((bp->hide==0) && (bp->f1 & SELECT)) sel++;
bp++;
}
- if(a==0) sel++;
+ if (a==0) sel++;
else {
bp++;
- if((bp->hide==0) && (bp->f1 & SELECT)) sel++;
+ if ((bp->hide==0) && (bp->f1 & SELECT)) sel++;
bp--;
}
- if(sel!=2) {
+ if (sel!=2) {
select_bpoint(bp, DESELECT, 1, VISIBLE);
lastsel= 1;
}
@@ -5334,11 +5378,11 @@ static void selectrandom_curve(ListBase *editnurb, float randfac)
BLI_srand( BLI_rand() ); /* random seed */
- for(nu= editnurb->first; nu; nu= nu->next) {
- if(nu->type == CU_BEZIER) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
+ if (nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
- while(a--) {
+ while (a--) {
if (BLI_frand() < randfac)
select_beztriple(bezt, SELECT, 1, VISIBLE);
bezt++;
@@ -5348,7 +5392,7 @@ static void selectrandom_curve(ListBase *editnurb, float randfac)
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
- while(a--) {
+ while (a--) {
if (BLI_frand() < randfac)
select_bpoint(bp, SELECT, 1, VISIBLE);
bp++;
@@ -5362,7 +5406,7 @@ static int select_random_exec(bContext *C, wmOperator *op)
Object *obedit= CTX_data_edit_object(C);
ListBase *editnurb= object_editcurve_get(obedit);
- if(!RNA_boolean_get(op->ptr, "extend"))
+ if (!RNA_boolean_get(op->ptr, "extend"))
CU_deselect_all(obedit);
selectrandom_curve(editnurb, RNA_float_get(op->ptr, "percent")/100.0f);
@@ -5397,7 +5441,8 @@ static int point_on_nurb(Nurb *nu, void *point)
if (nu->bezt) {
BezTriple *bezt= (BezTriple*)point;
return bezt >= nu->bezt && bezt < nu->bezt + nu->pntsu;
- } else {
+ }
+ else {
BPoint *bp= (BPoint*)point;
return bp >= nu->bp && bp < nu->bp + nu->pntsu * nu->pntsv;
}
@@ -5408,7 +5453,7 @@ static Nurb *get_lastsel_nurb(Curve *cu)
ListBase *nubase= curve_editnurbs(cu);
Nurb *nu= nubase->first;
- if(!cu->lastsel)
+ if (!cu->lastsel)
return NULL;
while (nu) {
@@ -5478,7 +5523,8 @@ int CU_select_nth(Object *obedit, int nth)
if (nu->bezt) {
select_nth_bezt(nu, cu->lastsel, nth);
- } else {
+ }
+ else {
select_nth_bp(nu, cu->lastsel, nth);
}
@@ -5493,7 +5539,8 @@ static int select_nth_exec(bContext *C, wmOperator *op)
if (!CU_select_nth(obedit, nth)) {
if (obedit->type == OB_SURF) {
BKE_report(op->reports, RPT_ERROR, "Surface hasn't got active point");
- } else {
+ }
+ else {
BKE_report(op->reports, RPT_ERROR, "Curve hasn't got active point");
}
@@ -5563,14 +5610,15 @@ static int delete_exec(bContext *C, wmOperator *op)
int a, cut= 0, type= RNA_enum_get(op->ptr, "type");
int nuindex= 0;
- if(obedit->type==OB_SURF) {
- if(type==0) {
+ if (obedit->type==OB_SURF) {
+ if (type==0) {
deleteflagNurb(C, op, 1);
- } else {
+ }
+ else {
keyIndex_delNurbList(editnurb, nubase);
freeNurblist(nubase);
- if(ED_curve_updateAnimPaths(obedit))
+ if (ED_curve_updateAnimPaths(obedit))
WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit);
}
@@ -5580,24 +5628,24 @@ static int delete_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
- if(type==0) {
+ if (type==0) {
/* first loop, can we remove entire pieces? */
Nurb *next;
nu= nubase->first;
- while(nu) {
+ while (nu) {
next= nu->next;
- if(nu->type == CU_BEZIER) {
+ if (nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
- if(a) {
- while(a) {
- if( BEZSELECTED_HIDDENHANDLES(cu, bezt) );
+ if (a) {
+ while (a) {
+ if ( BEZSELECTED_HIDDENHANDLES(cu, bezt) );
else break;
a--;
bezt++;
}
- if(a==0) {
- if(cu->actnu == nuindex)
+ if (a==0) {
+ if (cu->actnu == nuindex)
cu->actnu= -1;
BLI_remlink(nubase, nu);
@@ -5609,15 +5657,15 @@ static int delete_exec(bContext *C, wmOperator *op)
else {
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
- if(a) {
- while(a) {
- if(bp->f1 & SELECT);
+ if (a) {
+ while (a) {
+ if (bp->f1 & SELECT);
else break;
a--;
bp++;
}
- if(a==0) {
- if(cu->actnu == nuindex)
+ if (a==0) {
+ if (cu->actnu == nuindex)
cu->actnu= -1;
BLI_remlink(nubase, nu);
@@ -5639,14 +5687,14 @@ static int delete_exec(bContext *C, wmOperator *op)
}
/* 2nd loop, delete small pieces: just for curves */
nu= nubase->first;
- while(nu) {
+ while (nu) {
next= nu->next;
type= 0;
- if(nu->type == CU_BEZIER) {
+ if (nu->type == CU_BEZIER) {
int delta= 0;
bezt= nu->bezt;
- for(a=0;a<nu->pntsu;a++) {
- if( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) {
+ for (a=0;a<nu->pntsu;a++) {
+ if ( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) {
memmove(bezt, bezt+1, (nu->pntsu-a-1)*sizeof(BezTriple));
keyIndex_delBezt(editnurb, bezt + delta);
keyIndex_updateBezt(editnurb, bezt + 1, bezt, nu->pntsu-a-1);
@@ -5657,7 +5705,7 @@ static int delete_exec(bContext *C, wmOperator *op)
}
else bezt++;
}
- if(type) {
+ if (type) {
bezt1 =
(BezTriple*)MEM_mallocN((nu->pntsu) * sizeof(BezTriple), "delNurb");
memcpy(bezt1, nu->bezt, (nu->pntsu)*sizeof(BezTriple) );
@@ -5667,12 +5715,12 @@ static int delete_exec(bContext *C, wmOperator *op)
calchandlesNurb(nu);
}
}
- else if(nu->pntsv==1) {
+ else if (nu->pntsv==1) {
int delta= 0;
bp= nu->bp;
- for(a=0;a<nu->pntsu;a++) {
- if( bp->f1 & SELECT ) {
+ for (a=0;a<nu->pntsu;a++) {
+ if ( bp->f1 & SELECT ) {
memmove(bp, bp+1, (nu->pntsu-a-1)*sizeof(BPoint));
keyIndex_delBP(editnurb, bp + delta);
keyIndex_updateBP(editnurb, bp+1, bp, nu->pntsu-a-1);
@@ -5685,7 +5733,7 @@ static int delete_exec(bContext *C, wmOperator *op)
bp++;
}
}
- if(type) {
+ if (type) {
bp1 = (BPoint*)MEM_mallocN(nu->pntsu * sizeof(BPoint), "delNurb2");
memcpy(bp1, nu->bp, (nu->pntsu)*sizeof(BPoint) );
keyIndex_updateBP(editnurb, nu->bp, bp1, nu->pntsu);
@@ -5706,26 +5754,26 @@ static int delete_exec(bContext *C, wmOperator *op)
nu= next;
}
}
- else if(type==1) { /* erase segment */
+ else if (type==1) { /* erase segment */
/* find the 2 selected points */
bezt1= bezt2= NULL;
bp1= bp2= NULL;
nu1= NULL;
nuindex= 0;
- for(nu= nubase->first; nu; nu= nu->next) {
- if(nu->type == CU_BEZIER) {
+ for (nu= nubase->first; nu; nu= nu->next) {
+ if (nu->type == CU_BEZIER) {
bezt= nu->bezt;
- for(a=0; a<nu->pntsu-1; a++) {
- if( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) {
+ for (a=0; a<nu->pntsu-1; a++) {
+ if ( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) {
bezt1= bezt;
bezt2= bezt+1;
if ((bezt2->f1 & SELECT) || (bezt2->f2 & SELECT) || (bezt2->f3 & SELECT)) {
/* pass */
}
else { /* maybe do not make cyclic */
- if(a==0 && (nu->flagu & CU_NURB_CYCLIC) ) {
+ if (a==0 && (nu->flagu & CU_NURB_CYCLIC) ) {
bezt2= bezt+(nu->pntsu-1);
- if( (bezt2->f1 & SELECT) || (bezt2->f2 & SELECT) || (bezt2->f3 & SELECT) ) {
+ if ( (bezt2->f1 & SELECT) || (bezt2->f2 & SELECT) || (bezt2->f3 & SELECT) ) {
nu->flagu &= ~CU_NURB_CYCLIC;
calchandlesNurb(nu);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
@@ -5742,19 +5790,19 @@ static int delete_exec(bContext *C, wmOperator *op)
bezt++;
}
}
- else if(nu->pntsv==1) {
+ else if (nu->pntsv==1) {
bp= nu->bp;
- for(a=0; a<nu->pntsu-1; a++) {
- if( bp->f1 & SELECT ) {
+ for (a=0; a<nu->pntsu-1; a++) {
+ if ( bp->f1 & SELECT ) {
bp1= bp;
bp2= bp+1;
if (bp2->f1 & 1) {
/* pass */
}
else { /* maybe do not make cyclic */
- if(a==0 && (nu->flagu & CU_NURB_CYCLIC) ) {
+ if (a==0 && (nu->flagu & CU_NURB_CYCLIC) ) {
bp2= bp+(nu->pntsu-1);
- if( bp2->f1 & SELECT ) {
+ if ( bp2->f1 & SELECT ) {
nu->flagu &= ~CU_NURB_CYCLIC;
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
DAG_id_tag_update(obedit->data, 0);
@@ -5770,19 +5818,19 @@ static int delete_exec(bContext *C, wmOperator *op)
bp++;
}
}
- if(nu1) break;
+ if (nu1) break;
nuindex++;
}
- if(nu1) {
- if(bezt1) {
- if(nu1->pntsu==2) { /* remove completely */
- if(cu->actnu == nuindex)
+ if (nu1) {
+ if (bezt1) {
+ if (nu1->pntsu==2) { /* remove completely */
+ if (cu->actnu == nuindex)
cu->actnu= -1;
BLI_remlink(nubase, nu);
freeNurb(nu); nu = NULL;
}
- else if(nu1->flagu & CU_NURB_CYCLIC) { /* cyclic */
+ else if (nu1->flagu & CU_NURB_CYCLIC) { /* cyclic */
bezt =
(BezTriple*)MEM_mallocN((cut+1) * sizeof(BezTriple), "delNurb1");
ED_curve_beztcpy(editnurb, bezt, nu1->bezt, cut+1);
@@ -5820,15 +5868,15 @@ static int delete_exec(bContext *C, wmOperator *op)
calchandlesNurb(nu1);
}
}
- else if(bp1) {
- if(nu1->pntsu==2) { /* remove completely */
- if(cu->actnu == nuindex)
+ else if (bp1) {
+ if (nu1->pntsu==2) { /* remove completely */
+ if (cu->actnu == nuindex)
cu->actnu= -1;
BLI_remlink(nubase, nu);
freeNurb(nu); nu= NULL;
}
- else if(nu1->flagu & CU_NURB_CYCLIC) { /* cyclic */
+ else if (nu1->flagu & CU_NURB_CYCLIC) { /* cyclic */
bp =
(BPoint*)MEM_mallocN((cut+1) * sizeof(BPoint), "delNurb5");
ED_curve_bpcpy(editnurb, bp, nu1->bp, cut+1);
@@ -5865,13 +5913,13 @@ static int delete_exec(bContext *C, wmOperator *op)
}
}
}
- else if(type==2) {
+ else if (type==2) {
cu->actnu= -1;
keyIndex_delNurbList(editnurb, nubase);
freeNurblist(nubase);
}
- if(ED_curve_updateAnimPaths(obedit))
+ if (ED_curve_updateAnimPaths(obedit))
WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
@@ -5886,7 +5934,7 @@ static int delete_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
uiPopupMenu *pup;
uiLayout *layout;
- if(obedit->type==OB_SURF) {
+ if (obedit->type==OB_SURF) {
pup= uiPupMenuBegin(C, "Delete", ICON_NONE);
layout= uiPupMenuLayout(pup);
uiItemEnumO_ptr(layout, op->type, NULL, 0, "type", 0);
@@ -5937,12 +5985,12 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
Nurb *nu;
int clear= (strcmp(op->idname, "CURVE_OT_shade_flat") == 0);
- if(obedit->type != OB_CURVE)
+ if (obedit->type != OB_CURVE)
return OPERATOR_CANCELLED;
- for(nu= editnurb->first; nu; nu= nu->next) {
- if(isNurbsel(nu)) {
- if(!clear) nu->flag |= CU_SMOOTH;
+ for (nu= editnurb->first; nu; nu= nu->next) {
+ if (isNurbsel(nu)) {
+ if (!clear) nu->flag |= CU_SMOOTH;
else nu->flag &= ~CU_SMOOTH;
}
}
@@ -6002,26 +6050,27 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op))
invert_m4_m4(imat, ob->obmat);
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
- if(base->object->type==ob->type) {
- if(base->object != ob) {
+ if (base->object->type==ob->type) {
+ if (base->object != ob) {
cu= base->object->data;
- if(cu->nurb.first) {
+ if (cu->nurb.first) {
/* watch it: switch order here really goes wrong */
mult_m4_m4m4(cmat, imat, base->object->obmat);
nu= cu->nurb.first;
- while(nu) {
+ while (nu) {
newnu= duplicateNurb(nu);
- if(ob->totcol) { /* TODO, merge material lists */
+ if (ob->totcol) { /* TODO, merge material lists */
CLAMP(newnu->mat_nr, 0, ob->totcol-1);
- } else newnu->mat_nr= 0;
+ }
+ else newnu->mat_nr= 0;
BLI_addtail(&tempbase, newnu);
- if( (bezt= newnu->bezt) ) {
+ if ( (bezt= newnu->bezt) ) {
a= newnu->pntsu;
- while(a--) {
+ while (a--) {
mul_m4_v3(cmat, bezt->vec[0]);
mul_m4_v3(cmat, bezt->vec[1]);
mul_m4_v3(cmat, bezt->vec[2]);
@@ -6029,9 +6078,9 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op))
}
calchandlesNurb(newnu);
}
- if( (bp= newnu->bp) ) {
+ if ( (bp= newnu->bp) ) {
a= newnu->pntsu*nu->pntsv;
- while(a--) {
+ while (a--) {
mul_m4_v3(cmat, bp->vec);
bp++;
}
@@ -6065,7 +6114,7 @@ static const char *get_curve_defname(int type)
{
int stype= type & CU_PRIMITIVE;
- if((type & CU_TYPE)==CU_BEZIER) {
+ if ((type & CU_TYPE)==CU_BEZIER) {
switch (stype) {
case CU_PRIM_CURVE: return "BezierCurve";
case CU_PRIM_CIRCLE: return "BezierCircle";
@@ -6121,7 +6170,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
const int stype= (type & CU_PRIMITIVE);
const int force_3d = ((Curve *)obedit->data)->flag & CU_3D; /* could be adding to an existing 3D curve */
- if(rv3d) {
+ if (rv3d) {
copy_m4_m4(viewmat, rv3d->viewmat);
copy_v3_v3(zvec, rv3d->viewinv[2]);
}
@@ -6139,7 +6188,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
switch(stype) {
case CU_PRIM_CURVE: /* curve */
nu->resolu= cu->resolu;
- if(cutype==CU_BEZIER) {
+ if (cutype==CU_BEZIER) {
if (!force_3d) nu->flag |= CU_2D;
nu->pntsu= 2;
nu->bezt =
@@ -6154,7 +6203,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
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;
@@ -6167,7 +6216,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
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]);
calchandlesNurb(nu);
}
@@ -6179,7 +6228,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
nu->bp= callocstructN(BPoint, 4, "addNurbprim3");
bp= nu->bp;
- for(a=0;a<4;a++, bp++) {
+ for (a=0;a<4;a++, bp++) {
bp->vec[3]= 1.0;
bp->f1= SELECT;
bp->radius = bp->weight = 1.0;
@@ -6197,9 +6246,9 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
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) {
+ if (cutype==CU_NURBS) {
nu->knotsu= NULL; /* nurbs_knot_calc_u allocates */
nurbs_knot_calc_u(nu);
}
@@ -6215,7 +6264,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
nu->bp= callocstructN(BPoint, 5, "addNurbprim3");
bp= nu->bp;
- for(a=0;a<5;a++, bp++) {
+ for (a=0;a<5;a++, bp++) {
bp->vec[3]= 1.0;
bp->f1= SELECT;
bp->radius = bp->weight = 1.0;
@@ -6231,9 +6280,9 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
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) {
+ if (cutype==CU_NURBS) {
nu->knotsu= NULL; /* nurbs_knot_calc_u allocates */
nurbs_knot_calc_u(nu);
}
@@ -6242,7 +6291,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
case CU_PRIM_CIRCLE: /* circle */
nu->resolu= cu->resolu;
- if(cutype==CU_BEZIER) {
+ if (cutype==CU_BEZIER) {
if (!force_3d) nu->flag |= CU_2D;
nu->pntsu= 4;
nu->bezt= callocstructN(BezTriple, 4, "addNurbprim1");
@@ -6252,33 +6301,33 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
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;
calchandlesNurb(nu);
}
- else if( cutype==CU_NURBS ) { /* nurb */
+ else if ( cutype==CU_NURBS ) { /* nurb */
nu->pntsu= 8;
nu->pntsv= 1;
nu->orderu= 4;
@@ -6286,9 +6335,9 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
nu->flagu= CU_NURB_CYCLIC;
bp= nu->bp;
- for(a=0; a<8; a++) {
+ for (a=0; a<8; a++) {
bp->f1= SELECT;
- if(xzproj==0) {
+ if (xzproj==0) {
bp->vec[0]+= nurbcircle[a][0]*grid;
bp->vec[1]+= nurbcircle[a][1]*grid;
}
@@ -6296,7 +6345,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
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;
+ 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;
@@ -6308,7 +6357,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
}
break;
case CU_PRIM_PATCH: /* 4x4 patch */
- if( cutype==CU_NURBS ) { /* nurb */
+ if ( cutype==CU_NURBS ) { /* nurb */
nu->pntsu= 4;
nu->pntsv= 4;
@@ -6320,14 +6369,14 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
nu->flagv= 0;
bp= nu->bp;
- for(a=0; a<4; a++) {
- for(b=0; b<4; b++) {
+ for (a=0; a<4; a++) {
+ for (b=0; b<4; b++) {
bp->f1= SELECT;
fac= (float)a -1.5f;
bp->vec[0]+= fac*grid;
fac= (float)b -1.5f;
bp->vec[1]+= fac*grid;
- if(a==1 || a==2) if(b==1 || b==2) {
+ if (a==1 || a==2) if(b==1 || b==2) {
bp->vec[2]+= grid;
}
mul_m4_v3(mat,bp->vec);
@@ -6341,7 +6390,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
}
break;
case CU_PRIM_TUBE: /* Cylinder */
- if( cutype==CU_NURBS ) {
+ if ( cutype==CU_NURBS ) {
nu= add_nurbs_primitive(C, mat, CU_NURBS|CU_PRIM_CIRCLE, 0); /* circle */
nu->resolu= cu->resolu;
nu->flag= CU_SMOOTH;
@@ -6349,7 +6398,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
vec[0]=vec[1]= 0.0;
vec[2]= -grid;
- if(newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) {
+ if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) {
/* pass */
}
else {
@@ -6367,14 +6416,14 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
a= nu->pntsu*nu->pntsv;
bp= nu->bp;
- while(a-- >0) {
+ while (a-- >0) {
bp->f1 |= SELECT;
bp++;
}
}
break;
case CU_PRIM_SPHERE: /* sphere */
- if( cutype==CU_NURBS ) {
+ if ( cutype==CU_NURBS ) {
float tmp_cent[3] = {0.f, 0.f, 0.f};
float tmp_vec[3] = {0.f, 0.f, 1.f};
@@ -6388,11 +6437,11 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
nu->flagu= 0;
bp= nu->bp;
- for(a=0; a<5; a++) {
+ for (a=0; a<5; a++) {
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;
+ if (a & 1) bp->vec[3]= 0.5*M_SQRT2;
else bp->vec[3]= 1.0;
mul_m4_v3(mat,bp->vec);
bp++;
@@ -6402,7 +6451,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
BLI_addtail(editnurb, nu); /* temporal for spin */
- if(newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) spin_nurb(umat, obedit, tmp_vec, tmp_cent);
+ if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) spin_nurb(umat, obedit, tmp_vec, tmp_cent);
else if ((U.flag & USER_ADD_VIEWALIGNED)) spin_nurb(viewmat, obedit, zvec, mat[3]);
else spin_nurb(umat, obedit, tmp_vec, mat[3]);
@@ -6410,7 +6459,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
a= nu->pntsu*nu->pntsv;
bp= nu->bp;
- while(a-- >0) {
+ while (a-- >0) {
bp->f1 |= SELECT;
bp++;
}
@@ -6418,7 +6467,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
}
break;
case CU_PRIM_DONUT: /* torus */
- if( cutype==CU_NURBS ) {
+ if ( cutype==CU_NURBS ) {
float tmp_cent[3] = {0.f, 0.f, 0.f};
float tmp_vec[3] = {0.f, 0.f, 1.f};
@@ -6431,7 +6480,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
BLI_addtail(editnurb, nu); /* temporal for spin */
/* same as above */
- if(newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) spin_nurb(umat, obedit, tmp_vec, tmp_cent);
+ if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) spin_nurb(umat, obedit, tmp_vec, tmp_cent);
else if ((U.flag & USER_ADD_VIEWALIGNED)) spin_nurb(viewmat, obedit, zvec, mat[3]);
else spin_nurb(umat, obedit, tmp_vec, mat[3]);
@@ -6440,7 +6489,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
a= nu->pntsu*nu->pntsv;
bp= nu->bp;
- while(a-- >0) {
+ while (a-- >0) {
bp->f1 |= SELECT;
bp++;
}
@@ -6455,7 +6504,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
BLI_assert(nu != NULL);
- if(nu) { /* should always be set */
+ if (nu) { /* should always be set */
nu->flag |= CU_SMOOTH;
test2DNurb(nu);
@@ -6475,11 +6524,11 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
float loc[3], rot[3];
float mat[4][4];
- if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, &is_aligned))
+ if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, &is_aligned))
return OPERATOR_CANCELLED;
if (!isSurf) { /* adding curve */
- if(obedit==NULL || obedit->type!=OB_CURVE) {
+ if (obedit==NULL || obedit->type!=OB_CURVE) {
Curve *cu;
obedit= ED_object_add_type(C, OB_CURVE, loc, rot, TRUE, layer);
@@ -6488,13 +6537,13 @@ 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 DAG_id_tag_update(&obedit->id, OB_RECALC_DATA);
}
else { /* adding surface */
- if(obedit==NULL || obedit->type!=OB_SURF) {
+ if (obedit==NULL || obedit->type!=OB_SURF) {
obedit= ED_object_add_type(C, OB_SURF, loc, rot, TRUE, layer);
newob = 1;
}
@@ -6502,9 +6551,9 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
}
/* rename here, the undo stack checks name for valid undo pushes */
- if(newob) {
+ if (newob) {
- if(obedit->type==OB_CURVE) {
+ if (obedit->type==OB_CURVE) {
rename_id((ID *)obedit, get_curve_defname(type));
rename_id((ID *)obedit->data, get_curve_defname(type));
}
@@ -6515,7 +6564,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
}
/* ED_object_add_type doesnt do an undo, is needed for redo operator on primitive */
- if(newob && enter_editmode)
+ if (newob && enter_editmode)
ED_undo_push(C, "Enter Editmode");
ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
@@ -6812,20 +6861,20 @@ static int clear_tilt_exec(bContext *C, wmOperator *UNUSED(op))
BPoint *bp;
int a;
- for(nu= editnurb->first; nu; nu= nu->next) {
- if( nu->bezt ) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
+ if ( nu->bezt ) {
bezt= nu->bezt;
a= nu->pntsu;
- while(a--) {
- if(BEZSELECTED_HIDDENHANDLES(cu, bezt)) bezt->alfa= 0.0;
+ while (a--) {
+ if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) bezt->alfa= 0.0;
bezt++;
}
}
- else if(nu->bp) {
+ else if (nu->bp) {
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
- while(a--) {
- if(bp->f1 & SELECT) bp->alfa= 0.0;
+ while (a--) {
+ if (bp->f1 & SELECT) bp->alfa= 0.0;
bp++;
}
}
@@ -6860,7 +6909,8 @@ static void *undo_check_lastsel(void *lastsel, Nurb *nu, Nurb *newnu)
if (lastbezt >= nu->bezt && lastbezt < nu->bezt + nu->pntsu) {
return newnu->bezt + (lastbezt - nu->bezt);
}
- } else {
+ }
+ else {
BPoint *lastbp= (BPoint*)lastsel;
if (lastbp >= nu->bp && lastbp < nu->bp + nu->pntsu*nu->pntsv) {
return newnu->bp + (lastbp - nu->bp);
@@ -6888,8 +6938,8 @@ static void undoCurve_to_editCurve(void *ucu, void *UNUSED(edata), void *cu_v)
editnurb->keyindex= dupli_keyIndexHash(undoCurve->undoIndex);
}
- if(ad) {
- if(ad->action) {
+ if (ad) {
+ if (ad->action) {
free_fcurves(&ad->action->curves);
copy_fcurves(&ad->action->curves, &undoCurve->fcurves);
}
@@ -6899,7 +6949,7 @@ static void undoCurve_to_editCurve(void *ucu, void *UNUSED(edata), void *cu_v)
}
/* copy */
- for(nu= undobase->first; nu; nu= nu->next) {
+ for (nu= undobase->first; nu; nu= nu->next) {
newnu= duplicateNurb(nu);
if (lastsel == NULL) {
@@ -6938,15 +6988,15 @@ static void *editCurve_to_undoCurve(void *UNUSED(edata), void *cu_v)
tmpEditnurb.keyindex= undoCurve->undoIndex;
}
- if(ad) {
- if(ad->action)
+ if (ad) {
+ if (ad->action)
copy_fcurves(&undoCurve->fcurves, &ad->action->curves);
copy_fcurves(&undoCurve->drivers, &ad->drivers);
}
/* copy */
- for(nu= nubase->first; nu; nu= nu->next) {
+ for (nu= nubase->first; nu; nu= nu->next) {
newnu= duplicateNurb(nu);
if (lastsel == NULL) {
@@ -6972,7 +7022,7 @@ static void free_undoCurve(void *ucv)
freeNurblist(&undoCurve->nubase);
- if(undoCurve->undoIndex)
+ if (undoCurve->undoIndex)
BLI_ghash_free(undoCurve->undoIndex, NULL, (GHashValFreeFP)MEM_freeN);
free_fcurves(&undoCurve->fcurves);
@@ -7009,10 +7059,10 @@ int ED_curve_actSelection(Curve *cu, float center[3])
{
Nurb *nu= get_lastsel_nurb(cu);
- if(!nu)
+ if (!nu)
return 0;
- if(nu->bezt) {
+ if (nu->bezt) {
BezTriple *bezt= cu->lastsel;
copy_v3_v3(center, bezt->vec[1]);
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index 7f31b34b367..1f1d1495276 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -82,130 +82,130 @@ 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 (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;
}
- else if(char1=='c') {
- if(code==',') new= 231;
- if(code=='|') new= 162;
+ else if (char1=='c') {
+ if (code==',') new= 231;
+ if (code=='|') new= 162;
}
- else if(char1=='e') {
- if(code=='`') new= 232;
- else if(code==39) new= 233;
- else if(code=='^') new= 234;
- else if(code=='"') new= 235;
+ else if (char1=='e') {
+ 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;
+ else if (char1=='i') {
+ 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;
+ else if (char1=='n') {
+ 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 (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(char1=='s') {
- if(code=='s') new= 167;
+ else if (char1=='s') {
+ if (code=='s') new= 167;
}
- else if(char1=='u') {
- if(code=='`') new= 249;
- else if(code==39) new= 250;
- else if(code=='^') new= 251;
- else if(code=='"') new= 252;
+ else if (char1=='u') {
+ 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;
+ else if (char1=='y') {
+ 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;
+ 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;
}
- else if(char1=='C') {
- if(code==',') new= 199;
+ else if (char1=='C') {
+ 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;
+ else if (char1=='E') {
+ 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;
+ else if (char1=='I') {
+ 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;
+ else if (char1=='N') {
+ 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;
+ 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;
}
- else if(char1=='U') {
- if(code=='`') new= 217;
- else if(code==39) new= 218;
- else if(code=='^') new= 219;
- else if(code=='"') new= 220;
+ else if (char1=='U') {
+ 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;
+ else if (char1=='Y') {
+ if (code==39) new= 221;
}
- else if(char1=='1') {
- if(code=='4') new= 188;
- if(code=='2') new= 189;
+ else if (char1=='1') {
+ if (code=='4') new= 188;
+ if (code=='2') new= 189;
}
- else if(char1=='3') {
- if(code=='4') new= 190;
+ else if (char1=='3') {
+ if (code=='4') new= 190;
}
- else if(char1==':') {
- if(code=='-') new= 247;
+ else if (char1==':') {
+ if (code=='-') new= 247;
}
- else if(char1=='-') {
- if(code==':') new= 247;
- if(code=='|') new= 135;
- if(code=='+') new= 177;
+ else if (char1=='-') {
+ if (code==':') new= 247;
+ if (code=='|') new= 135;
+ if (code=='+') new= 177;
}
- else if(char1=='|') {
- if(code=='-') new= 135;
- if(code=='=') new= 136;
+ else if (char1=='|') {
+ if (code=='-') new= 135;
+ if (code=='=') new= 136;
}
- else if(char1=='=') {
- if(code=='|') new= 136;
+ else if (char1=='=') {
+ if (code=='|') new= 136;
}
- else if(char1=='+') {
- if(code=='-') new= 177;
+ else if (char1=='+') {
+ if (code=='-') new= 177;
}
- if(new) return new;
+ if (new) return new;
else return char1;
}
@@ -232,12 +232,12 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c)
{
Curve *cu= obedit->data;
- if(cu->len<MAXTEXT-1) {
+ if (cu->len<MAXTEXT-1) {
EditFont *ef= cu->editfont;
int x;
- for(x= cu->len; x>cu->pos; x--) ef->textbuf[x]= ef->textbuf[x-1];
- for(x= cu->len; x>cu->pos; x--) ef->textbufinfo[x]= ef->textbufinfo[x-1];
+ for (x= cu->len; x>cu->pos; x--) ef->textbuf[x]= ef->textbuf[x-1];
+ for (x= cu->len; x>cu->pos; x--) ef->textbufinfo[x]= ef->textbufinfo[x-1];
ef->textbuf[cu->pos]= c;
ef->textbufinfo[cu->pos] = cu->curinfo;
ef->textbufinfo[cu->pos].kern = 0;
@@ -262,7 +262,7 @@ static void text_update_edited(bContext *C, Scene *scene, Object *obedit, int re
EditFont *ef= cu->editfont;
cu->curinfo = ef->textbufinfo[cu->pos?cu->pos-1:0];
- if(obedit->totcol > 0) {
+ if (obedit->totcol > 0) {
obedit->actcol= ef->textbufinfo[cu->pos?cu->pos-1:0].mat_nr;
/* since this array is calloc'd, it can be 0 even though we try ensure
@@ -272,12 +272,12 @@ static void text_update_edited(bContext *C, Scene *scene, Object *obedit, int re
}
}
- if(mode == FO_EDIT)
+ if (mode == FO_EDIT)
update_string(cu);
BKE_text_to_curve(bmain, scene, obedit, mode);
- if(recalc)
+ if (recalc)
DAG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
}
@@ -291,22 +291,22 @@ static int insert_lorem_exec(bContext *C, wmOperator *UNUSED(op))
int i;
static const char *lastlorem;
- if(lastlorem)
+ if (lastlorem)
p= lastlorem;
else
p= ED_lorem;
i= rand()/(RAND_MAX/6)+4;
- for(p2=p; *p2 && i; p2++) {
+ for (p2=p; *p2 && i; p2++) {
insert_into_textbuf(obedit, *p2);
- if(*p2=='.')
+ if (*p2=='.')
i--;
}
lastlorem = p2+1;
- if(strlen(lastlorem)<5)
+ if (strlen(lastlorem)<5)
lastlorem = ED_lorem;
insert_into_textbuf(obedit, '\n');
@@ -350,8 +350,8 @@ static int paste_file(bContext *C, ReportList *reports, const char *filename)
fp= BLI_fopen(filename, "r");
- if(!fp) {
- if(reports)
+ if (!fp) {
+ if (reports)
BKE_reportf(reports, RPT_ERROR, "Failed to open file %s", filename);
return OPERATOR_CANCELLED;
}
@@ -368,7 +368,7 @@ static int paste_file(bContext *C, ReportList *reports, const char *filename)
fclose(fp);
strp[filelen]= 0;
- if(cu->len+filelen<MAXTEXT) {
+ if (cu->len+filelen<MAXTEXT) {
int tmplen;
wchar_t *mem = MEM_callocN((sizeof(wchar_t)*filelen)+(4*sizeof(wchar_t)), "temporary");
tmplen = BLI_strncpy_wchar_from_utf8(mem, strp, filelen + 1);
@@ -398,7 +398,7 @@ static int paste_file_exec(bContext *C, wmOperator *op)
static int paste_file_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
- if(RNA_struct_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath"))
return paste_file_exec(C, op);
WM_event_add_fileselect(C, op);
@@ -452,11 +452,11 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, float
cu->vfont= get_builtin_font();
cu->vfont->id.us++;
- for(tmp=firstline, a=0; cu->len<MAXTEXT && a<totline; tmp=tmp->next, a++)
+ for (tmp=firstline, a=0; cu->len<MAXTEXT && a<totline; tmp=tmp->next, a++)
nchars += strlen(tmp->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_callocN(nchars+4, "str");
cu->strinfo= MEM_callocN((nchars+4)*sizeof(CharInfo), "strinfo");
@@ -465,11 +465,11 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, float
cu->len= 0;
cu->pos= 0;
- for(tmp=firstline, a=0; cu->len<MAXTEXT && a<totline; tmp=tmp->next, a++) {
+ for (tmp=firstline, a=0; cu->len<MAXTEXT && a<totline; tmp=tmp->next, a++) {
strcat(cu->str, tmp->line);
cu->len+= strlen(tmp->line);
- if(tmp->next) {
+ if (tmp->next) {
strcat(cu->str, "\n");
cu->len++;
}
@@ -487,12 +487,12 @@ void ED_text_to_object(bContext *C, Text *text, int 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) {
+ if (split_lines) {
+ for (line=text->lines.first; line; line=line->next) {
/* skip lines with no text, but still make space for them */
- if(line->line[0] == '\0') {
+ if (line->line[0] == '\0') {
linenum++;
continue;
}
@@ -502,7 +502,7 @@ void ED_text_to_object(bContext *C, Text *text, int 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);
@@ -524,19 +524,19 @@ void ED_text_to_object(bContext *C, Text *text, int split_lines)
static short next_word(Curve *cu)
{
short s;
- for(s=cu->pos; (cu->str[s]) && (cu->str[s]!=' ') && (cu->str[s]!='\n') &&
+ for (s=cu->pos; (cu->str[s]) && (cu->str[s]!=' ') && (cu->str[s]!='\n') &&
(cu->str[s]!=1) && (cu->str[s]!='\r'); s++);
- if(cu->str[s]) return(s+1); else return(s);
+ if (cu->str[s]) return(s+1); else return(s);
}
static short prev_word(Curve *cu)
{
short s;
- if(cu->pos==0) return(0);
- for(s=cu->pos-2; (cu->str[s]) && (cu->str[s]!=' ') && (cu->str[s]!='\n') &&
+ if (cu->pos==0) return(0);
+ for (s=cu->pos-2; (cu->str[s]) && (cu->str[s]!=' ') && (cu->str[s]!='\n') &&
(cu->str[s]!=1) && (cu->str[s]!='\r'); s--);
- if(cu->str[s]) return(s+1); else return(s);
+ if (cu->str[s]) return(s+1); else return(s);
}
static int kill_selection(Object *obedit, int ins) /* 1 == new character */
@@ -548,16 +548,16 @@ static int kill_selection(Object *obedit, int ins) /* 1 == new character */
int getfrom;
direction = BKE_font_getselection(obedit, &selstart, &selend);
- if(direction) {
+ if (direction) {
int size;
- if(ins) offset = 1;
- if(cu->pos >= selstart) cu->pos = selstart+offset;
- if((direction == -1) && ins) {
+ if (ins) offset = 1;
+ if (cu->pos >= selstart) cu->pos = selstart+offset;
+ if ((direction == -1) && ins) {
selstart++;
selend++;
}
getfrom = selend+offset;
- if(ins==0) getfrom++;
+ if (ins==0) getfrom++;
size = (cu->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, ((cu->len-selstart)+offset)*sizeof(CharInfo));
@@ -584,11 +584,11 @@ static int set_style(bContext *C, const int style, const int clear)
EditFont *ef= cu->editfont;
int i, selstart, selend;
- if(!BKE_font_getselection(obedit, &selstart, &selend))
+ if (!BKE_font_getselection(obedit, &selstart, &selend))
return OPERATOR_CANCELLED;
- for(i=selstart; i<=selend; i++) {
- if(clear)
+ for (i=selstart; i<=selend; i++) {
+ if (clear)
ef->textbufinfo[i].flag &= ~style;
else
ef->textbufinfo[i].flag |= style;
@@ -635,7 +635,7 @@ static int toggle_style_exec(bContext *C, wmOperator *op)
Curve *cu= obedit->data;
int style, clear, selstart, selend;
- if(!BKE_font_getselection(obedit, &selstart, &selend))
+ if (!BKE_font_getselection(obedit, &selstart, &selend))
return OPERATOR_CANCELLED;
style= RNA_enum_get(op->ptr, "style");
@@ -670,7 +670,7 @@ static void copy_selection(Object *obedit)
{
int selstart, selend;
- if(BKE_font_getselection(obedit, &selstart, &selend)) {
+ if (BKE_font_getselection(obedit, &selstart, &selend)) {
Curve *cu= obedit->data;
EditFont *ef= cu->editfont;
@@ -709,7 +709,7 @@ static int cut_text_exec(bContext *C, wmOperator *UNUSED(op))
Object *obedit= CTX_data_edit_object(C);
int selstart, selend;
- if(!BKE_font_getselection(obedit, &selstart, &selend))
+ if (!BKE_font_getselection(obedit, &selstart, &selend))
return OPERATOR_CANCELLED;
copy_selection(obedit);
@@ -744,8 +744,8 @@ static int paste_selection(Object *obedit, ReportList *reports)
int len= wcslen(ef->copybuf);
// Verify that the copy buffer => [copy buffer len] + cu->len < MAXTEXT
- if(cu->len + len <= MAXTEXT) {
- if(len) {
+ if (cu->len + len <= MAXTEXT) {
+ if (len) {
int size = (cu->len * sizeof(wchar_t)) - (cu->pos*sizeof(wchar_t)) + sizeof(wchar_t);
memmove(ef->textbuf+cu->pos+len, ef->textbuf+cu->pos, size);
memcpy(ef->textbuf+cu->pos, ef->copybuf, len * sizeof(wchar_t));
@@ -770,7 +770,7 @@ static int paste_text_exec(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
- if(!paste_selection(obedit, op->reports))
+ if (!paste_selection(obedit, op->reports))
return OPERATOR_CANCELLED;
text_update_edited(C, scene, obedit, 1, FO_EDIT);
@@ -818,77 +818,77 @@ static int move_cursor(bContext *C, int type, int select)
switch(type) {
case LINE_BEGIN:
- if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
- while(cu->pos>0) {
- if(ef->textbuf[cu->pos-1]=='\n') break;
- if(ef->textbufinfo[cu->pos-1].flag & CU_CHINFO_WRAP) break;
+ if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
+ while (cu->pos>0) {
+ if (ef->textbuf[cu->pos-1]=='\n') break;
+ if (ef->textbufinfo[cu->pos-1].flag & CU_CHINFO_WRAP) break;
cu->pos--;
}
cursmove=FO_CURS;
break;
case LINE_END:
- if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
- while(cu->pos<cu->len) {
- if(ef->textbuf[cu->pos]==0) break;
- if(ef->textbuf[cu->pos]=='\n') break;
- if(ef->textbufinfo[cu->pos].flag & CU_CHINFO_WRAP ) break;
+ if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
+ while (cu->pos<cu->len) {
+ if (ef->textbuf[cu->pos]==0) break;
+ if (ef->textbuf[cu->pos]=='\n') break;
+ if (ef->textbufinfo[cu->pos].flag & CU_CHINFO_WRAP ) break;
cu->pos++;
}
cursmove=FO_CURS;
break;
case PREV_WORD:
- if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
+ if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
cu->pos= prev_word(cu);
cursmove= FO_CURS;
break;
case NEXT_WORD:
- if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
+ if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
cu->pos= next_word(cu);
cursmove= FO_CURS;
break;
case PREV_CHAR:
- if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
+ if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
cu->pos--;
cursmove=FO_CURS;
break;
case NEXT_CHAR:
- if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
+ if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
cu->pos++;
cursmove= FO_CURS;
break;
case PREV_LINE:
- if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
+ if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
cursmove=FO_CURSUP;
break;
case NEXT_LINE:
- if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
+ if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
cursmove= FO_CURSDOWN;
break;
case PREV_PAGE:
- if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
+ if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
cursmove=FO_PAGEUP;
break;
case NEXT_PAGE:
- if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
+ if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
cursmove=FO_PAGEDOWN;
break;
}
- if(cursmove == -1)
+ if (cursmove == -1)
return OPERATOR_CANCELLED;
- if(select == 0) {
- if(cu->selstart) {
+ if (select == 0) {
+ if (cu->selstart) {
struct Main *bmain= CTX_data_main(C);
cu->selstart = cu->selend = 0;
update_string(cu);
@@ -896,13 +896,13 @@ static int move_cursor(bContext *C, int type, int select)
}
}
- if(cu->pos>cu->len) cu->pos= cu->len;
- else if(cu->pos>=MAXTEXT) cu->pos= MAXTEXT;
- else if(cu->pos<0) cu->pos= 0;
+ if (cu->pos>cu->len) cu->pos= cu->len;
+ else if (cu->pos>=MAXTEXT) cu->pos= MAXTEXT;
+ else if (cu->pos<0) cu->pos= 0;
text_update_edited(C, scene, obedit, select, cursmove);
- if(select)
+ if (select)
cu->selend = cu->pos;
return OPERATOR_FINISHED;
@@ -974,7 +974,7 @@ static int change_spacing_exec(bContext *C, wmOperator *op)
kern += delta;
CLAMP(kern, -20, 20);
- if(ef->textbufinfo[cu->pos-1].kern == kern)
+ if (ef->textbufinfo[cu->pos-1].kern == kern)
return OPERATOR_CANCELLED;
ef->textbufinfo[cu->pos-1].kern = kern;
@@ -1012,14 +1012,14 @@ static int change_character_exec(bContext *C, wmOperator *op)
EditFont *ef= cu->editfont;
int character, delta= RNA_int_get(op->ptr, "delta");
- if(cu->pos <= 0)
+ if (cu->pos <= 0)
return OPERATOR_CANCELLED;
character= ef->textbuf[cu->pos - 1];
character += delta;
CLAMP(character, 0, 255);
- if(character == ef->textbuf[cu->pos - 1])
+ if (character == ef->textbuf[cu->pos - 1])
return OPERATOR_CANCELLED;
ef->textbuf[cu->pos - 1]= character;
@@ -1057,9 +1057,9 @@ static int line_break_exec(bContext *C, wmOperator *op)
EditFont *ef= cu->editfont;
const int ctrl= RNA_boolean_get(op->ptr, "ctrl");
- if(ctrl) {
+ if (ctrl) {
insert_into_textbuf(obedit, 1);
- if(ef->textbuf[cu->pos]!='\n')
+ if (ef->textbuf[cu->pos]!='\n')
insert_into_textbuf(obedit, '\n');
}
else
@@ -1109,16 +1109,16 @@ static int delete_exec(bContext *C, wmOperator *op)
EditFont *ef= cu->editfont;
int x, selstart, selend, type= RNA_enum_get(op->ptr, "type");
- if(cu->len == 0)
+ if (cu->len == 0)
return OPERATOR_CANCELLED;
- if(BKE_font_getselection(obedit, &selstart, &selend)) {
- if(type == DEL_NEXT_SEL) type= DEL_SELECTION;
- else if(type == DEL_PREV_SEL) type= DEL_SELECTION;
+ if (BKE_font_getselection(obedit, &selstart, &selend)) {
+ if (type == DEL_NEXT_SEL) type= DEL_SELECTION;
+ else if (type == DEL_PREV_SEL) type= DEL_SELECTION;
}
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) {
@@ -1127,28 +1127,28 @@ static int delete_exec(bContext *C, wmOperator *op)
ef->textbuf[0]= 0;
break;
case DEL_SELECTION:
- if(!kill_selection(obedit, 0))
+ if (!kill_selection(obedit, 0))
return OPERATOR_CANCELLED;
break;
case DEL_PREV_CHAR:
- if(cu->pos<=0)
+ if (cu->pos<=0)
return OPERATOR_CANCELLED;
- for(x=cu->pos;x<=cu->len;x++)
+ for (x=cu->pos;x<=cu->len;x++)
ef->textbuf[x-1]= ef->textbuf[x];
- for(x=cu->pos;x<=cu->len;x++)
+ for (x=cu->pos;x<=cu->len;x++)
ef->textbufinfo[x-1]= ef->textbufinfo[x];
cu->pos--;
ef->textbuf[--cu->len]='\0';
break;
case DEL_NEXT_CHAR:
- if(cu->pos>=cu->len)
+ if (cu->pos>=cu->len)
return OPERATOR_CANCELLED;
- for(x=cu->pos;x<cu->len;x++)
+ for (x=cu->pos;x<cu->len;x++)
ef->textbuf[x]= ef->textbuf[x+1];
- for(x=cu->pos;x<cu->len;x++)
+ for (x=cu->pos;x<cu->len;x++)
ef->textbufinfo[x]= ef->textbufinfo[x+1];
ef->textbuf[--cu->len]='\0';
@@ -1190,7 +1190,7 @@ 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);
@@ -1199,7 +1199,7 @@ 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);
@@ -1223,28 +1223,28 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt)
int event= evt->type, val= evt->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(cu->len!=0 && cu->pos>0)
+ if (RNA_struct_property_is_set(op->ptr, "accent")) {
+ if (cu->len!=0 && cu->pos>0)
accentcode= 1;
return OPERATOR_FINISHED;
}
/* tab should exit editmode, but we allow it to be typed using modifier keys */
- if(event==TABKEY) {
- if((alt||ctrl||shift) == 0)
+ if (event==TABKEY) {
+ if ((alt||ctrl||shift) == 0)
return OPERATOR_PASS_THROUGH;
else
ascii= 9;
}
- else if(event==BACKSPACEKEY)
+ else if (event==BACKSPACEKEY)
ascii= 0;
- if(val && (ascii || evt->utf8_buf[0])) {
+ if (val && (ascii || evt->utf8_buf[0])) {
/* handle case like TAB (== 9) */
- if( (ascii > 31 && ascii < 254 && ascii != 127) ||
+ if ( (ascii > 31 && ascii < 254 && ascii != 127) ||
(ascii==13) ||
(ascii==10) ||
(ascii==8) ||
@@ -1257,34 +1257,34 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt)
insert_into_textbuf(obedit, ascii);
accentcode= 0;
}
- else if(accentcode) {
- if(cu->pos>0) {
+ else if (accentcode) {
+ if (cu->pos>0) {
inserted_text[0]= findaccent(ef->textbuf[cu->pos-1], ascii);
ef->textbuf[cu->pos-1]= inserted_text[0];
}
accentcode= 0;
}
- else if(cu->len<MAXTEXT-1) {
- if(alt) {
+ else if (cu->len<MAXTEXT-1) {
+ if (alt) {
/* might become obsolete, apple has default values for this, other OS's too? */
- if(ascii=='t') ascii= 137;
- else if(ascii=='c') ascii= 169;
- else if(ascii=='f') ascii= 164;
- else if(ascii=='g') ascii= 176;
- else if(ascii=='l') ascii= 163;
- else if(ascii=='r') ascii= 174;
- else if(ascii=='s') ascii= 223;
- else if(ascii=='y') ascii= 165;
- else if(ascii=='.') ascii= 138;
- else if(ascii=='1') ascii= 185;
- else if(ascii=='2') ascii= 178;
- else if(ascii=='3') ascii= 179;
- else if(ascii=='%') ascii= 139;
- else if(ascii=='?') ascii= 191;
- else if(ascii=='!') ascii= 161;
- else if(ascii=='x') ascii= 215;
- else if(ascii=='>') ascii= 187;
- else if(ascii=='<') ascii= 171;
+ if (ascii=='t') ascii= 137;
+ else if (ascii=='c') ascii= 169;
+ else if (ascii=='f') ascii= 164;
+ else if (ascii=='g') ascii= 176;
+ else if (ascii=='l') ascii= 163;
+ else if (ascii=='r') ascii= 174;
+ else if (ascii=='s') ascii= 223;
+ else if (ascii=='y') ascii= 165;
+ else if (ascii=='.') ascii= 138;
+ else if (ascii=='1') ascii= 185;
+ else if (ascii=='2') ascii= 178;
+ else if (ascii=='3') ascii= 179;
+ else if (ascii=='%') ascii= 139;
+ else if (ascii=='?') ascii= 191;
+ else if (ascii=='!') ascii= 161;
+ else if (ascii=='x') ascii= 215;
+ else if (ascii=='>') ascii= 187;
+ else if (ascii=='<') ascii= 171;
}
inserted_text[0]= ascii;
@@ -1300,8 +1300,8 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt)
text_update_edited(C, scene, obedit, 1, FO_EDIT);
}
}
- else if(val && event == BACKSPACEKEY) {
- if(alt && cu->len!=0 && cu->pos>0)
+ else if (val && event == BACKSPACEKEY) {
+ if (alt && cu->len!=0 && cu->pos>0)
accentcode= 1;
return OPERATOR_PASS_THROUGH;
@@ -1309,7 +1309,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt)
else
return OPERATOR_PASS_THROUGH;
- if(inserted_text[0]) {
+ if (inserted_text[0]) {
/* store as utf8 in RNA string */
char inserted_utf8[8] = {0};
@@ -1431,7 +1431,7 @@ void make_editText(Object *obedit)
Curve *cu= obedit->data;
EditFont *ef= cu->editfont;
- if(ef==NULL) {
+ if (ef==NULL) {
ef= cu->editfont= MEM_callocN(sizeof(EditFont), "editfont");
ef->textbuf= MEM_callocN((MAXTEXT+4)*sizeof(wchar_t), "texteditbuf");
@@ -1451,9 +1451,9 @@ void make_editText(Object *obedit)
memcpy(ef->textbufinfo, cu->strinfo, (cu->len)*sizeof(CharInfo));
memcpy(ef->oldstrinfo, cu->strinfo, (cu->len)*sizeof(CharInfo));
- if(cu->pos>cu->len) cu->pos= cu->len;
+ if (cu->pos>cu->len) cu->pos= cu->len;
- if(cu->pos)
+ if (cu->pos)
cu->curinfo = ef->textbufinfo[cu->pos-1];
else
cu->curinfo = ef->textbufinfo[0];
@@ -1474,7 +1474,7 @@ void load_editText(Object *obedit)
update_string(cu);
- if(cu->strinfo)
+ if (cu->strinfo)
MEM_freeN(cu->strinfo);
cu->strinfo= MEM_callocN((cu->len+4)*sizeof(CharInfo), "texteditinfo");
memcpy(cu->strinfo, ef->textbufinfo, (cu->len)*sizeof(CharInfo));
@@ -1483,7 +1483,7 @@ void load_editText(Object *obedit)
/* this memory system is weak... */
- if(cu->selboxes) {
+ if (cu->selboxes) {
MEM_freeN(cu->selboxes);
cu->selboxes= NULL;
}
@@ -1512,18 +1512,18 @@ static int set_case(bContext *C, int ccase)
len= wcslen(ef->textbuf);
str= ef->textbuf;
- while(len) {
- if(*str>='a' && *str<='z')
+ while (len) {
+ if (*str>='a' && *str<='z')
*str-= 32;
len--;
str++;
}
- if(ccase == CASE_LOWER) {
+ if (ccase == CASE_LOWER) {
len= wcslen(ef->textbuf);
str= ef->textbuf;
- while(len) {
- if(*str>='A' && *str<='Z') {
+ while (len) {
+ if (*str>='A' && *str<='Z') {
*str+= 32;
}
len--;
@@ -1571,8 +1571,8 @@ static int toggle_case_exec(bContext *C, wmOperator *UNUSED(op))
len= wcslen(ef->textbuf);
str= ef->textbuf;
- while(len) {
- if(*str>='a' && *str<='z') {
+ while (len) {
+ if (*str>='a' && *str<='z') {
ccase= CASE_LOWER;
break;
}
@@ -1627,18 +1627,18 @@ static int font_open_exec(bContext *C, wmOperator *op)
font= load_vfont(bmain, filepath);
- if(!font) {
- if(op->customdata) MEM_freeN(op->customdata);
+ if (!font) {
+ 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;
- if(pprop->prop) {
+ if (pprop->prop) {
/* when creating new ID blocks, use is already 1, but RNA
* pointer se also increases user, so this compensates it */
font->id.us--;
@@ -1666,14 +1666,14 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
/* hook into UI */
pprop= op->customdata;
- if(pprop->prop) {
+ if (pprop->prop) {
idptr= RNA_property_pointer_get((PointerRNA *)pprop, pprop->prop);
font= idptr.id.data;
}
path = (font && strcmp(font->name, FO_BUILTIN_NAME) != 0)? font->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);
@@ -1711,7 +1711,7 @@ static int font_unlink_exec(bContext *C, wmOperator *op)
uiIDContextProperty(C, &pprop.ptr, &pprop.prop);
- if(pprop.prop==NULL) {
+ if (pprop.prop==NULL) {
BKE_report(op->reports, RPT_ERROR, "Incorrect context for running font unlink");
return OPERATOR_CANCELLED;
}
@@ -1783,7 +1783,7 @@ static void free_undoFont(void *strv)
static void *get_undoFont(bContext *C)
{
Object *obedit= CTX_data_edit_object(C);
- if(obedit && obedit->type==OB_FONT) {
+ if (obedit && obedit->type==OB_FONT) {
return obedit->data;
}
return NULL;