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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2005-08-14 10:08:41 +0400
committerDaniel Dunbar <daniel@zuster.org>2005-08-14 10:08:41 +0400
commit93aeb6b318a7ec8022e14bba7f9ab98aae0aab6e (patch)
tree3520b0cd661580fae23de6ea6456433914ced053 /source/blender/blenkernel
parent5f61dc89ba31bf7c6d27f2e4f870cb65e58d15e4 (diff)
- added make_orco_curf, even does keys!
- removed {lattice,curve}_modifier functions - changed render code to use displist for curve rendering instead of making its own. required adding a bevelSplitFlag field to DispList. I also fixed the bevel face splitting which did not work correctly in many situations. - changed so all curve data creation happens in makeDispListCurveTypes, includes making bevel list and filling polys - changed render code to use displist for surface rendering - removed Curve.orco variable, built as needed now - removed stupid BLI_setScanFill* functions... why use a function argument when you can use a global and two functions! Why indeed. (this fixed crash when reloading a file with filled curves and toggling editmode) - bug fix, setting curve width!=1 disabled simple bevel for no apparent reason - cleaned up lots and lots of curve/displist code (fun example: "if(dl->type==DL_INDEX3 || dl->type==DL_INDEX3)"). Hmmm! - switched almost all lattice calls to go through lattice_deform_verts, only exception left is particles - added DBG_show_shared_render_faces function in render, just helps to visualize which verts are shared while testing (no user interface). - renamed some curve bevel buttons and rewrote tooltips to be more obvious - made CU_FAST work without dupfontbase hack Also by the way I wrote down some notes on how curve code works, nothing spiffy but it is at: http://wiki.blender.org/bin/view.pl/Blenderdev/CurveNotes
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_curve.h3
-rw-r--r--source/blender/blenkernel/BKE_deform.h4
-rw-r--r--source/blender/blenkernel/BKE_displist.h7
-rw-r--r--source/blender/blenkernel/BKE_lattice.h3
-rw-r--r--source/blender/blenkernel/intern/action.c2
-rw-r--r--source/blender/blenkernel/intern/curve.c110
-rw-r--r--source/blender/blenkernel/intern/deform.c44
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c4
-rw-r--r--source/blender/blenkernel/intern/displist.c341
-rw-r--r--source/blender/blenkernel/intern/font.c4
-rw-r--r--source/blender/blenkernel/intern/lattice.c68
-rw-r--r--source/blender/blenkernel/intern/object.c4
-rw-r--r--source/blender/blenkernel/intern/softbody.c2
13 files changed, 255 insertions, 341 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;