First commit and merge from trunk for testing.
Merge: 14970-14988
This commit is contained in:
@@ -39,8 +39,8 @@ struct ListBase;
|
|||||||
struct BezTriple;
|
struct BezTriple;
|
||||||
struct BevList;
|
struct BevList;
|
||||||
|
|
||||||
#define KNOTSU(nu) ( (nu)->orderu+ (nu)->pntsu+ (nu->orderu-1)*((nu)->flagu & 1) )
|
#define KNOTSU(nu) ( (nu)->orderu+ (nu)->pntsu+ (nu->orderu-1)*((nu)->flagu & CU_CYCLIC) )
|
||||||
#define KNOTSV(nu) ( (nu)->orderv+ (nu)->pntsv+ (nu->orderv-1)*((nu)->flagv & 1) )
|
#define KNOTSV(nu) ( (nu)->orderv+ (nu)->pntsv+ (nu->orderv-1)*((nu)->flagv & CU_CYCLIC) )
|
||||||
|
|
||||||
|
|
||||||
void unlink_curve( struct Curve *cu);
|
void unlink_curve( struct Curve *cu);
|
||||||
@@ -84,5 +84,12 @@ void switchdirectionNurb( struct Nurb *nu);
|
|||||||
float (*curve_getVertexCos(struct Curve *cu, struct ListBase *lb, int *numVerts_r))[3];
|
float (*curve_getVertexCos(struct Curve *cu, struct ListBase *lb, int *numVerts_r))[3];
|
||||||
void curve_applyVertexCos(struct Curve *cu, struct ListBase *lb, float (*vertexCos)[3]);
|
void curve_applyVertexCos(struct Curve *cu, struct ListBase *lb, float (*vertexCos)[3]);
|
||||||
|
|
||||||
|
/* nurb checks if they can be drawn, also clamp order func */
|
||||||
|
int check_valid_nurb_u( struct Nurb *nu);
|
||||||
|
int check_valid_nurb_v( struct Nurb *nu);
|
||||||
|
|
||||||
|
int clamp_nurb_order_u( struct Nurb *nu);
|
||||||
|
int clamp_nurb_order_v( struct Nurb *nu);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -348,9 +348,9 @@ void freeNurb(Nurb *nu)
|
|||||||
if(nu->bp) MEM_freeN(nu->bp);
|
if(nu->bp) MEM_freeN(nu->bp);
|
||||||
nu->bp= 0;
|
nu->bp= 0;
|
||||||
if(nu->knotsu) MEM_freeN(nu->knotsu);
|
if(nu->knotsu) MEM_freeN(nu->knotsu);
|
||||||
nu->knotsu= 0;
|
nu->knotsu= NULL;
|
||||||
if(nu->knotsv) MEM_freeN(nu->knotsv);
|
if(nu->knotsv) MEM_freeN(nu->knotsv);
|
||||||
nu->knotsv= 0;
|
nu->knotsv= NULL;
|
||||||
/* if(nu->trim.first) freeNurblist(&(nu->trim)); */
|
/* if(nu->trim.first) freeNurblist(&(nu->trim)); */
|
||||||
|
|
||||||
MEM_freeN(nu);
|
MEM_freeN(nu);
|
||||||
@@ -393,7 +393,7 @@ Nurb *duplicateNurb(Nurb *nu)
|
|||||||
(BPoint*)MEM_mallocN((len)* sizeof(BPoint),"duplicateNurb3");
|
(BPoint*)MEM_mallocN((len)* sizeof(BPoint),"duplicateNurb3");
|
||||||
memcpy(newnu->bp, nu->bp, len*sizeof(BPoint));
|
memcpy(newnu->bp, nu->bp, len*sizeof(BPoint));
|
||||||
|
|
||||||
newnu->knotsu=newnu->knotsv= 0;
|
newnu->knotsu= newnu->knotsv= NULL;
|
||||||
|
|
||||||
if(nu->knotsu) {
|
if(nu->knotsu) {
|
||||||
len= KNOTSU(nu);
|
len= KNOTSU(nu);
|
||||||
@@ -506,6 +506,7 @@ static void calcknots(float *knots, short aantal, short order, short type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(type==2) {
|
else if(type==2) {
|
||||||
|
/* Warning, the order MUST be 2 or 4, if this is not enforced, the displist will be corrupt */
|
||||||
if(order==4) {
|
if(order==4) {
|
||||||
k= 0.34;
|
k= 0.34;
|
||||||
for(a=0;a<t;a++) {
|
for(a=0;a<t;a++) {
|
||||||
@@ -520,6 +521,9 @@ static void calcknots(float *knots, short aantal, short order, short type)
|
|||||||
knots[a]= (float)floor(k);
|
knots[a]= (float)floor(k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
printf("bez nurb curve order is not 3 or 4, should never happen\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -529,7 +533,8 @@ static void makecyclicknots(float *knots, short pnts, short order)
|
|||||||
int a, b, order2, c;
|
int a, b, order2, c;
|
||||||
|
|
||||||
if(knots==0) return;
|
if(knots==0) return;
|
||||||
order2=order-1;
|
|
||||||
|
order2=order-1;
|
||||||
|
|
||||||
/* do first long rows (order -1), remove identical knots at endpoints */
|
/* do first long rows (order -1), remove identical knots at endpoints */
|
||||||
if(order>2) {
|
if(order>2) {
|
||||||
@@ -549,26 +554,35 @@ static void makecyclicknots(float *knots, short pnts, short order)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void makeknots(Nurb *nu, short uv, short type) /* 0: uniform, 1: endpoints, 2: bezier */
|
/* type - 0: uniform, 1: endpoints, 2: bezier, note, cyclic nurbs are always uniform */
|
||||||
|
void makeknots(Nurb *nu, short uv, short type)
|
||||||
{
|
{
|
||||||
if( (nu->type & 7)==CU_NURBS ) {
|
if( (nu->type & 7)==CU_NURBS ) {
|
||||||
if(uv & 1) {
|
if(uv == 1) {
|
||||||
if(nu->knotsu) MEM_freeN(nu->knotsu);
|
if(nu->knotsu) MEM_freeN(nu->knotsu);
|
||||||
if(nu->pntsu>1) {
|
if(check_valid_nurb_u(nu)) {
|
||||||
nu->knotsu= MEM_callocN(4+sizeof(float)*KNOTSU(nu), "makeknots");
|
nu->knotsu= MEM_callocN(4+sizeof(float)*KNOTSU(nu), "makeknots");
|
||||||
calcknots(nu->knotsu, nu->pntsu, nu->orderu, type);
|
if(nu->flagu & CU_CYCLIC) {
|
||||||
if(nu->flagu & 1) makecyclicknots(nu->knotsu, nu->pntsu, nu->orderu);
|
calcknots(nu->knotsu, nu->pntsu, nu->orderu, 0); /* cyclic should be uniform */
|
||||||
|
makecyclicknots(nu->knotsu, nu->pntsu, nu->orderu);
|
||||||
|
} else {
|
||||||
|
calcknots(nu->knotsu, nu->pntsu, nu->orderu, type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else nu->knotsu= 0;
|
else nu->knotsu= NULL;
|
||||||
}
|
|
||||||
if(uv & 2) {
|
} else if(uv == 2) {
|
||||||
if(nu->knotsv) MEM_freeN(nu->knotsv);
|
if(nu->knotsv) MEM_freeN(nu->knotsv);
|
||||||
if(nu->pntsv>1) {
|
if(check_valid_nurb_v(nu)) {
|
||||||
nu->knotsv= MEM_callocN(4+sizeof(float)*KNOTSV(nu), "makeknots");
|
nu->knotsv= MEM_callocN(4+sizeof(float)*KNOTSV(nu), "makeknots");
|
||||||
calcknots(nu->knotsv, nu->pntsv, nu->orderv, type);
|
if(nu->flagv & CU_CYCLIC) {
|
||||||
if(nu->flagv & 1) makecyclicknots(nu->knotsv, nu->pntsv, nu->orderv);
|
calcknots(nu->knotsv, nu->pntsv, nu->orderv, 0); /* cyclic should be uniform */
|
||||||
|
makecyclicknots(nu->knotsv, nu->pntsv, nu->orderv);
|
||||||
|
} else {
|
||||||
|
calcknots(nu->knotsv, nu->pntsv, nu->orderv, type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else nu->knotsv= 0;
|
else nu->knotsv= NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -645,7 +659,7 @@ void makeNurbfaces(Nurb *nu, float *data, int rowstride)
|
|||||||
int i, j, iofs, jofs, cycl, len, resolu, resolv;
|
int i, j, iofs, jofs, cycl, len, resolu, resolv;
|
||||||
int istart, iend, jsta, jen, *jstart, *jend, ratcomp;
|
int istart, iend, jsta, jen, *jstart, *jend, ratcomp;
|
||||||
|
|
||||||
if(nu->knotsu==0 || nu->knotsv==0) return;
|
if(nu->knotsu==NULL || nu->knotsv==NULL) return;
|
||||||
if(nu->orderu>nu->pntsu) return;
|
if(nu->orderu>nu->pntsu) return;
|
||||||
if(nu->orderv>nu->pntsv) return;
|
if(nu->orderv>nu->pntsv) return;
|
||||||
if(data==0) return;
|
if(data==0) return;
|
||||||
@@ -679,24 +693,24 @@ void makeNurbfaces(Nurb *nu, float *data, int rowstride)
|
|||||||
|
|
||||||
fp= nu->knotsu;
|
fp= nu->knotsu;
|
||||||
ustart= fp[nu->orderu-1];
|
ustart= fp[nu->orderu-1];
|
||||||
if(nu->flagu & 1) uend= fp[nu->pntsu+nu->orderu-1];
|
if(nu->flagu & CU_CYCLIC) uend= fp[nu->pntsu+nu->orderu-1];
|
||||||
else uend= fp[nu->pntsu];
|
else uend= fp[nu->pntsu];
|
||||||
ustep= (uend-ustart)/(resolu-1+(nu->flagu & 1));
|
ustep= (uend-ustart)/(resolu-1+(nu->flagu & CU_CYCLIC));
|
||||||
basisu= (float *)MEM_mallocN(sizeof(float)*KNOTSU(nu), "makeNurbfaces3");
|
basisu= (float *)MEM_mallocN(sizeof(float)*KNOTSU(nu), "makeNurbfaces3");
|
||||||
|
|
||||||
fp= nu->knotsv;
|
fp= nu->knotsv;
|
||||||
vstart= fp[nu->orderv-1];
|
vstart= fp[nu->orderv-1];
|
||||||
|
|
||||||
if(nu->flagv & 1) vend= fp[nu->pntsv+nu->orderv-1];
|
if(nu->flagv & CU_CYCLIC) vend= fp[nu->pntsv+nu->orderv-1];
|
||||||
else vend= fp[nu->pntsv];
|
else vend= fp[nu->pntsv];
|
||||||
vstep= (vend-vstart)/(resolv-1+(nu->flagv & 1));
|
vstep= (vend-vstart)/(resolv-1+(nu->flagv & CU_CYCLIC));
|
||||||
len= KNOTSV(nu);
|
len= KNOTSV(nu);
|
||||||
basisv= (float *)MEM_mallocN(sizeof(float)*len*resolv, "makeNurbfaces3");
|
basisv= (float *)MEM_mallocN(sizeof(float)*len*resolv, "makeNurbfaces3");
|
||||||
jstart= (int *)MEM_mallocN(sizeof(float)*resolv, "makeNurbfaces4");
|
jstart= (int *)MEM_mallocN(sizeof(float)*resolv, "makeNurbfaces4");
|
||||||
jend= (int *)MEM_mallocN(sizeof(float)*resolv, "makeNurbfaces5");
|
jend= (int *)MEM_mallocN(sizeof(float)*resolv, "makeNurbfaces5");
|
||||||
|
|
||||||
/* precalculation of basisv and jstart,jend */
|
/* precalculation of basisv and jstart,jend */
|
||||||
if(nu->flagv & 1) cycl= nu->orderv-1;
|
if(nu->flagv & CU_CYCLIC) cycl= nu->orderv-1;
|
||||||
else cycl= 0;
|
else cycl= 0;
|
||||||
v= vstart;
|
v= vstart;
|
||||||
basis= basisv;
|
basis= basisv;
|
||||||
@@ -706,7 +720,7 @@ void makeNurbfaces(Nurb *nu, float *data, int rowstride)
|
|||||||
v+= vstep;
|
v+= vstep;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(nu->flagu & 1) cycl= nu->orderu-1;
|
if(nu->flagu & CU_CYCLIC) cycl= nu->orderu-1;
|
||||||
else cycl= 0;
|
else cycl= 0;
|
||||||
in= data;
|
in= data;
|
||||||
u= ustart;
|
u= ustart;
|
||||||
@@ -803,7 +817,7 @@ void makeNurbcurve(Nurb *nu, float *data, int resolu, int dim)
|
|||||||
float *basisu, *sum, *fp, *in;
|
float *basisu, *sum, *fp, *in;
|
||||||
int i, len, istart, iend, cycl;
|
int i, len, istart, iend, cycl;
|
||||||
|
|
||||||
if(nu->knotsu==0) return;
|
if(nu->knotsu==NULL) return;
|
||||||
if(nu->orderu>nu->pntsu) return;
|
if(nu->orderu>nu->pntsu) return;
|
||||||
if(data==0) return;
|
if(data==0) return;
|
||||||
|
|
||||||
@@ -820,12 +834,12 @@ void makeNurbcurve(Nurb *nu, float *data, int resolu, int dim)
|
|||||||
|
|
||||||
fp= nu->knotsu;
|
fp= nu->knotsu;
|
||||||
ustart= fp[nu->orderu-1];
|
ustart= fp[nu->orderu-1];
|
||||||
if(nu->flagu & 1) uend= fp[nu->pntsu+nu->orderu-1];
|
if(nu->flagu & CU_CYCLIC) uend= fp[nu->pntsu+nu->orderu-1];
|
||||||
else uend= fp[nu->pntsu];
|
else uend= fp[nu->pntsu];
|
||||||
ustep= (uend-ustart)/(resolu-1+(nu->flagu & 1));
|
ustep= (uend-ustart)/(resolu-1+(nu->flagu & CU_CYCLIC));
|
||||||
basisu= (float *)MEM_mallocN(sizeof(float)*KNOTSU(nu), "makeNurbcurve3");
|
basisu= (float *)MEM_mallocN(sizeof(float)*KNOTSU(nu), "makeNurbcurve3");
|
||||||
|
|
||||||
if(nu->flagu & 1) cycl= nu->orderu-1;
|
if(nu->flagu & CU_CYCLIC) cycl= nu->orderu-1;
|
||||||
else cycl= 0;
|
else cycl= 0;
|
||||||
|
|
||||||
in= data;
|
in= data;
|
||||||
@@ -1425,14 +1439,14 @@ static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float *
|
|||||||
|
|
||||||
/* returns a point */
|
/* returns a point */
|
||||||
if(prevbezt==nu->bezt) {
|
if(prevbezt==nu->bezt) {
|
||||||
if(nu->flagu & 1) pprev= last;
|
if(nu->flagu & CU_CYCLIC) pprev= last;
|
||||||
else pprev= prevbezt;
|
else pprev= prevbezt;
|
||||||
}
|
}
|
||||||
else pprev= prevbezt-1;
|
else pprev= prevbezt-1;
|
||||||
|
|
||||||
/* next point */
|
/* next point */
|
||||||
if(bezt==last) {
|
if(bezt==last) {
|
||||||
if(nu->flagu & 1) next= nu->bezt;
|
if(nu->flagu & CU_CYCLIC) next= nu->bezt;
|
||||||
else next= bezt;
|
else next= bezt;
|
||||||
}
|
}
|
||||||
else next= bezt+1;
|
else next= bezt+1;
|
||||||
@@ -1478,7 +1492,7 @@ void makeBevelList(Object *ob)
|
|||||||
while(nu) {
|
while(nu) {
|
||||||
/* check we are a single point? also check we are not a surface and that the orderu is sane,
|
/* check we are a single point? also check we are not a surface and that the orderu is sane,
|
||||||
* enforced in the UI but can go wrong possibly */
|
* enforced in the UI but can go wrong possibly */
|
||||||
if(nu->pntsu<2 || ((nu->type & 7)==CU_NURBS && nu->pntsu < nu->orderu)) {
|
if(!check_valid_nurb_u(nu)) {
|
||||||
bl= MEM_callocN(sizeof(BevList)+1*sizeof(BevPoint), "makeBevelList");
|
bl= MEM_callocN(sizeof(BevList)+1*sizeof(BevPoint), "makeBevelList");
|
||||||
BLI_addtail(&(cu->bev), bl);
|
BLI_addtail(&(cu->bev), bl);
|
||||||
bl->nr= 0;
|
bl->nr= 0;
|
||||||
@@ -1493,7 +1507,7 @@ void makeBevelList(Object *ob)
|
|||||||
bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelList");
|
bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelList");
|
||||||
BLI_addtail(&(cu->bev), bl);
|
BLI_addtail(&(cu->bev), bl);
|
||||||
|
|
||||||
if(nu->flagu & 1) bl->poly= 0;
|
if(nu->flagu & CU_CYCLIC) bl->poly= 0;
|
||||||
else bl->poly= -1;
|
else bl->poly= -1;
|
||||||
bl->nr= len;
|
bl->nr= len;
|
||||||
bl->flag= 0;
|
bl->flag= 0;
|
||||||
@@ -1512,17 +1526,17 @@ void makeBevelList(Object *ob)
|
|||||||
}
|
}
|
||||||
else if((nu->type & 7)==CU_BEZIER) {
|
else if((nu->type & 7)==CU_BEZIER) {
|
||||||
|
|
||||||
len= resolu*(nu->pntsu+ (nu->flagu & 1) -1)+1; /* in case last point is not cyclic */
|
len= resolu*(nu->pntsu+ (nu->flagu & CU_CYCLIC) -1)+1; /* in case last point is not cyclic */
|
||||||
bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelList");
|
bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelList");
|
||||||
BLI_addtail(&(cu->bev), bl);
|
BLI_addtail(&(cu->bev), bl);
|
||||||
|
|
||||||
if(nu->flagu & 1) bl->poly= 0;
|
if(nu->flagu & CU_CYCLIC) bl->poly= 0;
|
||||||
else bl->poly= -1;
|
else bl->poly= -1;
|
||||||
bevp= (BevPoint *)(bl+1);
|
bevp= (BevPoint *)(bl+1);
|
||||||
|
|
||||||
a= nu->pntsu-1;
|
a= nu->pntsu-1;
|
||||||
bezt= nu->bezt;
|
bezt= nu->bezt;
|
||||||
if(nu->flagu & 1) {
|
if(nu->flagu & CU_CYCLIC) {
|
||||||
a++;
|
a++;
|
||||||
prevbezt= nu->bezt+(nu->pntsu-1);
|
prevbezt= nu->bezt+(nu->pntsu-1);
|
||||||
}
|
}
|
||||||
@@ -1595,7 +1609,7 @@ void makeBevelList(Object *ob)
|
|||||||
MEM_freeN(data);
|
MEM_freeN(data);
|
||||||
MEM_freeN(data_a);
|
MEM_freeN(data_a);
|
||||||
|
|
||||||
if((nu->flagu & 1)==0) { /* not cyclic: endpoint */
|
if((nu->flagu & CU_CYCLIC)==0) { /* not cyclic: endpoint */
|
||||||
bevp->x= prevbezt->vec[1][0];
|
bevp->x= prevbezt->vec[1][0];
|
||||||
bevp->y= prevbezt->vec[1][1];
|
bevp->y= prevbezt->vec[1][1];
|
||||||
bevp->z= prevbezt->vec[1][2];
|
bevp->z= prevbezt->vec[1][2];
|
||||||
@@ -1611,7 +1625,7 @@ void makeBevelList(Object *ob)
|
|||||||
BLI_addtail(&(cu->bev), bl);
|
BLI_addtail(&(cu->bev), bl);
|
||||||
bl->nr= len;
|
bl->nr= len;
|
||||||
bl->flag= 0;
|
bl->flag= 0;
|
||||||
if(nu->flagu & 1) bl->poly= 0;
|
if(nu->flagu & CU_CYCLIC) bl->poly= 0;
|
||||||
else bl->poly= -1;
|
else bl->poly= -1;
|
||||||
bevp= (BevPoint *)(bl+1);
|
bevp= (BevPoint *)(bl+1);
|
||||||
|
|
||||||
@@ -2209,7 +2223,7 @@ void calchandlesNurb(Nurb *nu) /* first, if needed, set handle flags */
|
|||||||
|
|
||||||
a= nu->pntsu;
|
a= nu->pntsu;
|
||||||
bezt= nu->bezt;
|
bezt= nu->bezt;
|
||||||
if(nu->flagu & 1) prev= bezt+(a-1);
|
if(nu->flagu & CU_CYCLIC) prev= bezt+(a-1);
|
||||||
else prev= 0;
|
else prev= 0;
|
||||||
next= bezt+1;
|
next= bezt+1;
|
||||||
|
|
||||||
@@ -2217,7 +2231,7 @@ void calchandlesNurb(Nurb *nu) /* first, if needed, set handle flags */
|
|||||||
calchandleNurb(bezt, prev, next, 0);
|
calchandleNurb(bezt, prev, next, 0);
|
||||||
prev= bezt;
|
prev= bezt;
|
||||||
if(a==1) {
|
if(a==1) {
|
||||||
if(nu->flagu & 1) next= nu->bezt;
|
if(nu->flagu & CU_CYCLIC) next= nu->bezt;
|
||||||
else next= 0;
|
else next= 0;
|
||||||
}
|
}
|
||||||
else next++;
|
else next++;
|
||||||
@@ -2608,3 +2622,63 @@ void curve_applyVertexCos(Curve *cu, ListBase *lb, float (*vertexCos)[3])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int check_valid_nurb_u( struct Nurb *nu )
|
||||||
|
{
|
||||||
|
if (nu==NULL) return 0;
|
||||||
|
if (nu->pntsu <= 1) return 0;
|
||||||
|
if ((nu->type & 7)!=CU_NURBS) return 1; /* not a nurb, lets assume its valid */
|
||||||
|
|
||||||
|
if (nu->pntsu < nu->orderu) return 0;
|
||||||
|
if (((nu->flag & CU_CYCLIC)==0) && ((nu->flagu>>1) & 2)) { /* Bezier U Endpoints */
|
||||||
|
if (nu->orderu==4) {
|
||||||
|
if (nu->pntsu < 5) return 0; /* bezier with 4 orderu needs 5 points */
|
||||||
|
} else if (nu->orderu != 3) return 0; /* order must be 3 or 4 */
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
int check_valid_nurb_v( struct Nurb *nu)
|
||||||
|
{
|
||||||
|
if (nu==NULL) return 0;
|
||||||
|
if (nu->pntsv <= 1) return 0;
|
||||||
|
if ((nu->type & 7)!=CU_NURBS) return 1; /* not a nurb, lets assume its valid */
|
||||||
|
|
||||||
|
if (nu->pntsv < nu->orderv) return 0;
|
||||||
|
if (((nu->flag & CU_CYCLIC)==0) && ((nu->flagv>>1) & 2)) { /* Bezier V Endpoints */
|
||||||
|
if (nu->orderv==4) {
|
||||||
|
if (nu->pntsv < 5) return 0; /* bezier with 4 orderu needs 5 points */
|
||||||
|
} else if (nu->orderv != 3) return 0; /* order must be 3 or 4 */
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int clamp_nurb_order_u( struct Nurb *nu )
|
||||||
|
{
|
||||||
|
int change = 0;
|
||||||
|
if(nu->pntsu<nu->orderu) {
|
||||||
|
nu->orderu= nu->pntsu;
|
||||||
|
change= 1;
|
||||||
|
}
|
||||||
|
if(((nu->flag & CU_CYCLIC)==0) && (nu->flagu>>1)&2) {
|
||||||
|
CLAMP(nu->orderu, 3,4);
|
||||||
|
change= 1;
|
||||||
|
}
|
||||||
|
return change;
|
||||||
|
}
|
||||||
|
|
||||||
|
int clamp_nurb_order_v( struct Nurb *nu)
|
||||||
|
{
|
||||||
|
int change = 0;
|
||||||
|
if(nu->pntsv<nu->orderv) {
|
||||||
|
nu->orderv= nu->pntsv;
|
||||||
|
change= 1;
|
||||||
|
}
|
||||||
|
if(((nu->flag & CU_CYCLIC)==0) && (nu->flagv>>1)&2) {
|
||||||
|
CLAMP(nu->orderv, 3,4);
|
||||||
|
change= 1;
|
||||||
|
}
|
||||||
|
return change;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -783,7 +783,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase)
|
|||||||
else
|
else
|
||||||
resolu= nu->resolu;
|
resolu= nu->resolu;
|
||||||
|
|
||||||
if(nu->pntsu<2 || ((nu->type & 7)==CU_NURBS && nu->pntsu < nu->orderu));
|
if(!check_valid_nurb_u(nu));
|
||||||
else if((nu->type & 7)==CU_BEZIER) {
|
else if((nu->type & 7)==CU_BEZIER) {
|
||||||
|
|
||||||
/* count */
|
/* count */
|
||||||
@@ -816,7 +816,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase)
|
|||||||
|
|
||||||
data= dl->verts;
|
data= dl->verts;
|
||||||
|
|
||||||
if(nu->flagu & 1) {
|
if(nu->flagu & CU_CYCLIC) {
|
||||||
dl->type= DL_POLY;
|
dl->type= DL_POLY;
|
||||||
a= nu->pntsu;
|
a= nu->pntsu;
|
||||||
}
|
}
|
||||||
@@ -863,7 +863,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase)
|
|||||||
dl->charidx = nu->charidx;
|
dl->charidx = nu->charidx;
|
||||||
|
|
||||||
data= dl->verts;
|
data= dl->verts;
|
||||||
if(nu->flagu & 1) dl->type= DL_POLY;
|
if(nu->flagu & CU_CYCLIC) dl->type= DL_POLY;
|
||||||
else dl->type= DL_SEGM;
|
else dl->type= DL_SEGM;
|
||||||
makeNurbcurve(nu, data, resolu, 3);
|
makeNurbcurve(nu, data, resolu, 3);
|
||||||
}
|
}
|
||||||
@@ -878,7 +878,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase)
|
|||||||
dl->charidx = nu->charidx;
|
dl->charidx = nu->charidx;
|
||||||
|
|
||||||
data= dl->verts;
|
data= dl->verts;
|
||||||
if(nu->flagu & 1) dl->type= DL_POLY;
|
if(nu->flagu & CU_CYCLIC) dl->type= DL_POLY;
|
||||||
else dl->type= DL_SEGM;
|
else dl->type= DL_SEGM;
|
||||||
|
|
||||||
a= len;
|
a= len;
|
||||||
@@ -1330,7 +1330,7 @@ void makeDispListSurf(Object *ob, ListBase *dispbase, int forRender)
|
|||||||
dl->rt= nu->flag;
|
dl->rt= nu->flag;
|
||||||
|
|
||||||
data= dl->verts;
|
data= dl->verts;
|
||||||
if(nu->flagu & 1) dl->type= DL_POLY;
|
if(nu->flagu & CU_CYCLIC) dl->type= DL_POLY;
|
||||||
else dl->type= DL_SEGM;
|
else dl->type= DL_SEGM;
|
||||||
|
|
||||||
makeNurbcurve(nu, data, nu->resolu, 3);
|
makeNurbcurve(nu, data, nu->resolu, 3);
|
||||||
|
|||||||
@@ -440,7 +440,7 @@ static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, i
|
|||||||
if (nu2 == NULL) return;
|
if (nu2 == NULL) return;
|
||||||
nu2->resolu= cu->resolu;
|
nu2->resolu= cu->resolu;
|
||||||
nu2->bezt = NULL;
|
nu2->bezt = NULL;
|
||||||
nu2->knotsu = nu2->knotsv = 0;
|
nu2->knotsu = nu2->knotsv = NULL;
|
||||||
nu2->flag= 0;
|
nu2->flag= 0;
|
||||||
nu2->charidx = charidx+1000;
|
nu2->charidx = charidx+1000;
|
||||||
if (mat_nr > 0) nu2->mat_nr= mat_nr-1;
|
if (mat_nr > 0) nu2->mat_nr= mat_nr-1;
|
||||||
@@ -529,7 +529,7 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float
|
|||||||
memcpy(nu2, nu1, sizeof(struct Nurb));
|
memcpy(nu2, nu1, sizeof(struct Nurb));
|
||||||
nu2->resolu= cu->resolu;
|
nu2->resolu= cu->resolu;
|
||||||
nu2->bp = 0;
|
nu2->bp = 0;
|
||||||
nu2->knotsu = nu2->knotsv = 0;
|
nu2->knotsu = nu2->knotsv = NULL;
|
||||||
nu2->flag= CU_SMOOTH;
|
nu2->flag= CU_SMOOTH;
|
||||||
nu2->charidx = charidx;
|
nu2->charidx = charidx;
|
||||||
if (info->mat_nr) {
|
if (info->mat_nr) {
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vfd)
|
|||||||
nu->type= CU_BEZIER+CU_2D;
|
nu->type= CU_BEZIER+CU_2D;
|
||||||
nu->pntsu = onpoints[j];
|
nu->pntsu = onpoints[j];
|
||||||
nu->resolu= 8;
|
nu->resolu= 8;
|
||||||
nu->flagu= 1;
|
nu->flagu= CU_CYCLIC;
|
||||||
nu->bezt = bezt;
|
nu->bezt = bezt;
|
||||||
|
|
||||||
//individual curve loop, start-end
|
//individual curve loop, start-end
|
||||||
|
|||||||
@@ -2017,7 +2017,7 @@ static VFontData *objfnt_to_vfontdata(objfnt *fnt)
|
|||||||
nu->type= CU_BEZIER+CU_2D;
|
nu->type= CU_BEZIER+CU_2D;
|
||||||
nu->pntsu = count;
|
nu->pntsu = count;
|
||||||
nu->resolu= 8;
|
nu->resolu= 8;
|
||||||
nu->flagu= 1;
|
nu->flagu= CU_CYCLIC;
|
||||||
nu->bezt = bezt;
|
nu->bezt = bezt;
|
||||||
stop = 0;
|
stop = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ struct BezTriple;
|
|||||||
struct BPoint;
|
struct BPoint;
|
||||||
struct BezTripleNurb;
|
struct BezTripleNurb;
|
||||||
|
|
||||||
|
void set_actNurb(struct Nurb *nu);
|
||||||
|
struct Nurb * get_actNurb( void );
|
||||||
|
|
||||||
short isNurbsel(struct Nurb *nu);
|
short isNurbsel(struct Nurb *nu);
|
||||||
int isNurbsel_count(struct Nurb *nu);
|
int isNurbsel_count(struct Nurb *nu);
|
||||||
void printknots(void);
|
void printknots(void);
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ include nan_compile.mk
|
|||||||
|
|
||||||
CFLAGS += $(LEVEL_1_C_WARNINGS)
|
CFLAGS += $(LEVEL_1_C_WARNINGS)
|
||||||
|
|
||||||
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
|
|
||||||
CPPFLAGS += -I../../python
|
|
||||||
CPPFLAGS += -I../../blenkernel
|
CPPFLAGS += -I../../blenkernel
|
||||||
CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
|
CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
|
||||||
CPPFLAGS += -I../../makesdna
|
CPPFLAGS += -I../../makesdna
|
||||||
|
|||||||
@@ -828,7 +828,7 @@ static PyObject *Part_GetLoc( BPy_PartSys * self, PyObject * args ){
|
|||||||
/* little hack to calculate hair steps in render mode */
|
/* little hack to calculate hair steps in render mode */
|
||||||
psys->renderdata = (void*)(int)1;
|
psys->renderdata = (void*)(int)1;
|
||||||
|
|
||||||
psys_cache_paths(ob, psys, cfra, 0);
|
psys_cache_paths(ob, psys, cfra, 1);
|
||||||
|
|
||||||
psys->renderdata = NULL;
|
psys->renderdata = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -3071,7 +3071,6 @@ static void editing_panel_font_type(Object *ob, Curve *cu)
|
|||||||
|
|
||||||
void do_curvebuts(unsigned short event)
|
void do_curvebuts(unsigned short event)
|
||||||
{
|
{
|
||||||
extern Nurb *lastnu;
|
|
||||||
extern ListBase editNurb; /* from editcurve */
|
extern ListBase editNurb; /* from editcurve */
|
||||||
Object *ob;
|
Object *ob;
|
||||||
Curve *cu;
|
Curve *cu;
|
||||||
@@ -3105,13 +3104,15 @@ void do_curvebuts(unsigned short event)
|
|||||||
if(isNurbsel(nu)) {
|
if(isNurbsel(nu)) {
|
||||||
if((nu->type & 7)==CU_NURBS) {
|
if((nu->type & 7)==CU_NURBS) {
|
||||||
if(event<B_UNIFV) {
|
if(event<B_UNIFV) {
|
||||||
nu->flagu &= 1;
|
nu->flagu &= CU_CYCLIC; /* disable all flags except for CU_CYCLIC */
|
||||||
nu->flagu += ((event-B_UNIFU)<<1);
|
nu->flagu |= ((event-B_UNIFU)<<1);
|
||||||
|
clamp_nurb_order_u(nu);
|
||||||
makeknots(nu, 1, nu->flagu>>1);
|
makeknots(nu, 1, nu->flagu>>1);
|
||||||
}
|
}
|
||||||
else if(nu->pntsv>1) {
|
else if(nu->pntsv>1) {
|
||||||
nu->flagv &= 1;
|
nu->flagv &= CU_CYCLIC; /* disable all flags except for CU_CYCLIC */
|
||||||
nu->flagv += ((event-B_UNIFV)<<1);
|
nu->flagv |= ((event-B_UNIFV)<<1);
|
||||||
|
clamp_nurb_order_v(nu);
|
||||||
makeknots(nu, 2, nu->flagv>>1);
|
makeknots(nu, 2, nu->flagv>>1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3147,15 +3148,13 @@ void do_curvebuts(unsigned short event)
|
|||||||
break;
|
break;
|
||||||
case B_SETORDER:
|
case B_SETORDER:
|
||||||
if(G.obedit) {
|
if(G.obedit) {
|
||||||
nu= lastnu;
|
nu= get_actNurb();
|
||||||
if(nu && (nu->type & 7)==CU_NURBS ) {
|
if(nu && (nu->type & 7)==CU_NURBS ) {
|
||||||
if(nu->orderu>nu->pntsu) {
|
if(clamp_nurb_order_u(nu)) {
|
||||||
nu->orderu= nu->pntsu;
|
|
||||||
scrarea_queue_winredraw(curarea);
|
scrarea_queue_winredraw(curarea);
|
||||||
}
|
}
|
||||||
makeknots(nu, 1, nu->flagu>>1);
|
makeknots(nu, 1, nu->flagu>>1);
|
||||||
if(nu->orderv>nu->pntsv) {
|
if(clamp_nurb_order_v(nu)) {
|
||||||
nu->orderv= nu->pntsv;
|
|
||||||
scrarea_queue_winredraw(curarea);
|
scrarea_queue_winredraw(curarea);
|
||||||
}
|
}
|
||||||
makeknots(nu, 2, nu->flagv>>1);
|
makeknots(nu, 2, nu->flagv>>1);
|
||||||
@@ -3273,7 +3272,6 @@ static void editing_panel_curve_tools(Object *ob, Curve *cu)
|
|||||||
{
|
{
|
||||||
Nurb *nu;
|
Nurb *nu;
|
||||||
extern ListBase editNurb; /* from editcurve */
|
extern ListBase editNurb; /* from editcurve */
|
||||||
extern Nurb *lastnu;
|
|
||||||
uiBlock *block;
|
uiBlock *block;
|
||||||
short *sp;
|
short *sp;
|
||||||
|
|
||||||
@@ -3309,8 +3307,11 @@ static void editing_panel_curve_tools(Object *ob, Curve *cu)
|
|||||||
uiBlockEndAlign(block);
|
uiBlockEndAlign(block);
|
||||||
|
|
||||||
if(ob==G.obedit) {
|
if(ob==G.obedit) {
|
||||||
nu= lastnu;
|
nu= get_actNurb();
|
||||||
if(nu==NULL) nu= lastnu= editNurb.first;
|
if(nu==NULL && editNurb.first) {
|
||||||
|
nu= editNurb.first;
|
||||||
|
set_actNurb(nu);
|
||||||
|
}
|
||||||
if(nu) {
|
if(nu) {
|
||||||
if (ob->type==OB_CURVE) {
|
if (ob->type==OB_CURVE) {
|
||||||
uiDefBut(block, LABEL, 0, "Tilt",
|
uiDefBut(block, LABEL, 0, "Tilt",
|
||||||
|
|||||||
@@ -4097,16 +4097,34 @@ void transform_armature_mirror_update(void)
|
|||||||
if (eboflip) {
|
if (eboflip) {
|
||||||
/* we assume X-axis flipping for now */
|
/* we assume X-axis flipping for now */
|
||||||
if (ebo->flag & BONE_TIPSEL) {
|
if (ebo->flag & BONE_TIPSEL) {
|
||||||
|
EditBone *children;
|
||||||
|
|
||||||
eboflip->tail[0]= -ebo->tail[0];
|
eboflip->tail[0]= -ebo->tail[0];
|
||||||
eboflip->tail[1]= ebo->tail[1];
|
eboflip->tail[1]= ebo->tail[1];
|
||||||
eboflip->tail[2]= ebo->tail[2];
|
eboflip->tail[2]= ebo->tail[2];
|
||||||
eboflip->rad_tail= ebo->rad_tail;
|
eboflip->rad_tail= ebo->rad_tail;
|
||||||
|
|
||||||
|
/* Also move connected children, in case children's name aren't mirrored properly */
|
||||||
|
for (children=G.edbo.first; children; children=children->next) {
|
||||||
|
if (children->parent == eboflip && children->flag & BONE_CONNECTED) {
|
||||||
|
VECCOPY(children->head, eboflip->tail);
|
||||||
|
children->rad_head = ebo->rad_tail;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (ebo->flag & BONE_ROOTSEL) {
|
if (ebo->flag & BONE_ROOTSEL) {
|
||||||
eboflip->head[0]= -ebo->head[0];
|
eboflip->head[0]= -ebo->head[0];
|
||||||
eboflip->head[1]= ebo->head[1];
|
eboflip->head[1]= ebo->head[1];
|
||||||
eboflip->head[2]= ebo->head[2];
|
eboflip->head[2]= ebo->head[2];
|
||||||
eboflip->rad_head= ebo->rad_head;
|
eboflip->rad_head= ebo->rad_head;
|
||||||
|
|
||||||
|
/* Also move connected parent, in case parent's name isn't mirrored properly */
|
||||||
|
if (eboflip->parent && eboflip->flag & BONE_CONNECTED)
|
||||||
|
{
|
||||||
|
EditBone *parent = eboflip->parent;
|
||||||
|
VECCOPY(parent->tail, eboflip->head);
|
||||||
|
parent->rad_tail = ebo->rad_head;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (ebo->flag & BONE_SELECTED) {
|
if (ebo->flag & BONE_SELECTED) {
|
||||||
eboflip->dist= ebo->dist;
|
eboflip->dist= ebo->dist;
|
||||||
|
|||||||
@@ -99,7 +99,7 @@
|
|||||||
|
|
||||||
ListBase editNurb;
|
ListBase editNurb;
|
||||||
BPoint *lastselbp;
|
BPoint *lastselbp;
|
||||||
Nurb *lastnu; /* for selected */
|
int actnu; /* for selected */
|
||||||
|
|
||||||
|
|
||||||
/* void freeNurblist(ListBase *lb); already declared in the kernel */
|
/* void freeNurblist(ListBase *lb); already declared in the kernel */
|
||||||
@@ -109,6 +109,23 @@ float nurbcircle[8][2]= {
|
|||||||
{0.0, 1.0}, { 1.0, 1.0}, { 1.0, 0.0}, { 1.0, -1.0}
|
{0.0, 1.0}, { 1.0, 1.0}, { 1.0, 0.0}, { 1.0, -1.0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* this replaces the active flag used in uv/face mode */
|
||||||
|
void set_actNurb(Nurb *nu)
|
||||||
|
{
|
||||||
|
if (nu==NULL) {
|
||||||
|
actnu = -1;
|
||||||
|
} else {
|
||||||
|
actnu = BLI_findindex(&editNurb, nu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Nurb * get_actNurb( void )
|
||||||
|
{
|
||||||
|
return BLI_findlink(&editNurb, actnu);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ******************* SELECTION FUNCTIONS ********************* */
|
/* ******************* SELECTION FUNCTIONS ********************* */
|
||||||
|
|
||||||
/* returns 1 in case (de)selection was successful */
|
/* returns 1 in case (de)selection was successful */
|
||||||
@@ -318,14 +335,14 @@ void load_editNurb()
|
|||||||
BLI_addtail(&(cu->nurb), newnu);
|
BLI_addtail(&(cu->nurb), newnu);
|
||||||
|
|
||||||
if((nu->type & 7)==CU_NURBS) {
|
if((nu->type & 7)==CU_NURBS) {
|
||||||
if(nu->pntsu < nu->orderu) nu->orderu= nu->pntsu;
|
clamp_nurb_order_u(nu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lastnu= NULL; /* for selected */
|
set_actNurb(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void make_editNurb()
|
void make_editNurb()
|
||||||
@@ -361,8 +378,7 @@ void make_editNurb()
|
|||||||
else G.obedit= NULL;
|
else G.obedit= NULL;
|
||||||
|
|
||||||
countall();
|
countall();
|
||||||
|
set_actNurb(NULL);
|
||||||
lastnu= NULL; /* for selected */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void remake_editNurb()
|
void remake_editNurb()
|
||||||
@@ -457,8 +473,7 @@ void separate_nurb()
|
|||||||
countall();
|
countall();
|
||||||
allqueue(REDRAWVIEW3D, 0);
|
allqueue(REDRAWVIEW3D, 0);
|
||||||
allqueue(REDRAWBUTSEDIT, 0);
|
allqueue(REDRAWBUTSEDIT, 0);
|
||||||
|
set_actNurb(NULL);
|
||||||
lastnu= NULL; /* for selected */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ******************* FLAGS ********************* */
|
/* ******************* FLAGS ********************* */
|
||||||
@@ -640,7 +655,7 @@ void deleteflagNurb(short flag)
|
|||||||
}
|
}
|
||||||
if(a==0) {
|
if(a==0) {
|
||||||
BLI_remlink(&editNurb, nu);
|
BLI_remlink(&editNurb, nu);
|
||||||
freeNurb(nu);
|
freeNurb(nu); nu=NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* is nurb in U direction selected */
|
/* is nurb in U direction selected */
|
||||||
@@ -674,7 +689,7 @@ void deleteflagNurb(short flag)
|
|||||||
nu->pntsv= newv;
|
nu->pntsv= newv;
|
||||||
MEM_freeN(nu->bp);
|
MEM_freeN(nu->bp);
|
||||||
nu->bp= newbp;
|
nu->bp= newbp;
|
||||||
if(nu->orderv>nu->pntsv) nu->orderv= nu->pntsv;
|
clamp_nurb_order_v(nu);
|
||||||
|
|
||||||
makeknots(nu, 2, nu->flagv>>1);
|
makeknots(nu, 2, nu->flagv>>1);
|
||||||
}
|
}
|
||||||
@@ -714,13 +729,13 @@ void deleteflagNurb(short flag)
|
|||||||
nu->pntsu= nu->pntsv;
|
nu->pntsu= nu->pntsv;
|
||||||
nu->pntsv= 1;
|
nu->pntsv= 1;
|
||||||
SWAP(short, nu->orderu, nu->orderv);
|
SWAP(short, nu->orderu, nu->orderv);
|
||||||
if(nu->orderu>nu->pntsu) nu->orderu= nu->pntsu;
|
clamp_nurb_order_u(nu);
|
||||||
if(nu->knotsv) MEM_freeN(nu->knotsv);
|
if(nu->knotsv) MEM_freeN(nu->knotsv);
|
||||||
nu->knotsv= 0;
|
nu->knotsv= NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nu->pntsu= newu;
|
nu->pntsu= newu;
|
||||||
if(nu->orderu>nu->pntsu) nu->orderu= nu->pntsu;
|
clamp_nurb_order_u(nu);
|
||||||
}
|
}
|
||||||
makeknots(nu, 1, nu->flagu>>1);
|
makeknots(nu, 1, nu->flagu>>1);
|
||||||
}
|
}
|
||||||
@@ -878,7 +893,7 @@ void adduplicateflagNurb(short flag)
|
|||||||
newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN");
|
newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN");
|
||||||
memcpy(newnu, nu, sizeof(Nurb));
|
memcpy(newnu, nu, sizeof(Nurb));
|
||||||
BLI_addtail(&editNurb, newnu);
|
BLI_addtail(&editNurb, newnu);
|
||||||
lastnu= newnu;
|
set_actNurb(newnu);
|
||||||
newnu->pntsu= enda-starta+1;
|
newnu->pntsu= enda-starta+1;
|
||||||
newnu->bezt=
|
newnu->bezt=
|
||||||
(BezTriple*)MEM_mallocN((enda - starta + 1) * sizeof(BezTriple), "adduplicateN");
|
(BezTriple*)MEM_mallocN((enda - starta + 1) * sizeof(BezTriple), "adduplicateN");
|
||||||
@@ -891,8 +906,10 @@ void adduplicateflagNurb(short flag)
|
|||||||
bezt1++;
|
bezt1++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(nu->flagu & 1) {
|
if(nu->flagu & CU_CYCLIC) {
|
||||||
if(starta!=0 || enda!=nu->pntsu-1) newnu->flagu--;
|
if(starta!=0 || enda!=nu->pntsu-1) {
|
||||||
|
newnu->flagu &= ~CU_CYCLIC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bezt++;
|
bezt++;
|
||||||
@@ -913,7 +930,7 @@ void adduplicateflagNurb(short flag)
|
|||||||
if(enda>=starta) {
|
if(enda>=starta) {
|
||||||
newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN3");
|
newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN3");
|
||||||
memcpy(newnu, nu, sizeof(Nurb));
|
memcpy(newnu, nu, sizeof(Nurb));
|
||||||
lastnu= newnu;
|
set_actNurb(newnu);
|
||||||
BLI_addtail(&editNurb, newnu);
|
BLI_addtail(&editNurb, newnu);
|
||||||
newnu->pntsu= enda-starta+1;
|
newnu->pntsu= enda-starta+1;
|
||||||
newnu->bp = (BPoint*)MEM_mallocN((enda-starta+1) * sizeof(BPoint), "adduplicateN4");
|
newnu->bp = (BPoint*)MEM_mallocN((enda-starta+1) * sizeof(BPoint), "adduplicateN4");
|
||||||
@@ -926,12 +943,14 @@ void adduplicateflagNurb(short flag)
|
|||||||
bp1++;
|
bp1++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(nu->flagu & 1) {
|
if(nu->flagu & CU_CYCLIC) {
|
||||||
if(starta!=0 || enda!=nu->pntsu-1) newnu->flagu--;
|
if(starta!=0 || enda!=nu->pntsu-1) {
|
||||||
|
newnu->flagu &= ~CU_CYCLIC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* knots */
|
/* knots */
|
||||||
newnu->knotsu= 0;
|
newnu->knotsu= NULL;
|
||||||
makeknots(newnu, 1, newnu->flagu>>1);
|
makeknots(newnu, 1, newnu->flagu>>1);
|
||||||
}
|
}
|
||||||
bp++;
|
bp++;
|
||||||
@@ -971,14 +990,16 @@ void adduplicateflagNurb(short flag)
|
|||||||
newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN5");
|
newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN5");
|
||||||
memcpy(newnu, nu, sizeof(Nurb));
|
memcpy(newnu, nu, sizeof(Nurb));
|
||||||
BLI_addtail(&editNurb, newnu);
|
BLI_addtail(&editNurb, newnu);
|
||||||
lastnu= newnu;
|
set_actNurb(newnu);
|
||||||
newnu->pntsu= newu;
|
newnu->pntsu= newu;
|
||||||
newnu->pntsv= newv;
|
newnu->pntsv= newv;
|
||||||
newnu->bp =
|
newnu->bp =
|
||||||
(BPoint*)MEM_mallocN(newu * newv * sizeof(BPoint), "adduplicateN6");
|
(BPoint*)MEM_mallocN(newu * newv * sizeof(BPoint), "adduplicateN6");
|
||||||
newnu->orderu= MIN2(nu->orderu, newu);
|
clamp_nurb_order_u(newnu);
|
||||||
newnu->orderv= MIN2(nu->orderv, newv);
|
clamp_nurb_order_v(newnu);
|
||||||
|
|
||||||
|
newnu->knotsu= newnu->knotsv= NULL;
|
||||||
|
|
||||||
bp= newnu->bp;
|
bp= newnu->bp;
|
||||||
bp1= nu->bp;
|
bp1= nu->bp;
|
||||||
for(a=0; a<nu->pntsv; a++) {
|
for(a=0; a<nu->pntsv; a++) {
|
||||||
@@ -990,23 +1011,20 @@ void adduplicateflagNurb(short flag)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(nu->pntsu==newnu->pntsu) {
|
if (check_valid_nurb_u(newnu)) {
|
||||||
newnu->knotsu= MEM_mallocN(sizeof(float)*KNOTSU(nu), "adduplicateN6");
|
if(nu->pntsu==newnu->pntsu && nu->knotsu) {
|
||||||
memcpy(newnu->knotsu, nu->knotsu, sizeof(float)*KNOTSU(nu));
|
newnu->knotsu= MEM_dupallocN( nu->knotsu );
|
||||||
|
} else {
|
||||||
|
makeknots(newnu, 1, newnu->flagu>>1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
if (check_valid_nurb_v(newnu)) {
|
||||||
newnu->knotsu= 0;
|
if(nu->pntsv==newnu->pntsv && nu->knotsv) {
|
||||||
makeknots(newnu, 1, newnu->flagu>>1);
|
newnu->knotsv= MEM_dupallocN( nu->knotsv );
|
||||||
|
} else {
|
||||||
|
makeknots(newnu, 2, newnu->flagv>>1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(nu->pntsv==newnu->pntsv) {
|
|
||||||
newnu->knotsv= MEM_mallocN(sizeof(float)*KNOTSV(nu), "adduplicateN7");
|
|
||||||
memcpy(newnu->knotsv, nu->knotsv, sizeof(float)*KNOTSV(nu));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
newnu->knotsv= 0;
|
|
||||||
makeknots(newnu, 2, newnu->flagv>>1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
MEM_freeN(usel);
|
MEM_freeN(usel);
|
||||||
}
|
}
|
||||||
@@ -1015,7 +1033,7 @@ void adduplicateflagNurb(short flag)
|
|||||||
nu= nu->prev;
|
nu= nu->prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* lastnu changed */
|
/* actnu changed */
|
||||||
allqueue(REDRAWBUTSEDIT, 0);
|
allqueue(REDRAWBUTSEDIT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1569,7 +1587,7 @@ void subdivideNurb()
|
|||||||
newly created. Old points are discarded.
|
newly created. Old points are discarded.
|
||||||
*/
|
*/
|
||||||
/* count */
|
/* count */
|
||||||
if(nu->flagu & 1) {
|
if(nu->flagu & CU_CYCLIC) {
|
||||||
a= nu->pntsu;
|
a= nu->pntsu;
|
||||||
bezt= nu->bezt;
|
bezt= nu->bezt;
|
||||||
prevbezt= bezt+(a-1);
|
prevbezt= bezt+(a-1);
|
||||||
@@ -1590,7 +1608,7 @@ void subdivideNurb()
|
|||||||
beztnew =
|
beztnew =
|
||||||
(BezTriple*)MEM_mallocN((amount + nu->pntsu) * sizeof(BezTriple), "subdivNurb");
|
(BezTriple*)MEM_mallocN((amount + nu->pntsu) * sizeof(BezTriple), "subdivNurb");
|
||||||
beztn= beztnew;
|
beztn= beztnew;
|
||||||
if(nu->flagu & 1) {
|
if(nu->flagu & CU_CYCLIC) {
|
||||||
a= nu->pntsu;
|
a= nu->pntsu;
|
||||||
bezt= nu->bezt;
|
bezt= nu->bezt;
|
||||||
prevbezt= bezt+(a-1);
|
prevbezt= bezt+(a-1);
|
||||||
@@ -1622,7 +1640,7 @@ void subdivideNurb()
|
|||||||
VecMidf(beztn->vec[1], vec+9, vec+12);
|
VecMidf(beztn->vec[1], vec+9, vec+12);
|
||||||
VECCOPY(beztn->vec[2], vec+12);
|
VECCOPY(beztn->vec[2], vec+12);
|
||||||
/* handle of next bezt */
|
/* handle of next bezt */
|
||||||
if(a==0 && (nu->flagu & 1)) {VECCOPY(beztnew->vec[0], vec+6);}
|
if(a==0 && (nu->flagu & CU_CYCLIC)) {VECCOPY(beztnew->vec[0], vec+6);}
|
||||||
else {VECCOPY(bezt->vec[0], vec+6);}
|
else {VECCOPY(bezt->vec[0], vec+6);}
|
||||||
|
|
||||||
beztn->radius = (prevbezt->radius + bezt->radius)/2.0f;
|
beztn->radius = (prevbezt->radius + bezt->radius)/2.0f;
|
||||||
@@ -1635,7 +1653,7 @@ void subdivideNurb()
|
|||||||
bezt++;
|
bezt++;
|
||||||
}
|
}
|
||||||
/* last point */
|
/* last point */
|
||||||
if((nu->flagu & 1)==0) memcpy(beztn, prevbezt, sizeof(BezTriple));
|
if((nu->flagu & CU_CYCLIC)==0) memcpy(beztn, prevbezt, sizeof(BezTriple));
|
||||||
|
|
||||||
MEM_freeN(nu->bezt);
|
MEM_freeN(nu->bezt);
|
||||||
nu->bezt= beztnew;
|
nu->bezt= beztnew;
|
||||||
@@ -1652,7 +1670,7 @@ void subdivideNurb()
|
|||||||
stable... nzc 30-5-'00
|
stable... nzc 30-5-'00
|
||||||
*/
|
*/
|
||||||
/* count */
|
/* count */
|
||||||
if(nu->flagu & 1) {
|
if(nu->flagu & CU_CYCLIC) {
|
||||||
a= nu->pntsu*nu->pntsv;
|
a= nu->pntsu*nu->pntsv;
|
||||||
bp= nu->bp;
|
bp= nu->bp;
|
||||||
prevbp= bp+(a-1);
|
prevbp= bp+(a-1);
|
||||||
@@ -1674,7 +1692,7 @@ void subdivideNurb()
|
|||||||
(BPoint*)MEM_mallocN((amount + nu->pntsu) * sizeof(BPoint), "subdivNurb2");
|
(BPoint*)MEM_mallocN((amount + nu->pntsu) * sizeof(BPoint), "subdivNurb2");
|
||||||
bpn= bpnew;
|
bpn= bpnew;
|
||||||
|
|
||||||
if(nu->flagu & 1) {
|
if(nu->flagu & CU_CYCLIC) {
|
||||||
a= nu->pntsu;
|
a= nu->pntsu;
|
||||||
bp= nu->bp;
|
bp= nu->bp;
|
||||||
prevbp= bp+(a-1);
|
prevbp= bp+(a-1);
|
||||||
@@ -1701,7 +1719,7 @@ void subdivideNurb()
|
|||||||
prevbp= bp;
|
prevbp= bp;
|
||||||
bp++;
|
bp++;
|
||||||
}
|
}
|
||||||
if((nu->flagu & 1)==0) memcpy(bpn, prevbp, sizeof(BPoint)); /* last point */
|
if((nu->flagu & CU_CYCLIC)==0) memcpy(bpn, prevbp, sizeof(BPoint)); /* last point */
|
||||||
|
|
||||||
MEM_freeN(nu->bp);
|
MEM_freeN(nu->bp);
|
||||||
nu->bp= bpnew;
|
nu->bp= bpnew;
|
||||||
@@ -2075,7 +2093,7 @@ int convertspline(short type, Nurb *nu)
|
|||||||
nu->type &= ~7;
|
nu->type &= ~7;
|
||||||
nu->type+= 4;
|
nu->type+= 4;
|
||||||
nu->orderu= 4;
|
nu->orderu= 4;
|
||||||
nu->flagu &= 1;
|
nu->flagu &= CU_CYCLIC; /* disable all flags except for cyclic */
|
||||||
nu->flagu += 4;
|
nu->flagu += 4;
|
||||||
makeknots(nu, 1, nu->flagu>>1);
|
makeknots(nu, 1, nu->flagu>>1);
|
||||||
a= nu->pntsu*nu->pntsv;
|
a= nu->pntsu*nu->pntsv;
|
||||||
@@ -2126,10 +2144,10 @@ int convertspline(short type, Nurb *nu)
|
|||||||
nu->orderv= 1;
|
nu->orderv= 1;
|
||||||
nu->type &= ~7;
|
nu->type &= ~7;
|
||||||
nu->type+= type;
|
nu->type+= type;
|
||||||
if(nu->flagu & 1) c= nu->orderu-1;
|
if(nu->flagu & CU_CYCLIC) c= nu->orderu-1;
|
||||||
else c= 0;
|
else c= 0;
|
||||||
if(type== 4) {
|
if(type== 4) {
|
||||||
nu->flagu &= 1;
|
nu->flagu &= CU_CYCLIC; /* disable all flags except for cyclic */
|
||||||
nu->flagu += 4;
|
nu->flagu += 4;
|
||||||
makeknots(nu, 1, nu->flagu>>1);
|
makeknots(nu, 1, nu->flagu>>1);
|
||||||
}
|
}
|
||||||
@@ -2139,9 +2157,9 @@ int convertspline(short type, Nurb *nu)
|
|||||||
if(type==0) { /* to Poly */
|
if(type==0) { /* to Poly */
|
||||||
nu->type &= ~7;
|
nu->type &= ~7;
|
||||||
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= 0;
|
nu->knotsu= NULL;
|
||||||
if(nu->knotsv) MEM_freeN(nu->knotsv);
|
if(nu->knotsv) MEM_freeN(nu->knotsv);
|
||||||
nu->knotsv= 0;
|
nu->knotsv= NULL;
|
||||||
}
|
}
|
||||||
else if(type==CU_BEZIER) { /* to Bezier */
|
else if(type==CU_BEZIER) { /* to Bezier */
|
||||||
nr= nu->pntsu/3;
|
nr= nu->pntsu/3;
|
||||||
@@ -2170,7 +2188,7 @@ int convertspline(short type, Nurb *nu)
|
|||||||
MEM_freeN(nu->bp);
|
MEM_freeN(nu->bp);
|
||||||
nu->bp= 0;
|
nu->bp= 0;
|
||||||
MEM_freeN(nu->knotsu);
|
MEM_freeN(nu->knotsu);
|
||||||
nu->knotsu= 0;
|
nu->knotsu= NULL;
|
||||||
nu->pntsu= nr;
|
nu->pntsu= nr;
|
||||||
nu->type &= ~7;
|
nu->type &= ~7;
|
||||||
nu->type+= 1;
|
nu->type+= 1;
|
||||||
@@ -2481,7 +2499,7 @@ void merge_nurb()
|
|||||||
BLI_freelistN(&nsortbase);
|
BLI_freelistN(&nsortbase);
|
||||||
|
|
||||||
countall();
|
countall();
|
||||||
lastnu= NULL;
|
set_actNurb(NULL);
|
||||||
|
|
||||||
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
||||||
|
|
||||||
@@ -2527,7 +2545,7 @@ void addsegment_nurb()
|
|||||||
|
|
||||||
/* find both nurbs and points, nu1 will be put behind nu2 */
|
/* find both nurbs and points, nu1 will be put behind nu2 */
|
||||||
for(nu= editNurb.first; nu; nu= nu->next) {
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
||||||
if((nu->flagu & 1)==0) { /* not cyclic */
|
if((nu->flagu & CU_CYCLIC)==0) { /* not cyclic */
|
||||||
if( (nu->type & 7)==CU_BEZIER ) {
|
if( (nu->type & 7)==CU_BEZIER ) {
|
||||||
bezt= nu->bezt;
|
bezt= nu->bezt;
|
||||||
if(nu1==0) {
|
if(nu1==0) {
|
||||||
@@ -2594,7 +2612,7 @@ void addsegment_nurb()
|
|||||||
nu1->bezt= bezt;
|
nu1->bezt= bezt;
|
||||||
nu1->pntsu+= nu2->pntsu;
|
nu1->pntsu+= nu2->pntsu;
|
||||||
BLI_remlink(&editNurb, nu2);
|
BLI_remlink(&editNurb, nu2);
|
||||||
freeNurb(nu2);
|
freeNurb(nu2); nu2= NULL;
|
||||||
calchandlesNurb(nu1);
|
calchandlesNurb(nu1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -2632,11 +2650,11 @@ void addsegment_nurb()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
freeNurb(nu2);
|
freeNurb(nu2); nu2= NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lastnu= NULL; /* for selected */
|
set_actNurb(NULL); /* for selected */
|
||||||
|
|
||||||
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
||||||
|
|
||||||
@@ -2704,8 +2722,8 @@ void mouse_nurb()
|
|||||||
|
|
||||||
rightmouse_transform();
|
rightmouse_transform();
|
||||||
|
|
||||||
if(nu!=lastnu) {
|
if(nu!=get_actNurb()) {
|
||||||
lastnu= nu;
|
set_actNurb(nu);
|
||||||
allqueue(REDRAWBUTSEDIT, 0);
|
allqueue(REDRAWBUTSEDIT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2808,7 +2826,7 @@ static void spin_nurb(float *dvec, short mode)
|
|||||||
for(nu= editNurb.first; nu; nu= nu->next) {
|
for(nu= editNurb.first; nu; nu= nu->next) {
|
||||||
if(isNurbsel(nu)) {
|
if(isNurbsel(nu)) {
|
||||||
nu->orderv= 4;
|
nu->orderv= 4;
|
||||||
nu->flagv |= 1;
|
nu->flagv |= CU_CYCLIC;
|
||||||
makeknots(nu, 2, nu->flagv>>1);
|
makeknots(nu, 2, nu->flagv>>1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3006,8 +3024,8 @@ void makecyclicNurb()
|
|||||||
bp= nu->bp;
|
bp= nu->bp;
|
||||||
while(a--) {
|
while(a--) {
|
||||||
if( bp->f1 & SELECT ) {
|
if( bp->f1 & SELECT ) {
|
||||||
if(nu->flagu & CU_CYCLIC) nu->flagu--;
|
if(nu->flagu & CU_CYCLIC) nu->flagu &= ~CU_CYCLIC;
|
||||||
else nu->flagu++;
|
else nu->flagu |= CU_CYCLIC;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bp++;
|
bp++;
|
||||||
@@ -3018,8 +3036,8 @@ void makecyclicNurb()
|
|||||||
bezt= nu->bezt;
|
bezt= nu->bezt;
|
||||||
while(a--) {
|
while(a--) {
|
||||||
if( BEZSELECTED_HIDDENHANDLES(bezt) ) {
|
if( BEZSELECTED_HIDDENHANDLES(bezt) ) {
|
||||||
if(nu->flagu & CU_CYCLIC) nu->flagu--;
|
if(nu->flagu & CU_CYCLIC) nu->flagu &= ~CU_CYCLIC;
|
||||||
else nu->flagu++;
|
else nu->flagu |= CU_CYCLIC;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bezt++;
|
bezt++;
|
||||||
@@ -3027,26 +3045,28 @@ void makecyclicNurb()
|
|||||||
calchandlesNurb(nu);
|
calchandlesNurb(nu);
|
||||||
}
|
}
|
||||||
else if(nu->pntsv==1 && (nu->type & 7)==CU_NURBS) {
|
else if(nu->pntsv==1 && (nu->type & 7)==CU_NURBS) {
|
||||||
a= nu->pntsu;
|
if (nu->knotsu) { /* if check_valid_nurb_u fails the knotsu can be NULL */
|
||||||
bp= nu->bp;
|
a= nu->pntsu;
|
||||||
while(a--) {
|
bp= nu->bp;
|
||||||
if( bp->f1 & SELECT ) {
|
while(a--) {
|
||||||
if(nu->flagu & CU_CYCLIC) nu->flagu--;
|
if( bp->f1 & SELECT ) {
|
||||||
else {
|
if(nu->flagu & CU_CYCLIC) nu->flagu &= ~CU_CYCLIC;
|
||||||
nu->flagu++;
|
else {
|
||||||
nu->flagu &= ~2; /* endpoint flag, fixme */
|
nu->flagu |= CU_CYCLIC;
|
||||||
fp= MEM_mallocN(sizeof(float)*KNOTSU(nu), "makecyclicN");
|
nu->flagu &= ~2; /* endpoint flag, fixme */
|
||||||
b= (nu->orderu+nu->pntsu);
|
fp= MEM_mallocN(sizeof(float)*KNOTSU(nu), "makecyclicN");
|
||||||
memcpy(fp, nu->knotsu, sizeof(float)*b);
|
b= (nu->orderu+nu->pntsu);
|
||||||
MEM_freeN(nu->knotsu);
|
memcpy(fp, nu->knotsu, sizeof(float)*b);
|
||||||
nu->knotsu= fp;
|
MEM_freeN(nu->knotsu);
|
||||||
|
nu->knotsu= fp;
|
||||||
|
|
||||||
makeknots(nu, 1, 0); /* 1==u 0==uniform */
|
makeknots(nu, 1, 0); /* 1==u 0==uniform */
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
bp++;
|
||||||
}
|
}
|
||||||
bp++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(nu->type==CU_NURBS) {
|
else if(nu->type==CU_NURBS) {
|
||||||
@@ -3060,29 +3080,37 @@ void makecyclicNurb()
|
|||||||
|
|
||||||
if( bp->f1 & SELECT) {
|
if( bp->f1 & SELECT) {
|
||||||
if(cyclmode==1 && nu->pntsu>1) {
|
if(cyclmode==1 && nu->pntsu>1) {
|
||||||
if(nu->flagu & CU_CYCLIC) nu->flagu--;
|
if(nu->flagu & CU_CYCLIC) nu->flagu &= ~CU_CYCLIC;
|
||||||
else {
|
else {
|
||||||
nu->flagu++;
|
nu->flagu |= CU_CYCLIC;
|
||||||
fp= MEM_mallocN(sizeof(float)*KNOTSU(nu), "makecyclicN");
|
if (check_valid_nurb_u(nu)) {
|
||||||
b= (nu->orderu+nu->pntsu);
|
fp= MEM_mallocN(sizeof(float)*KNOTSU(nu), "makecyclicN");
|
||||||
memcpy(fp, nu->knotsu, sizeof(float)*b);
|
b= (nu->orderu+nu->pntsu);
|
||||||
MEM_freeN(nu->knotsu);
|
if (nu->knotsu) { /* null if check_valid_nurb_u failed before but is valid now */
|
||||||
nu->knotsu= fp;
|
memcpy(fp, nu->knotsu, sizeof(float)*b);
|
||||||
|
MEM_freeN(nu->knotsu);
|
||||||
|
}
|
||||||
|
nu->knotsu= fp;
|
||||||
|
|
||||||
makeknots(nu, 1, 0); /* 1==u 0==uniform */
|
makeknots(nu, 1, 0); /* 1==u 0==uniform */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(cyclmode==2 && nu->pntsv>1) {
|
if(cyclmode==2 && nu->pntsv>1) {
|
||||||
if(nu->flagv & 1) nu->flagv--;
|
if(nu->flagv & 1) nu->flagv--;
|
||||||
else {
|
else {
|
||||||
nu->flagv++;
|
nu->flagv++;
|
||||||
fp= MEM_mallocN(sizeof(float)*KNOTSV(nu), "makecyclicN");
|
if (check_valid_nurb_v(nu)) {
|
||||||
b= (nu->orderv+nu->pntsv);
|
fp= MEM_mallocN(sizeof(float)*KNOTSV(nu), "makecyclicN");
|
||||||
memcpy(fp, nu->knotsv, sizeof(float)*b);
|
b= (nu->orderv+nu->pntsv);
|
||||||
MEM_freeN(nu->knotsv);
|
if (nu->knotsv) { /* null if check_valid_nurb_v failed before but is valid now */
|
||||||
nu->knotsv= fp;
|
memcpy(fp, nu->knotsv, sizeof(float)*b);
|
||||||
|
MEM_freeN(nu->knotsv);
|
||||||
|
}
|
||||||
|
nu->knotsv= fp;
|
||||||
|
|
||||||
makeknots(nu, 2, 0); /* 2==v 0==uniform */
|
makeknots(nu, 2, 0); /* 2==v 0==uniform */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -3638,7 +3666,7 @@ void delNurb()
|
|||||||
}
|
}
|
||||||
if(a==0) {
|
if(a==0) {
|
||||||
BLI_remlink(&editNurb, nu);
|
BLI_remlink(&editNurb, nu);
|
||||||
freeNurb(nu);
|
freeNurb(nu); nu= NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3654,15 +3682,18 @@ void delNurb()
|
|||||||
}
|
}
|
||||||
if(a==0) {
|
if(a==0) {
|
||||||
BLI_remlink(&editNurb, nu);
|
BLI_remlink(&editNurb, nu);
|
||||||
freeNurb(nu);
|
freeNurb(nu); nu= NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Never allow the order to exceed the number of points */
|
/* Never allow the order to exceed the number of points
|
||||||
if ((nu->type & 7)==CU_NURBS && (nu->pntsu < nu->orderu)) {
|
- note, this is ok but changes unselected nurbs, disable for now */
|
||||||
nu->orderu = nu->pntsu;
|
/*
|
||||||
|
if ((nu!= NULL) && ((nu->type & 7)==CU_NURBS)) {
|
||||||
|
clamp_nurb_order_u(nu);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
nu= next;
|
nu= next;
|
||||||
}
|
}
|
||||||
/* 2nd loop, delete small pieces: just for curves */
|
/* 2nd loop, delete small pieces: just for curves */
|
||||||
@@ -3710,10 +3741,12 @@ void delNurb()
|
|||||||
MEM_freeN(nu->bp);
|
MEM_freeN(nu->bp);
|
||||||
nu->bp= bp1;
|
nu->bp= bp1;
|
||||||
|
|
||||||
/* Never allow the order to exceed the number of points */
|
/* Never allow the order to exceed the number of points\
|
||||||
if ((nu->type & 7)==CU_NURBS && (nu->pntsu < nu->orderu)) {
|
- note, this is ok but changes unselected nurbs, disable for now */
|
||||||
nu->orderu = nu->pntsu;
|
/*
|
||||||
}
|
if ((nu->type & 7)==CU_NURBS) {
|
||||||
|
clamp_nurb_order_u(nu);
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
makeknots(nu, 1, nu->flagu>>1);
|
makeknots(nu, 1, nu->flagu>>1);
|
||||||
}
|
}
|
||||||
@@ -3736,10 +3769,10 @@ void delNurb()
|
|||||||
bezt2= bezt+1;
|
bezt2= bezt+1;
|
||||||
if( (bezt2->f1 & SELECT) || (bezt2->f2 & SELECT) || (bezt2->f3 & SELECT) ) ;
|
if( (bezt2->f1 & SELECT) || (bezt2->f2 & SELECT) || (bezt2->f3 & SELECT) ) ;
|
||||||
else { /* maybe do not make cyclic */
|
else { /* maybe do not make cyclic */
|
||||||
if(a==0 && (nu->flagu & 1) ) {
|
if(a==0 && (nu->flagu & CU_CYCLIC) ) {
|
||||||
bezt2= bezt+(nu->pntsu-1);
|
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--;
|
nu->flagu &= ~CU_CYCLIC;
|
||||||
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
||||||
allqueue(REDRAWVIEW3D, 0);
|
allqueue(REDRAWVIEW3D, 0);
|
||||||
allqueue(REDRAWBUTSEDIT, 0);
|
allqueue(REDRAWBUTSEDIT, 0);
|
||||||
@@ -3763,10 +3796,10 @@ void delNurb()
|
|||||||
bp2= bp+1;
|
bp2= bp+1;
|
||||||
if( bp2->f1 & 1 ) ;
|
if( bp2->f1 & 1 ) ;
|
||||||
else { /* maybe do not make cyclic */
|
else { /* maybe do not make cyclic */
|
||||||
if(a==0 && (nu->flagu & 1) ) {
|
if(a==0 && (nu->flagu & CU_CYCLIC) ) {
|
||||||
bp2= bp+(nu->pntsu-1);
|
bp2= bp+(nu->pntsu-1);
|
||||||
if( bp2->f1 & 1 ) {
|
if( bp2->f1 & SELECT ) {
|
||||||
nu->flagu--;
|
nu->flagu &= ~CU_CYCLIC;
|
||||||
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
||||||
allqueue(REDRAWVIEW3D, 0);
|
allqueue(REDRAWVIEW3D, 0);
|
||||||
allqueue(REDRAWBUTSEDIT, 0);
|
allqueue(REDRAWBUTSEDIT, 0);
|
||||||
@@ -3790,16 +3823,16 @@ void delNurb()
|
|||||||
if(bezt1) {
|
if(bezt1) {
|
||||||
if(nu1->pntsu==2) { /* remove completely */
|
if(nu1->pntsu==2) { /* remove completely */
|
||||||
BLI_remlink(&editNurb, nu);
|
BLI_remlink(&editNurb, nu);
|
||||||
freeNurb(nu);
|
freeNurb(nu); nu = NULL;
|
||||||
}
|
}
|
||||||
else if(nu1->flagu & 1) { /* cyclic */
|
else if(nu1->flagu & CU_CYCLIC) { /* cyclic */
|
||||||
bezt =
|
bezt =
|
||||||
(BezTriple*)MEM_mallocN((cut+1) * sizeof(BezTriple), "delNurb1");
|
(BezTriple*)MEM_mallocN((cut+1) * sizeof(BezTriple), "delNurb1");
|
||||||
memcpy(bezt, nu1->bezt,(cut+1)*sizeof(BezTriple));
|
memcpy(bezt, nu1->bezt,(cut+1)*sizeof(BezTriple));
|
||||||
a= nu1->pntsu-cut-1;
|
a= nu1->pntsu-cut-1;
|
||||||
memcpy(nu1->bezt, bezt2, a*sizeof(BezTriple));
|
memcpy(nu1->bezt, bezt2, a*sizeof(BezTriple));
|
||||||
memcpy(nu1->bezt+a, bezt, (cut+1)*sizeof(BezTriple));
|
memcpy(nu1->bezt+a, bezt, (cut+1)*sizeof(BezTriple));
|
||||||
nu1->flagu--;
|
nu1->flagu &= ~CU_CYCLIC;
|
||||||
MEM_freeN(bezt);
|
MEM_freeN(bezt);
|
||||||
calchandlesNurb(nu);
|
calchandlesNurb(nu);
|
||||||
}
|
}
|
||||||
@@ -3832,16 +3865,16 @@ void delNurb()
|
|||||||
else if(bp1) {
|
else if(bp1) {
|
||||||
if(nu1->pntsu==2) { /* remove completely */
|
if(nu1->pntsu==2) { /* remove completely */
|
||||||
BLI_remlink(&editNurb, nu);
|
BLI_remlink(&editNurb, nu);
|
||||||
freeNurb(nu);
|
freeNurb(nu); nu= NULL;
|
||||||
}
|
}
|
||||||
else if(nu1->flagu & 1) { /* cyclic */
|
else if(nu1->flagu & CU_CYCLIC) { /* cyclic */
|
||||||
bp =
|
bp =
|
||||||
(BPoint*)MEM_mallocN((cut+1) * sizeof(BPoint), "delNurb5");
|
(BPoint*)MEM_mallocN((cut+1) * sizeof(BPoint), "delNurb5");
|
||||||
memcpy(bp, nu1->bp,(cut+1)*sizeof(BPoint));
|
memcpy(bp, nu1->bp,(cut+1)*sizeof(BPoint));
|
||||||
a= nu1->pntsu-cut-1;
|
a= nu1->pntsu-cut-1;
|
||||||
memcpy(nu1->bp, bp2, a*sizeof(BPoint));
|
memcpy(nu1->bp, bp2, a*sizeof(BPoint));
|
||||||
memcpy(nu1->bp+a, bp, (cut+1)*sizeof(BPoint));
|
memcpy(nu1->bp+a, bp, (cut+1)*sizeof(BPoint));
|
||||||
nu1->flagu--;
|
nu1->flagu &= ~CU_CYCLIC;
|
||||||
MEM_freeN(bp);
|
MEM_freeN(bp);
|
||||||
}
|
}
|
||||||
else { /* add new curve */
|
else { /* add new curve */
|
||||||
@@ -4151,7 +4184,7 @@ Nurb *addNurbprim(int type, int stype, int newname)
|
|||||||
if((type & 7)==CU_BEZIER) {
|
if((type & 7)==CU_BEZIER) {
|
||||||
nu->pntsu= 4;
|
nu->pntsu= 4;
|
||||||
nu->bezt= callocstructN(BezTriple, 4, "addNurbprim1");
|
nu->bezt= callocstructN(BezTriple, 4, "addNurbprim1");
|
||||||
nu->flagu= 1;
|
nu->flagu= CU_CYCLIC;
|
||||||
bezt= nu->bezt;
|
bezt= nu->bezt;
|
||||||
|
|
||||||
for(a=0;a<3;a++) {
|
for(a=0;a<3;a++) {
|
||||||
@@ -4200,7 +4233,7 @@ Nurb *addNurbprim(int type, int stype, int newname)
|
|||||||
nu->pntsv= 1;
|
nu->pntsv= 1;
|
||||||
nu->orderu= 4;
|
nu->orderu= 4;
|
||||||
nu->bp= callocstructN(BPoint, 8, "addNurbprim6");
|
nu->bp= callocstructN(BPoint, 8, "addNurbprim6");
|
||||||
nu->flagu= 1;
|
nu->flagu= CU_CYCLIC;
|
||||||
bp= nu->bp;
|
bp= nu->bp;
|
||||||
|
|
||||||
for(a=0; a<8; a++) {
|
for(a=0; a<8; a++) {
|
||||||
@@ -4592,10 +4625,6 @@ static void undoCurve_to_editCurve(void *lbv)
|
|||||||
{
|
{
|
||||||
ListBase *lb= lbv;
|
ListBase *lb= lbv;
|
||||||
Nurb *nu, *newnu;
|
Nurb *nu, *newnu;
|
||||||
int nr, lastnunr= 0;
|
|
||||||
|
|
||||||
/* we try to restore lastnu too, for buttons */
|
|
||||||
for(nu= editNurb.first; nu; nu = nu->next, lastnunr++) if(nu==lastnu) break;
|
|
||||||
|
|
||||||
freeNurblist(&editNurb);
|
freeNurblist(&editNurb);
|
||||||
|
|
||||||
@@ -4604,9 +4633,6 @@ static void undoCurve_to_editCurve(void *lbv)
|
|||||||
newnu= duplicateNurb(nu);
|
newnu= duplicateNurb(nu);
|
||||||
BLI_addtail(&editNurb, newnu);
|
BLI_addtail(&editNurb, newnu);
|
||||||
}
|
}
|
||||||
/* restore */
|
|
||||||
for(nr=0, lastnu= editNurb.first; lastnu; lastnu = lastnu->next, nr++) if(nr==lastnunr) break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *editCurve_to_undoCurve(void)
|
static void *editCurve_to_undoCurve(void)
|
||||||
|
|||||||
@@ -659,6 +659,10 @@ void pose_copy_menu(void)
|
|||||||
free_constraints(&pchan->constraints);
|
free_constraints(&pchan->constraints);
|
||||||
copy_constraints(&pchan->constraints, &pchanact->constraints);
|
copy_constraints(&pchan->constraints, &pchanact->constraints);
|
||||||
pchan->constflag = pchanact->constflag;
|
pchan->constflag = pchanact->constflag;
|
||||||
|
|
||||||
|
if (ob->pose) {
|
||||||
|
ob->pose->flag |= POSE_RECALC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 6: /* Transform Locks */
|
case 6: /* Transform Locks */
|
||||||
@@ -741,6 +745,10 @@ void pose_copy_menu(void)
|
|||||||
}
|
}
|
||||||
BLI_freelistN(&const_copy);
|
BLI_freelistN(&const_copy);
|
||||||
update_pose_constraint_flags(ob->pose); /* we could work out the flags but its simpler to do this */
|
update_pose_constraint_flags(ob->pose); /* we could work out the flags but its simpler to do this */
|
||||||
|
|
||||||
|
if (ob->pose) {
|
||||||
|
ob->pose->flag |= POSE_RECALC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); // and all its relations
|
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); // and all its relations
|
||||||
|
|||||||
@@ -4054,6 +4054,7 @@ void createTransData(TransInfo *t)
|
|||||||
t->flag |= T_POINTS;
|
t->flag |= T_POINTS;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
t->flag &= ~T_PROP_EDIT; /* no proportional edit in object mode */
|
||||||
createTransObject(t);
|
createTransObject(t);
|
||||||
t->flag |= T_OBJECT;
|
t->flag |= T_OBJECT;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user