Shapekeys for curves/surfeces
Fix #21498: Edit curve Shape key /252_r 27318 Added full support of shape keys for curves and nurbs surfaces including topology changing in edit mode, undo stuff, updating relative keys when working under basis and so on.
This commit is contained in:
@@ -105,5 +105,7 @@ int check_valid_nurb_v( struct Nurb *nu);
|
||||
int clamp_nurb_order_u( struct Nurb *nu);
|
||||
int clamp_nurb_order_v( struct Nurb *nu);
|
||||
|
||||
ListBase *BKE_curve_nurbs(struct Curve *cu);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -66,6 +66,8 @@
|
||||
#include "BKE_utildefines.h"
|
||||
#include "BKE_depsgraph.h"
|
||||
|
||||
#include "ED_curve.h" /* for ED_curve_nurbs */
|
||||
|
||||
// XXX bad level call...
|
||||
|
||||
/* --------------------- */
|
||||
@@ -458,17 +460,17 @@ void calc_curvepath(Object *ob)
|
||||
float *fp, *dist, *maxdist, xyz[3];
|
||||
float fac, d=0, fac1, fac2;
|
||||
int a, tot, cycl=0;
|
||||
ListBase *nurbs;
|
||||
|
||||
/* in a path vertices are with equal differences: path->len = number of verts */
|
||||
/* NOW WITH BEVELCURVE!!! */
|
||||
|
||||
if(ob==NULL || ob->type != OB_CURVE) return;
|
||||
cu= ob->data;
|
||||
if(cu->editnurb)
|
||||
nu= cu->editnurb->first;
|
||||
else
|
||||
nu= cu->nurb.first;
|
||||
|
||||
|
||||
nurbs= BKE_curve_nurbs(cu);
|
||||
nu= nurbs->first;
|
||||
|
||||
if(cu->path) free_path(cu->path);
|
||||
cu->path= NULL;
|
||||
|
||||
|
||||
@@ -58,6 +58,8 @@
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_utildefines.h" // VECCOPY
|
||||
|
||||
#include "ED_curve.h"
|
||||
|
||||
/* globals */
|
||||
|
||||
/* local */
|
||||
@@ -104,13 +106,8 @@ void free_curve(Curve *cu)
|
||||
BLI_freelistN(&cu->bev);
|
||||
freedisplist(&cu->disp);
|
||||
BKE_free_editfont(cu);
|
||||
|
||||
if(cu->editnurb) {
|
||||
freeNurblist(cu->editnurb);
|
||||
MEM_freeN(cu->editnurb);
|
||||
cu->editnurb= NULL;
|
||||
}
|
||||
|
||||
free_curve_editNurb(cu);
|
||||
unlink_curve(cu);
|
||||
BKE_free_animdata((ID *)cu);
|
||||
|
||||
@@ -2008,8 +2005,10 @@ void makeBevelList(Object *ob)
|
||||
/* STEP 1: MAKE POLYS */
|
||||
|
||||
BLI_freelistN(&(cu->bev));
|
||||
if(cu->editnurb && ob->type!=OB_FONT) nu= cu->editnurb->first;
|
||||
else nu= cu->nurb.first;
|
||||
if(cu->editnurb && ob->type!=OB_FONT) {
|
||||
ListBase *nurbs= ED_curve_editnurbs(cu);
|
||||
nu= nurbs->first;
|
||||
} else nu= cu->nurb.first;
|
||||
|
||||
while(nu) {
|
||||
|
||||
@@ -2999,7 +2998,7 @@ float (*curve_getKeyVertexCos(Curve *cu, ListBase *lb, float *key))[3]
|
||||
VECCOPY(co, key); co+=3; key+=3;
|
||||
VECCOPY(co, key); co+=3; key+=3;
|
||||
VECCOPY(co, key); co+=3; key+=3;
|
||||
key++; /* skip tilt */
|
||||
key+=3; /* skip tilt */
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -3099,5 +3098,12 @@ int clamp_nurb_order_v( struct Nurb *nu)
|
||||
return change;
|
||||
}
|
||||
|
||||
/* Get edit nurbs or normal nurbs list */
|
||||
ListBase *BKE_curve_nurbs(Curve *cu)
|
||||
{
|
||||
if (cu->editnurb) {
|
||||
return ED_curve_editnurbs(cu);
|
||||
}
|
||||
|
||||
|
||||
return &cu->nurb;
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
|
||||
#include "BLO_sys_types.h" // for intptr_t support
|
||||
|
||||
#include "ED_curve.h" /* for BKE_curve_nurbs */
|
||||
|
||||
static void boundbox_displist(Object *ob);
|
||||
|
||||
@@ -1221,7 +1222,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl
|
||||
ModifierData *md = modifiers_getVirtualModifierList(ob);
|
||||
ModifierData *preTesselatePoint;
|
||||
Curve *cu= ob->data;
|
||||
ListBase *nurb= cu->editnurb?cu->editnurb:&cu->nurb;
|
||||
ListBase *nurb= BKE_curve_nurbs(cu);
|
||||
int numVerts = 0;
|
||||
int editmode = (!forRender && cu->editnurb);
|
||||
float (*originalVerts)[3] = NULL;
|
||||
@@ -1324,8 +1325,9 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
|
||||
ModifierData *md = modifiers_getVirtualModifierList(ob);
|
||||
ModifierData *preTesselatePoint;
|
||||
Curve *cu= ob->data;
|
||||
ListBase *nurb= cu->editnurb?cu->editnurb:&cu->nurb;
|
||||
int required_mode, totvert = 0;
|
||||
ListBase *nurb= BKE_curve_nurbs(cu);
|
||||
DispList *dl;
|
||||
int required_mode = 0, totvert = 0;
|
||||
int editmode = (!forRender && cu->editnurb);
|
||||
DerivedMesh *dm= NULL, *ndm;
|
||||
float (*vertCos)[3] = NULL;
|
||||
@@ -1590,9 +1592,9 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase,
|
||||
int numVerts;
|
||||
float (*originalVerts)[3];
|
||||
float (*deformedVerts)[3];
|
||||
|
||||
|
||||
if(!forRender && cu->editnurb)
|
||||
nubase= cu->editnurb;
|
||||
nubase= ED_curve_editnurbs(cu);
|
||||
else
|
||||
nubase= &cu->nurb;
|
||||
|
||||
@@ -1689,10 +1691,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
|
||||
cu->taperobj = NULL;
|
||||
}
|
||||
|
||||
if(cu->editnurb)
|
||||
nubase= cu->editnurb;
|
||||
else
|
||||
nubase= &cu->nurb;
|
||||
nubase= BKE_curve_nurbs(cu);
|
||||
|
||||
BLI_freelistN(&(cu->bev));
|
||||
|
||||
|
||||
@@ -542,11 +542,15 @@ static void cp_key(int start, int end, int tot, char *poin, Key *key, KeyBlock *
|
||||
poinsize= ofs[0];
|
||||
}
|
||||
else if( GS(key->from->name)==ID_CU ) {
|
||||
if(mode==KEY_BPOINT) ofs[0]= sizeof(float)*4;
|
||||
else ofs[0]= sizeof(float)*10;
|
||||
|
||||
if(mode==KEY_BPOINT) {
|
||||
ofs[0]= sizeof(float)*4;
|
||||
poinsize= ofs[0];
|
||||
}else {
|
||||
ofs[0]= sizeof(float)*12;
|
||||
poinsize= ofs[0]/3;
|
||||
}
|
||||
|
||||
ofs[1]= 0;
|
||||
poinsize= ofs[0];
|
||||
}
|
||||
|
||||
if(end>tot) end= tot;
|
||||
@@ -612,7 +616,7 @@ static void cp_key(int start, int end, int tot, char *poin, Key *key, KeyBlock *
|
||||
memcpy(poin, k1, sizeof(float)*4);
|
||||
break;
|
||||
case IPO_BEZTRIPLE:
|
||||
memcpy(poin, k1, sizeof(float)*10);
|
||||
memcpy(poin, k1, sizeof(float)*12);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -644,28 +648,25 @@ static void cp_key(int start, int end, int tot, char *poin, Key *key, KeyBlock *
|
||||
static void cp_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock *kb, int start, int end, char *out, int tot)
|
||||
{
|
||||
Nurb *nu;
|
||||
char *poin;
|
||||
int a, step, a1, a2;
|
||||
|
||||
for(a=0, nu=cu->nurb.first; nu; nu=nu->next, a+=step) {
|
||||
if(nu->bp) {
|
||||
step= nu->pntsu*nu->pntsv;
|
||||
|
||||
/* exception because keys prefer to work with complete blocks */
|
||||
poin= out - a*sizeof(float)*4;
|
||||
a1= MAX2(a, start);
|
||||
a2= MIN2(a+step, end);
|
||||
|
||||
if(a1<a2) cp_key(a1, a2, tot, poin, key, actkb, kb, NULL, KEY_BPOINT);
|
||||
}
|
||||
else if(nu->bezt) {
|
||||
step= 3*nu->pntsu;
|
||||
|
||||
poin= out - a*sizeof(float)*10;
|
||||
|
||||
a1= MAX2(a, start);
|
||||
a2= MIN2(a+step, end);
|
||||
|
||||
if(a1<a2) cp_key(a1, a2, tot, poin, key, actkb, kb, NULL, KEY_BEZTRIPLE);
|
||||
if(a1<a2) cp_key(a1, a2, tot, out, key, actkb, kb, NULL, KEY_BPOINT);
|
||||
}
|
||||
else if(nu->bezt) {
|
||||
step= 3*nu->pntsu;
|
||||
|
||||
/* exception because keys prefer to work with complete blocks */
|
||||
a1= MAX2(a, start);
|
||||
a2= MIN2(a+step, end);
|
||||
|
||||
if(a1<a2) cp_key(a1, a2, tot, out, key, actkb, kb, NULL, KEY_BEZTRIPLE);
|
||||
}
|
||||
else
|
||||
step= 0;
|
||||
@@ -679,26 +680,34 @@ void do_rel_key(int start, int end, int tot, char *basispoin, Key *key, KeyBlock
|
||||
int *ofsp, ofs[3], elemsize, b;
|
||||
char *cp, *poin, *reffrom, *from, elemstr[8];
|
||||
char *freefrom, *freereffrom;
|
||||
|
||||
int poinsize= 0;
|
||||
|
||||
if(key->from==NULL) return;
|
||||
|
||||
|
||||
if( GS(key->from->name)==ID_ME ) {
|
||||
ofs[0]= sizeof(float)*3;
|
||||
ofs[1]= 0;
|
||||
poinsize= ofs[0];
|
||||
}
|
||||
else if( GS(key->from->name)==ID_LT ) {
|
||||
ofs[0]= sizeof(float)*3;
|
||||
ofs[1]= 0;
|
||||
poinsize= ofs[0];
|
||||
}
|
||||
else if( GS(key->from->name)==ID_CU ) {
|
||||
if(mode==KEY_BPOINT) ofs[0]= sizeof(float)*4;
|
||||
else ofs[0]= sizeof(float)*10;
|
||||
|
||||
if(mode==KEY_BPOINT) {
|
||||
ofs[0]= sizeof(float)*4;
|
||||
poinsize= ofs[0];
|
||||
} else {
|
||||
ofs[0]= sizeof(float)*12;
|
||||
poinsize= ofs[0] / 3;
|
||||
}
|
||||
|
||||
ofs[1]= 0;
|
||||
}
|
||||
|
||||
|
||||
if(end>tot) end= tot;
|
||||
|
||||
|
||||
/* in case of beztriple */
|
||||
elemstr[0]= 1; /* nr of ipofloats */
|
||||
elemstr[1]= IPO_BEZTRIPLE;
|
||||
@@ -730,7 +739,7 @@ void do_rel_key(int start, int end, int tot, char *basispoin, Key *key, KeyBlock
|
||||
from= key_block_get_data(key, actkb, kb, &freefrom);
|
||||
reffrom= key_block_get_data(key, actkb, refb, &freereffrom);
|
||||
|
||||
poin+= start*ofs[0];
|
||||
poin+= start*poinsize;
|
||||
reffrom+= key->elemsize*start; // key elemsize yes!
|
||||
from+= key->elemsize*start;
|
||||
|
||||
@@ -756,7 +765,7 @@ void do_rel_key(int start, int end, int tot, char *basispoin, Key *key, KeyBlock
|
||||
rel_flerp(4, (float *)poin, (float *)reffrom, (float *)from, weight);
|
||||
break;
|
||||
case IPO_BEZTRIPLE:
|
||||
rel_flerp(10, (float *)poin, (float *)reffrom, (float *)from, weight);
|
||||
rel_flerp(12, (float *)poin, (float *)reffrom, (float *)from, weight);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -803,11 +812,15 @@ static void do_key(int start, int end, int tot, char *poin, Key *key, KeyBlock *
|
||||
poinsize= ofs[0];
|
||||
}
|
||||
else if( GS(key->from->name)==ID_CU ) {
|
||||
if(mode==KEY_BPOINT) ofs[0]= sizeof(float)*4;
|
||||
else ofs[0]= sizeof(float)*10;
|
||||
|
||||
if(mode==KEY_BPOINT) {
|
||||
ofs[0]= sizeof(float)*4;
|
||||
poinsize= ofs[0];
|
||||
} else {
|
||||
ofs[0]= sizeof(float)*12;
|
||||
poinsize= ofs[0] / 3;
|
||||
}
|
||||
|
||||
ofs[1]= 0;
|
||||
poinsize= ofs[0];
|
||||
}
|
||||
|
||||
if(end>tot) end= tot;
|
||||
@@ -929,7 +942,7 @@ static void do_key(int start, int end, int tot, char *poin, Key *key, KeyBlock *
|
||||
flerp(4, (float *)poin, (float *)k1, (float *)k2, (float *)k3, (float *)k4, t);
|
||||
break;
|
||||
case IPO_BEZTRIPLE:
|
||||
flerp(10, (void *)poin, (void *)k1, (void *)k2, (void *)k3, (void *)k4, t);
|
||||
flerp(12, (void *)poin, (void *)k1, (void *)k2, (void *)k3, (void *)k4, t);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1137,19 +1150,16 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, int tot)
|
||||
static void do_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock **k, float *t, char *out, int tot)
|
||||
{
|
||||
Nurb *nu;
|
||||
char *poin;
|
||||
int a, step;
|
||||
|
||||
for(a=0, nu=cu->nurb.first; nu; nu=nu->next, a+=step) {
|
||||
if(nu->bp) {
|
||||
step= nu->pntsu*nu->pntsv;
|
||||
poin= out - a*sizeof(float)*4;
|
||||
do_key(a, a+step, tot, poin, key, actkb, k, t, KEY_BPOINT);
|
||||
do_key(a, a+step, tot, out, key, actkb, k, t, KEY_BPOINT);
|
||||
}
|
||||
else if(nu->bezt) {
|
||||
step= 3*nu->pntsu;
|
||||
poin= out - a*sizeof(float)*10;
|
||||
do_key(a, a+step, tot, poin, key, actkb, k, t, KEY_BEZTRIPLE);
|
||||
do_key(a, a+step, tot, out, key, actkb, k, t, KEY_BEZTRIPLE);
|
||||
}
|
||||
else
|
||||
step= 0;
|
||||
@@ -1159,19 +1169,16 @@ static void do_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock **k, float
|
||||
static void do_rel_cu_key(Curve *cu, Key *key, KeyBlock *actkb, float ctime, char *out, int tot)
|
||||
{
|
||||
Nurb *nu;
|
||||
char *poin;
|
||||
int a, step;
|
||||
|
||||
for(a=0, nu=cu->nurb.first; nu; nu=nu->next, a+=step) {
|
||||
if(nu->bp) {
|
||||
step= nu->pntsu*nu->pntsv;
|
||||
poin= out - a*sizeof(float)*3;
|
||||
do_rel_key(a, a+step, tot, out, key, actkb, KEY_BPOINT);
|
||||
}
|
||||
else if(nu->bezt) {
|
||||
step= 3*nu->pntsu;
|
||||
poin= out - a*sizeof(float)*10;
|
||||
do_rel_key(a, a+step, tot, poin, key, actkb, KEY_BEZTRIPLE);
|
||||
do_rel_key(a, a+step, tot, out, key, actkb, KEY_BEZTRIPLE);
|
||||
}
|
||||
else
|
||||
step= 0;
|
||||
@@ -1184,35 +1191,61 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, int tot)
|
||||
KeyBlock *k[4], *actkb= ob_get_keyblock(ob);
|
||||
float cfra, ctime, t[4], delta;
|
||||
int a, flag = 0, step = 0;
|
||||
|
||||
if(key->slurph) {
|
||||
delta= key->slurph;
|
||||
delta/= tot;
|
||||
|
||||
|
||||
if(key->slurph && key->type!=KEY_RELATIVE) {
|
||||
Nurb *nu;
|
||||
int mode, i= 0, remain= 0, estep, count;
|
||||
|
||||
delta= (float)key->slurph / tot;
|
||||
|
||||
step= 1;
|
||||
if(tot>100 && slurph_opt) {
|
||||
step= tot/50;
|
||||
delta*= step;
|
||||
/* in do_key and cp_key the case a>tot has been handled */
|
||||
}
|
||||
|
||||
|
||||
cfra= (float)scene->r.cfra;
|
||||
|
||||
for(a=0; a<tot; a+=step, cfra+= delta) {
|
||||
ctime= bsystem_time(scene, 0, cfra, 0.0f); // XXX old cruft
|
||||
#if 0 // XXX old animation system
|
||||
if(calc_ipo_spec(key->ipo, KEY_SPEED, &ctime)==0) {
|
||||
ctime /= 100.0;
|
||||
CLAMP(ctime, 0.0, 1.0);
|
||||
|
||||
for(nu=cu->nurb.first; nu; nu=nu->next) {
|
||||
if(nu->bp) {
|
||||
mode= KEY_BPOINT;
|
||||
estep= nu->pntsu*nu->pntsv;
|
||||
}
|
||||
else if(nu->bezt) {
|
||||
mode= KEY_BEZTRIPLE;
|
||||
estep= 3*nu->pntsu;
|
||||
}
|
||||
#endif // XXX old animation system
|
||||
|
||||
flag= setkeys(ctime, &key->block, k, t, 0);
|
||||
|
||||
if(flag==0)
|
||||
do_key(a, a+step, tot, (char *)out, key, actkb, k, t, 0);
|
||||
else
|
||||
cp_key(a, a+step, tot, (char *)out, key, actkb, k[2], NULL, 0);
|
||||
step= 0;
|
||||
|
||||
a= 0;
|
||||
while (a < estep) {
|
||||
if (remain <= 0) {
|
||||
cfra+= delta;
|
||||
ctime= bsystem_time(scene, 0, cfra, 0.0f); // XXX old cruft
|
||||
|
||||
ctime /= 100.0f;
|
||||
CLAMP(ctime, 0.0f, 1.0f); // XXX for compat, we use this, but this clamping was confusing
|
||||
flag= setkeys(ctime, &key->block, k, t, 0);
|
||||
|
||||
remain= step;
|
||||
}
|
||||
|
||||
count= MIN2(remain, estep);
|
||||
if (mode == KEY_BEZTRIPLE) {
|
||||
count += 3 - count % 3;
|
||||
}
|
||||
|
||||
if(flag==0)
|
||||
do_key(i, i+count, tot, (char *)out, key, actkb, k, t, mode);
|
||||
else
|
||||
cp_key(i, i+count, tot, (char *)out, key, actkb, k[2], NULL, mode);
|
||||
|
||||
a += count;
|
||||
i += count;
|
||||
remain -= count;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1336,11 +1369,11 @@ float *do_ob_key(Scene *scene, Object *ob)
|
||||
for(nu=cu->nurb.first; nu; nu=nu->next) {
|
||||
if(nu->bezt) {
|
||||
tot += 3*nu->pntsu;
|
||||
size += nu->pntsu*10*sizeof(float);
|
||||
size += nu->pntsu*12*sizeof(float);
|
||||
}
|
||||
else if(nu->bp) {
|
||||
tot += nu->pntsu*nu->pntsv;
|
||||
size += nu->pntsu*nu->pntsv*10*sizeof(float);
|
||||
size += nu->pntsu*nu->pntsv*12*sizeof(float);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1885,13 +1885,12 @@ static void give_parvert(Object *par, int nr, float *vec)
|
||||
BPoint *bp;
|
||||
BezTriple *bezt;
|
||||
int found= 0;
|
||||
|
||||
ListBase *nurbs;
|
||||
|
||||
cu= par->data;
|
||||
if(cu->editnurb)
|
||||
nu= cu->editnurb->first;
|
||||
else
|
||||
nu= cu->nurb.first;
|
||||
|
||||
nurbs= BKE_curve_nurbs(cu);
|
||||
nu= nurbs->first;
|
||||
|
||||
count= 0;
|
||||
while(nu && !found) {
|
||||
if(nu->type == CU_BEZIER) {
|
||||
@@ -2946,7 +2945,7 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, char *name, int from_
|
||||
Curve *cu= ob->data;
|
||||
Key *key= cu->key;
|
||||
KeyBlock *kb;
|
||||
ListBase *lb= (cu->editnurb)? cu->editnurb: &cu->nurb;
|
||||
ListBase *lb= BKE_curve_nurbs(cu);
|
||||
int newkey= 0;
|
||||
|
||||
if(key==NULL) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -37,6 +37,10 @@ struct Text;
|
||||
struct View3D;
|
||||
struct wmOperator;
|
||||
struct wmKeyConfig;
|
||||
struct Curve;
|
||||
struct EditNurb;
|
||||
struct BezTriple;
|
||||
struct BPoint;
|
||||
|
||||
/* curve_ops.c */
|
||||
void ED_operatortypes_curve(void);
|
||||
@@ -55,6 +59,8 @@ void load_editNurb (struct Object *obedit);
|
||||
void make_editNurb (struct Object *obedit);
|
||||
void free_editNurb (struct Object *obedit);
|
||||
|
||||
void free_curve_editNurb (struct Curve *cu);
|
||||
|
||||
int mouse_nurb (struct bContext *C, short mval[2], int extend);
|
||||
|
||||
struct Nurb *add_nurbs_primitive(struct bContext *C, float mat[4][4], int type, int newname);
|
||||
@@ -72,6 +78,10 @@ void free_editText (struct Object *obedit);
|
||||
void ED_text_to_object(struct bContext *C, struct Text *text, int split_lines);
|
||||
|
||||
int CU_select_nth(struct Object *obedit, int nth);
|
||||
ListBase *ED_curve_editnurbs(struct Curve *cu);
|
||||
|
||||
void ED_curve_beztcpy(struct EditNurb *editnurb, struct BezTriple *dst, struct BezTriple *src, int count);
|
||||
void ED_curve_bpcpy(struct EditNurb *editnurb, struct BPoint *dst, struct BPoint *src, int count);
|
||||
|
||||
#endif /* ED_CURVE_H */
|
||||
|
||||
|
||||
@@ -310,11 +310,11 @@ static int material_slot_assign_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
}
|
||||
else if(ELEM(ob->type, OB_CURVE, OB_SURF)) {
|
||||
ListBase *editnurb= ((Curve*)ob->data)->editnurb;
|
||||
Nurb *nu;
|
||||
ListBase *nurbs= ED_curve_editnurbs((Curve*)ob->data);
|
||||
|
||||
if(editnurb) {
|
||||
for(nu= editnurb->first; nu; nu= nu->next)
|
||||
if(nurbs) {
|
||||
for(nu= nurbs->first; nu; nu= nu->next)
|
||||
if(isNurbsel(nu))
|
||||
nu->mat_nr= nu->charidx= ob->actcol-1;
|
||||
}
|
||||
@@ -368,13 +368,13 @@ static int material_slot_de_select(bContext *C, int select)
|
||||
}
|
||||
}
|
||||
else if ELEM(ob->type, OB_CURVE, OB_SURF) {
|
||||
ListBase *editnurb= ((Curve*)ob->data)->editnurb;
|
||||
ListBase *nurbs= ED_curve_editnurbs((Curve*)ob->data);
|
||||
Nurb *nu;
|
||||
BPoint *bp;
|
||||
BezTriple *bezt;
|
||||
int a;
|
||||
|
||||
for(nu= editnurb->first; nu; nu=nu->next) {
|
||||
for(nu= nurbs->first; nu; nu=nu->next) {
|
||||
if(nu->mat_nr==ob->actcol-1) {
|
||||
if(nu->bezt) {
|
||||
a= nu->pntsu;
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
|
||||
#include "ED_armature.h"
|
||||
#include "ED_mesh.h"
|
||||
#include "ED_curve.h" /* for ED_curve_editnurbs */
|
||||
|
||||
#include "BLI_editVert.h"
|
||||
|
||||
@@ -187,8 +188,9 @@ static void stats_object_edit(Object *obedit, SceneStats *stats)
|
||||
BezTriple *bezt;
|
||||
BPoint *bp;
|
||||
int a;
|
||||
ListBase *nurbs= ED_curve_editnurbs(cu);
|
||||
|
||||
for(nu=cu->editnurb->first; nu; nu=nu->next) {
|
||||
for(nu=nurbs->first; nu; nu=nu->next) {
|
||||
if(nu->type == CU_BEZIER) {
|
||||
bezt= nu->bezt;
|
||||
a= nu->pntsu;
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_interface.h"
|
||||
|
||||
|
||||
#include "info_intern.h" // own include
|
||||
|
||||
/* ******************** default callbacks for info space ***************** */
|
||||
|
||||
@@ -86,6 +86,7 @@
|
||||
#include "ED_screen.h"
|
||||
#include "ED_sculpt.h"
|
||||
#include "ED_types.h"
|
||||
#include "ED_curve.h" /* for ED_curve_editnurbs */
|
||||
|
||||
#include "UI_resources.h"
|
||||
|
||||
@@ -1610,10 +1611,11 @@ void nurbs_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, Nurb
|
||||
short s[2] = {IS_CLIPPED, 0};
|
||||
Nurb *nu;
|
||||
int i;
|
||||
ListBase *nurbs= ED_curve_editnurbs(cu);
|
||||
|
||||
ED_view3d_local_clipping(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */
|
||||
|
||||
for (nu= cu->editnurb->first; nu; nu=nu->next) {
|
||||
for (nu= nurbs->first; nu; nu=nu->next) {
|
||||
if(nu->type == CU_BEZIER) {
|
||||
for (i=0; i<nu->pntsu; i++) {
|
||||
BezTriple *bezt = &nu->bezt[i];
|
||||
@@ -5882,7 +5884,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
|
||||
cu= ob->data;
|
||||
|
||||
if(cu->editnurb) {
|
||||
drawnurb(scene, v3d, rv3d, base, cu->editnurb->first, dt);
|
||||
ListBase *nurbs= ED_curve_editnurbs(cu);
|
||||
drawnurb(scene, v3d, rv3d, base, nurbs->first, dt);
|
||||
}
|
||||
else if(dt==OB_BOUNDBOX) {
|
||||
if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0)
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
#include "ED_mesh.h"
|
||||
#include "ED_screen.h"
|
||||
#include "ED_transform.h"
|
||||
#include "ED_curve.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
@@ -205,8 +206,9 @@ static void v3d_editvertex_buts(const bContext *C, uiLayout *layout, View3D *v3d
|
||||
BPoint *bp;
|
||||
BezTriple *bezt;
|
||||
int a;
|
||||
|
||||
nu= cu->editnurb->first;
|
||||
ListBase *nurbs= ED_curve_editnurbs(cu);
|
||||
|
||||
nu= nurbs->first;
|
||||
while(nu) {
|
||||
if(nu->type == CU_BEZIER) {
|
||||
bezt= nu->bezt;
|
||||
@@ -410,8 +412,9 @@ static void v3d_editvertex_buts(const bContext *C, uiLayout *layout, View3D *v3d
|
||||
BPoint *bp;
|
||||
BezTriple *bezt;
|
||||
int a;
|
||||
|
||||
nu= cu->editnurb->first;
|
||||
ListBase *nurbs= ED_curve_editnurbs(cu);
|
||||
|
||||
nu= nurbs->first;
|
||||
while(nu) {
|
||||
if(nu->type == CU_BEZIER) {
|
||||
bezt= nu->bezt;
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
#include "ED_armature.h"
|
||||
#include "ED_mesh.h"
|
||||
#include "ED_screen.h"
|
||||
#include "ED_curve.h" /* for ED_curve_editnurbs */
|
||||
|
||||
#include "view3d_intern.h"
|
||||
|
||||
@@ -100,8 +101,9 @@ static void special_transvert_update(Scene *scene, Object *obedit)
|
||||
}
|
||||
else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
|
||||
Curve *cu= obedit->data;
|
||||
Nurb *nu= cu->editnurb->first;
|
||||
|
||||
ListBase *nurbs= ED_curve_editnurbs(cu);
|
||||
Nurb *nu= nurbs->first;
|
||||
|
||||
while(nu) {
|
||||
test2DNurb(nu);
|
||||
testhandlesNurb(nu); /* test for bezier too */
|
||||
@@ -288,8 +290,9 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode)
|
||||
else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
|
||||
Curve *cu= obedit->data;
|
||||
int totmalloc= 0;
|
||||
|
||||
for(nu= cu->editnurb->first; nu; nu= nu->next) {
|
||||
ListBase *nurbs= ED_curve_editnurbs(cu);
|
||||
|
||||
for(nu= nurbs->first; nu; nu= nu->next) {
|
||||
if(nu->type == CU_BEZIER)
|
||||
totmalloc += 3*nu->pntsu;
|
||||
else
|
||||
@@ -297,7 +300,7 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode)
|
||||
}
|
||||
tv=transvmain= MEM_callocN(totmalloc*sizeof(TransVert), "maketransverts curve");
|
||||
|
||||
nu= cu->editnurb->first;
|
||||
nu= nurbs->first;
|
||||
while(nu) {
|
||||
if(nu->type == CU_BEZIER) {
|
||||
a= nu->pntsu;
|
||||
|
||||
@@ -94,6 +94,7 @@
|
||||
#include "ED_mesh.h"
|
||||
#include "ED_types.h"
|
||||
#include "ED_uvedit.h"
|
||||
#include "ED_curve.h" /* for ED_curve_editnurbs */
|
||||
|
||||
#include "UI_view2d.h"
|
||||
|
||||
@@ -1347,12 +1348,14 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
|
||||
int count=0, countsel=0;
|
||||
int propmode = t->flag & T_PROP_EDIT;
|
||||
short hide_handles = (cu->drawflag & CU_HIDE_HANDLES);
|
||||
|
||||
ListBase *nurbs;
|
||||
|
||||
/* to be sure */
|
||||
if(cu->editnurb==NULL) return;
|
||||
|
||||
/* count total of vertices, check identical as in 2nd loop for making transdata! */
|
||||
for(nu= cu->editnurb->first; nu; nu= nu->next) {
|
||||
nurbs= ED_curve_editnurbs(cu);
|
||||
for(nu= nurbs->first; nu; nu= nu->next) {
|
||||
if(nu->type == CU_BEZIER) {
|
||||
for(a=0, bezt= nu->bezt; a<nu->pntsu; a++, bezt++) {
|
||||
if(bezt->hide==0) {
|
||||
@@ -1388,7 +1391,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
|
||||
invert_m3_m3(smtx, mtx);
|
||||
|
||||
td = t->data;
|
||||
for(nu= cu->editnurb->first; nu; nu= nu->next) {
|
||||
for(nu= nurbs->first; nu; nu= nu->next) {
|
||||
if(nu->type == CU_BEZIER) {
|
||||
TransData *head, *tail;
|
||||
head = tail = td;
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
#include "ED_space_api.h"
|
||||
#include "ED_uvedit.h"
|
||||
#include "ED_view3d.h"
|
||||
#include "ED_curve.h" /* for ED_curve_editnurbs */
|
||||
|
||||
//#include "BDR_unwrapper.h"
|
||||
|
||||
@@ -636,14 +637,15 @@ void recalcData(TransInfo *t)
|
||||
if (t->obedit) {
|
||||
if ELEM(t->obedit->type, OB_CURVE, OB_SURF) {
|
||||
Curve *cu= t->obedit->data;
|
||||
Nurb *nu= cu->editnurb->first;
|
||||
ListBase *nurbs= ED_curve_editnurbs(cu);
|
||||
Nurb *nu= nurbs->first;
|
||||
|
||||
if(t->state != TRANS_CANCEL) {
|
||||
clipMirrorModifier(t, t->obedit);
|
||||
}
|
||||
|
||||
DAG_id_flush_update(t->obedit->data, OB_RECALC_DATA); /* sets recalc flags */
|
||||
|
||||
|
||||
if (t->state == TRANS_CANCEL) {
|
||||
while(nu) {
|
||||
calchandlesNurb(nu); /* Cant do testhandlesNurb here, it messes up the h1 and h2 flags */
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
#include "ED_mesh.h"
|
||||
#include "ED_particle.h"
|
||||
#include "ED_view3d.h"
|
||||
#include "ED_curve.h" /* for ED_curve_editnurbs */
|
||||
|
||||
#include "UI_resources.h"
|
||||
|
||||
@@ -311,8 +312,9 @@ int calc_manipulator_stats(const bContext *C)
|
||||
Nurb *nu;
|
||||
BezTriple *bezt;
|
||||
BPoint *bp;
|
||||
ListBase *nurbs= ED_curve_editnurbs(cu);
|
||||
|
||||
nu= cu->editnurb->first;
|
||||
nu= nurbs->first;
|
||||
while(nu) {
|
||||
if(nu->type == CU_BEZIER) {
|
||||
bezt= nu->bezt;
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
|
||||
#include "ED_armature.h"
|
||||
#include "ED_mesh.h"
|
||||
#include "ED_curve.h" /* for ED_curve_editnurbs */
|
||||
|
||||
|
||||
#include "RNA_define.h"
|
||||
@@ -740,8 +741,9 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
|
||||
Nurb *nu;
|
||||
BezTriple *bezt;
|
||||
int a;
|
||||
|
||||
for (nu = cu->editnurb->first; nu; nu = nu->next)
|
||||
ListBase *nurbs= ED_curve_editnurbs(cu);
|
||||
|
||||
for (nu = nurbs->first; nu; nu = nu->next)
|
||||
{
|
||||
/* only bezier has a normal */
|
||||
if(nu->type == CU_BEZIER)
|
||||
|
||||
@@ -48,6 +48,7 @@ struct VFont;
|
||||
struct AnimData;
|
||||
struct SelBox;
|
||||
struct EditFont;
|
||||
struct GHash;
|
||||
|
||||
/* These two Lines with # tell makesdna this struct can be excluded. */
|
||||
#
|
||||
@@ -150,6 +151,14 @@ typedef struct TextBox {
|
||||
float x, y, w, h;
|
||||
} TextBox;
|
||||
|
||||
typedef struct EditNurb {
|
||||
/* base of nurbs' list (old Curve->editnurb) */
|
||||
ListBase nurbs;
|
||||
|
||||
/* index data for shape keys */
|
||||
struct GHash *keyindex;
|
||||
} EditNurb;
|
||||
|
||||
typedef struct Curve {
|
||||
ID id;
|
||||
struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */
|
||||
@@ -159,7 +168,7 @@ typedef struct Curve {
|
||||
ListBase nurb; /* actual data, called splines in rna */
|
||||
ListBase disp;
|
||||
|
||||
ListBase *editnurb; /* edited data, not in file, use pointer so we can check for it */
|
||||
EditNurb *editnurb; /* edited data, not in file, use pointer so we can check for it */
|
||||
|
||||
struct Object *bevobj, *taperobj, *textoncurve;
|
||||
struct Ipo *ipo; // XXX depreceated... old animation system
|
||||
|
||||
@@ -36,6 +36,9 @@
|
||||
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "BKE_curve.h"
|
||||
#include "ED_curve.h"
|
||||
|
||||
EnumPropertyItem beztriple_handle_type_items[] = {
|
||||
{HD_FREE, "FREE", 0, "Free", ""},
|
||||
{HD_AUTO, "AUTO", 0, "Auto", ""},
|
||||
@@ -71,6 +74,8 @@ EnumPropertyItem curve_type_items[] = {
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "ED_curve.h" /* for BKE_curve_nurbs */
|
||||
|
||||
static StructRNA *rna_Curve_refine(PointerRNA *ptr)
|
||||
{
|
||||
Curve *cu= (Curve*)ptr->data;
|
||||
@@ -193,7 +198,8 @@ static void rna_Curve_active_textbox_index_range(PointerRNA *ptr, int *min, int
|
||||
static void rna_Curve_dimension_set(PointerRNA *ptr, int value)
|
||||
{
|
||||
Curve *cu= (Curve*)ptr->id.data;
|
||||
Nurb *nu= cu->editnurb ? cu->editnurb->first : cu->nurb.first;
|
||||
ListBase *nurbs= BKE_curve_nurbs(cu);
|
||||
Nurb *nu= nurbs->first;
|
||||
|
||||
if(value==CU_3D) {
|
||||
cu->flag |= CU_3D;
|
||||
@@ -309,11 +315,9 @@ static void rna_Curve_taperObject_set(PointerRNA *ptr, PointerRNA value)
|
||||
static void rna_Curve_resolution_u_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||
{
|
||||
Curve *cu= (Curve*)ptr->id.data;
|
||||
Nurb *nu=NULL;
|
||||
|
||||
if (cu->editnurb) nu= cu->editnurb->first;
|
||||
else nu=cu->nurb.first;
|
||||
|
||||
ListBase *nurbs= BKE_curve_nurbs(cu);
|
||||
Nurb *nu= nurbs->first;
|
||||
|
||||
while(nu) {
|
||||
nu->resolu= cu->resolu;
|
||||
nu= nu->next;
|
||||
@@ -325,16 +329,15 @@ static void rna_Curve_resolution_u_update_data(Main *bmain, Scene *scene, Pointe
|
||||
static void rna_Curve_resolution_v_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||
{
|
||||
Curve *cu= (Curve*)ptr->id.data;
|
||||
Nurb *nu=NULL;
|
||||
|
||||
if (cu->editnurb) nu= cu->editnurb->first;
|
||||
else nu=cu->nurb.first;
|
||||
|
||||
ListBase *nurbs= BKE_curve_nurbs(cu);
|
||||
Nurb *nu=nurbs->first;
|
||||
|
||||
|
||||
while(nu) {
|
||||
nu->resolv= cu->resolv;
|
||||
nu= nu->next;
|
||||
}
|
||||
|
||||
|
||||
rna_Curve_update_data(bmain, scene, ptr);
|
||||
}
|
||||
|
||||
@@ -466,12 +469,9 @@ static void rna_Curve_spline_remove(Curve *cu, ReportList *reports, Nurb *nu)
|
||||
{
|
||||
/* todo, check we're in the list */
|
||||
int found= 0;
|
||||
if(cu->editnurb) {
|
||||
found= BLI_remlink_safe(cu->editnurb, nu);
|
||||
}
|
||||
else {
|
||||
found= BLI_remlink_safe(&cu->nurb, nu);
|
||||
}
|
||||
ListBase *nurbs= BKE_curve_nurbs(cu);
|
||||
|
||||
found= BLI_remlink_safe(nurbs, nu);
|
||||
|
||||
if(!found) {
|
||||
BKE_reportf(reports, RPT_ERROR, "Curve \"%s\" does not contain spline given", cu->id.name+2);
|
||||
@@ -486,11 +486,10 @@ static PointerRNA rna_Curve_active_spline_get(PointerRNA *ptr)
|
||||
{
|
||||
Curve *cu= (Curve*)ptr->data;
|
||||
Nurb *nu;
|
||||
ListBase *nurbs= BKE_curve_nurbs(cu);
|
||||
|
||||
if(cu->editnurb)
|
||||
nu= BLI_findlink(cu->editnurb, cu->actnu);
|
||||
else
|
||||
nu= BLI_findlink(&cu->nurb, cu->actnu); // currently set to -1, should be changed to be allowed outside of editmode.
|
||||
// for curve outside editmode will set to -1, should be changed to be allowed outside of editmode.
|
||||
nu= BLI_findlink(nurbs, cu->actnu);
|
||||
|
||||
if(nu)
|
||||
return rna_pointer_inherit_refine(ptr, &RNA_Spline, nu);
|
||||
@@ -502,14 +501,13 @@ static void rna_Curve_active_spline_set(PointerRNA *ptr, PointerRNA value)
|
||||
{
|
||||
Curve *cu= (Curve*)ptr->data;
|
||||
Nurb *nu= value.data;
|
||||
ListBase *nubase= BKE_curve_nurbs(cu);
|
||||
|
||||
/* -1 is ok for an unset index */
|
||||
if(nu==NULL)
|
||||
cu->actnu= -1;
|
||||
else if(cu->editnurb)
|
||||
cu->actnu= BLI_findindex(cu->editnurb, nu);
|
||||
else
|
||||
cu->actnu= BLI_findindex(&cu->nurb, nu);
|
||||
cu->actnu= BLI_findindex(nubase, nu);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
@@ -255,6 +255,9 @@ void ED_sequencer_update_view(struct bContext *C, int view){}
|
||||
float ED_rollBoneToVector(struct EditBone *bone, float new_up_axis[3]){return 0.0f;}
|
||||
void ED_space_image_size(struct SpaceImage *sima, int *width, int *height){}
|
||||
|
||||
struct ListBase *ED_curve_editnurbs(struct Curve *cu){return NULL;}
|
||||
void free_curve_editNurb (struct Curve *cu){};
|
||||
|
||||
void EM_selectmode_set(struct EditMesh *em){}
|
||||
int EM_texFaceCheck(struct EditMesh *em){return 0;}
|
||||
struct MTFace *EM_get_active_mtface(struct EditMesh *em, struct EditFace **act_efa, struct MCol **mcol, int sloopy){return (struct MTFace *)NULL;}
|
||||
|
||||
Reference in New Issue
Block a user