- split makeDispList into makeDispList{Mesh,MBall,CurveTypes}, there is
still a makeDispList that dispatches to the appropriate one. makeDispList is on the way out and this makes it easier to track down exactly which places use makedispList and for what types of objects. - switch calls to makeDispList to appropriate more specific function (if the object type is known by caller). - added mesh_changed function that invalidates cached mesh data (but does not rebuild, mesh data gets rebuilt on access). Most old calls to makeDispListMesh use this instead now.
This commit is contained in:
@@ -142,6 +142,10 @@ 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 makeDispList(struct Object *ob);
|
||||
extern void mesh_changed(struct Object *meshOb);
|
||||
extern void makeDispListMesh(struct Object *ob);
|
||||
extern void makeDispListCurveTypes(struct Object *ob);
|
||||
extern void makeDispListMBall(struct Object *ob);
|
||||
extern void set_displist_onlyzero(int val);
|
||||
extern void shadeDispList(struct Object *ob);
|
||||
void freefastshade(void);
|
||||
|
||||
@@ -75,7 +75,7 @@ void copy_dverts(struct MDeformVert *dst, struct MDeformVert *src, int totvert);
|
||||
int mesh_uses_displist(struct Mesh *me);
|
||||
int update_realtime_texture(struct TFace *tface, double time);
|
||||
void mesh_delete_material_index(struct Mesh *me, int index);
|
||||
void mesh_set_smooth_flag(struct Mesh *me, int enableSmooth);
|
||||
void mesh_set_smooth_flag(struct Object *meshOb, int enableSmooth);
|
||||
|
||||
void make_edges(struct Mesh *me);
|
||||
|
||||
|
||||
@@ -301,17 +301,6 @@ void frames_duplilist(Object *ob)
|
||||
|
||||
if(ob->transflag & OB_DUPLINOSPEED) enable_cu_speed= 0;
|
||||
|
||||
/* this to make sure that something is z-buffered in drawobject.c */
|
||||
if(G.background==0 && ob->type==OB_MESH) {
|
||||
Mesh *me= ob->data;
|
||||
DispList *dl;
|
||||
if(me->disp.first==0) addnormalsDispList(ob, &me->disp);
|
||||
if(ob->dt==OB_SHADED) {
|
||||
dl= ob->disp.first;
|
||||
if(dl==0 || dl->col1==0) shadeDispList(ob);
|
||||
}
|
||||
}
|
||||
|
||||
for(G.scene->r.cfra= ob->dupsta; G.scene->r.cfra<=ob->dupend; G.scene->r.cfra++) {
|
||||
|
||||
ok= 1;
|
||||
|
||||
@@ -1212,7 +1212,7 @@ void makebevelcurve(Object *ob, ListBase *disp)
|
||||
|
||||
dl= bevcu->disp.first;
|
||||
if(dl==0) {
|
||||
makeDispList(cu->bevobj);
|
||||
makeDispListCurveTypes(cu->bevobj);
|
||||
dl= bevcu->disp.first;
|
||||
}
|
||||
while(dl) {
|
||||
|
||||
@@ -650,12 +650,34 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
|
||||
|
||||
}
|
||||
|
||||
static float *mesh_build_faceNormals(Object *meshOb)
|
||||
{
|
||||
Mesh *me = meshOb->data;
|
||||
float *nors = MEM_mallocN(sizeof(float)*3*me->totface, "meshnormals");
|
||||
float *n1 = nors;
|
||||
int i;
|
||||
|
||||
for (i=0; i<me->totface; i++,n1+=3) {
|
||||
MFace *mf = &me->mface[i];
|
||||
|
||||
if (mf->v3) {
|
||||
MVert *ve1= &me->mvert[mf->v1];
|
||||
MVert *ve2= &me->mvert[mf->v2];
|
||||
MVert *ve3= &me->mvert[mf->v3];
|
||||
MVert *ve4= &me->mvert[mf->v4];
|
||||
|
||||
if(mf->v4) CalcNormFloat4(ve1->co, ve2->co, ve3->co, ve4->co, n1);
|
||||
else CalcNormFloat(ve1->co, ve2->co, ve3->co, n1);
|
||||
}
|
||||
}
|
||||
|
||||
return nors;
|
||||
}
|
||||
|
||||
void addnormalsDispList(Object *ob, ListBase *lb)
|
||||
{
|
||||
DispList *dl = NULL;
|
||||
Mesh *me;
|
||||
MVert *ve1, *ve2, *ve3, *ve4;
|
||||
MFace *mface;
|
||||
float *vdata, *ndata, nor[3];
|
||||
float *v1, *v2, *v3, *v4;
|
||||
float *n1, *n2, *n3, *n4;
|
||||
@@ -678,23 +700,7 @@ void addnormalsDispList(Object *ob, ListBase *lb)
|
||||
else return;
|
||||
|
||||
if(dl->nors==0) {
|
||||
dl->nors= MEM_mallocN(sizeof(float)*3*me->totface, "meshnormals");
|
||||
n1= dl->nors;
|
||||
mface= me->mface;
|
||||
a= me->totface;
|
||||
while(a--) {
|
||||
if(mface->v3) {
|
||||
ve1= me->mvert+mface->v1;
|
||||
ve2= me->mvert+mface->v2;
|
||||
ve3= me->mvert+mface->v3;
|
||||
ve4= me->mvert+mface->v4;
|
||||
|
||||
if(mface->v4) CalcNormFloat4(ve1->co, ve2->co, ve3->co, ve4->co, n1);
|
||||
else CalcNormFloat(ve1->co, ve2->co, ve3->co, n1);
|
||||
}
|
||||
n1+= 3;
|
||||
mface++;
|
||||
}
|
||||
dl->nors= mesh_build_faceNormals(ob);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -909,7 +915,7 @@ void shadeDispList(Object *ob)
|
||||
}
|
||||
}
|
||||
else if(me->totvert>0) {
|
||||
float *vnors, *vn;
|
||||
float *vnors, *vn, *nors;
|
||||
|
||||
if(me->orco==0 && need_orco) {
|
||||
make_orco_mesh(me);
|
||||
@@ -917,11 +923,7 @@ void shadeDispList(Object *ob)
|
||||
orco= me->orco;
|
||||
/* ms= me->msticky; */
|
||||
|
||||
dl= me->disp.first;
|
||||
if(dl==0 || dl->nors==0) addnormalsDispList(ob, &me->disp);
|
||||
dl= me->disp.first;
|
||||
if(dl==0 || dl->nors==0) return;
|
||||
nor= dl->nors;
|
||||
nors = nor = mesh_build_faceNormals(ob);
|
||||
|
||||
dl= MEM_callocN(sizeof(DispList), "displistshade");
|
||||
BLI_addtail(&ob->disp, dl);
|
||||
@@ -1034,6 +1036,7 @@ void shadeDispList(Object *ob)
|
||||
}
|
||||
|
||||
MEM_freeN(vnors);
|
||||
MEM_freeN(nors);
|
||||
|
||||
if(me->orco) {
|
||||
MEM_freeN(me->orco);
|
||||
@@ -1568,7 +1571,7 @@ float calc_taper(Object *taperobj, int cur, int tot)
|
||||
cu= taperobj->data;
|
||||
dl= cu->disp.first;
|
||||
if(dl==NULL) {
|
||||
makeDispList(taperobj);
|
||||
makeDispListCurveTypes(taperobj);
|
||||
dl= cu->disp.first;
|
||||
}
|
||||
if(dl) {
|
||||
@@ -1601,10 +1604,70 @@ float calc_taper(Object *taperobj, int cur, int tot)
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
void makeDispList(Object *ob)
|
||||
void mesh_changed(Object *meshOb)
|
||||
{
|
||||
Mesh *me = meshOb->data;
|
||||
|
||||
freedisplist(&meshOb->disp);
|
||||
freedisplist(&me->disp);
|
||||
|
||||
if (me->derived) {
|
||||
me->derived->release(me->derived);
|
||||
me->derived = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void makeDispListMesh(Object *ob)
|
||||
{
|
||||
EditMesh *em = G.editMesh;
|
||||
Mesh *me;
|
||||
|
||||
if(!ob || (ob->flag&OB_FROMDUPLI) || ob->type!=OB_MESH) return;
|
||||
|
||||
freedisplist(&(ob->disp));
|
||||
|
||||
me= ob->data;
|
||||
freedisplist(&me->disp);
|
||||
if (me->derived) {
|
||||
me->derived->release(me->derived);
|
||||
me->derived= NULL;
|
||||
}
|
||||
|
||||
tex_space_mesh(ob->data);
|
||||
|
||||
if (ob!=G.obedit) mesh_modifier(ob, 's');
|
||||
|
||||
if (mesh_uses_displist(me)) { /* subsurf */
|
||||
if (ob==G.obedit) {
|
||||
G.editMesh->derived= subsurf_make_derived_from_editmesh(em, me->subdiv, me->subsurftype, G.editMesh->derived);
|
||||
} else {
|
||||
me->derived= subsurf_make_derived_from_mesh(me, me->subdiv);
|
||||
}
|
||||
}
|
||||
|
||||
if (ob!=G.obedit) mesh_modifier(ob, 'e');
|
||||
|
||||
boundbox_displist(ob);
|
||||
}
|
||||
void makeDispListMBall(Object *ob)
|
||||
{
|
||||
if(!ob || (ob->flag&OB_FROMDUPLI) || ob->type!=OB_MBALL) return;
|
||||
|
||||
freedisplist(&(ob->disp));
|
||||
|
||||
if(ob->type==OB_MBALL) {
|
||||
if(ob==find_basis_mball(ob)) {
|
||||
metaball_polygonize(ob);
|
||||
tex_space_mball(ob);
|
||||
|
||||
object_deform(ob);
|
||||
}
|
||||
}
|
||||
|
||||
boundbox_displist(ob);
|
||||
}
|
||||
void makeDispListCurveTypes(Object *ob)
|
||||
{
|
||||
Nurb *nu;
|
||||
Curve *cu;
|
||||
BPoint *bp;
|
||||
@@ -1615,43 +1678,13 @@ void makeDispList(Object *ob)
|
||||
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_MESH) {
|
||||
me= ob->data;
|
||||
freedisplist(&me->disp);
|
||||
if (me->derived) {
|
||||
me->derived->release(me->derived);
|
||||
me->derived= NULL;
|
||||
}
|
||||
|
||||
tex_space_mesh(ob->data);
|
||||
|
||||
if (ob!=G.obedit) mesh_modifier(ob, 's');
|
||||
|
||||
if (mesh_uses_displist(me)) { /* subsurf */
|
||||
if (ob==G.obedit) {
|
||||
G.editMesh->derived= subsurf_make_derived_from_editmesh(em, me->subdiv, me->subsurftype, G.editMesh->derived);
|
||||
} else {
|
||||
me->derived= subsurf_make_derived_from_mesh(me, me->subdiv);
|
||||
}
|
||||
}
|
||||
|
||||
if (ob!=G.obedit) mesh_modifier(ob, 'e');
|
||||
}
|
||||
else if(ob->type==OB_MBALL) {
|
||||
if(ob==find_basis_mball(ob)) {
|
||||
metaball_polygonize(ob);
|
||||
tex_space_mball(ob);
|
||||
|
||||
object_deform(ob);
|
||||
}
|
||||
}
|
||||
else if(ob->type==OB_SURF) {
|
||||
|
||||
if(ob->type==OB_SURF) {
|
||||
draw= ob->dt;
|
||||
cu= ob->data;
|
||||
dispbase= &(cu->disp);
|
||||
@@ -1891,6 +1924,17 @@ void makeDispList(Object *ob)
|
||||
boundbox_displist(ob);
|
||||
}
|
||||
|
||||
void makeDispList(Object *ob)
|
||||
{
|
||||
if (ob->type==OB_MESH) {
|
||||
makeDispListMesh(ob);
|
||||
} else if (ob->type==OB_MBALL) {
|
||||
makeDispListMBall(ob);
|
||||
} else {
|
||||
makeDispListCurveTypes(ob);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*******************************/
|
||||
/***** OUTLINE *****/
|
||||
|
||||
@@ -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) makeDispList(cu->textoncurve);
|
||||
if(cucu->path==NULL) makeDispListCurveTypes(cu->textoncurve);
|
||||
if(cucu->path) {
|
||||
|
||||
|
||||
|
||||
@@ -153,6 +153,8 @@ void free_mesh(Mesh *me)
|
||||
if(me->bb) MEM_freeN(me->bb);
|
||||
if(me->disp.first) freedisplist(&me->disp);
|
||||
if(me->derived) me->derived->release(me->derived);
|
||||
|
||||
BLI_freelistN(&me->modifiers);
|
||||
}
|
||||
|
||||
void copy_dverts(MDeformVert *dst, MDeformVert *src, int copycount)
|
||||
@@ -1259,7 +1261,8 @@ void mesh_delete_material_index(Mesh *me, int index) {
|
||||
}
|
||||
}
|
||||
|
||||
void mesh_set_smooth_flag(Mesh *me, int enableSmooth) {
|
||||
void mesh_set_smooth_flag(Object *meshOb, int enableSmooth) {
|
||||
Mesh *me = meshOb->data;
|
||||
int i;
|
||||
|
||||
for (i=0; i<me->totface; i++) {
|
||||
@@ -1271,4 +1274,6 @@ void mesh_set_smooth_flag(Mesh *me, int enableSmooth) {
|
||||
mf->flag &= ~ME_SMOOTH;
|
||||
}
|
||||
}
|
||||
|
||||
mesh_changed(meshOb);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,6 @@ PyObject *Curve_getNurb( BPy_Curve * self, int n );
|
||||
static int Curve_length( PyInstanceObject * inst );
|
||||
void update_displists( void *data );
|
||||
|
||||
void makeDispList( Object * ob );
|
||||
struct chartrans *text_to_curve( Object * ob, int mode );
|
||||
|
||||
|
||||
|
||||
@@ -355,7 +355,7 @@ PyObject *M_Library_Update( PyObject * self )
|
||||
} else {
|
||||
if( ob->type == OB_MESH && ob->parent
|
||||
&& ob->parent->type == OB_LATTICE )
|
||||
makeDispList( ob );
|
||||
makeDispListMesh( ob );
|
||||
}
|
||||
|
||||
ob = ob->id.next;
|
||||
|
||||
@@ -1209,7 +1209,7 @@ static void init_render_mball(Object *ob)
|
||||
dlo= ob->disp.first;
|
||||
if(dlo) BLI_remlink(&ob->disp, dlo);
|
||||
|
||||
makeDispList(ob);
|
||||
makeDispListMBall(ob);
|
||||
dl= ob->disp.first;
|
||||
if(dl==0) return;
|
||||
|
||||
@@ -2222,7 +2222,7 @@ static void init_render_curve(Object *ob)
|
||||
/* no modifier call here, is in makedisp */
|
||||
|
||||
/* test displist */
|
||||
if(cu->disp.first==0) makeDispList(ob);
|
||||
if(cu->disp.first==0) makeDispListCurveTypes(ob);
|
||||
dl= cu->disp.first;
|
||||
if(cu->disp.first==0) return;
|
||||
|
||||
@@ -2664,9 +2664,6 @@ void RE_freeRotateBlenderScene(void)
|
||||
{
|
||||
ShadBuf *shb;
|
||||
Object *ob = NULL;
|
||||
Mesh *me;
|
||||
Curve *cu;
|
||||
DispList *dl;
|
||||
unsigned long *ztile;
|
||||
int a, b, v;
|
||||
char *ctile;
|
||||
@@ -2720,26 +2717,26 @@ void RE_freeRotateBlenderScene(void)
|
||||
while(ob) {
|
||||
|
||||
if ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT) {
|
||||
cu= ob->data;
|
||||
Curve *cu= ob->data;
|
||||
if(cu->orco) {
|
||||
MEM_freeN(cu->orco);
|
||||
cu->orco= 0;
|
||||
}
|
||||
}
|
||||
else if(ob->type==OB_MESH) {
|
||||
me= ob->data;
|
||||
Mesh *me= ob->data;
|
||||
if(me->orco) {
|
||||
MEM_freeN(me->orco);
|
||||
me->orco= 0;
|
||||
}
|
||||
if ((me->flag&ME_SUBSURF) && ((me->subdiv!=me->subdivr) || (ob->effect.first != NULL) || ob==G.obedit) ) {
|
||||
/* Need to recalc for effects since they are time dependant */
|
||||
makeDispList(ob); /* XXX this should be replaced with proper caching */
|
||||
makeDispListMesh(ob); /* XXX this should be replaced with proper caching */
|
||||
}
|
||||
}
|
||||
else if(ob->type==OB_MBALL) {
|
||||
if(ob->disp.first && ob->disp.first!=ob->disp.last) {
|
||||
dl= ob->disp.first;
|
||||
DispList *dl= ob->disp.first;
|
||||
BLI_remlink(&ob->disp, dl);
|
||||
freedisplist(&ob->disp);
|
||||
BLI_addtail(&ob->disp, dl);
|
||||
@@ -3019,7 +3016,7 @@ void RE_rotateBlenderScene(void)
|
||||
cu= obd->data;
|
||||
if(cu->disp.first==NULL) {
|
||||
obd->flag &= ~OB_FROMDUPLI;
|
||||
makeDispList(obd);
|
||||
makeDispListCurveTypes(obd);
|
||||
obd->flag |= OB_FROMDUPLI;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -885,7 +885,7 @@ void rotate_uv_tface()
|
||||
}
|
||||
|
||||
BIF_undo_push("Rotate UV face");
|
||||
makeDispList(OBACT);
|
||||
mesh_changed(OBACT);
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
allqueue(REDRAWIMAGE, 0);
|
||||
}
|
||||
@@ -1226,9 +1226,11 @@ void set_faceselect() /* toggle */
|
||||
BIF_undo_push("Set UV Faceselect");
|
||||
}
|
||||
else if((G.f & (G_WEIGHTPAINT|G_VERTEXPAINT|G_TEXTUREPAINT))==0) {
|
||||
if(me) reveal_tface();
|
||||
if(me) {
|
||||
reveal_tface();
|
||||
mesh_changed(ob);
|
||||
}
|
||||
setcursor_space(SPACE_VIEW3D, CURSOR_STD);
|
||||
makeDispList(ob);
|
||||
BIF_undo_push("End UV Faceselect");
|
||||
}
|
||||
countall();
|
||||
|
||||
@@ -1153,7 +1153,7 @@ void make_parent(void)
|
||||
mode= PAROBJECT;
|
||||
if((cu->flag & CU_PATH)==0) {
|
||||
cu->flag |= CU_PATH|CU_FOLLOW;
|
||||
makeDispList(par); // force creation of path data
|
||||
makeDispListCurveTypes(par); // force creation of path data
|
||||
}
|
||||
else cu->flag |= CU_FOLLOW;
|
||||
}
|
||||
@@ -1881,7 +1881,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);
|
||||
makeDispList(OBACT);
|
||||
makeDispListCurveTypes(OBACT);
|
||||
|
||||
OBACT->flag &= ~SELECT;
|
||||
BASACT->flag &= ~SELECT;
|
||||
@@ -2269,7 +2269,7 @@ void convertmenu(void)
|
||||
cu= ob->data;
|
||||
|
||||
dl= cu->disp.first;
|
||||
if(dl==0) makeDispList(ob); // force creation
|
||||
if(dl==0) makeDispListCurveTypes(ob); // force creation
|
||||
|
||||
nurbs_to_mesh(ob); /* also does users */
|
||||
|
||||
@@ -2347,7 +2347,7 @@ void flip_subdivison(Object *ob, int level)
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
allqueue(REDRAWOOPS, 0);
|
||||
allqueue(REDRAWBUTSEDIT, 0);
|
||||
makeDispList(ob); // no dependency?
|
||||
mesh_changed(ob);
|
||||
|
||||
BIF_undo_push("Switch subsurf on/off");
|
||||
}
|
||||
|
||||
@@ -761,7 +761,7 @@ void transform_tface_uv(int mode, int context) // 2 args, for callback
|
||||
G.moving= 0;
|
||||
prop_size*= 3;
|
||||
|
||||
makeDispList(OBACT);
|
||||
mesh_changed(OBACT);
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
|
||||
if(event!=ESCKEY && event!=RIGHTMOUSE)
|
||||
|
||||
@@ -1808,8 +1808,8 @@ static void tb_do_mesh(void *arg, int event){
|
||||
case 2: G.f ^= G_DRAWEDGES; break;
|
||||
case 3: G.f ^= G_DRAWFACES; break;
|
||||
case 4: G.f ^= G_DRAWNORMALS; break;
|
||||
case 5: me->flag ^= ME_SUBSURF; makeDispList(OBACT); break;
|
||||
case 6: me->flag ^= ME_OPT_EDGES; makeDispList(OBACT); break;
|
||||
case 5: me->flag ^= ME_SUBSURF; mesh_changed(OBACT); break;
|
||||
case 6: me->flag ^= ME_OPT_EDGES; mesh_changed(OBACT); break;
|
||||
}
|
||||
addqueue(curarea->win, REDRAW, 1);
|
||||
}
|
||||
|
||||
@@ -766,7 +766,7 @@ void wpaint_undo (void){
|
||||
me->dvert= MEM_mallocN(sizeof(MDeformVert)*me->totvert, "deformVert");
|
||||
copy_dverts(me->dvert, wpaintundobuf, totwpaintundo);
|
||||
|
||||
makeDispList(OBACT);
|
||||
mesh_changed(OBACT);
|
||||
scrarea_do_windraw(curarea);
|
||||
|
||||
}
|
||||
@@ -940,7 +940,7 @@ void weight_paint(void)
|
||||
me->mcol= 0;
|
||||
}
|
||||
|
||||
makeDispList(ob);
|
||||
mesh_changed(ob);
|
||||
// this flag is event for softbody to refresh weightpaint values
|
||||
if(ob->soft) ob->softflag |= OB_SB_REDO;
|
||||
|
||||
@@ -1152,8 +1152,9 @@ void set_wpaint(void) /* toggle */
|
||||
}
|
||||
else {
|
||||
freefastshade(); /* to be sure */
|
||||
if (ob)
|
||||
makeDispList(ob);
|
||||
if (me) {
|
||||
mesh_changed(ob);
|
||||
}
|
||||
if(!(G.f & G_FACESELECT))
|
||||
setcursor_space(SPACE_VIEW3D, CURSOR_STD);
|
||||
}
|
||||
@@ -1200,7 +1201,9 @@ void set_vpaint(void) /* toggle */
|
||||
}
|
||||
else {
|
||||
freefastshade(); /* to be sure */
|
||||
if (ob) makeDispList(ob);
|
||||
if (me) {
|
||||
mesh_changed(ob);
|
||||
}
|
||||
if((G.f & G_FACESELECT)==0) setcursor_space(SPACE_VIEW3D, CURSOR_STD);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user