- added Mesh->derived and Mesh->decimated DerivedMesh pointers
- removed DL_MESH displist type!!!! Now store a DerivedMesh directly. - May still be some issues left having to do with releasing this at the right time (old code just splashed free_displist all over the place).
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
*needsFree = 0;
|
||||
return me->derived;
|
||||
} else {
|
||||
*needsFree = 1;
|
||||
if(G.obedit && me==G.obedit->data) {
|
||||
return getSSDerivedMesh(G.editMesh, dl->mesh, 0);
|
||||
return subsurf_make_derived_from_editmesh(G.editMesh, me->subdivr, me->flag, me->subsurftype);
|
||||
} else {
|
||||
return getSSDerivedMesh(NULL, dl->mesh, 0);
|
||||
}
|
||||
} else {
|
||||
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);
|
||||
} 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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])
|
||||
{
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
{
|
||||
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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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);
|
||||
if (needsFree) {
|
||||
dm->release(dm);
|
||||
}
|
||||
|
||||
mvert= dlm->mvert;
|
||||
totvert= dlm->totvert;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
start = 0;
|
||||
totface = me->totface;
|
||||
|
||||
@@ -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);
|
||||
|
||||
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
|
||||
|
||||
if (dmNeedsFree) {
|
||||
dm->release(dm);
|
||||
}
|
||||
break;
|
||||
case OB_CURVE:
|
||||
case OB_SURF:
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
if (dmNeedsFree) {
|
||||
dm->release(dm);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -2178,7 +2180,10 @@ void convertmenu(void)
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user