diff options
author | Daniel Dunbar <daniel@zuster.org> | 2005-07-17 08:17:33 +0400 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2005-07-17 08:17:33 +0400 |
commit | e6f45278137567e697327ccdab3099d0145117dd (patch) | |
tree | d80641360e323b0fd2d60fb4c04106af7439e8af | |
parent | 80327e675addf423a2db9cb80768c7e327834d04 (diff) |
- added DerivedMesh.getMinMax function (calls DO_MINMAX on all vertices)
- static'd boundbox_displist
- added getMinMax implementations for all existing DerivedMesh
implementations (mesh, editmesh, displistmesh, and ccgsubsurf)
-rw-r--r-- | source/blender/blenkernel/BKE_DerivedMesh.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_displist.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 38 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/displist.c | 12 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 47 |
5 files changed, 93 insertions, 9 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 756f9051308..7f71e887791 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -61,9 +61,11 @@ struct DerivedMesh { void (*getMappedVertCoEM)(DerivedMesh *dm, void *vert, float co_r[3]); - /* Convert to new DispListMesh, should be free'd by caller */ + /* Convert to new DispListMesh, should be free'd by caller */ struct DispListMesh* (*convertToDispListMesh)(DerivedMesh *dm); + /* Iterate over all vertex points, calling DO_MINMAX with given args */ + void (*getMinMax)(DerivedMesh *dm, float min_r[3], float max_r[3]); /* Direct Access Operations */ /* o Can be undefined */ diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h index 05bf911474b..4efb3f1edb7 100644 --- a/source/blender/blenkernel/BKE_displist.h +++ b/source/blender/blenkernel/BKE_displist.h @@ -148,7 +148,6 @@ extern void makeDispListCurveTypes(struct Object *ob); extern void makeDispListMBall(struct Object *ob); extern void shadeDispList(struct Object *ob); void freefastshade(void); -void boundbox_displist(struct Object *ob); void imagestodisplist(void); void reshadeall_displist(void); void filldisplist(struct ListBase *dispbase, struct ListBase *to); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 62c6fa0f01f..a861b7d4d47 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -45,6 +45,7 @@ #include "BLI_blenlib.h" #include "BLI_editVert.h" +#include "BKE_utildefines.h" #include "BKE_DerivedMesh.h" #include "BKE_displist.h" #include "BKE_effect.h" @@ -112,6 +113,19 @@ static float *meshDM__getVertCoP(MeshDerivedMesh *mdm, int index) } } +static void meshDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3]) +{ + MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm; + Mesh *me = mdm->ob->data; + int i; + + for (i=0; i<me->totvert; i++) { + MVert *mv = &me->mvert[i]; + + DO_MINMAX(mv->co, min_r, max_r); + } +} + static void meshDM_getVertCo(DerivedMesh *dm, int index, float co_r[3]) { float *co = meshDM__getVertCoP((MeshDerivedMesh*) dm, index); @@ -435,6 +449,8 @@ static DerivedMesh *getMeshDerivedMesh(Object *ob, float *extverts, float *nors) { MeshDerivedMesh *mdm = MEM_callocN(sizeof(*mdm), "dm"); + mdm->dm.getMinMax = meshDM_getMinMax; + mdm->dm.convertToDispListMesh = meshDM_convertToDispListMesh; mdm->dm.getNumVerts = meshDM_getNumVerts; mdm->dm.getNumFaces = meshDM_getNumFaces; @@ -564,6 +580,15 @@ static void emDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int)) } } +static void emDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3]) +{ + EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm; + EditVert *eve; + + for (eve= emdm->em->verts.first; eve; eve= eve->next) { + DO_MINMAX(eve->co, min_r, max_r); + } +} static int emDM_getNumVerts(DerivedMesh *dm) { EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm; @@ -581,6 +606,8 @@ static DerivedMesh *getEditMeshDerivedMesh(EditMesh *em) { EditMeshDerivedMesh *emdm = MEM_callocN(sizeof(*emdm), "dm"); + emdm->dm.getMinMax = emDM_getMinMax; + emdm->dm.getNumVerts = emDM_getNumVerts; emdm->dm.getNumFaces = emDM_getNumFaces; emdm->dm.getMappedVertCoEM = emDM_getMappedVertCoEM; @@ -845,6 +872,15 @@ static void ssDM_drawFacesTex(DerivedMesh *dm, int (*setDrawParams)(TFace *tf, i } } +static void ssDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3]) +{ + SSDerivedMesh *ssdm = (SSDerivedMesh*) dm; + int i; + + for (i=0; i<ssdm->dlm->totvert; i++) { + DO_MINMAX(ssdm->dlm->mvert[i].co, min_r, max_r); + } +} static int ssDM_getNumVerts(DerivedMesh *dm) { SSDerivedMesh *ssdm = (SSDerivedMesh*) dm; @@ -878,6 +914,8 @@ DerivedMesh *derivedmesh_from_displistmesh(DispListMesh *dlm) { SSDerivedMesh *ssdm = MEM_callocN(sizeof(*ssdm), "dm"); + ssdm->dm.getMinMax = ssDM_getMinMax; + ssdm->dm.getNumVerts = ssDM_getNumVerts; ssdm->dm.getNumFaces = ssDM_getNumFaces; ssdm->dm.convertToDispListMesh = ssDM_convertToDispListMesh; diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 3cc3a31af3e..16485d91fc9 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -105,6 +105,8 @@ struct _FastLamp { /***/ +static void boundbox_displist(Object *ob); + static FastLamp *fastlamplist= NULL; static float fviewmat[4][4]; @@ -771,7 +773,7 @@ void shadeDispList(Object *ob) { MFace *mface; MVert *mvert; - DispList *dl, *dlob, *dldeform; + DispList *dl, *dlob; Material *ma = NULL; Mesh *me; Curve *cu; @@ -790,9 +792,6 @@ void shadeDispList(Object *ob) Mat3CpyMat4(imat, tmat); if(ob->transflag & OB_NEG_SCALE) Mat3MulFloat((float *)imat, -1.0); - /* we extract dl_verts, deform info */ - dldeform= find_displist(&ob->disp, DL_VERTS); - dl = find_displist(&ob->disp, DL_VERTCOL); if (dl) { BLI_remlink(&ob->disp, dl); @@ -1179,8 +1178,7 @@ void reshadeall_displist(void) ob= base->object; - /* we extract dl_verts, deform info */ - dldeform= find_displist(&ob->disp, DL_VERTS); + dldeform= find_displist(&ob->disp, DL_VERTS); // removed after switchover if(dldeform) BLI_remlink(&ob->disp, dldeform); /* Metaballs have standard displist at the Object */ @@ -2211,7 +2209,7 @@ void imagestodisplist(void) allqueue(REDRAWVIEW3D, 0); } -void boundbox_displist(Object *ob) +static void boundbox_displist(Object *ob) { BoundBox *bb=0; float min[3], max[3]; diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 92989638f63..ac48ff5acbb 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -41,6 +41,7 @@ #include "DNA_object_types.h" #include "BKE_bad_level_calls.h" +#include "BKE_utildefines.h" #include "BKE_global.h" #include "BKE_mesh.h" #include "BKE_subsurf.h" @@ -570,6 +571,51 @@ typedef struct { SubSurf *ss; } CCGDerivedMesh; +static void ccgDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3]) { + CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; + CCGSubSurf *ss = ccgdm->ss->subSurf; + CCGVertIterator *vi = ccgSubSurf_getVertIterator(ss); + CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss); + CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss); + int i, edgeSize = ccgSubSurf_getEdgeSize(ss); + int gridSize = ccgSubSurf_getGridSize(ss); + + for (; !ccgVertIterator_isStopped(vi); ccgVertIterator_next(vi)) { + CCGVert *v = ccgVertIterator_getCurrent(vi); + float *co = ccgSubSurf_getVertData(ss, v); + + DO_MINMAX(co, min_r, max_r); + } + + for (; !ccgEdgeIterator_isStopped(ei); ccgEdgeIterator_next(ei)) { + CCGEdge *e = ccgEdgeIterator_getCurrent(ei); + EditEdge *eed = ccgSubSurf_getEdgeEdgeHandle(ss, e); + VertData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e); + + for (i=1; i<edgeSize-1; i++) + DO_MINMAX(edgeData[i].co, min_r, max_r); + } + + for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) { + CCGFace *f = ccgFaceIterator_getCurrent(fi); + EditFace *efa = ccgSubSurf_getFaceFaceHandle(ss, f); + int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(ss, f); + + for (S=0; S<numVerts; S++) { + VertData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); + + for (x=0; x<gridSize; x++) + DO_MINMAX(faceGridData[x].co, min_r, max_r); + for (y=0; y<gridSize; y++) + for (x=0; x<gridSize; x++) + DO_MINMAX(faceGridData[y*gridSize + x].co, min_r, max_r); + } + } + + ccgFaceIterator_free(fi); + ccgEdgeIterator_free(ei); + ccgVertIterator_free(vi); +} static int ccgDM_getNumVerts(DerivedMesh *dm) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; @@ -910,6 +956,7 @@ static void ccgDM_release(DerivedMesh *dm) { static CCGDerivedMesh *getCCGDerivedMesh(SubSurf *ss) { CCGDerivedMesh *ccgdm = MEM_mallocN(sizeof(*ccgdm), "dm"); + ccgdm->dm.getMinMax = ccgDM_getMinMax; ccgdm->dm.getNumVerts = ccgDM_getNumVerts; ccgdm->dm.getNumFaces = ccgDM_getNumFaces; ccgdm->dm.getMappedVertCoEM = ccgDM_getMappedVertCoEM; |