diff options
Diffstat (limited to 'source/blender/src')
-rw-r--r-- | source/blender/src/buttons_editing.c | 45 | ||||
-rw-r--r-- | source/blender/src/drawmesh.c | 5 | ||||
-rw-r--r-- | source/blender/src/drawobject.c | 37 | ||||
-rw-r--r-- | source/blender/src/edit.c | 2 | ||||
-rw-r--r-- | source/blender/src/editmesh_mods.c | 7 | ||||
-rw-r--r-- | source/blender/src/editobject.c | 9 |
6 files changed, 60 insertions, 45 deletions
diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 7829aa467bd..b228bd444b6 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -264,7 +264,6 @@ static void decimate_faces(void) if(LOD_LoadMesh(&lod) ) { if( LOD_PreprocessMesh(&lod) ) { - DispList *dl; DispListMesh *dlm; MFace *mfaceint; @@ -275,11 +274,11 @@ static void decimate_faces(void) } /* ok, put back the stuff in a displist */ - freedisplist(&(ob->disp)); - dl= MEM_callocN(sizeof(DispList), "disp"); - BLI_addtail(&ob->disp, dl); - dl->type= DL_MESH; - dlm=dl->mesh= MEM_callocN(sizeof(DispListMesh), "dispmesh"); + if (me->decimated) { + displistmesh_free(me->decimated); + } + + dlm= me->decimated= MEM_callocN(sizeof(DispListMesh), "dispmesh"); dlm->mvert= MEM_callocN(lod.vertex_num*sizeof(MVert), "mvert"); dlm->mface= MEM_callocN(lod.face_num*sizeof(MFace), "mface"); dlm->totvert= lod.vertex_num; @@ -320,8 +319,14 @@ static void decimate_cancel(void) ob= OBACT; if(ob) { - freedisplist(&ob->disp); - makeDispList(ob); + if (ob->type==OB_MESH) { + Mesh *me = ob->data; + + if (me->decimated) { + displistmesh_free(me->decimated); + me->decimated = NULL; + } + } } allqueue(REDRAWVIEW3D, 0); } @@ -329,9 +334,6 @@ static void decimate_cancel(void) static void decimate_apply(void) { Object *ob; - DispList *dl; - DispListMesh *dlm; - Mesh *me; MFace *mface; MFace *mfaceint; int a; @@ -339,11 +341,11 @@ static void decimate_apply(void) if(G.obedit) return; ob= OBACT; - if(ob) { - dl= ob->disp.first; - if(dl && dl->mesh) { - dlm= dl->mesh; - me= ob->data; + if(ob && ob->type==OB_MESH) { + Mesh *me = ob->data; + + if (me->decimated) { + DispListMesh *dlm= me->decimated; // vertices if(me->mvert) MEM_freeN(me->mvert); @@ -369,7 +371,8 @@ static void decimate_apply(void) test_index_mface(mface, 3); } - freedisplist(&ob->disp); + displistmesh_free(me->decimated); + me->decimated= NULL; G.obedit= ob; make_editMesh(); @@ -709,11 +712,11 @@ static void editing_panel_mesh_type(Object *ob, Mesh *me) /* decimator */ if(G.obedit==NULL) { int tottria= decimate_count_tria(ob); - DispList *dl; + Mesh *me = ob->data; - // wacko, wait for new displist system (ton) - if( (dl=ob->disp.first) && dl->mesh); - else decim_faces= tottria; + if (!me->decimated) { + decim_faces= tottria; + } uiBlockBeginAlign(block); uiBlockSetCol(block, TH_BUT_SETTING1); diff --git a/source/blender/src/drawmesh.c b/source/blender/src/drawmesh.c index 969aa2300be..bca1729cf6e 100644 --- a/source/blender/src/drawmesh.c +++ b/source/blender/src/drawmesh.c @@ -933,11 +933,12 @@ void draw_tface_mesh(Object *ob, Mesh *me, int dt) if(mesh_uses_displist(me) && editing==0) { dm = mesh_get_derived(ob); + dm->drawFacesTex(dm, draw_tface_mesh__set_draw); } else { dm = mesh_get_base_derived(ob); + dm->drawFacesTex(dm, draw_tface_mesh__set_draw); + dm->release(dm); } - dm->drawFacesTex(dm, draw_tface_mesh__set_draw); - dm->release(dm); start = 0; totface = me->totface; diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index d12b767290a..2c3796c2496 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -1000,9 +1000,8 @@ void calc_mesh_facedots_ext(void) } /* window coord, assuming all matrices are set OK */ -static void calc_meshverts(void) +static void calc_meshverts(DerivedMesh *dm) { - DerivedMesh *dm = mesh_get_cage_derived(G.obedit); float co[3], mat[4][4]; EditVert *eve; @@ -1017,26 +1016,31 @@ static void calc_meshverts(void) } MTC_Mat4SwapMat4(G.vd->persmat, mat); - dm->release(dm); } /* window coord for current window, sets matrices temporal */ void calc_meshverts_ext(void) { + int dmNeedsFree; + DerivedMesh *dm = mesh_get_cage_derived(G.obedit, &dmNeedsFree); areawinset(curarea->win); persp(PERSP_VIEW); mymultmatrix(G.obedit->obmat); - calc_meshverts(); + calc_meshverts(dm); myloadmatrix(G.vd->viewmat); - + + if (dmNeedsFree) { + dm->release(dm); + } } /* window coord for current window, sets matrices temporal, sets (eve->f & 2) when not visible */ void calc_meshverts_ext_f2(void) { - DerivedMesh *dm = mesh_get_cage_derived(G.obedit); + int dmNeedsFree; + DerivedMesh *dm = mesh_get_cage_derived(G.obedit, &dmNeedsFree); float co[3], mat[4][4]; EditVert *eve; @@ -1063,7 +1067,9 @@ void calc_meshverts_ext_f2(void) MTC_Mat4SwapMat4(G.vd->persmat, mat); myloadmatrix(G.vd->viewmat); - dm->release(dm); + if (dmNeedsFree) { + dm->release(dm); + } } @@ -1569,8 +1575,7 @@ static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *baseDM, Derived } if(ob==G.obedit) { - // XXX Not clear this is needed here. - zr - calc_meshverts(); + calc_meshverts(cageDM); draw_em_fancy_verts(em, cageDM); if(G.f & G_DRAWNORMALS) { @@ -1620,8 +1625,8 @@ static void draw_mesh_fancy(Object *ob, DerivedMesh *baseDM, DerivedMesh *realDM // This is only for objects from the decimator and // is a temporal solution, a reconstruction of the // displist system should take care of it (zr/ton) - if(obDL && obDL->mesh) { - DispListMesh *dlm = obDL->mesh; + if(me->decimated) { + DispListMesh *dlm = me->decimated; MVert *mvert= dlm->mvert; MFace *mface= dlm->mface; int i; @@ -1751,9 +1756,6 @@ static void draw_mesh_object(Object *ob, int dt) } baseDM->release(baseDM); - if (realDM) { - realDM->release(realDM); - } } /* ************** DRAW DISPLIST ****************** */ @@ -3737,6 +3739,7 @@ static int bbs_mesh_solid(Object *ob, DerivedMesh *dm, int facecol) void draw_object_backbufsel(Object *ob) { extern int em_solidoffs, em_wireoffs, em_vertoffs; // let linker solve it... from editmesh_mods.c + int dmNeedsFree; DerivedMesh *dm; mymultmatrix(ob->obmat); @@ -3746,7 +3749,7 @@ void draw_object_backbufsel(Object *ob) switch( ob->type) { case OB_MESH: - dm = mesh_get_cage_derived(ob); + dm = mesh_get_cage_derived(ob, &dmNeedsFree); if(G.obedit) { em_solidoffs= bbs_mesh_solid(ob, dm, G.scene->selectmode & SCE_SELECT_FACE); @@ -3764,7 +3767,9 @@ void draw_object_backbufsel(Object *ob) } else bbs_mesh_solid(ob, dm, 1); // 1= facecol, faceselect - dm->release(dm); + if (dmNeedsFree) { + dm->release(dm); + } break; case OB_CURVE: case OB_SURF: diff --git a/source/blender/src/edit.c b/source/blender/src/edit.c index 35b973fc151..fdcdf2401c1 100644 --- a/source/blender/src/edit.c +++ b/source/blender/src/edit.c @@ -495,8 +495,6 @@ void count_object(Object *ob, int sel) if (dm) { totvert= dm->getNumVerts(dm); totface= dm->getNumFaces(dm); - - dm->release(dm); } else { totvert= me->totvert; totface= me->totface; diff --git a/source/blender/src/editmesh_mods.c b/source/blender/src/editmesh_mods.c index dd5422ff449..1a87e5ada3d 100644 --- a/source/blender/src/editmesh_mods.c +++ b/source/blender/src/editmesh_mods.c @@ -628,7 +628,8 @@ static EditFace *findnearestface(short *dist) /* for interactivity, frontbuffer draw in current window */ static void unified_select_draw(EditVert *eve, EditEdge *eed, EditFace *efa) { - DerivedMesh *dm = mesh_get_cage_derived(G.obedit); + int dmNeedsFree; + DerivedMesh *dm = mesh_get_cage_derived(G.obedit, &dmNeedsFree); glDrawBuffer(GL_FRONT); @@ -711,7 +712,9 @@ static void unified_select_draw(EditVert *eve, EditEdge *eed, EditFace *efa) /* signal that frontbuf differs from back */ curarea->win_swap= WIN_FRONT_OK; - dm->release(dm); + if (dmNeedsFree) { + dm->release(dm); + } } diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index d139b05a6f8..748d6508f55 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -96,6 +96,7 @@ #include "BKE_booleanops.h" #include "BKE_curve.h" #include "BKE_displist.h" +#include "BKE_DerivedMesh.h" #include "BKE_effect.h" #include "BKE_font.h" #include "BKE_global.h" @@ -2151,6 +2152,7 @@ void convertmenu(void) if (mesh_uses_displist(oldme)) { DispListMesh *dlm; + DerivedMesh *dm; basedel = base; @@ -2177,8 +2179,11 @@ void convertmenu(void) me->mat= MEM_dupallocN(oldme->mat); for(a=0; a<ob1->totcol; a++) id_us_plus((ID *)me->mat[a]); } - - dlm= subsurf_make_dispListMesh_from_mesh(oldme, oldme->subdiv, oldme->flag); + + dm= subsurf_make_derived_from_mesh(oldme, oldme->subdiv, oldme->flag); + dlm= dm->convertToDispListMesh(dm); + dm->release(dm); + displistmesh_to_mesh(dlm, ob1->data); displistmesh_free(dlm); |