diff options
27 files changed, 516 insertions, 983 deletions
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index dadc2b67519..4effdb6af8a 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -69,7 +69,8 @@ void makeNurbfaces( struct Nurb *nu, float *data, int rowstride); void makeNurbcurve_forw(struct Nurb *nu, float *data); void makeNurbcurve( struct Nurb *nu, float *data, int dim); void forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride); -void make_orco_surf( struct Curve *cu); +float *make_orco_curve( struct Object *ob); +float *make_orco_surf( struct Object *ob); void makebevelcurve( struct Object *ob, struct ListBase *disp); short bevelinside(struct BevList *bl1,struct BevList *bl2); int vergxcobev(const void *a1, const void *a2); diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h index a151cff8879..5888975feb6 100644 --- a/source/blender/blenkernel/BKE_deform.h +++ b/source/blender/blenkernel/BKE_deform.h @@ -47,9 +47,5 @@ struct bDeformGroup* copy_defgroup (struct bDeformGroup *ingroup); struct bDeformGroup *get_named_vertexgroup (Object *ob, char *name); int get_defgroup_num (struct Object *ob, struct bDeformGroup *dg); -int curve_modifier(struct Object *ob, char mode); -int lattice_modifier(struct Object *ob, char mode); - - #endif diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h index 1102603b6a4..434f9fb1ef9 100644 --- a/source/blender/blenkernel/BKE_displist.h +++ b/source/blender/blenkernel/BKE_displist.h @@ -127,6 +127,8 @@ typedef struct DispList { unsigned int *col1, *col2; int charidx; int pad; + + unsigned int *bevelSplitFlag; } DispList; extern void copy_displist(struct ListBase *lbn, struct ListBase *lb); @@ -135,12 +137,11 @@ extern DispList *find_displist_create(struct ListBase *lb, int type); extern DispList *find_displist(struct ListBase *lb, int type); extern void addnormalsDispList(struct Object *ob, struct ListBase *lb); extern void count_displist(struct ListBase *lb, int *totvert, int *totface); -extern void curve_to_filledpoly(struct Curve *cu, struct ListBase *nurb, struct ListBase *dispbase); extern void freedisplist(struct ListBase *lb); extern int displist_has_faces(struct ListBase *lb); -extern float calc_taper(struct Object *taperobj, int cur, int tot); extern void makeDispListMesh(struct Object *ob); -extern void makeDispListCurveTypes(struct Object *ob); +extern void makeDispListSurf(struct Object *ob, struct ListBase *dispbase, int forRender); +extern void makeDispListCurveTypes(struct Object *ob, int forOrco); extern void makeDispListMBall(struct Object *ob); extern void shadeDispList(struct Object *ob); void freefastshade(void); diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h index 6b6bae6e4c4..38bbd9301f7 100644 --- a/source/blender/blenkernel/BKE_lattice.h +++ b/source/blender/blenkernel/BKE_lattice.h @@ -50,7 +50,8 @@ void calc_lat_fudu(int flag, int res, float *fu, float *du); void init_latt_deform(struct Object *oblatt, struct Object *ob); void calc_latt_deform(float *co); void end_latt_deform(void); -int object_deform(struct Object *ob); +int object_deform_mball(struct Object *ob); +int object_deform_curve(struct Object *ob, struct ListBase *lb); struct BPoint *latt_bp(struct Lattice *lt, int u, int v, int w); void outside_lattice(struct Lattice *lt); void curve_deform_verts(struct Object *cuOb, struct Object *target, float (*vertexCos)[3], int numVerts); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index f465f85b98d..fb10d5d769b 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -544,7 +544,7 @@ void do_all_actions(Object *ob) if (cu->flag & CU_PATH){ /* Ensure we have a valid path */ - if(cu->path==NULL || cu->path->data==NULL) makeDispListCurveTypes(ob->parent); + if(cu->path==NULL || cu->path->data==NULL) makeDispListCurveTypes(ob->parent, 0); if(cu->path) { /* Find the position on the path */ diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 3db4a91fc1e..150f5eddd41 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1039,37 +1039,24 @@ void forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int i /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -void make_orco_surf(Curve *cu) +float *make_orco_surf(Object *ob) { + Curve *cu = ob->data; Nurb *nu; int a, b, tot=0; int sizeu, sizev;// ### float *data; + float *orco; - - /* first calculate the size of the datablock */ - nu= cu->nurb.first; - while(nu) { -/* this is a bad hack: as we want to avoid the seam in a cyclic nurbs -texture wrapping, reserve extra orco data space to save these extra needed -vertex based UV coordinates for the meridian vertices. -Vertices on the 0/2pi boundary are not duplicated inside the displist but later in -the renderface/vert construction. - -See also blenderWorldManipulation.c: init_render_surf() - -*/ - + /* first calculate the size of the datablock */ + for (nu=cu->nurb.first; nu; nu=nu->next) { sizeu = nu->resolu; sizev = nu->resolv; if(nu->pntsv>1) tot+= sizeu * sizev; - - nu= nu->next; } /* makeNurbfaces wants zeros */ - data= cu->orco= MEM_callocN(3*sizeof(float)*tot, "make_orco"); + data= orco= MEM_callocN(3*sizeof(float)*tot, "make_orco"); - nu= cu->nurb.first; - while(nu) { + for (nu=cu->nurb.first; nu; nu=nu->next) { if(nu->pntsv>1) { sizeu = nu->resolu; sizev = nu->resolv; @@ -1095,7 +1082,7 @@ See also blenderWorldManipulation.c: init_render_surf() for(b=0; b<sizeu; b++) { for(a=0; a<sizev; a++) { - data = cu->orco + 3 * (b * sizev + a); + data = orco + 3 * (b * sizev + a); data[0]= (data[0]-cu->loc[0])/cu->size[0]; data[1]= (data[1]-cu->loc[1])/cu->size[1]; data[2]= (data[2]-cu->loc[2])/cu->size[2]; @@ -1103,13 +1090,83 @@ See also blenderWorldManipulation.c: init_render_surf() } } } - nu= nu->next; } - /* loadkeypostype(22, base, base); */ + return orco; } + /* NOTE: This routine is tied to the order of vertex + * built by displist and as passed to the renderer. + */ +float *make_orco_curve(Object *ob) +{ + Curve *cu = ob->data; + DispList *dl; + int u, v, numVerts; + float *fp, *orco; + int remakeDisp = 0; + + if (!(cu->flag&CU_UV_ORCO) && cu->key && cu->key->refkey) { + cp_cu_key(cu, cu->key->refkey, 0, count_curveverts(&cu->nurb)); + makeDispListCurveTypes(ob, 1); + remakeDisp = 1; + } + + /* Assumes displist has been built */ + + numVerts = 0; + for (dl=cu->disp.first; dl; dl=dl->next) { + if (dl->type==DL_INDEX3) { + numVerts += dl->nr; + } else if (dl->type==DL_SURF) { + numVerts += dl->parts*dl->nr; + } + } + + fp= orco= MEM_mallocN(3*sizeof(float)*numVerts, "cu_orco"); + + for (dl=cu->disp.first; dl; dl=dl->next) { + if (dl->type==DL_INDEX3) { + for (u=0; u<dl->nr; u++,fp+=3) { + if (cu->flag&CU_UV_ORCO) { + fp[0]= 2.0f*u/(dl->nr-1) - 1.0f; + fp[1]= 0.0; + fp[2]= 0.0; + } else { + VECCOPY(fp, &dl->verts[u*3]); + + fp[0]= (fp[0]-cu->loc[0])/cu->size[0]; + fp[1]= (fp[1]-cu->loc[1])/cu->size[1]; + fp[2]= (fp[2]-cu->loc[2])/cu->size[2]; + } + } + } else if (dl->type==DL_SURF) { + for (u=0; u<dl->parts; u++) { + for (v=0; v<dl->nr; v++,fp+=3) { + if (cu->flag&CU_UV_ORCO) { + fp[0]= 2.0f*u/(dl->parts-1) - 1.0f; + fp[1]= 2.0f*v/(dl->nr-1) - 1.0f; + fp[2]= 0.0; + } else { + VECCOPY(fp, &dl->verts[(dl->nr*u + v)*3]); + + fp[0]= (fp[0]-cu->loc[0])/cu->size[0]; + fp[1]= (fp[1]-cu->loc[1])/cu->size[1]; + fp[2]= (fp[2]-cu->loc[2])/cu->size[2]; + } + } + } + } + } + + if (remakeDisp) { + makeDispListCurveTypes(ob, 0); + } + + return orco; +} + /* ***************** BEVEL ****************** */ @@ -1122,6 +1179,7 @@ void makebevelcurve(Object *ob, ListBase *disp) cu= ob->data; + disp->first = disp->last = NULL; if(cu->bevobj && cu->bevobj!=ob) { if(cu->bevobj->type==OB_CURVE) { bevcu= cu->bevobj->data; @@ -1131,7 +1189,7 @@ void makebevelcurve(Object *ob, ListBase *disp) dl= bevcu->disp.first; if(dl==0) { - makeDispListCurveTypes(cu->bevobj); + makeDispListCurveTypes(cu->bevobj, 0); dl= bevcu->disp.first; } while(dl) { @@ -1158,6 +1216,9 @@ void makebevelcurve(Object *ob, ListBase *disp) } } } + else if(cu->ext1==0.0 && cu->ext2==0.0) { + ; + } else if(cu->ext2==0.0) { dl= MEM_callocN(sizeof(DispList), "makebevelcurve2"); dl->verts= MEM_mallocN(2*3*sizeof(float), "makebevelcurve2"); @@ -1259,7 +1320,6 @@ void makebevelcurve(Object *ob, ListBase *disp) fp+= 3; } } - } int cu_isectLL(float *v1, float *v2, float *v3, float *v4, short cox, short coy, float *labda, float *mu, float *vec) diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 84a96a8e694..be3c1afc2c5 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -154,47 +154,3 @@ int get_defgroup_num (Object *ob, bDeformGroup *dg) } -/* *************** HOOK ****************** */ - -int curve_modifier(Object *ob, char mode) -{ - static ListBase nurb={NULL, NULL}; - Curve *cu= ob->data; - Nurb *nu, *newnu; - int done= 0; - - do_curve_key(cu); - - /* conditions if it's needed */ - if(ob->parent && ob->partype==PARSKEL); - else if(ob->parent && ob->parent->type==OB_LATTICE); - else return 0; - - if(mode=='s') { // "start" - /* copy */ - nurb.first= nurb.last= NULL; - nu= cu->nurb.first; - while(nu) { - newnu= duplicateNurb(nu); - BLI_addtail(&nurb, newnu); - nu= nu->next; - } - } - else if(mode=='e') { - /* paste */ - freeNurblist(&cu->nurb); - cu->nurb= nurb; - } - - return done; -} - -int lattice_modifier(Object *ob, char mode) -{ - Lattice *lt = ob->data; - - do_latt_key(lt); - - return 0; -} - diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index bf0bab5403f..37bcf2051d1 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -1437,10 +1437,6 @@ void DAG_scene_update_flags(Scene *sce, unsigned int lay) case OB_MESH: me= ob->data; if(me->key) ob->recalc |= OB_RECALC_DATA; - else if(ob->effect.first) { - Effect *eff= ob->effect.first; - if(eff->type==EFF_WAVE) ob->recalc |= OB_RECALC_DATA; - } break; case OB_CURVE: case OB_SURF: diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index ce4e45db405..b343c066421 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -79,6 +79,7 @@ #include "BKE_mball.h" #include "BKE_material.h" #include "BKE_curve.h" +#include "BKE_key.h" #include "BKE_anim.h" #include "BKE_screen.h" #include "BKE_texture.h" @@ -203,6 +204,7 @@ void free_disp_elem(DispList *dl) if(dl->index) MEM_freeN(dl->index); if(dl->col1) MEM_freeN(dl->col1); if(dl->col2) MEM_freeN(dl->col2); + if(dl->bevelSplitFlag) MEM_freeN(dl->bevelSplitFlag); MEM_freeN(dl); } } @@ -1034,7 +1036,7 @@ void count_displist(ListBase *lb, int *totvert, int *totface) } } -static void curve_to_displist(ListBase *nubase, ListBase *dispbase) +static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase) { Nurb *nu; DispList *dl; @@ -1044,7 +1046,6 @@ static void curve_to_displist(ListBase *nubase, ListBase *dispbase) int a, len; nu= nubase->first; - while(nu) { if(nu->hide==0) { if((nu->type & 7)==CU_BEZIER) { @@ -1209,14 +1210,7 @@ void filldisplist(ListBase *dispbase, ListBase *to) dl= dl->next; } - /* to make edgefill work - G.obedit can be 0 on file load */ - if (G.obedit) { - BLI_setScanFillObjectRef(G.obedit); - BLI_setScanFillColourRef(&G.obedit->actcol); - } - - if(totvert && BLI_edgefill(0)!=0) { + if(totvert && BLI_edgefill(0, (G.obedit && G.obedit->actcol)?(G.obedit->actcol-1):0)) { /* count faces */ tot= 0; @@ -1284,8 +1278,6 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase) int a, dpoly; front.first= front.last= back.first= back.last= 0; - if(cu->flag & CU_3D) return; - if( (cu->flag & (CU_FRONT+CU_BACK))==0 ) return; dl= dispbase->first; while(dl) { @@ -1346,23 +1338,13 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase) void curve_to_filledpoly(Curve *cu, ListBase *nurb, ListBase *dispbase) { - DispList *dl; - Nurb *nu; - - dl= dispbase->first; - if(cu->flag & CU_3D) return; - - nu= nurb->first; - while(nu) { - if(nu->flagu & CU_CYCLIC) break; - nu= nu->next; - } - if(nu==0) return; - if(dl->type==DL_SURF) bevels_to_filledpoly(cu, dispbase); + if(dispbase->first && ((DispList*) dispbase->first)->type==DL_SURF) { + bevels_to_filledpoly(cu, dispbase); + } else { - if(cu->flag & CU_FRONT) filldisplist(dispbase, dispbase); + filldisplist(dispbase, dispbase); } } @@ -1372,7 +1354,7 @@ void curve_to_filledpoly(Curve *cu, ListBase *nurb, ListBase *dispbase) - first point left, last point right - based on subdivided points in original curve, not on points in taper curve (still) */ -float calc_taper(Object *taperobj, int cur, int tot) +static float calc_taper(Object *taperobj, int cur, int tot) { Curve *cu; DispList *dl; @@ -1382,7 +1364,7 @@ float calc_taper(Object *taperobj, int cur, int tot) cu= taperobj->data; dl= cu->disp.first; if(dl==NULL) { - makeDispListCurveTypes(taperobj); + makeDispListCurveTypes(taperobj, 0); dl= cu->disp.first; } if(dl) { @@ -1426,127 +1408,95 @@ void makeDispListMBall(Object *ob) metaball_polygonize(ob); tex_space_mball(ob); - object_deform(ob); + object_deform_mball(ob); } } boundbox_displist(ob); } -void makeDispListCurveTypes(Object *ob) +void makeDispListSurf(Object *ob, ListBase *dispbase, int forRender) { Nurb *nu; - Curve *cu; - BPoint *bp; - ListBase dlbev, *dispbase; - DispList *dl, *dlb; - BevList *bl; - BevPoint *bevp; - float *data, *fp1, widfac, vec[3]; - int len, a, b, draw=0; - - if(!ob || (ob->flag&OB_FROMDUPLI) || !ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return; - if(ob==NULL) return; - if(ob->flag & OB_FROMDUPLI) return; - - freedisplist(&(ob->disp)); - - if(ob->type==OB_SURF) { - draw= ob->dt; - cu= ob->data; - dispbase= &(cu->disp); - freedisplist(dispbase); + Curve *cu = ob->data; + DispList *dl; + float *data; + int len; - if(ob==G.obedit) nu= editNurb.first; - else { - curve_modifier(ob, 's'); - nu= cu->nurb.first; - } + if(!forRender && ob==G.obedit) nu= editNurb.first; + else { + do_curve_key(cu); + + nu= cu->nurb.first; + } - while(nu) { - if(nu->hide==0) { - if(nu->pntsv==1) { - if(draw==0) len= nu->pntsu; - else len= nu->pntsu*nu->resolu; - - dl= MEM_callocN(sizeof(DispList), "makeDispListsurf"); - dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); - - BLI_addtail(dispbase, dl); - dl->parts= 1; - dl->nr= len; - dl->col= nu->mat_nr; - dl->rt= nu->flag; - - data= dl->verts; - if(nu->flagu & 1) dl->type= DL_POLY; - else dl->type= DL_SEGM; - - if(draw==0) { - bp= nu->bp; - while(len--) { - VECCOPY(data, bp->vec); - bp++; - data+= 3; - } - } - else makeNurbcurve(nu, data, 3); - } - else { - if(draw==0 && ob==G.obedit) ; - else { - if(draw==0) len= nu->pntsu*nu->pntsv; - else len= nu->resolu*nu->resolv; - - dl= MEM_callocN(sizeof(DispList), "makeDispListsurf"); - dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); - BLI_addtail(dispbase, dl); - - dl->col= nu->mat_nr; - dl->rt= nu->flag; - - data= dl->verts; - dl->type= DL_SURF; + while(nu) { + if(forRender || nu->hide==0) { + if(nu->pntsv==1) { + len= nu->pntsu*nu->resolu; + + dl= MEM_callocN(sizeof(DispList), "makeDispListsurf"); + dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); + + BLI_addtail(dispbase, dl); + dl->parts= 1; + dl->nr= len; + dl->col= nu->mat_nr; + dl->rt= nu->flag; + + data= dl->verts; + if(nu->flagu & 1) dl->type= DL_POLY; + else dl->type= DL_SEGM; + + makeNurbcurve(nu, data, 3); + } + else { + len= nu->resolu*nu->resolv; + + dl= MEM_callocN(sizeof(DispList), "makeDispListsurf"); + dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); + BLI_addtail(dispbase, dl); - if(draw==0) { - dl->parts= nu->pntsv; - dl->nr= nu->pntsu; - if(nu->flagu & CU_CYCLIC) dl->flag|= DL_CYCL_U; - if(nu->flagv & CU_CYCLIC) dl->flag|= DL_CYCL_V; + dl->col= nu->mat_nr; + dl->rt= nu->flag; + + data= dl->verts; + dl->type= DL_SURF; - bp= nu->bp; - while(len--) { - VECCOPY(data, bp->vec); - bp++; - data+= 3; - } - } - else { - dl->parts= nu->resolu; /* in reverse, because makeNurbfaces works that way */ - dl->nr= nu->resolv; - if(nu->flagv & CU_CYCLIC) dl->flag|= DL_CYCL_U; /* reverse too! */ - if(nu->flagu & CU_CYCLIC) dl->flag|= DL_CYCL_V; + dl->parts= nu->resolu; /* in reverse, because makeNurbfaces works that way */ + dl->nr= nu->resolv; + if(nu->flagv & CU_CYCLIC) dl->flag|= DL_CYCL_U; /* reverse too! */ + if(nu->flagu & CU_CYCLIC) dl->flag|= DL_CYCL_V; - makeNurbfaces(nu, data, 0); - } - } - } + makeNurbfaces(nu, data, 0); } - nu= nu->next; } - + nu= nu->next; + } + + if (!forRender) { tex_space_curve(cu); + } + + if(forRender || ob!=G.obedit) object_deform_curve(ob, dispbase); +} +void makeDispListCurveTypes(Object *ob, int forOrco) +{ + Curve *cu = ob->data; + ListBase *dispbase; + + if((ob->flag&OB_FROMDUPLI) || !ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return; + if(ob->flag & OB_FROMDUPLI) return; - if(ob!=G.obedit) curve_modifier(ob, 'e'); - if(ob!=G.obedit) object_deform(ob); + freedisplist(&(ob->disp)); + dispbase= &(cu->disp); + freedisplist(dispbase); + + if(ob->type==OB_SURF) { + makeDispListSurf(ob, dispbase, 0); } else if ELEM(ob->type, OB_CURVE, OB_FONT) { int obedit= (G.obedit && G.obedit->data==ob->data); - draw= ob->dt; - cu= ob->data; - dispbase= &(cu->disp); - freedisplist(dispbase); - BLI_freelistN(&(cu->bev)); if(cu->path) free_path(cu->path); @@ -1554,64 +1504,48 @@ void makeDispListCurveTypes(Object *ob) if(ob->type==OB_FONT) text_to_curve(ob, 0); - if(!obedit) curve_modifier(ob, 's'); - + if(!obedit && !forOrco) do_curve_key(cu); + + makeBevelList(ob); + if(obedit) { - if(ob->type==OB_CURVE) curve_to_displist(&editNurb, dispbase); - else curve_to_displist(&cu->nurb, dispbase); - makeBevelList(ob); // always needed, so calc_curvepath() can work - } - else if(cu->ext1==0.0 && cu->ext2==0.0 && cu->bevobj==NULL && cu->width==1.0) { - curve_to_displist(&cu->nurb, dispbase); - makeBevelList(ob); // always needed, so calc_curvepath() can work + if(ob->type==OB_CURVE) { + curve_to_displist(cu, &editNurb, dispbase); + curve_to_filledpoly(cu, &editNurb, dispbase); + } + else { + curve_to_displist(cu, &cu->nurb, dispbase); + if (!(cu->flag&CU_FAST)) { + curve_to_filledpoly(cu, &cu->nurb, dispbase); + } + } } else { - - makeBevelList(ob); + ListBase dlbev;; - dlbev.first= dlbev.last= NULL; - if(cu->ext1!=0.0 || cu->ext2!=0.0 || cu->bevobj) { - if(ob->dt!=0) makebevelcurve(ob, &dlbev); - } + /* If curve has no bevel will return nothing */ + makebevelcurve(ob, &dlbev); - /* work with bevellist */ - widfac= cu->width-1.0; - bl= cu->bev.first; - nu= cu->nurb.first; - while(bl) { - if(dlbev.first==0) { - dl= MEM_callocN(sizeof(DispList), "makeDispListbev"); - dl->verts= MEM_callocN(3*sizeof(float)*bl->nr, "dlverts"); - BLI_addtail(dispbase, dl); - - if(bl->poly!= -1) dl->type= DL_POLY; - else dl->type= DL_SEGM; - - if(dl->type==DL_SEGM) dl->flag = (DL_FRONT_CURVE|DL_BACK_CURVE); + if (!dlbev.first) { + curve_to_displist(cu, &cu->nurb, dispbase); + } else { + float widfac= cu->width-1.0; + BevList *bl= cu->bev.first; + Nurb *nu= cu->nurb.first; + + for (; bl && nu; bl=bl->next,nu=nu->next) { + DispList *dlb; - dl->parts= 1; - dl->nr= bl->nr; - dl->col= nu->mat_nr; + for (dlb=dlbev.first; dlb; dlb=dlb->next) { + DispList *dl; + float *fp1, *data; + BevPoint *bevp; + int a,b; - a= dl->nr; - bevp= (BevPoint *)(bl+1); - data= dl->verts; - while(a--) { - data[0]= bevp->x+widfac*bevp->sina; - data[1]= bevp->y+widfac*bevp->cosa; - data[2]= bevp->z; - bevp++; - data+=3; - } - } - else { - /* for each part of the bevel use a separate displblock */ - dlb= dlbev.first; - while(dlb) { + /* for each part of the bevel use a separate displblock */ dl= MEM_callocN(sizeof(DispList), "makeDispListbev1"); - dl->verts= MEM_callocN(3*sizeof(float)*dlb->nr*bl->nr, "dlverts"); + dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr*bl->nr, "dlverts"); BLI_addtail(dispbase, dl); - /* dl->type= dlb->type; */ dl->type= DL_SURF; @@ -1623,23 +1557,24 @@ void makeDispListCurveTypes(Object *ob) dl->nr= dlb->nr; dl->col= nu->mat_nr; dl->rt= nu->flag; + dl->bevelSplitFlag= MEM_callocN(sizeof(*dl->col2)*((bl->nr+0x1F)>>5), "col2"); + bevp= (BevPoint *)(bl+1); - data= dl->verts; + /* for each point of poly make a bevel piece */ bevp= (BevPoint *)(bl+1); - for(a=0; a<bl->nr; a++) { /* for each point of poly make a bevel piece */ - float fac; + for(a=0; a<bl->nr; a++,bevp++) { + float fac = calc_taper(cu->taperobj, a, bl->nr); - /* returns 1.0 if no taper, of course */ - fac= calc_taper(cu->taperobj, a, bl->nr); - - /* rotate bevel piece and write in data */ - fp1= dlb->verts; - b= dlb->nr; + if (bevp->f1) { + dl->bevelSplitFlag[a>>5] |= 1<<(a&0x1F); + } - while(b--) { - + /* rotate bevel piece and write in data */ + fp1= dlb->verts; + for (b=0; b<dlb->nr; b++,fp1+=3,data+=3) { if(cu->flag & CU_3D) { - + float vec[3]; + vec[0]= fp1[1]+widfac; vec[1]= fp1[2]; vec[2]= 0.0; @@ -1651,38 +1586,24 @@ void makeDispListCurveTypes(Object *ob) data[2]= bevp->z+ fac*vec[2]; } else { - data[0]= bevp->x+ fac*(fp1[1]+widfac)*bevp->sina; - data[1]= bevp->y+ fac*(fp1[1]+widfac)*bevp->cosa; + data[0]= bevp->x+ fac*(widfac+fp1[1])*bevp->sina; + data[1]= bevp->y+ fac*(widfac+fp1[1])*bevp->cosa; data[2]= bevp->z+ fac*fp1[2]; } - - data+=3; - fp1+=3; } - - bevp++; } - - dlb= dlb->next; } } - bl= bl->next; - nu= nu->next; - } - - if(cu->ext1!=0.0 || cu->ext2!=0.0 || cu->bevobj) { freedisplist(&dlbev); } + + curve_to_filledpoly(cu, &cu->nurb, dispbase); } if(cu->flag & CU_PATH) calc_curvepath(ob); - if(!obedit) { - curve_modifier(ob, 'e'); - object_deform(ob); - } + if(!obedit) object_deform_curve(ob, &cu->disp); tex_space_curve(cu); - } boundbox_displist(ob); @@ -2009,7 +1930,7 @@ static void boundbox_displist(Object *ob) dl= cu->disp.first; while (dl) { - if(dl->type==DL_INDEX3 || dl->type==DL_INDEX3) tot= dl->nr; + if(dl->type==DL_INDEX3) tot= dl->nr; else tot= dl->nr*dl->parts; vert= dl->verts; diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 6855b826f7c..40c62e2c407 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -383,9 +383,9 @@ struct chartrans *text_to_curve(Object *ob, int mode) cu= ob->data; mem= cu->str; + if (cu->str==0) return 0; slen = strlen(mem); - if (cu->str==0) return 0; if (cu->strinfo==NULL) { /* old file */ cu->strinfo = MEM_callocN((slen+1) * sizeof(CharInfo), "strinfo compat"); } @@ -560,7 +560,7 @@ struct chartrans *text_to_curve(Object *ob, int mode) oldflag= cucu->flag; cucu->flag |= (CU_PATH+CU_FOLLOW); - if(cucu->path==NULL) makeDispListCurveTypes(cu->textoncurve); + if(cucu->path==NULL) makeDispListCurveTypes(cu->textoncurve, 0); if(cucu->path) { diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index c7d11559db7..0143cdcb649 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -240,7 +240,7 @@ void init_latt_deform(Object *oblatt, Object *ob) fp= latticedata= MEM_mallocN(sizeof(float)*3*deformLatt->pntsu*deformLatt->pntsv*deformLatt->pntsw, "latticedata"); - lattice_modifier(oblatt, 's'); + do_latt_key(oblatt->data); bp= deformLatt->def; //if(ob) where_is_object(ob); causes lag here, but why! (ton) @@ -284,9 +284,6 @@ void init_latt_deform(Object *oblatt, Object *ob) } vec[2]+= dw; } - - lattice_modifier(oblatt, 'e'); - } void calc_latt_deform(float *co) @@ -556,51 +553,36 @@ void lattice_deform_verts(Object *laOb, Object *target, float (*vertexCos)[3], i end_latt_deform(); } -int object_deform(Object *ob) +int object_deform_mball(Object *ob) { - Curve *cu; - DispList *dl; - float *fp; - int a, tot; + if(ob->parent && ob->parent->type==OB_LATTICE && ob->partype==PARSKEL) { + DispList *dl; - if(ob->parent==NULL) return 0; - - if(ob->parent->type==OB_LATTICE) { - init_latt_deform(ob->parent, ob); - - if(ob->type==OB_MBALL) { - dl=ob->disp.first; - while(dl) { - fp = dl->verts; - for(a=0;a<dl->nr;a++,fp+=3) - calc_latt_deform(fp); - dl=dl->next; - } - } - else if ELEM(ob->type, OB_CURVE, OB_SURF) { - cu= ob->data; - /* apply deform on displist */ - dl= cu->disp.first; - while(dl) { - - fp= dl->verts; - - if(dl->type==DL_INDEX3) tot=dl->parts; - else tot= dl->nr*dl->parts; - - for(a=0; a<tot; a++, fp+=3) { - calc_latt_deform(fp); - } - - dl= dl->next; - } + for (dl=ob->disp.first; dl; dl=dl->next) { + lattice_deform_verts(ob->parent, ob, (float(*)[3]) dl->verts, dl->nr); } - end_latt_deform(); + return 1; + } else { + return 0; } - - return 0; +} + +int object_deform_curve(Object *ob, ListBase *lb) +{ + if(ob->parent && ob->parent->type==OB_LATTICE && ob->partype==PARSKEL) { + DispList *dl; + for (dl=lb->first; dl; dl=dl->next) { + int tot = (dl->type==DL_INDEX3)?dl->parts:dl->nr*dl->parts; + + lattice_deform_verts(ob->parent, ob, (float(*)[3]) dl->verts, tot); + } + + return 1; + } else { + return 0; + } } BPoint *latt_bp(Lattice *lt, int u, int v, int w) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index ab0ee151209..a43ae4e2978 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1038,7 +1038,7 @@ void ob_parcurve(Object *ob, Object *par, float mat[][4]) cu= par->data; if(cu->path==NULL || cu->path->data==NULL) /* only happens on reload file */ - makeDispListCurveTypes(par); + makeDispListCurveTypes(par, 0); if(cu->path==NULL) return; /* exception, timeoffset is regarded as distance offset */ @@ -1760,7 +1760,7 @@ void object_handle_update(Object *ob) makeDispListMBall(ob); } else if(ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - makeDispListCurveTypes(ob); + makeDispListCurveTypes(ob, 0); } else if(ob->type==OB_ARMATURE) { /* this actually only happens for reading old files... */ diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 5e23e00bb19..86ec2cc0705 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -928,7 +928,7 @@ static void softbody_to_mesh(Object *ob, float (*vertexCos)[3]) static void makelatticesprings(Lattice *lt, BodySpring *bs, int dostiff) { BPoint *bp, *bpu; - int u, v, w, dv, dw, uxt, vxt, wxt, bpc, bpuc; + int u, v, w, dv, dw, bpc, bpuc; int debugspringcounter = 0; bp= lt->def; bpc =0; diff --git a/source/blender/blenlib/BLI_blenlib.h b/source/blender/blenlib/BLI_blenlib.h index 2c11250c944..0759a2f8865 100644 --- a/source/blender/blenlib/BLI_blenlib.h +++ b/source/blender/blenlib/BLI_blenlib.h @@ -282,7 +282,7 @@ void BLI_union_rctf(struct rctf *rcta, struct rctf *rctb); /* scanfill.c: used in displist only... */ struct EditVert *BLI_addfillvert(float *vec); struct EditEdge *BLI_addfilledge(struct EditVert *v1, struct EditVert *v2); -int BLI_edgefill(int mode); /* DE HOOFD FILL ROUTINE */ +int BLI_edgefill(int mode, int mat_nr); void BLI_end_edgefill(void); /* noise.h: */ @@ -327,24 +327,6 @@ void BLI_setErrorCallBack(void (*f)(char*)); */ void BLI_setInterruptCallBack(int (*f)(void)); -/** - * Before scanfilling is done, these two references need to be set. If - * the object reference is NULL, the function will fail. If the object - * is set, but no colour is available, colour can be omitted. - * - * @attention Also see BLI_setScanFillColourRef - */ -void BLI_setScanFillObjectRef(void* ob); - -/** - * Before scanfilling is done, these two references need to be set. If - * the object reference is NULL, the function will fail. If the object - * is set, but no colour is available, colour can be omitted. - * - * @attention Also see BLI_setScanFillObjectRef - */ -void BLI_setScanFillColourRef(char* c); - int BLI_strcasecmp(const char *s1, const char *s2); int BLI_strncasecmp(const char *s1, const char *s2, int n); diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index 66c2e364ea3..90ada479ca5 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -54,19 +54,6 @@ /* callbacks for errors and interrupts and some goo */ static void (*BLI_localErrorCallBack)(char*) = NULL; static int (*BLI_localInterruptCallBack)(void) = NULL; -static void *objectref = NULL; -static char *colourref = NULL; - - -void BLI_setScanFillObjectRef(void* ob) -{ - objectref = ob; -} - -void BLI_setScanFillColourRef(char* c) -{ - colourref = c; -} void BLI_setErrorCallBack(void (*f)(char*)) { @@ -87,7 +74,7 @@ void callLocalErrorCallBack(char* msg) } /* ignore if the interrupt wasn't set */ -int callLocalInterruptCallBack(void) +static int callLocalInterruptCallBack(void) { if (BLI_localInterruptCallBack) { return BLI_localInterruptCallBack(); @@ -112,39 +99,21 @@ typedef struct ScFillVert { /* local funcs */ -int vergscdata(const void *a1, const void *a2); -int vergpoly(const void *a1, const void *a2); -void *new_mem_element(int size); -void addfillface(EditVert *v1, EditVert *v2, EditVert *v3); -int boundinside(PolyFill *pf1, PolyFill *pf2); -int boundisect(PolyFill *pf2, PolyFill *pf1); -void mergepolysSimp(PolyFill *pf1, PolyFill *pf2) /* pf2 added to pf1 */; -EditEdge *existfilledge(EditVert *v1, EditVert *v2); -short addedgetoscanvert(ScFillVert *sc, EditEdge *eed); -short testedgeside(float *v1, float *v2, float *v3); -short testedgeside2(float *v1, float *v2, float *v3); -short boundinsideEV(EditEdge *eed, EditVert *eve) /* is eve within boundbox eed */; -void testvertexnearedge(void); -void scanfill(PolyFill *pf); -void fill_mesh(void); -ScFillVert *addedgetoscanlist(EditEdge *eed, int len); -void splitlist(ListBase *tempve, ListBase *temped, short nr); - -/* This one is also used in isect.c Keep it here until we know what to do with isect.c */ + #define COMPLIMIT 0.0003 -ScFillVert *scdata; +static ScFillVert *scdata; ListBase fillvertbase = {0,0}; ListBase filledgebase = {0,0}; ListBase fillfacebase = {0,0}; -short cox, coy; +static short cox, coy; /* **** FUBCTIONS FOR QSORT *************************** */ -int vergscdata(const void *a1, const void *a2) +static int vergscdata(const void *a1, const void *a2) { const ScFillVert *x1=a1,*x2=a2; @@ -156,7 +125,7 @@ int vergscdata(const void *a1, const void *a2) return 0; } -int vergpoly(const void *a1, const void *a2) +static int vergpoly(const void *a1, const void *a2) { const PolyFill *x1=a1, *x2=a2; @@ -181,7 +150,7 @@ struct mem_elements { free in the end, with argument '-1' */ -void *new_mem_element(int size) +static void *new_mem_element(int size) { int blocksize= 16384; static int offs= 0; /* the current free adress */ @@ -239,12 +208,9 @@ EditVert *BLI_addfillvert(float *vec) eve= new_mem_element(sizeof(EditVert)); BLI_addtail(&fillvertbase, eve); - if(vec) { - *(eve->co) = *(vec); - *(eve->co + 1) = *(vec + 1); - *(eve->co + 2) = *(vec + 2); - } -/* VECCOPY(eve->co, vec); */ + eve->co[0] = vec[0]; + eve->co[1] = vec[1]; + eve->co[2] = vec[2]; return eve; } @@ -262,7 +228,7 @@ EditEdge *BLI_addfilledge(EditVert *v1, EditVert *v2) return newed; } -void addfillface(EditVert *v1, EditVert *v2, EditVert *v3) +static void addfillface(EditVert *v1, EditVert *v2, EditVert *v3, int mat_nr) { /* does not make edges */ EditFace *evl; @@ -274,17 +240,11 @@ void addfillface(EditVert *v1, EditVert *v2, EditVert *v3) evl->v2= v2; evl->v3= v3; evl->f= 2; - /* G.obedit is Object*, actcol is char */ -/* if(G.obedit && G.obedit->actcol) evl->mat_nr= G.obedit->actcol-1; */ - if (objectref && colourref && *colourref) { - evl->mat_nr = *colourref - 1; - } else { - evl->mat_nr = 0; - } + evl->mat_nr= mat_nr; } -int boundinside(PolyFill *pf1, PolyFill *pf2) +static int boundinside(PolyFill *pf1, PolyFill *pf2) { /* is pf2 INSIDE pf1 ? using bounding box */ /* test first if polys exist */ @@ -298,7 +258,7 @@ int boundinside(PolyFill *pf1, PolyFill *pf2) return 0; } -int boundisect(PolyFill *pf2, PolyFill *pf1) +static int boundisect(PolyFill *pf2, PolyFill *pf1) { /* has pf2 been touched (intersected) by pf1 ? with bounding box */ /* test first if polys exist */ @@ -325,7 +285,7 @@ int boundisect(PolyFill *pf2, PolyFill *pf1) -void mergepolysSimp(PolyFill *pf1, PolyFill *pf2) /* add pf2 to pf1 */ +static void mergepolysSimp(PolyFill *pf1, PolyFill *pf2) /* add pf2 to pf1 */ { EditVert *eve; EditEdge *eed; @@ -350,7 +310,7 @@ void mergepolysSimp(PolyFill *pf1, PolyFill *pf2) /* add pf2 to pf1 */ -EditEdge *existfilledge(EditVert *v1, EditVert *v2) +static EditEdge *existfilledge(EditVert *v1, EditVert *v2) { EditEdge *eed; @@ -364,7 +324,7 @@ EditEdge *existfilledge(EditVert *v1, EditVert *v2) } -short testedgeside(float *v1, float *v2, float *v3) +static short testedgeside(float *v1, float *v2, float *v3) /* is v3 to the right of v1-v2 ? With exception: v3==v1 || v3==v2 */ { float inp; @@ -380,7 +340,7 @@ short testedgeside(float *v1, float *v2, float *v3) return 1; } -short testedgeside2(float *v1, float *v2, float *v3) +static short testedgeside2(float *v1, float *v2, float *v3) /* is v3 to the right of v1-v2 ? no intersection allowed! */ { float inp; @@ -392,7 +352,7 @@ short testedgeside2(float *v1, float *v2, float *v3) return 1; } -short addedgetoscanvert(ScFillVert *sc, EditEdge *eed) +static short addedgetoscanvert(ScFillVert *sc, EditEdge *eed) { /* find first edge to the right of eed, and insert eed before that */ EditEdge *ed; @@ -436,7 +396,7 @@ short addedgetoscanvert(ScFillVert *sc, EditEdge *eed) } -ScFillVert *addedgetoscanlist(EditEdge *eed, int len) +static ScFillVert *addedgetoscanlist(EditEdge *eed, int len) { /* inserts edge at correct location in ScFillVert list */ /* returns sc when edge already exists */ @@ -467,7 +427,7 @@ ScFillVert *addedgetoscanlist(EditEdge *eed, int len) return 0; } -short boundinsideEV(EditEdge *eed, EditVert *eve) +static short boundinsideEV(EditEdge *eed, EditVert *eve) /* is eve inside boundbox eed */ { float minx,maxx,miny,maxy; @@ -493,7 +453,7 @@ short boundinsideEV(EditEdge *eed, EditVert *eve) } -void testvertexnearedge(void) +static void testvertexnearedge(void) { /* only vertices with ->h==1 are being tested for being close to an edge, if true insert */ @@ -560,7 +520,7 @@ void testvertexnearedge(void) } } -void splitlist(ListBase *tempve, ListBase *temped, short nr) +static void splitlist(ListBase *tempve, ListBase *temped, short nr) { /* everything is in templist, write only poly nr to fillist */ EditVert *eve,*nextve; @@ -590,7 +550,7 @@ void splitlist(ListBase *tempve, ListBase *temped, short nr) } -void scanfill(PolyFill *pf) +static void scanfill(PolyFill *pf, int mat_nr) { ScFillVert *sc = NULL, *sc1; EditVert *eve,*v1,*v2,*v3; @@ -775,7 +735,7 @@ void scanfill(PolyFill *pf) else { /* new triangle */ /* printf("add face %x %x %x\n",v1,v2,v3); */ - addfillface(v1, v2, v3); + addfillface(v1, v2, v3, mat_nr); totface++; BLI_remlink((ListBase *)&(sc->first),ed1); BLI_addtail(&filledgebase,ed1); @@ -844,7 +804,7 @@ void scanfill(PolyFill *pf) -int BLI_edgefill(int mode) /* THE MAIN FILL ROUTINE */ +int BLI_edgefill(int mode, int mat_nr) { /* - fill works with its own lists, so create that first (no faces!) @@ -1122,7 +1082,7 @@ int BLI_edgefill(int mode) /* THE MAIN FILL ROUTINE */ for(a=0;a<poly;a++) { if(pf->edges>1) { splitlist(&tempve,&temped,pf->nr); - scanfill(pf); + scanfill(pf, mat_nr); } pf++; } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 2d17bc7783b..3455867f75e 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3468,7 +3468,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) ob= main->object.first; while(ob) { ob->ipoflag |= OB_OFFS_PARENT; - if(ob->dt==0) ob->dt= 3; + if(ob->dt==0) ob->dt= OB_SOLID; ob= ob->id.next; } diff --git a/source/blender/include/blendef.h b/source/blender/include/blendef.h index 42d6238be4e..16fa5623d26 100644 --- a/source/blender/include/blendef.h +++ b/source/blender/include/blendef.h @@ -115,9 +115,6 @@ #define FNT_PDRAW 1 #define FNT_HAEBERLI 2 -/* isect and scanfill */ -#define COMPLIMIT 0.0003 - /* getbutton */ /* do_global_buttons(event) */ diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index fc6698ee138..460e5f92431 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -133,8 +133,7 @@ typedef struct Curve { struct Material **mat; ListBase bev; - float *orco; - + float loc[3]; float size[3]; float rot[3]; diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c index d70d5dc80c5..bafce42c645 100644 --- a/source/blender/python/api2_2x/NMesh.c +++ b/source/blender/python/api2_2x/NMesh.c @@ -2439,19 +2439,12 @@ static PyObject *M_NMesh_GetRawFromObject( PyObject * self, PyObject * args ) Curve *cu= ob->data; lb= &cu->disp; - if(lb->first==0) makeDispListCurveTypes(ob); + if(lb->first==0) makeDispListCurveTypes(ob, 0); dl= lb->first; if(dl==0) return EXPP_ReturnPyObjError( PyExc_AttributeError, "Object does not have geometry data" ); - /* rule: dl->type INDEX3 is always first in list */ - if(dl->type!=DL_INDEX3) { - curve_to_filledpoly(ob->data, &cu->nurb, lb); - - dl= lb->first; - } - if(dl->nors==0) addnormalsDispList(ob, lb); nmesh = new_NMesh_displist(lb, ob); @@ -2460,7 +2453,7 @@ static PyObject *M_NMesh_GetRawFromObject( PyObject * self, PyObject * args ) case OB_SURF: lb= &((Curve *)ob->data)->disp; - if(lb->first==0) makeDispListCurveTypes(ob); + if(lb->first==0) makeDispListCurveTypes(ob, 0); dl= lb->first; if(dl==0) diff --git a/source/blender/renderconverter/intern/convertBlenderScene.c b/source/blender/renderconverter/intern/convertBlenderScene.c index 394a40388e8..40af2793c82 100644 --- a/source/blender/renderconverter/intern/convertBlenderScene.c +++ b/source/blender/renderconverter/intern/convertBlenderScene.c @@ -124,8 +124,6 @@ static Material *give_render_material(Object *ob, int nr); /* blenderWorldManipulation.c */ -/*static void split_u_renderfaces(int startvlak, int startvert, int usize, int plek, int cyclu);*/ -static void split_v_renderfaces(int startvlak, int startvert, int usize, int vsize, int plek, int cyclu, int cyclv); static int contrpuntnormr(float *n, float *puno); static void as_addvert(VertRen *v1, VlakRen *vlr); static void as_freevert(VertRen *ver); @@ -339,96 +337,95 @@ static HaloRen *initstar(float *vec, float hasize) } - /* ------------------------------------------------------------------------- */ -#if 0 -static void split_u_renderfaces(int startvlak, int startvert, int usize, int plek, int cyclu) +static void split_v_renderfaces(int startvlak, int startvert, int usize, int vsize, int uIndex, int cyclu, int cyclv) { - VlakRen *vlr; - VertRen *v1, *v2; - int a, v; - - if(cyclu) cyclu= 1; + int vLen = vsize-1+(!!cyclv); + int uLen = usize-1+(!!cyclu); + int v; + + for (v=0; v<vLen; v++) { + VlakRen *vlr = RE_findOrAddVlak(startvlak + vLen*uIndex + v); + VertRen *vert = RE_findOrAddVert(R.totvert++); + + if (cyclv) { + *vert = *vlr->v2; + vlr->v2 = vert; + + if (v==vLen-1) { + VlakRen *vlr = RE_findOrAddVlak(startvlak + vLen*uIndex + 0); + vlr->v1 = vert; + } else { + VlakRen *vlr = RE_findOrAddVlak(startvlak + vLen*uIndex + v+1); + vlr->v1 = vert; + } + } else { + *vert = *vlr->v2; + vlr->v2 = vert; - /* first give all involved vertices a pointer to the new one */ - v= startvert+ plek*usize; - for(a=0; a<usize; a++) { - v2= RE_findOrAddVert(R.totvert++); - v1= RE_findOrAddVert(v++); - *v2= *v1; - v1->sticky= (float *)v2; - } + if (v<vLen-1) { + VlakRen *vlr = RE_findOrAddVlak(startvlak + vLen*uIndex + v+1); + vlr->v1 = vert; + } - /* check involved faces and replace pointers */ - v= startvlak+plek*(usize-1+cyclu); - for(a=1-cyclu; a<usize; a++) { - vlr= RE_findOrAddVlak(v++); - vlr->v1= (VertRen *)(vlr->v1->sticky); - vlr->v2= (VertRen *)(vlr->v2->sticky); + if (v==0) { + vert = RE_findOrAddVert(R.totvert++); + *vert = *vlr->v1; + vlr->v1 = vert; + } + } } - } -#endif - -/* ------------------------------------------------------------------------- */ -static void split_v_renderfaces(int startvlak, int startvert, int usize, int vsize, int plek, int cyclu, int cyclv) +#if 0 +static void DBG_show_shared_render_faces(int firstvert, int firstface) { - VlakRen *vlr; - VertRen *v1=0; - int a, vlak, ofs; - - if(vsize<2) return; - - /* check involved faces and create doubles */ - /* because (evt) split_u already has been done, you cannot work with vertex->sticky pointers */ - /* because faces do not share vertices anymore */ - - if(plek+cyclu==usize) plek= -1; + int i; - vlak= startvlak+(plek+cyclu); - ofs= (usize-1+cyclu); + for (i=firstvert; i<R.totvert; i++) { + VertRen *ver = RE_findOrAddVert(i); - for(a=1; a<vsize; a++) { + ver->n[0] = ver->n[1] = ver->n[2] = 0.0; + ver->sticky = 0; + } - vlr= RE_findOrAddVlak(vlak); - if (vlr->v1 == 0) return; /* OOPS, when not cyclic */ + for (i=firstface; i<R.totvlak; i++) { + VlakRen *vlr = RE_findOrAddVlak(i); - v1= RE_findOrAddVert(R.totvert++); - *v1= *(vlr->v1); + if (vlr->v3) { + float cent[3]; - vlr->v1= v1; + if (vlr->v4) { + CalcCent4f(cent, vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4->co); + VecAddf(vlr->v4->n, vlr->v4->n, cent); + vlr->v4->sticky = (float*) (((int) vlr->v4->sticky) + 1); + } else { + CalcCent3f(cent, vlr->v1->co, vlr->v2->co, vlr->v3->co); + } - /* vlr= findOrAddVlak(vlak+1); */ - /* vlr->v1= v1; */ + VecAddf(vlr->v1->n, vlr->v1->n, cent); + VecAddf(vlr->v2->n, vlr->v2->n, cent); + VecAddf(vlr->v3->n, vlr->v3->n, cent); - if(a>1) { - vlr= RE_findOrAddVlak(vlak-ofs); - if(vlr->v4->sticky) { - v1= RE_findOrAddVert(R.totvert++); - *v1= *(vlr->v4); - vlr->v4= v1; - } - else vlr->v4= v1; + vlr->v1->sticky = (float*) (((int) vlr->v1->sticky) + 1); + vlr->v2->sticky = (float*) (((int) vlr->v2->sticky) + 1); + vlr->v3->sticky = (float*) (((int) vlr->v3->sticky) + 1); } + } - if(a== vsize-1) { - if(cyclv) { - ; - } - else { - vlr= RE_findOrAddVlak(vlak); - v1= RE_findOrAddVert(R.totvert++); - *v1= *(vlr->v4); - vlr->v4= v1; - } - } + for (i=firstvert; i<R.totvert; i++) { + VertRen *ver = RE_findOrAddVert(i); - vlak+= ofs; + VecMulf(ver->n, 1.f/(int) ver->sticky); + + VecLerpf(ver->co, ver->co, ver->n, 0.3); + ver->sticky = 0; } + calc_vertexnormals(firstvert, firstface); } +#endif /* ------------------------------------------------------------------------- */ @@ -1229,20 +1226,26 @@ static void init_render_mball(Object *ob) static GHash *g_orco_hash = NULL; -static float *get_mesh_orco(Object *ob) +static float *get_object_orco(Object *ob) { - Mesh *me = ob->data; float *orco; if (!g_orco_hash) g_orco_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); - orco = BLI_ghash_lookup(g_orco_hash, me); + orco = BLI_ghash_lookup(g_orco_hash, ob); if (!orco) { - orco = mesh_create_orco_render(ob); + if (ob->type==OB_MESH) { + orco = mesh_create_orco_render(ob); + } else if (ELEM(ob->type, OB_CURVE, OB_FONT)) { + orco = make_orco_curve(ob); + } else if (ob->type==OB_SURF) { + orco = make_orco_surf(ob); + } - BLI_ghash_insert(g_orco_hash, me, orco); + if (orco) + BLI_ghash_insert(g_orco_hash, ob, orco); } return orco; @@ -1305,10 +1308,7 @@ static void init_render_mesh(Object *ob) } } - /* we do this before deform */ - if(need_orco) { - orco = get_mesh_orco(ob); - } + if(need_orco) orco = get_object_orco(ob); dm = mesh_create_derived_render(ob); dlm = dm->convertToDispListMesh(dm, 1); @@ -1767,8 +1767,8 @@ static void init_render_surf(Object *ob) VertRen *ver, *v1, *v2, *v3, *v4; VlakRen *vlr; Material *matar[32]; - float *data, *fp, *orco, n1[3], flen, mat[4][4]; - int len, a, need_orco=0, startvlak, startvert, p1, p2, p3, p4; + float *data, *orco=NULL, *orcobase=NULL, n1[3], flen, mat[4][4]; + int a, need_orco=0, startvlak, startvert, p1, p2, p3, p4; int u, v; int sizeu, sizev; VlakRen *vlr1, *vlr2, *vlr3; @@ -1793,55 +1793,10 @@ static void init_render_surf(Object *ob) if(ob->parent && (ob->parent->type==OB_LATTICE)) need_orco= 1; - if(cu->orco==0 && need_orco) make_orco_surf(cu); - orco= cu->orco; - - curve_modifier(ob, 's'); + if(need_orco) orcobase= orco= get_object_orco(ob); - /* make a complete new displist, the base-displist can be different */ displist.first= displist.last= 0; - nu= cu->nurb.first; - while(nu) { - if(nu->pntsv>1) { - len= nu->resolu*nu->resolv; - /* makeNurbfaces wants zeros */ - - dl= MEM_callocN(sizeof(DispList)+len*3*sizeof(float), "makeDispList1"); - dl->verts= MEM_callocN(len*3*sizeof(float), "makeDispList01"); - BLI_addtail(&displist, dl); - - dl->parts= nu->resolu; /* switched order, makeNurbfaces works that way... */ - dl->nr= nu->resolv; - dl->col= nu->mat_nr; - dl->rt= nu->flag; - - data= dl->verts; - dl->type= DL_SURF; - /* if nurbs cyclic (u/v) set flags in displist accordingly */ - if(nu->flagv & CU_CYCLIC) dl->flag |= DL_CYCL_U; - if(nu->flagu & CU_CYCLIC) dl->flag |= DL_CYCL_V; - - makeNurbfaces(nu, data, 0); - } - nu= nu->next; - } - - if(ob->parent && ob->parent->type==OB_LATTICE) { - init_latt_deform(ob->parent, ob); - dl= displist.first; - while(dl) { - - fp= dl->verts; - len= dl->nr*dl->parts; - for(a=0; a<len; a++, fp+=3) calc_latt_deform(fp); - - dl= dl->next; - } - end_latt_deform(); - } - - /* note; deform will be included in modifier() later */ - curve_modifier(ob, 'e'); + makeDispListSurf(ob, &displist, 1); dl= displist.first; /* walk along displaylist and create rendervertices/-faces */ @@ -1875,7 +1830,7 @@ static void init_render_surf(Object *ob) ver= RE_findOrAddVert(R.totvert++); VECCOPY(ver->co, v1->co); if(orco) { - ver->orco= cu->orco + 3*(u*sizev + 0); + ver->orco= orcobase + 3*(u*sizev + 0); } } } @@ -1891,7 +1846,7 @@ static void init_render_surf(Object *ob) ver= RE_findOrAddVert(R.totvert++); VECCOPY(ver->co, v1->co); if(orco) { - ver->orco= cu->orco + 3*(0*sizev + v); + ver->orco= orcobase + 3*(0*sizev + v); } } } @@ -2011,20 +1966,15 @@ static void init_render_surf(Object *ob) static void init_render_curve(Object *ob) { extern Material defmaterial; // initrender.c - Lattice *lt=0; Curve *cu; VertRen *ver; VlakRen *vlr; - ListBase dlbev; - Nurb *nu=0; - DispList *dlb, *dl; - BevList *bl; - BevPoint *bevp; + DispList *dl; Material *matar[32]; - float len, *data, *fp, *fp1, fac; - float n[3], vec[3], widfac, size[3], mat[4][4]; - int nr, startvert, startvlak, a, b, p1, p2, p3, p4; - int totvert, frontside, need_orco=0, firststartvert, *index; + float len, *data, *fp, *orco=NULL; + float n[3], mat[4][4]; + int nr, startvert, startvlak, a, b; + int frontside, need_orco=0; cu= ob->data; if(cu->nurb.first==NULL) return; @@ -2032,17 +1982,9 @@ static void init_render_curve(Object *ob) /* no modifier call here, is in makedisp */ /* test displist */ - if(cu->disp.first==0) makeDispListCurveTypes(ob); + if(cu->disp.first==0) makeDispListCurveTypes(ob, 0); dl= cu->disp.first; if(cu->disp.first==0) return; - - if(dl->type!=DL_INDEX3) { - curve_to_filledpoly(cu, &cu->nurb, &cu->disp); - } - - if(cu->bev.first==0) makeBevelList(ob); - - firststartvert= R.totvert; MTC_Mat4MulMat4(mat, ob->obmat, R.viewmat); MTC_Mat4Invert(ob->imat, mat); @@ -2057,231 +1999,13 @@ static void init_render_curve(Object *ob) } } - /* bevelcurve in displist */ - dlbev.first= dlbev.last= 0; - - if(cu->ext1!=0.0 || cu->ext2!=0.0 || cu->bevobj!=NULL) { - makebevelcurve(ob, &dlbev); - } - - /* uv orcos? count amount of points and malloc */ - if(need_orco && (cu->flag & CU_UV_ORCO)) { - if(cu->flag & CU_PATH); - else { - totvert= 0; - bl= cu->bev.first; - while(bl) { - dlb= dlbev.first; - while(dlb) { - totvert+= dlb->nr*bl->nr; - dlb= dlb->next; - } - bl= bl->next; - } + if(need_orco) orco= get_object_orco(ob); - if(totvert) { - fp= cu->orco= MEM_mallocN(3*sizeof(float)*totvert, "cu->orco"); - - bl= cu->bev.first; - while(bl) { - dlb= dlbev.first; - while(dlb) { - for(b=0; b<dlb->nr; b++) { - fac= (2.0*b/(float)(dlb->nr-1)) - 1.0; - for(a=0; a<bl->nr; a++, fp+=3) { - fp[0]= (2.0*a/(float)(bl->nr-1)) - 1.0; - fp[1]= fac; - fp[2]= 0.0; - } - } - dlb= dlb->next; - } - bl= bl->next; - } - } - } - } - - if(ob->parent && ob->parent->type==OB_LATTICE) { - lt= ob->parent->data; - init_latt_deform(ob->parent, ob); - need_orco= 1; - } - - /* do keypos? NOTE: watch it : orcos */ - - /* effect on text? */ - - /* boundboxclip still todo */ - - /* side faces of poly: work with bevellist */ - widfac= (cu->width-1.0); - - bl= cu->bev.first; - nu= cu->nurb.first; - while(bl) { - - if(dlbev.first) { /* otherwise just a poly */ - - dlb= dlbev.first; /* bevel loop */ - while(dlb) { - data= MEM_mallocN(3*sizeof(float)*dlb->nr*bl->nr, "init_render_curve3"); - fp= data; - - /* for each point at bevelcurve do the entire poly */ - fp1= dlb->verts; - b= dlb->nr; - while(b--) { - - bevp= (BevPoint *)(bl+1); - for(a=0; a<bl->nr; a++) { - float fac; - - /* returns 1.0 if no taper, of course */ - fac= calc_taper(cu->taperobj, a, bl->nr); - - if(cu->flag & CU_3D) { - vec[0]= fp1[1]+widfac; - vec[1]= fp1[2]; - vec[2]= 0.0; - - MTC_Mat3MulVecfl(bevp->mat, vec); - - fp[0]= bevp->x+ fac*vec[0]; - fp[1]= bevp->y+ fac*vec[1]; - fp[2]= bevp->z+ fac*vec[2]; - } - else { - - fp[0]= bevp->x+ fac*(widfac+fp1[1])*bevp->sina; - fp[1]= bevp->y+ fac*(widfac+fp1[1])*bevp->cosa; - fp[2]= bevp->z+ fac*fp1[2]; - /* do not MatMul here: polyfill should work uniform, independent which frame */ - } - fp+= 3; - bevp++; - } - fp1+=3; - } - - /* make render vertices */ - fp= data; - startvert= R.totvert; - nr= dlb->nr*bl->nr; - - while(nr--) { - ver= RE_findOrAddVert(R.totvert++); - - if(lt) calc_latt_deform(fp); - - VECCOPY(ver->co, fp); - MTC_Mat4MulVecfl(mat, ver->co); - fp+= 3; - } - - startvlak= R.totvlak; - - for(a=0; a<dlb->nr; a++) { - - frontside= (a >= dlb->nr/2); - - DL_SURFINDEX(bl->poly>0, dlb->type==DL_POLY, bl->nr, dlb->nr); - p1+= startvert; - p2+= startvert; - p3+= startvert; - p4+= startvert; - - for(; b<bl->nr; b++) { - - vlr= RE_findOrAddVlak(R.totvlak++); - vlr->ob= vlr_set_ob(ob); - vlr->v1= RE_findOrAddVert(p2); - vlr->v2= RE_findOrAddVert(p1); - vlr->v3= RE_findOrAddVert(p3); - vlr->v4= RE_findOrAddVert(p4); - vlr->ec= ME_V2V3+ME_V3V4; - if(a==0) vlr->ec+= ME_V1V2; - - vlr->flag= nu->flag; - vlr->lay= ob->lay; - - /* this is not really scientific: the vertices - * 2, 3 en 4 seem to give better vertexnormals than 1 2 3: - * front and backside treated different!! - */ - - if(frontside) - CalcNormFloat(vlr->v2->co, vlr->v3->co, vlr->v4->co, vlr->n); - else - CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->n); - - vlr->mat= matar[ nu->mat_nr ]; - - p4= p3; - p3++; - p2= p1; - p1++; - - } - - } - - /* here was split_u before, for split off standard bevels, not needed anymore */ - /* but it could check on the bevel-curve BevPoints for u-split though... */ - - /* make double points: SPLIT BEVELS */ - bevp= (BevPoint *)(bl+1); - for(a=0; a<bl->nr; a++) { - if(bevp->f1) - split_v_renderfaces(startvlak, startvert, bl->nr, dlb->nr, a, bl->poly>0, - dlb->type==DL_POLY); - bevp++; - } - - /* vertex normals */ - for(a= startvlak; a<R.totvlak; a++) { - vlr= RE_findOrAddVlak(a); - - VecAddf(vlr->v1->n, vlr->v1->n, vlr->n); - VecAddf(vlr->v3->n, vlr->v3->n, vlr->n); - VecAddf(vlr->v2->n, vlr->v2->n, vlr->n); - VecAddf(vlr->v4->n, vlr->v4->n, vlr->n); - } - for(a=startvert; a<R.totvert; a++) { - ver= RE_findOrAddVert(a); - len= Normalise(ver->n); - if(len==0.0) ver->sticky= (float *)1; - else ver->sticky= 0; - } - for(a= startvlak; a<R.totvlak; a++) { - vlr= RE_findOrAddVlak(a); - if(vlr->v1->sticky) VECCOPY(vlr->v1->n, vlr->n); - if(vlr->v2->sticky) VECCOPY(vlr->v2->n, vlr->n); - if(vlr->v3->sticky) VECCOPY(vlr->v3->n, vlr->n); - if(vlr->v4->sticky) VECCOPY(vlr->v4->n, vlr->n); - } - - dlb= dlb->next; - - MEM_freeN(data); - } - - } - bl= bl->next; - nu= nu->next; - } - - if(dlbev.first) { - freedisplist(&dlbev); - } - - if(cu->flag & CU_PATH) return; - - /* from displist the filled faces can be extracted */ dl= cu->disp.first; - while(dl) { if(dl->type==DL_INDEX3) { + int *index; + startvert= R.totvert; data= dl->verts; @@ -2294,12 +2018,20 @@ static void init_render_curve(Object *ob) for(a=0; a<dl->nr; a++, data+=3) { ver= RE_findOrAddVert(R.totvert++); VECCOPY(ver->co, data); + MTC_Mat4MulVecfl(mat, ver->co); if(ver->co[2] < 0.0) { VECCOPY(ver->n, n); + ver->sticky = (float*) 1; } else { ver->n[0]= -n[0]; ver->n[1]= -n[1]; ver->n[2]= -n[2]; + ver->sticky = (float*) 0; + } + + if (orco) { + ver->orco = orco; + orco += 3; } } @@ -2314,7 +2046,7 @@ static void init_render_curve(Object *ob) vlr->v3= RE_findOrAddVert(startvert+index[2]); vlr->v4= NULL; - if(vlr->v1->co[2] < 0.0) { + if(vlr->v1->sticky) { VECCOPY(vlr->n, n); } else { @@ -2329,50 +2061,103 @@ static void init_render_curve(Object *ob) vlr->ec= 0; vlr->lay= ob->lay; } - /* rotate verts */ - for(a=0; a<dl->nr; a++) { - ver= RE_findOrAddVert(startvert+a); + } + else if (dl->type==DL_SURF) { + int p1,p2,p3,p4; + float *surforco = orco; + + fp= dl->verts; + startvert= R.totvert; + nr= dl->nr*dl->parts; + + while(nr--) { + ver= RE_findOrAddVert(R.totvert++); + + VECCOPY(ver->co, fp); MTC_Mat4MulVecfl(mat, ver->co); + fp+= 3; + + if (orco) { + ver->orco = orco; + orco += 3; + } } - - } - dl= dl->next; - } - if(lt) { - end_latt_deform(); - } + startvlak= R.totvlak; + + for(a=0; a<dl->parts; a++) { + + frontside= (a >= dl->nr/2); + + DL_SURFINDEX(dl->flag & DL_CYCL_U, dl->flag & DL_CYCL_V, dl->nr, dl->parts); + p1+= startvert; + p2+= startvert; + p3+= startvert; + p4+= startvert; - if(need_orco) { /* the stupid way: should be replaced; taking account for keys! */ + for(; b<dl->nr; b++) { + vlr= RE_findOrAddVlak(R.totvlak++); + vlr->ob= vlr_set_ob(ob); + vlr->v1= RE_findOrAddVert(p2); + vlr->v2= RE_findOrAddVert(p1); + vlr->v3= RE_findOrAddVert(p3); + vlr->v4= RE_findOrAddVert(p4); + vlr->ec= ME_V2V3+ME_V3V4; + if(a==0) vlr->ec+= ME_V1V2; + + vlr->flag= dl->rt; + vlr->lay= ob->lay; + + /* this is not really scientific: the vertices + * 2, 3 en 4 seem to give better vertexnormals than 1 2 3: + * front and backside treated different!! + */ - VECCOPY(size, cu->size); + if(frontside) + CalcNormFloat(vlr->v2->co, vlr->v3->co, vlr->v4->co, vlr->n); + else + CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->n); - nr= R.totvert-firststartvert; - if(nr) { - if(cu->orco) { - fp= cu->orco; - while(nr--) { - ver= RE_findOrAddVert(firststartvert++); - ver->orco= fp; - fp+= 3; + vlr->mat= matar[ dl->col ]; + + p4= p3; + p3++; + p2= p1; + p1++; } } - else { - fp= cu->orco= MEM_mallocN(sizeof(float)*3*nr, "cu orco"); - while(nr--) { - ver= RE_findOrAddVert(firststartvert++); - ver->orco= fp; - - VECCOPY(fp, ver->co); - MTC_Mat4MulVecfl(ob->imat, fp); - - fp[0]= (fp[0]-cu->loc[0])/size[0]; - fp[1]= (fp[1]-cu->loc[1])/size[1]; - fp[2]= (fp[2]-cu->loc[2])/size[2]; - fp+= 3; - } + + if (dl->bevelSplitFlag) { + for(a=0; a<dl->parts-1+!!(dl->flag&DL_CYCL_V); a++) + if(dl->bevelSplitFlag[a>>5]&(1<<(a&0x1F))) + split_v_renderfaces(startvlak, startvert, dl->parts, dl->nr, a, dl->flag&DL_CYCL_V, dl->flag&DL_CYCL_U); + } + + /* vertex normals */ + for(a= startvlak; a<R.totvlak; a++) { + vlr= RE_findOrAddVlak(a); + + VecAddf(vlr->v1->n, vlr->v1->n, vlr->n); + VecAddf(vlr->v3->n, vlr->v3->n, vlr->n); + VecAddf(vlr->v2->n, vlr->v2->n, vlr->n); + VecAddf(vlr->v4->n, vlr->v4->n, vlr->n); + } + for(a=startvert; a<R.totvert; a++) { + ver= RE_findOrAddVert(a); + len= Normalise(ver->n); + if(len==0.0) ver->sticky= (float *)1; + else ver->sticky= 0; + } + for(a= startvlak; a<R.totvlak; a++) { + vlr= RE_findOrAddVlak(a); + if(vlr->v1->sticky) VECCOPY(vlr->v1->n, vlr->n); + if(vlr->v2->sticky) VECCOPY(vlr->v2->n, vlr->n); + if(vlr->v3->sticky) VECCOPY(vlr->v3->n, vlr->n); + if(vlr->v4->sticky) VECCOPY(vlr->v4->n, vlr->n); } } + + dl= dl->next; } } @@ -2520,15 +2305,7 @@ void RE_freeRotateBlenderScene(void) /* free orco. check all objects because of duplis and sets */ ob= G.main->object.first; while(ob) { - - if ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT) { - Curve *cu= ob->data; - if(cu->orco) { - MEM_freeN(cu->orco); - cu->orco= 0; - } - } - else if(ob->type==OB_MBALL) { + if(ob->type==OB_MBALL) { if(ob->disp.first && ob->disp.first!=ob->disp.last) { DispList *dl= ob->disp.first; BLI_remlink(&ob->disp, dl); @@ -2810,7 +2587,7 @@ void RE_rotateBlenderScene(void) cu= obd->data; if(cu->disp.first==NULL) { obd->flag &= ~OB_FROMDUPLI; - makeDispListCurveTypes(obd); + makeDispListCurveTypes(obd, 0); obd->flag |= OB_FROMDUPLI; } } diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 43725f464f0..d984f5bd994 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -388,7 +388,7 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an else nu->flag &= ~ME_SMOOTH; nu= nu->next; } - makeDispListCurveTypes(base->object); + makeDispListCurveTypes(base->object, 0); } } base= base->next; @@ -1210,9 +1210,8 @@ void do_fontbuts(unsigned short event) case B_FASTFONT: if (G.obedit) { - cu= G.obedit->data; - cu->flag ^= CU_FAST; - error("Not in editmode!"); + DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); + allqueue(REDRAWVIEW3D, 0); } break; case B_INSTB: @@ -1225,7 +1224,7 @@ void do_fontbuts(unsigned short event) allqueue(REDRAWBUTSEDIT, 0); allqueue(REDRAWVIEW3D, 0); text_to_curve(ob, 0); - makeDispListCurveTypes(ob); + makeDispListCurveTypes(ob, 0); } else { error("Do you really need that many text frames?"); @@ -1240,7 +1239,7 @@ void do_fontbuts(unsigned short event) allqueue(REDRAWBUTSEDIT, 0); allqueue(REDRAWVIEW3D, 0); text_to_curve(ob, 0); - makeDispListCurveTypes(ob); + makeDispListCurveTypes(ob, 0); } break; case B_TOUPPER: @@ -1721,9 +1720,9 @@ static void editing_panel_curve_type(Object *ob, Curve *cu) uiBlockBeginAlign(block); uiDefButF(block, NUM, B_MAKEDISP, "Width:", 760,90,150,19, &cu->width, 0.0, 2.0, 1, 0, "Make interpolated result thinner or fatter"); - uiDefButF(block, NUM, B_MAKEDISP, "Ext1:", 760,70,150,19, &cu->ext1, 0.0, 5.0, 10, 0, "Extrude depth"); - uiDefButF(block, NUM, B_MAKEDISP, "Ext2:", 760,50,150,19, &cu->ext2, 0.0, 2.0, 1, 0, "Extrude beveling depth"); - uiDefButS(block, NUM, B_MAKEDISP, "BevResol:", 760,30,150,19, &cu->bevresol, 0.0, 10.0, 0, 0, "Amount of bevels"); + uiDefButF(block, NUM, B_MAKEDISP, "Extrude:", 760,70,150,19, &cu->ext1, 0.0, 5.0, 10, 0, "Curve extrusion size when not using a bevel object"); + uiDefButF(block, NUM, B_MAKEDISP, "Bevel Depth:", 760,50,150,19, &cu->ext2, 0.0, 2.0, 1, 0, "Bevel depth when not using a bevel object"); + uiDefButS(block, NUM, B_MAKEDISP, "BevResol:", 760,30,150,19, &cu->bevresol, 0.0, 10.0, 0, 0, "Bevel resolution when depth is non-zero and not using a bevel object"); uiDefIDPoinBut(block, test_obcurpoin_but, B_CHANGEDEP, "BevOb:", 760,10,150,19, &cu->bevobj, "Curve object name that defines the bevel shape"); uiDefIDPoinBut(block, test_obcurpoin_but, B_CHANGEDEP, "TaperOb:", 760,-10,150,19, &cu->taperobj, "Curve object name that defines the taper (width)"); @@ -1732,10 +1731,7 @@ static void editing_panel_curve_type(Object *ob, Curve *cu) uiDefButBitS(block, TOG, CU_BACK, B_MAKEDISP, "Back", 760,130,50,19, &cu->flag, 0, 0, 0, 0, "Draw filled back for curves"); uiDefButBitS(block, TOG, CU_FRONT, B_MAKEDISP, "Front",810,130,50,19, &cu->flag, 0, 0, 0, 0, "Draw filled front for curves"); uiDefButBitS(block, TOG, CU_3D, B_CU3D, "3D", 860,130,50,19, &cu->flag, 0, 0, 0, 0, "Allow Curve Object to be 3d, it doesn't fill then"); - - } - } diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 46b58eb1759..608867efa9b 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -1333,7 +1333,6 @@ void do_effects_panels(unsigned short event) while(eff) { if(eff->flag & SELECT) { if(eff->type==EFF_PARTICLE) build_particle_system(ob); - else if(eff->type==EFF_WAVE) freedisplist(&ob->disp); } eff= eff->next; } diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index 9ad5fe1f566..eed2ce037ee 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -74,7 +74,6 @@ #include "BKE_utildefines.h" #include "BKE_curve.h" #include "BKE_constraint.h" // for the get_constraint_target function -#include "BKE_deform.h" // lattice_modifier() #include "BKE_DerivedMesh.h" #include "BKE_displist.h" #include "BKE_effect.h" @@ -82,6 +81,7 @@ #include "BKE_global.h" #include "BKE_image.h" #include "BKE_ipo.h" +#include "BKE_key.h" #include "BKE_lattice.h" #include "BKE_mesh.h" #include "BKE_material.h" @@ -876,7 +876,7 @@ static void drawlattice(Object *ob) cpack(0x004000); } else { - lattice_modifier(ob, 's'); + do_latt_key(lt); bp= lt->def; } @@ -963,8 +963,6 @@ static void drawlattice(Object *ob) if(G.vd->zbuf) glEnable(GL_DEPTH_TEST); } - else lattice_modifier(ob, 'e'); - } /* ***************** ******************** */ @@ -2325,21 +2323,12 @@ static void drawDispList(Object *ob, int dt) cu= ob->data; lb= &cu->disp; - if(lb->first==0) makeDispListCurveTypes(ob); if(solid) { dl= lb->first; if(dl==0) return; - /* rule: dl->type INDEX3 is always first in list */ - if(dl->type!=DL_INDEX3) { - if(ob==G.obedit) curve_to_filledpoly(ob->data, &editNurb, lb); - else curve_to_filledpoly(ob->data, &cu->nurb, lb); - - dl= lb->first; - } if(dl->nors==0) addnormalsDispList(ob, lb); - index3_nors_incr= 0; if( displist_has_faces(lb)==0) { @@ -2375,7 +2364,6 @@ static void drawDispList(Object *ob, int dt) case OB_SURF: lb= &((Curve *)ob->data)->disp; - if(lb->first==0) makeDispListCurveTypes(ob); if(solid) { dl= lb->first; @@ -2738,85 +2726,57 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel) static void drawnurb(Object *ob, Nurb *nurb, int dt) { - Curve *cu; + Curve *cu = ob->data; Nurb *nu; - BevPoint *bevp; BevList *bl; - float vec[3]; - int a, nr, skip; /* first non-selected handles */ - nu= nurb; - while(nu) { + for(nu=nurb; nu; nu=nu->next) { if((nu->type & 7)==CU_BEZIER) { tekenhandlesN(nu, 0); } - nu= nu->next; } /* then DispList */ BIF_ThemeColor(TH_WIRE); - cu= ob->data; drawDispList(ob, dt); draw_editnurb(ob, nurb, 0); draw_editnurb(ob, nurb, 1); if(cu->flag & CU_3D) { - - if(cu->bev.first==0) makeBevelList(ob); - BIF_ThemeColor(TH_WIRE); - bl= cu->bev.first; - nu= nurb; - while(nu && bl) { - bevp= (BevPoint *)(bl+1); - nr= bl->nr; - - skip= nu->resolu/16; + glBegin(GL_LINES); + for (bl=cu->bev.first,nu=nurb; nu && bl; bl=bl->next,nu=nu->next) { + BevPoint *bevp= (BevPoint *)(&bl+1); + int nr= bl->nr; + int skip= nu->resolu/16; - while(nr-- > 0) { - - glBegin(GL_LINE_STRIP); - vec[0]= bevp->x-G.scene->editbutsize*bevp->mat[0][0]; - vec[1]= bevp->y-G.scene->editbutsize*bevp->mat[0][1]; - vec[2]= bevp->z-G.scene->editbutsize*bevp->mat[0][2]; - glVertex3fv(vec); - vec[0]= bevp->x+G.scene->editbutsize*bevp->mat[0][0]; - vec[1]= bevp->y+G.scene->editbutsize*bevp->mat[0][1]; - vec[2]= bevp->z+G.scene->editbutsize*bevp->mat[0][2]; - glVertex3fv(vec); + while (nr-->0) { + float ox = G.scene->editbutsize*bevp->mat[0][0]; + float oy = G.scene->editbutsize*bevp->mat[0][1]; + float oz = G.scene->editbutsize*bevp->mat[0][2]; - glEnd(); + glVertex3f(bevp->x - ox, bevp->y - oy, bevp->z - oz); + glVertex3f(bevp->x + ox, bevp->y + oy, bevp->z + oz); - bevp++; - - a= skip; - while(a--) { - bevp++; - nr--; - } + bevp += skip+1; + nr -= skip; } - - bl= bl->next; - nu= nu->next; } + glEnd(); } if(G.vd->zbuf) glDisable(GL_DEPTH_TEST); - nu= nurb; - while(nu) { + for(nu=nurb; nu; nu=nu->next) { if((nu->type & 7)==1) tekenhandlesN(nu, 1); tekenvertsN(nu, 0); - nu= nu->next; } - nu= nurb; - while(nu) { + for(nu=nurb; nu; nu=nu->next) { tekenvertsN(nu, 1); - nu= nu->next; } if(G.vd->zbuf) glEnable(GL_DEPTH_TEST); @@ -3272,10 +3232,6 @@ static void draw_bounding_volume(Object *ob) } else if ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT) { bb= ( (Curve *)ob->data )->bb; - if(bb==0) { - makeDispListCurveTypes(ob); - bb= ( (Curve *)ob->data )->bb; - } } else if(ob->type==OB_MBALL) { bb= ob->bb; @@ -3620,6 +3576,7 @@ void draw_object(Base *base) break; case OB_FONT: cu= ob->data; + if (cu->disp.first==NULL) makeDispListCurveTypes(ob, 0); if(ob==G.obedit) { tekentextcurs(); @@ -3628,6 +3585,8 @@ void draw_object(Base *base) set_inverted_drawing(1); drawDispList(ob, OB_WIRE); set_inverted_drawing(0); + } else { + drawDispList(ob, dt); } if (cu->linewidth != 0.0) { @@ -3703,6 +3662,7 @@ void draw_object(Base *base) case OB_CURVE: case OB_SURF: cu= ob->data; + if (cu->disp.first==NULL) makeDispListCurveTypes(ob, 0); if(ob==G.obedit) { drawnurb(ob, editNurb.first, dt); diff --git a/source/blender/src/editcurve.c b/source/blender/src/editcurve.c index 6932d583ba8..dee9b789108 100644 --- a/source/blender/src/editcurve.c +++ b/source/blender/src/editcurve.c @@ -3884,7 +3884,7 @@ void clear_tilt() nu= nu->next; } - makeBevelList(G.obedit); + DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA); allqueue(REDRAWVIEW3D, 0); BIF_undo_push("Clear tilt"); diff --git a/source/blender/src/editdeform.c b/source/blender/src/editdeform.c index 1c046a6f4d9..1dfce2ba879 100644 --- a/source/blender/src/editdeform.c +++ b/source/blender/src/editdeform.c @@ -631,13 +631,10 @@ void object_apply_deform(Object *ob) if(cu->id.us>1) { err= "Can't apply deformation to Curve with other users"; } else { - curve_modifier(ob, 's'); // start - curve_modifier(ob, 'a'); // apply and end freedisplist(&ob->disp); } } if(err) error(err); - } diff --git a/source/blender/src/editmesh_tools.c b/source/blender/src/editmesh_tools.c index b839ed0f2b5..77e7f6a68b8 100644 --- a/source/blender/src/editmesh_tools.c +++ b/source/blender/src/editmesh_tools.c @@ -1071,13 +1071,7 @@ void fill_mesh(void) } } - /* to make edgefill work */ - BLI_setScanFillObjectRef(G.obedit); - BLI_setScanFillColourRef(&G.obedit->actcol); - - ok= BLI_edgefill(0); - - if(ok) { + if(BLI_edgefill(0, (G.obedit && G.obedit->actcol)?(G.obedit->actcol-1):0)) { efa= fillfacebase.first; while(efa) { efan= addfacelist(efa->v3->vn, efa->v2->vn, efa->v1->vn, 0, NULL, NULL); // normals default pointing up diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index 783032b4bda..419f4ee833b 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -171,8 +171,6 @@ /* --------------------------------- */ -Base *dupfontbase; - void add_object_draw(int type) /* for toolbox or menus, only non-editmode stuff */ { Object *ob; @@ -1176,7 +1174,7 @@ void make_parent(void) mode= PAROBJECT; if((cu->flag & CU_PATH)==0) { cu->flag |= CU_PATH|CU_FOLLOW; - makeDispListCurveTypes(par); // force creation of path data + makeDispListCurveTypes(par, 0); // force creation of path data } else cu->flag |= CU_FOLLOW; } @@ -1383,7 +1381,6 @@ void enter_editmode(void) Mesh *me; int ok= 0; bArmature *arm; - Curve *cu; if(G.scene->id.lib) return; base= BASACT; @@ -1427,20 +1424,6 @@ void enter_editmode(void) allqueue (REDRAWVIEW3D,0); } else if(ob->type==OB_FONT) { - cu= ob->data; - if ((cu->flag & CU_FAST)==0) { - base->flag |= SELECT; - ob->flag |= SELECT; - G.qual |= LR_ALTKEY; /* patch to make sure we get a linked duplicate */ - adduplicate(1); - G.qual &= ~LR_ALTKEY; - dupfontbase = BASACT; - BASACT->flag &= ~SELECT; - BASACT->object->flag &= ~SELECT; - set_active_base(base); - base->flag |= SELECT; - base->object->flag |= SELECT; - } G.obedit= ob; ok= 1; make_editText(); @@ -1478,7 +1461,6 @@ void enter_editmode(void) void exit_editmode(int freedata) /* freedata==0 at render, 1= freedata, 2= do undo buffer too */ { - Base *oldbase; Object *ob; if(G.obedit==NULL) return; @@ -1540,23 +1522,6 @@ void exit_editmode(int freedata) /* freedata==0 at render, 1= freedata, 2= do un } DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); - // evil HACK! - if ((ob->type == OB_FONT) && (freedata)) { - Curve *cu= ob->data; - if ((cu->flag & CU_FAST)==0) { - oldbase = BASACT; - BASACT->flag &= ~SELECT; - BASACT->object->flag &= ~SELECT; - set_active_base(dupfontbase); - BASACT->flag |= SELECT; - BASACT->object->flag |= SELECT; - delete_obj(1); - oldbase->flag |= SELECT; - oldbase->object->flag |= SELECT; - set_active_base(oldbase); - } - } - if(freedata) { setcursor_space(SPACE_VIEW3D, CURSOR_STD); @@ -1900,7 +1865,7 @@ void split_font() text_to_curve(OBACT, 0); // pass 1: only one letter, adapt position text_to_curve(OBACT, 0); // pass 2: remake freedisplist(&OBACT->disp); - makeDispListCurveTypes(OBACT); + makeDispListCurveTypes(OBACT, 0); OBACT->flag &= ~SELECT; BASACT->flag &= ~SELECT; @@ -2281,7 +2246,7 @@ void convertmenu(void) cu= ob->data; dl= cu->disp.first; - if(dl==0) makeDispListCurveTypes(ob); // force creation + if(dl==0) makeDispListCurveTypes(ob, 0); // force creation nurbs_to_mesh(ob); /* also does users */ |