diff options
Diffstat (limited to 'source/blender')
21 files changed, 166 insertions, 130 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index e8a6a82ff48..4fb8ae49052 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -46,6 +46,7 @@ */ struct Object; +struct EditMesh; struct DispListMesh; typedef struct DerivedMesh DerivedMesh; @@ -146,14 +147,18 @@ struct DerivedMesh { void (*release)(DerivedMesh *dm); }; + /* Internal function, just temporarily exposed */ +DerivedMesh *derivedmesh_from_displistmesh(struct EditMesh *em, struct DispListMesh *dlm); + DerivedMesh *mesh_get_derived(struct Object *ob); -DerivedMesh *mesh_get_derived_render(struct Object *ob); DerivedMesh *mesh_get_base_derived(struct Object *ob); +DerivedMesh *mesh_get_derived_render(struct Object *ob, int *needsFree_r); + /* Utility function, just chooses appropriate DerivedMesh based - * on mesh flags. + * on mesh flags. Release result if *needsFree_r is true. */ -DerivedMesh *mesh_get_cage_derived(struct Object *ob); +DerivedMesh *mesh_get_cage_derived(struct Object *ob, int *needsFree_r); #endif diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h index 0146d1a2341..ac8c601c5a5 100644 --- a/source/blender/blenkernel/BKE_displist.h +++ b/source/blender/blenkernel/BKE_displist.h @@ -45,7 +45,6 @@ #define DL_VERTCOL 6 #define DL_VERTS 7 #define DL_NORS 8 -#define DL_MESH 9 /* dl->flag */ #define DL_CYCL_U 1 @@ -133,8 +132,6 @@ typedef struct DispList { float *verts, *nors; int *index; unsigned int *col1, *col2; - struct DispListMesh *mesh; - } DispList; extern void copy_displist(struct ListBase *lbn, struct ListBase *lb); diff --git a/source/blender/blenkernel/BKE_subsurf.h b/source/blender/blenkernel/BKE_subsurf.h index a23cd5755d1..39ea8c7a0c6 100644 --- a/source/blender/blenkernel/BKE_subsurf.h +++ b/source/blender/blenkernel/BKE_subsurf.h @@ -33,12 +33,12 @@ struct Mesh; struct Object; -struct Displist; struct DispListMesh; +struct DerivedMesh; struct EditMesh; -struct DispListMesh *subsurf_make_dispListMesh_from_editmesh(struct EditMesh *em, int subdivLevels, int flags, short type); -struct DispListMesh *subsurf_make_dispListMesh_from_mesh(struct Mesh *me, int subdivLevels, int flags); +struct DerivedMesh *subsurf_make_derived_from_editmesh(struct EditMesh *em, int subdivLevels, int flags, short type); +struct DerivedMesh *subsurf_make_derived_from_mesh(struct Mesh *me, int subdivLevels, int flags); #ifdef USE_CCGSUBSURFLIB struct DispListMesh *subsurf_ccg_make_dispListMesh_from_editmesh(struct EditMesh *em, int subdivLevels, int flags); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index c8d820db281..1c6b6ebe2d3 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -20,7 +20,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * The Original Code is Copyright (C) 2005 Blender Foundation. * All rights reserved. * * The Original Code is: all of this file. @@ -1072,14 +1072,12 @@ static void ssDM_release(DerivedMesh *dm) { SSDerivedMesh *ssdm = (SSDerivedMesh*) dm; - if (ssdm->needsFree) { - displistmesh_free(ssdm->dlm); - } + displistmesh_free(ssdm->dlm); MEM_freeN(dm); } -static DerivedMesh *getSSDerivedMesh(EditMesh *em, DispListMesh *dlm, int needsFree) +DerivedMesh *derivedmesh_from_displistmesh(EditMesh *em, DispListMesh *dlm) { SSDerivedMesh *ssdm = MEM_mallocN(sizeof(*ssdm), "dm"); @@ -1110,7 +1108,6 @@ static DerivedMesh *getSSDerivedMesh(EditMesh *em, DispListMesh *dlm, int needsF ssdm->dlm = dlm; ssdm->em = em; - ssdm->needsFree = needsFree; return (DerivedMesh*) ssdm; } @@ -1145,50 +1142,28 @@ DerivedMesh *mesh_get_derived(Object *ob) Mesh *me= ob->data; if (mesh_uses_displist(me)) { - DispList *dl; - build_mesh_data(ob); - dl= find_displist(&me->disp, DL_MESH); - - // XXX, This test should not be here because - // build_mesh_data should have made DLM... problem - // is there is an exception for objects from dupli, - // they only get displist built for first object. - // - // Would work fine except countall gets a derived - // mesh before the displist has been evaluated. - if (dl) { - if(G.obedit && me==G.obedit->data) { - return getSSDerivedMesh(G.editMesh, dl->mesh, 0); - } else { - return getSSDerivedMesh(NULL, dl->mesh, 0); - } - } + + return me->derived; } return NULL; } -DerivedMesh *mesh_get_derived_render(Object *ob) +DerivedMesh *mesh_get_derived_render(Object *ob, int *needsFree) { Mesh *me= ob->data; if (mesh_uses_displist(me)) { if (me->subdiv==me->subdivr) { - DispList *dl= find_displist(&me->disp, DL_MESH); - - if(G.obedit && me==G.obedit->data) { - return getSSDerivedMesh(G.editMesh, dl->mesh, 0); - } else { - return getSSDerivedMesh(NULL, dl->mesh, 0); - } + *needsFree = 0; + return me->derived; } else { + *needsFree = 1; if(G.obedit && me==G.obedit->data) { - DispListMesh *dlm = subsurf_make_dispListMesh_from_editmesh(G.editMesh, me->subdivr, me->flag, me->subsurftype); - return getSSDerivedMesh(G.editMesh, dlm, 1); + return subsurf_make_derived_from_editmesh(G.editMesh, me->subdivr, me->flag, me->subsurftype); } else { - DispListMesh *dlm = subsurf_make_dispListMesh_from_mesh(me, me->subdivr, me->flag); - return getSSDerivedMesh(NULL, dlm, 1); + return subsurf_make_derived_from_mesh(me, me->subdivr, me->flag); } } } @@ -1212,15 +1187,18 @@ DerivedMesh *mesh_get_base_derived(Object *ob) } } -DerivedMesh *mesh_get_cage_derived(struct Object *ob) +DerivedMesh *mesh_get_cage_derived(struct Object *ob, int *needsFree) { Mesh *me= ob->data; DerivedMesh *dm = NULL; + *needsFree = 0; + if (me->flag&ME_OPT_EDGES) { dm = mesh_get_derived(ob); } if (!dm) { + *needsFree = 1; dm = mesh_get_base_derived(ob); } diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 7387aa545f2..739376591ef 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -328,7 +328,6 @@ 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->mesh) displistmesh_free(dl->mesh); MEM_freeN(dl); } } @@ -411,7 +410,7 @@ int displist_has_faces(ListBase *lb) dl= lb->first; while(dl) { - if ELEM6(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF, DL_MESH, DL_TRIA, DL_POLY) + if ELEM5(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF, DL_TRIA, DL_POLY) return 1; dl= dl->next; } @@ -434,7 +433,6 @@ void copy_displist(ListBase *lbn, ListBase *lb) dln->index= MEM_dupallocN(dl->index); dln->col1= MEM_dupallocN(dl->col1); dln->col2= MEM_dupallocN(dl->col2); - if (dl->mesh) dln->mesh= displistmesh_copy(dl->mesh); dl= dl->next; } @@ -947,8 +945,6 @@ void shadeDispList(Object *ob) dlm= dm->convertToDispListMesh(dm); - dm->release(dm); - if (dlm && dlm->totvert) { float *vnors, *vn; int i; @@ -1769,24 +1765,21 @@ void makeDispList(Object *ob) 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 */ - DispListMesh *dlm; - if (ob==G.obedit) { - dlm= subsurf_make_dispListMesh_from_editmesh(em, me->subdiv, me->flag, me->subsurftype); + me->derived= subsurf_make_derived_from_editmesh(em, me->subdiv, me->flag, me->subsurftype); } else { - dlm= subsurf_make_dispListMesh_from_mesh(me, me->subdiv, me->flag); + me->derived= subsurf_make_derived_from_mesh(me, me->subdiv, me->flag); } - - dl= MEM_callocN(sizeof(*dl), "dl"); - dl->type= DL_MESH; - dl->mesh= dlm; - BLI_addtail(&me->disp, dl); } if (ob!=G.obedit) mesh_modifier(ob, 'e'); diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index d283c5808c6..6fe6b708f58 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -1234,8 +1234,6 @@ void build_particle_system(Object *ob) DerivedMesh *dm = mesh_get_derived(ob); dlm = dm->convertToDispListMesh(dm); - - dm->release(dm); } else { dlm = NULL; } diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index 2c16b76235a..cc96a0fdc4f 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -2559,7 +2559,6 @@ static int write_object_stl(FILE *fpSTL, Object *ob, Mesh *me) numfacets += write_displistmesh_stl(fpSTL, ob, dlm); displistmesh_free(dlm); - dm->release(dm); } else { numfacets += write_mesh_stl(fpSTL, ob, me); diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 039ce481a76..53f6f724b22 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -55,6 +55,7 @@ #include "DNA_meshdata_types.h" #include "BKE_main.h" +#include "BKE_DerivedMesh.h" #include "BKE_global.h" #include "BKE_mesh.h" #include "BKE_subsurf.h" @@ -151,6 +152,7 @@ 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); } void copy_dverts(MDeformVert *dst, MDeformVert *src, int copycount) @@ -422,6 +424,7 @@ void tex_space_mesh(Mesh *me) void make_orco_displist_mesh(Object *ob, int subdivlvl) { Mesh *me; + DerivedMesh *dm; DispListMesh *dlm; int i; @@ -432,7 +435,9 @@ void make_orco_displist_mesh(Object *ob, int subdivlvl) cp_key(0, me->totvert, me->totvert, (char*) me->mvert->co, me->key, me->key->refkey, 0); } - dlm= subsurf_make_dispListMesh_from_mesh(me, subdivlvl, me->flag); + dm= subsurf_make_derived_from_mesh(me, subdivlvl, me->flag); + dlm= dm->convertToDispListMesh(dm); + dm->release(dm); /* Restore correct key */ do_ob_key(ob); diff --git a/source/blender/blenkernel/intern/subsurf.c b/source/blender/blenkernel/intern/subsurf.c index 6baba62053a..8c8863c3324 100644 --- a/source/blender/blenkernel/intern/subsurf.c +++ b/source/blender/blenkernel/intern/subsurf.c @@ -53,6 +53,7 @@ #include "BKE_mesh.h" #include "BKE_subsurf.h" #include "BKE_displist.h" +#include "BKE_DerivedMesh.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" @@ -1094,7 +1095,7 @@ static DispListMesh *subsurf_subdivide_to_displistmesh(HyperMesh *hme, short sub return dlm; } -DispListMesh *subsurf_make_dispListMesh_from_editmesh(EditMesh *em, int subdivLevels, int flags, short type) { +static DispListMesh *subsurf_make_dispListMesh_from_editmesh(EditMesh *em, int subdivLevels, int flags, short type) { if (subdivLevels<1) { return displistmesh_from_editmesh(em); #ifdef USE_CCGSUBSURFLIB @@ -1108,7 +1109,11 @@ DispListMesh *subsurf_make_dispListMesh_from_editmesh(EditMesh *em, int subdivLe } } -DispListMesh *subsurf_make_dispListMesh_from_mesh(Mesh *me, int subdivLevels, int flags) { +DerivedMesh *subsurf_make_derived_from_editmesh(EditMesh *em, int subdivLevels, int flags, short type) { + return derivedmesh_from_displistmesh(em, subsurf_make_dispListMesh_from_editmesh(em, subdivLevels, flags, type)); +} + +static DispListMesh *subsurf_make_dispListMesh_from_mesh(Mesh *me, int subdivLevels, int flags) { if (subdivLevels<1) { return displistmesh_from_mesh(me, NULL); #ifdef USE_CCGSUBSURFLIB @@ -1122,6 +1127,10 @@ DispListMesh *subsurf_make_dispListMesh_from_mesh(Mesh *me, int subdivLevels, in } } +DerivedMesh *subsurf_make_derived_from_mesh(Mesh *me, int subdivLevels, int flags) { + return derivedmesh_from_displistmesh(NULL, subsurf_make_dispListMesh_from_mesh(me, subdivLevels, flags)); +} + // editarmature.c void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3]) { diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 88b2eecf891..98b47482d0c 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1,3 +1,35 @@ +/** + * $Id$ + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2005 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + #ifdef USE_CCGSUBSURFLIB #include <stdlib.h> diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c index 1eaff59bf7b..7797557c1f7 100644 --- a/source/blender/blenlib/intern/noise.c +++ b/source/blender/blenlib/intern/noise.c @@ -39,11 +39,6 @@ #include <config.h> #endif -#ifdef _WIN32 -#pragma warning (once : 4244) // "conversion from double to float" -#pragma warning (once : 4305) // "truncation from const double to float" -#endif - /* local */ float noise3_perlin(float vec[3]); float turbulence_perlin(float *point, float lofreq, float hifreq); diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index c937fa02b43..50ac321d353 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -321,7 +321,6 @@ void BLI_adddirstrings() struct direntry * file; struct tm *tm; time_t zero= 0; - struct passwd *pwuser; file = &files[0]; @@ -356,12 +355,15 @@ void BLI_adddirstrings() #ifdef WIN32 strcpy(files[num].owner,"user"); #else - pwuser = getpwuid(files[num].s.st_uid); - if ( pwuser ) { - strcpy(files[num].owner, pwuser->pw_name); - } else { - sprintf(files[num].owner, "%d", files[num].s.st_uid); - } + { + struct passwd *pwuser; + pwuser = getpwuid(files[num].s.st_uid); + if ( pwuser ) { + strcpy(files[num].owner, pwuser->pw_name); + } else { + sprintf(files[num].owner, "%d", files[num].s.st_uid); + } + } #endif tm= localtime(&files[num].s.st_mtime); diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index 79bf76618a6..796a06a21e6 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -35,6 +35,8 @@ #include "DNA_listBase.h" #include "DNA_ID.h" +struct DerivedMesh; +struct DispListMesh; struct Ipo; struct Key; struct Material; @@ -77,6 +79,11 @@ typedef struct Mesh { struct Mesh *texcomesh; float *orco; + /* not written in file, caches derived mesh */ + struct DerivedMesh *derived; + /* hacky place to store temporary decimated mesh */ + struct DispListMesh *decimated; + struct OcInfo *oc; /* not written in file */ void *sumohandle; @@ -87,14 +94,13 @@ typedef struct Mesh { float size[3]; float rot[3]; + float cubemapsize, pad; + short smoothresh, flag; - short subdiv, subdivr, subdivdone; + short subdiv, subdivr; short totcol; short subsurftype; - short reserved1; /* Padding */ - - float cubemapsize; } Mesh; diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c index 563ceed2722..9a833045a13 100644 --- a/source/blender/python/api2_2x/NMesh.c +++ b/source/blender/python/api2_2x/NMesh.c @@ -2169,7 +2169,6 @@ static PyObject *M_NMesh_GetRawFromObject( PyObject * self, PyObject * args ) DispListMesh *dlm = dm->convertToDispListMesh(dm); nmesh = new_NMesh_internal( me, dlm, NULL ); displistmesh_free(dlm); - dm->release(dm); } else if( ( dl = find_displist( &ob->disp, DL_VERTS ) ) ) nmesh = new_NMesh_internal( me, NULL, dl->verts ); diff --git a/source/blender/renderconverter/intern/convertBlenderScene.c b/source/blender/renderconverter/intern/convertBlenderScene.c index 563600e69e1..0d67fe6478a 100644 --- a/source/blender/renderconverter/intern/convertBlenderScene.c +++ b/source/blender/renderconverter/intern/convertBlenderScene.c @@ -1354,9 +1354,12 @@ static void init_render_mesh(Object *ob) do_puno= mesh_modifier(ob, 's'); if (mesh_uses_displist(me)) { - DerivedMesh *dm = mesh_get_derived_render(ob); + int needsFree; + DerivedMesh *dm = mesh_get_derived_render(ob, &needsFree); dlm = dm->convertToDispListMesh(dm); - dm->release(dm); + if (needsFree) { + dm->release(dm); + } mvert= dlm->mvert; totvert= dlm->totvert; 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); |