[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18945] branches/bmesh/blender/source/ blender: made extrude properly delete unneeded geometry
Joseph Eagar
joeedh at gmail.com
Thu Feb 12 19:05:34 CET 2009
Revision: 18945
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18945
Author: joeedh
Date: 2009-02-12 19:05:34 +0100 (Thu, 12 Feb 2009)
Log Message:
-----------
made extrude properly delete unneeded geometry
Modified Paths:
--------------
branches/bmesh/blender/source/blender/blenlib/intern/BLI_ghash.c
branches/bmesh/blender/source/blender/blenlib/intern/BLI_mempool.c
branches/bmesh/blender/source/blender/bmesh/bmesh_operators.h
branches/bmesh/blender/source/blender/bmesh/operators/bmesh_dupeops.c
branches/bmesh/blender/source/blender/bmesh/operators/extrudeops.c
Modified: branches/bmesh/blender/source/blender/blenlib/intern/BLI_ghash.c
===================================================================
--- branches/bmesh/blender/source/blender/blenlib/intern/BLI_ghash.c 2009-02-12 16:59:51 UTC (rev 18944)
+++ branches/bmesh/blender/source/blender/blenlib/intern/BLI_ghash.c 2009-02-12 18:05:34 UTC (rev 18945)
@@ -33,6 +33,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_ghash.h"
+#include "BLI_mempool.h"
#include "BLO_sys_types.h" // for intptr_t support
@@ -63,6 +64,7 @@
GHashCmpFP cmpfp;
Entry **buckets;
+ struct BLI_mempool *entrypool;
int nbuckets, nentries, cursize;
};
@@ -72,7 +74,8 @@
GHash *gh= MEM_mallocN(sizeof(*gh), "GHash");
gh->hashfp= hashfp;
gh->cmpfp= cmpfp;
-
+ gh->entrypool = BLI_mempool_create(sizeof(Entry), 1, 32);
+
gh->cursize= 0;
gh->nentries= 0;
gh->nbuckets= hashsizes[gh->cursize];
@@ -85,7 +88,7 @@
void BLI_ghash_insert(GHash *gh, void *key, void *val) {
unsigned int hash= gh->hashfp(key)%gh->nbuckets;
- Entry *e= malloc(sizeof(*e));
+ Entry *e= BLI_mempool_alloc(gh->entrypool);
e->key= key;
e->val= val;
@@ -141,7 +144,7 @@
if (keyfreefp) keyfreefp(e->key);
if (valfreefp) valfreefp(e->val);
- free(e);
+ BLI_mempool_free(gh->entrypool, e);
e= n;
@@ -185,13 +188,14 @@
if (keyfreefp) keyfreefp(e->key);
if (valfreefp) valfreefp(e->val);
- free(e);
+ BLI_mempool_free(gh->entrypool, e);
e= n;
}
}
free(gh->buckets);
+ BLI_mempool_destroy(gh->entrypool);
gh->buckets = 0;
gh->nentries = 0;
gh->nbuckets = 0;
Modified: branches/bmesh/blender/source/blender/blenlib/intern/BLI_mempool.c
===================================================================
--- branches/bmesh/blender/source/blender/blenlib/intern/BLI_mempool.c 2009-02-12 16:59:51 UTC (rev 18944)
+++ branches/bmesh/blender/source/blender/blenlib/intern/BLI_mempool.c 2009-02-12 18:05:34 UTC (rev 18945)
@@ -65,7 +65,8 @@
pool->chunks.first = pool->chunks.last = NULL;
maxchunks = tote / pchunk;
-
+ if (maxchunks==0) maxchunks = 1;
+
/*allocate the actual chunks*/
for(i=0; i < maxchunks; i++){
BLI_mempool_chunk *mpchunk = MEM_mallocN(sizeof(BLI_mempool_chunk), "BLI_Mempool Chunk");
@@ -85,6 +86,7 @@
/*set the end of this chunks memoryy to the new tail for next iteration*/
lasttail = curnode;
}
+
/*terminate the list*/
curnode->next = NULL;
return pool;
Modified: branches/bmesh/blender/source/blender/bmesh/bmesh_operators.h
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/bmesh_operators.h 2009-02-12 16:59:51 UTC (rev 18944)
+++ branches/bmesh/blender/source/blender/bmesh/bmesh_operators.h 2009-02-12 18:05:34 UTC (rev 18945)
@@ -180,6 +180,7 @@
#define DEL_EDGESFACES 4
#define DEL_FACES 5
#define DEL_ALL 6
+#define DEL_ONLYTAGGED 7
/*BMOP_DEL_CONTEXT*/
enum {
Modified: branches/bmesh/blender/source/blender/bmesh/operators/bmesh_dupeops.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/bmesh_dupeops.c 2009-02-12 16:59:51 UTC (rev 18944)
+++ branches/bmesh/blender/source/blender/bmesh/operators/bmesh_dupeops.c 2009-02-12 18:05:34 UTC (rev 18945)
@@ -339,22 +339,53 @@
BMOperator *splitop = op;
BMOperator dupeop;
BMOperator delop;
+ BMVert *v;
+ BMEdge *e;
+ BMFace *f;
+ BMIter iter, iter2;
+ int found;
/*initialize our sub-operators*/
BMO_Init_Op(&dupeop, BMOP_DUPE);
BMO_Init_Op(&delop, BMOP_DEL);
- BMO_Set_Int(&delop, BMOP_DEL_CONTEXT, DEL_FACES);
-
BMO_CopySlot(splitop, &dupeop, BMOP_SPLIT_MULTIN, BMOP_DUPE_MULTIN);
BMO_Exec_Op(bm, &dupeop);
+
+ BMO_Flag_Buffer(bm, splitop, BMOP_SPLIT_MULTIN, SPLIT_INPUT);
+ /*make sure to remove edges and verts we don't need.*/
+ for (e= BMIter_New(&iter, bm, BM_EDGES, NULL);e;e=BMIter_Step(&iter)) {
+ found = 0;
+ f = BMIter_New(&iter2, bm, BM_FACES_OF_EDGE, e);
+ for (; f; f=BMIter_Step(&iter2)) {
+ if (!BMO_TestFlag(bm, f, SPLIT_INPUT)) {
+ found = 1;
+ break;
+ }
+ }
+ if (!found) BMO_SetFlag(bm, e, SPLIT_INPUT);
+ }
+
+ for (v= BMIter_New(&iter, bm, BM_VERTS, NULL);v;v=BMIter_Step(&iter)) {
+ found = 0;
+ e = BMIter_New(&iter2, bm, BM_EDGES_OF_VERT, v);
+ for (; e; e=BMIter_Step(&iter2)) {
+ if (!BMO_TestFlag(bm, e, SPLIT_INPUT)) {
+ found = 1;
+ break;
+ }
+ }
+ if (!found) BMO_SetFlag(bm, v, SPLIT_INPUT);
+
+ }
+
/*connect outputs of dupe to delete, exluding keep geometry*/
- BMO_Flag_Buffer(bm, splitop, BMOP_SPLIT_MULTIN, SPLIT_INPUT);
+ BMO_Set_Int(&delop, BMOP_DEL_CONTEXT, DEL_ONLYTAGGED);
BMO_Unflag_Buffer(bm, splitop, BMOP_SPLIT_KEEPIN, SPLIT_INPUT);
BMO_Flag_To_Slot(bm, &delop, BMOP_DEL_MULTIN, SPLIT_INPUT, BM_ALL);
- //BMO_Exec_Op(bm, &delop);
+ BMO_Exec_Op(bm, &delop);
/*now we make our outputs by copying the dupe outputs*/
BMO_CopySlot(&dupeop, splitop, BMOP_DUPE_NEW, BMOP_SPLIT_MULTOUT);
@@ -464,7 +495,11 @@
}
else if(type == DEL_EDGESFACES) delete_edges(bm);
else if(type == DEL_ONLYFACES) BM_remove_tagged_faces(bm, DEL_INPUT);
- else if(type == DEL_FACES){
+ else if (type == DEL_ONLYTAGGED) {
+ BM_remove_tagged_faces(bm, DEL_INPUT);
+ BM_remove_tagged_edges(bm, DEL_INPUT);
+ BM_remove_tagged_verts(bm, DEL_INPUT);
+ } else if(type == DEL_FACES){
/*go through and mark all edges and all verts of all faces for delete*/
for(f = BMIter_New(&faces, bm, BM_FACES, bm); f; f = BMIter_Step(&faces)){
if(BMO_TestFlag(bm, (BMHeader*)f, DEL_INPUT)){
Modified: branches/bmesh/blender/source/blender/bmesh/operators/extrudeops.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/extrudeops.c 2009-02-12 16:59:51 UTC (rev 18944)
+++ branches/bmesh/blender/source/blender/bmesh/operators/extrudeops.c 2009-02-12 18:05:34 UTC (rev 18945)
@@ -26,7 +26,7 @@
/*initialize our sub-operators*/
BMO_Init_Op(&splitop, BMOP_SPLIT);
- BMO_Flag_To_Slot(bm, op, BMOP_EXFACE_EDGEFACEIN, EXT_INPUT, BM_ALL);
+ BMO_Flag_Buffer(bm, op, BMOP_EXFACE_EDGEFACEIN, EXT_INPUT);
/*calculate geometry to keep*/
for (edge = BMIter_New(&iter, bm, BM_EDGES, NULL); edge; edge=BMIter_Step(&iter)) {
@@ -36,7 +36,11 @@
if (BMO_TestFlag(bm, f, EXT_INPUT)) rlen++;
}
- if (rlen < 2) BMO_SetFlag(bm, edge, EXT_KEEP);
+ if (rlen < 2) {
+ BMO_SetFlag(bm, edge, EXT_KEEP);
+ BMO_SetFlag(bm, edge->v1, EXT_KEEP);
+ BMO_SetFlag(bm, edge->v2, EXT_KEEP);
+ }
}
BMO_CopySlot(op, &splitop, BMOP_EXFACE_EDGEFACEIN, BMOP_SPLIT_MULTIN);
@@ -50,7 +54,10 @@
for (; edge; edge=BMO_IterStep(&siter)) {
if (BMO_InMap(bm, op, BMOP_EXFACE_EXCLUDEMAP, edge)) continue;
- newedge = *(BMEdge**)BMO_IterMapVal(&siter);
+ newedge = BMO_IterMapVal(&siter);
+ if (!newedge) continue;
+ newedge = *(BMEdge**)newedge;
+
verts[0] = edge->v1;
verts[1] = edge->v2;
verts[2] = newedge->v2;
More information about the Bf-blender-cvs
mailing list