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/editcurve.c')
-rw-r--r--source/blender/editors/curve/editcurve.c98
1 files changed, 48 insertions, 50 deletions
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 4246c889de0..871f00a585c 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -194,7 +194,7 @@ int isNurbsel(Nurb *nu)
BPoint *bp;
int a;
- if((nu->type & 7)==CU_BEZIER) {
+ if(nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
while(a--) {
@@ -219,7 +219,7 @@ int isNurbsel_count(Nurb *nu)
BPoint *bp;
int a, sel=0;
- if((nu->type & 7)==CU_BEZIER) {
+ if(nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
while(a--) {
@@ -247,7 +247,7 @@ void printknots(Object *obedit)
int a, num;
for(nu= editnurb->first; nu; nu= nu->next) {
- if(isNurbsel(nu) && (nu->type & 7)==CU_NURBS) {
+ 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]);
@@ -300,7 +300,7 @@ void load_editNurb(Object *obedit)
newnu= duplicateNurb(nu);
BLI_addtail(&(cu->nurb), newnu);
- if((nu->type & 7)==CU_NURBS) {
+ if(nu->type == CU_NURBS) {
clamp_nurb_order_u(nu);
}
}
@@ -484,7 +484,7 @@ static void setflagsNurb(ListBase *editnurb, short flag)
int a;
for(nu= editnurb->first; nu; nu= nu->next) {
- if( (nu->type & 7)==CU_BEZIER) {
+ if(nu->type == CU_BEZIER) {
a= nu->pntsu;
bezt= nu->bezt;
while(a--) {
@@ -511,7 +511,7 @@ static void rotateflagNurb(ListBase *editnurb, short flag, float *cent, float ro
int a;
for(nu= editnurb->first; nu; nu= nu->next) {
- if((nu->type & 7)==CU_NURBS) {
+ if(nu->type == CU_NURBS) {
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
@@ -540,7 +540,7 @@ static void translateflagNurb(ListBase *editnurb, short flag, float *vec)
int a;
for(nu= editnurb->first; nu; nu= nu->next) {
- if( (nu->type & 7)==CU_BEZIER) {
+ if(nu->type == CU_BEZIER) {
a= nu->pntsu;
bezt= nu->bezt;
while(a--) {
@@ -570,7 +570,7 @@ static void weightflagNurb(ListBase *editnurb, short flag, float w, int mode) /*
int a;
for(nu= editnurb->first; nu; nu= nu->next) {
- if((nu->type & 7)==CU_NURBS) {
+ if(nu->type == CU_NURBS) {
a= nu->pntsu*nu->pntsv;
bp= nu->bp;
while(a--) {
@@ -834,7 +834,7 @@ static void adduplicateflagNurb(Object *obedit, short flag)
nu= editnurb->last;
while(nu) {
- if( (nu->type & 7)==CU_BEZIER) {
+ if(nu->type == CU_BEZIER) {
bezt= nu->bezt;
for(a=0; a<nu->pntsu; a++) {
enda= -1;
@@ -1381,7 +1381,7 @@ static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short
for(nu= editnurb->first; nu; nu= nu->next) {
lastsel=0;
- if((nu->type & 7)==CU_BEZIER) {
+ if(nu->type == CU_BEZIER) {
a= nu->pntsu;
bezt= nu->bezt;
if(next < 0) bezt= (nu->bezt + (a-1));
@@ -1447,7 +1447,7 @@ void selectend_nurb(Object *obedit, short selfirst, short doswap, short selstatu
for(nu= editnurb->first; nu; nu= nu->next) {
sel= 0;
- if((nu->type & 7)==CU_BEZIER) {
+ if(nu->type == CU_BEZIER) {
a= nu->pntsu;
/* which point? */
@@ -1546,7 +1546,7 @@ static short nurb_has_selected_cps(ListBase *editnurb)
int a;
for(nu= editnurb->first; nu; nu= nu->next) {
- if((nu->type & 7)==CU_BEZIER) {
+ if(nu->type == CU_BEZIER) {
a= nu->pntsu;
bezt= nu->bezt;
while(a--) {
@@ -1616,7 +1616,7 @@ static int hide_exec(bContext *C, wmOperator *op)
int a, sel, invert= RNA_boolean_get(op->ptr, "unselected");
for(nu= editnurb->first; nu; nu= nu->next) {
- if((nu->type & 7)==CU_BEZIER) {
+ if(nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
sel= 0;
@@ -1690,7 +1690,7 @@ static int reveal_exec(bContext *C, wmOperator *op)
for(nu= editnurb->first; nu; nu= nu->next) {
nu->hide= 0;
- if((nu->type & 7)==CU_BEZIER) {
+ if(nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
while(a--) {
@@ -1746,7 +1746,7 @@ static int select_inverse_exec(bContext *C, wmOperator *op)
int a;
for(nu= editnurb->first; nu; nu= nu->next) {
- if((nu->type & 7)==CU_BEZIER) {
+ if(nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
while(a--) {
@@ -1814,7 +1814,7 @@ static int subdivide_exec(bContext *C, wmOperator *op)
for(nu= editnurb->first; nu; nu= nu->next) {
amount= 0;
- if((nu->type & 7)==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
@@ -1895,7 +1895,7 @@ static int subdivide_exec(bContext *C, wmOperator *op)
calchandlesNurb(nu);
}
- } /* End of 'if((nu->type & 7)==CU_BEZIER)' */
+ } /* End of 'if(nu->type == CU_BEZIER)' */
else if (nu->pntsv==1) {
/*
All flat lines (ie. co-planar), except flat Nurbs. Flat NURB curves
@@ -1964,7 +1964,7 @@ static int subdivide_exec(bContext *C, wmOperator *op)
}
}
} /* End of 'else if(nu->pntsv==1)' */
- else if((nu->type & 7)==CU_NURBS) {
+ else if(nu->type == CU_NURBS) {
/* This is a very strange test ... */
/**
Subdivide NURB surfaces - nzc 30-5-'00 -
@@ -2163,7 +2163,7 @@ static int subdivide_exec(bContext *C, wmOperator *op)
MEM_freeN(usel);
MEM_freeN(vsel);
- } /* End of 'if((nu->type & 7)==CU_NURBS)' */
+ } /* End of 'if(nu->type == CU_NURBS)' */
}
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
@@ -2256,7 +2256,7 @@ static void findselectedNurbvert(ListBase *editnurb, Nurb **nu, BezTriple **bezt
*bezt= 0;
*bp= 0;
for(nu1= editnurb->first; nu1; nu1= nu1->next) {
- if((nu1->type & 7)==CU_BEZIER) {
+ if(nu1->type == CU_BEZIER) {
bezt1= nu1->bezt;
a= nu1->pntsu;
while(a--) {
@@ -2313,7 +2313,7 @@ static int convertspline(short type, Nurb *nu)
BPoint *bp;
int a, c, nr;
- if((nu->type & 7)==CU_POLY) {
+ if(nu->type == CU_POLY) {
if(type==CU_BEZIER) { /* to Bezier with vecthandles */
nr= nu->pntsu;
bezt =
@@ -2333,13 +2333,11 @@ static int convertspline(short type, Nurb *nu)
MEM_freeN(nu->bp);
nu->bp= 0;
nu->pntsu= nr;
- nu->type &= ~7;
- nu->type |= CU_BEZIER;
+ nu->type = CU_BEZIER;
calchandlesNurb(nu);
}
else if(type==CU_NURBS) {
- nu->type &= ~7;
- nu->type |= CU_NURBS;
+ nu->type = CU_NURBS;
nu->orderu= 4;
nu->flagu &= CU_CYCLIC; /* disable all flags except for cyclic */
nu->flagu += 4;
@@ -2352,7 +2350,7 @@ static int convertspline(short type, Nurb *nu)
}
}
}
- else if((nu->type & 7)==CU_BEZIER) { /* Bezier */
+ else if(nu->type == CU_BEZIER) { /* Bezier */
if(type==0 || type==4) { /* to Poly or Nurb */
nr= 3*nu->pntsu;
nu->bp = MEM_callocN(nr * sizeof(BPoint), "setsplinetype");
@@ -2390,8 +2388,7 @@ static int convertspline(short type, Nurb *nu)
nu->pntsv= 1;
nu->orderu= 4;
nu->orderv= 1;
- nu->type &= ~7;
- nu->type+= type;
+ nu->type |= type;
if(nu->flagu & CU_CYCLIC) c= nu->orderu-1;
else c= 0;
if(type== 4) {
@@ -2401,9 +2398,9 @@ static int convertspline(short type, Nurb *nu)
}
}
}
- else if((nu->type & 7)==CU_NURBS) {
- if(type==0) { /* to Poly */
- nu->type &= ~7;
+ 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 */
nu->knotsu= NULL;
if(nu->knotsv) MEM_freeN(nu->knotsv);
@@ -2438,8 +2435,7 @@ static int convertspline(short type, Nurb *nu)
MEM_freeN(nu->knotsu);
nu->knotsu= NULL;
nu->pntsu= nr;
- nu->type &= ~7;
- nu->type |= CU_BEZIER;
+ nu->type = CU_BEZIER;
}
}
}
@@ -2799,7 +2795,7 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu
}
}
- if((nu1->type & 7)==CU_NURBS) {
+ if(nu1->type == CU_NURBS) {
/* merge knots */
makeknots(nu1, 1);
@@ -2903,7 +2899,7 @@ static int make_segment_exec(bContext *C, wmOperator *op)
/* find both nurbs and points, nu1 will be put behind nu2 */
for(nu= editnurb->first; nu; nu= nu->next) {
if((nu->flagu & CU_CYCLIC)==0) { /* not cyclic */
- if( (nu->type & 7)==CU_BEZIER ) {
+ if(nu->type == CU_BEZIER) {
bezt= nu->bezt;
if(nu1==0) {
if( BEZSELECTED_HIDDENHANDLES(bezt) ) nu1= nu;
@@ -2960,7 +2956,7 @@ static int make_segment_exec(bContext *C, wmOperator *op)
if((nu1 && nu2) && (nu1!=nu2)) {
if( nu1->type==nu2->type) {
- if((nu1->type & 7)==CU_BEZIER) {
+ if(nu1->type == CU_BEZIER) {
bezt =
(BezTriple*)MEM_mallocN((nu1->pntsu+nu2->pntsu) * sizeof(BezTriple), "addsegmentN");
memcpy(bezt, nu2->bezt, nu2->pntsu*sizeof(BezTriple));
@@ -2986,7 +2982,7 @@ static int make_segment_exec(bContext *C, wmOperator *op)
BLI_remlink(editnurb, nu2);
/* now join the knots */
- if((nu1->type & 7)==CU_NURBS) {
+ if(nu1->type == CU_NURBS) {
if(nu1->knotsu==NULL) {
makeknots(nu1, 1);
}
@@ -3266,7 +3262,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
findselectedNurbvert(editnurb, &nu, &bezt, &bp);
if(bezt==0 && bp==0) return OPERATOR_CANCELLED;
- if((nu->type & 7)==CU_BEZIER) {
+ if(nu->type == CU_BEZIER) {
/* which bezpoint? */
if(bezt== nu->bezt) { /* first */
BEZ_DESEL(bezt);
@@ -3485,7 +3481,7 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op)
for(nu= editnurb->first; nu; nu= nu->next) {
if( nu->pntsu>1 || nu->pntsv>1) {
- if( (nu->type & 7)==CU_POLY ) {
+ if(nu->type == CU_POLY) {
a= nu->pntsu;
bp= nu->bp;
while(a--) {
@@ -3496,7 +3492,7 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op)
bp++;
}
}
- else if( (nu->type & 7)==CU_BEZIER ) {
+ else if(nu->type == CU_BEZIER) {
a= nu->pntsu;
bezt= nu->bezt;
while(a--) {
@@ -3508,7 +3504,7 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op)
}
calchandlesNurb(nu);
}
- else if(nu->pntsv==1 && (nu->type & 7)==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;
@@ -3959,7 +3955,7 @@ static int select_less_exec(bContext *C, wmOperator *op)
for(nu= editnurb->first; nu; nu= nu->next) {
lastsel=0;
/* check what type of curve/nurb it is */
- if((nu->type & 7)==CU_BEZIER) {
+ if(nu->type == CU_BEZIER) {
a= nu->pntsu;
bezt= nu->bezt;
while(a--) {
@@ -4105,7 +4101,7 @@ static int select_random_exec(bContext *C, wmOperator *op)
/* select elements */
for(i=1, nu= editnurb->first; nu; nu= nu->next) {
- if((nu->type & 7)==CU_BEZIER) {
+ if(nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
while(a--) {
@@ -4249,7 +4245,7 @@ static int delete_exec(bContext *C, wmOperator *op)
nu= editnurb->first;
while(nu) {
next= nu->next;
- if( (nu->type & 7)==CU_BEZIER ) {
+ if(nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
if(a) {
@@ -4285,7 +4281,7 @@ static int delete_exec(bContext *C, wmOperator *op)
/* Never allow the order to exceed the number of points
- note, this is ok but changes unselected nurbs, disable for now */
/*
- if ((nu!= NULL) && ((nu->type & 7)==CU_NURBS)) {
+ if ((nu!= NULL) && (nu->type == CU_NURBS)) {
clamp_nurb_order_u(nu);
}
*/
@@ -4296,7 +4292,7 @@ static int delete_exec(bContext *C, wmOperator *op)
while(nu) {
next= nu->next;
type= 0;
- if( (nu->type & 7)==CU_BEZIER ) {
+ if(nu->type == CU_BEZIER) {
bezt= nu->bezt;
for(a=0;a<nu->pntsu;a++) {
if( BEZSELECTED_HIDDENHANDLES(bezt) ) {
@@ -4339,7 +4335,7 @@ static int delete_exec(bContext *C, wmOperator *op)
/* Never allow the order to exceed the number of points\
- note, this is ok but changes unselected nurbs, disable for now */
/*
- if ((nu->type & 7)==CU_NURBS) {
+ if (nu->type == CU_NURBS) {
clamp_nurb_order_u(nu);
}*/
}
@@ -4356,7 +4352,7 @@ static int delete_exec(bContext *C, wmOperator *op)
nu1= 0;
while(nu) {
next= nu->next;
- if( (nu->type & 7)==CU_BEZIER ) {
+ if(nu->type == CU_BEZIER) {
bezt= nu->bezt;
for(a=0; a<nu->pntsu-1; a++) {
if( BEZSELECTED_HIDDENHANDLES(bezt) ) {
@@ -4730,7 +4726,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname)
/* these types call this function to return a Nurb */
if (stype!=CU_PRIM_TUBE && stype!=CU_PRIM_DONUT) {
nu = (Nurb*)MEM_callocN(sizeof(Nurb), "addNurbprim");
- nu->type= type;
+ nu->type= cutype;
nu->resolu= 4;
nu->resolv= 4;
}
@@ -4743,6 +4739,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname)
rename_id((ID *)obedit->data, "Curve");
}
if(cutype==CU_BEZIER) {
+ nu->flag= CU_2D;
nu->pntsu= 2;
nu->bezt =
(BezTriple*)MEM_callocN(2 * sizeof(BezTriple), "addNurbprim1");
@@ -4851,6 +4848,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname)
rename_id((ID *)obedit->data, "CurveCircle");
}
if(cutype==CU_BEZIER) {
+ nu->flag= CU_2D;
nu->pntsu= 4;
nu->bezt= callocstructN(BezTriple, 4, "addNurbprim1");
nu->flagu= CU_CYCLIC;
@@ -5077,7 +5075,7 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname)
}
/* always do: */
- nu->flag= CU_SMOOTH;
+ nu->flag |= CU_SMOOTH;
test2DNurb(nu);