Revision: 18925 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18925 Author: joeedh Date: 2009-02-11 13:32:29 +0100 (Wed, 11 Feb 2009)
Log Message: ----------- split and dupe ops now spit out an edge map for finding the edge skirts. still need to implement a mapping for isolated vert splitting. note, this isn't tested. Modified Paths: -------------- branches/bmesh/blender/source/blender/bmesh/bmesh_operators.h branches/bmesh/blender/source/blender/bmesh/intern/bmesh_opdefines.c branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators.c branches/bmesh/blender/source/blender/bmesh/operators/bmesh_dupeops.c branches/bmesh/blender/source/blender/bmesh/operators/subdivideop.c Modified: branches/bmesh/blender/source/blender/bmesh/bmesh_operators.h =================================================================== --- branches/bmesh/blender/source/blender/bmesh/bmesh_operators.h 2009-02-11 12:19:42 UTC (rev 18924) +++ branches/bmesh/blender/source/blender/bmesh/bmesh_operators.h 2009-02-11 12:32:29 UTC (rev 18925) @@ -83,6 +83,7 @@ void BMO_HeaderFlag_To_Slot(struct BMesh *bm, struct BMOperator *op, int slotcode, int flag, int type); int BMO_CountSlotBuf(struct BMesh *bm, struct BMOperator *op, int slotcode); +/*copies data, doesn't store a reference to it.*/ void BMO_Insert_Mapping(BMesh *bm, BMOperator *op, int slotcode, void *element, void *data, int len); void BMO_Insert_MapFloat(BMesh *bm, BMOperator *op, int slotcode, @@ -94,6 +95,13 @@ void BMO_Mapping_To_Flag(struct BMesh *bm, struct BMOperator *op, int slotcode, int flag); +/*do NOT use these for non-operator-api-allocated memory! instead + use BMO_Get_MapData, which copies the data.*/ +void BMO_Insert_MapPointer(BMesh *bm, BMOperator *op, int slotcode, + void *element, void *val); +void *BMO_Get_MapPointer(BMesh *bm, BMOperator *op, int slotcode, + void *element); + /*if msg is null, then the default message for the errorcode is used*/ void BMOP_RaiseError(BMesh *bm, int errcode, char *msg); /*returns error code or 0 if no error*/ @@ -119,6 +127,7 @@ enum { BMOP_SPLIT_MULTIN, BMOP_SPLIT_MULTOUT, + BMOP_SPLIT_BOUNDS_EDGEMAP, BMOP_SPLIT_TOTSLOT, }; @@ -129,6 +138,9 @@ BMOP_DUPE_MULTIN, BMOP_DUPE_ORIG, BMOP_DUPE_NEW, + /*we need a map for verts duplicated not connected + to any faces, too.*/ + BMOP_DUPE_BOUNDS_EDGEMAP, BMOP_DUPE_TOTSLOT }; Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_opdefines.c =================================================================== --- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_opdefines.c 2009-02-11 12:19:42 UTC (rev 18924) +++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_opdefines.c 2009-02-11 12:32:29 UTC (rev 18925) @@ -70,14 +70,16 @@ }; BMOpDefine def_dupeop = { - {BMOP_OPSLOT_PNT_BUF, BMOP_OPSLOT_PNT_BUF, BMOP_OPSLOT_PNT_BUF}, + {BMOP_OPSLOT_PNT_BUF, BMOP_OPSLOT_PNT_BUF, + BMOP_OPSLOT_PNT_BUF, BMOP_OPSLOT_MAPPING}, dupeop_exec, BMOP_DUPE_TOTSLOT, 0 }; BMOpDefine def_splitop = { - {BMOP_OPSLOT_PNT_BUF, BMOP_OPSLOT_PNT_BUF}, + {BMOP_OPSLOT_PNT_BUF, BMOP_OPSLOT_PNT_BUF, + BMOP_OPSLOT_MAPPING}, splitop_exec, BMOP_SPLIT_TOTSLOT, 0 Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators.c =================================================================== --- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators.c 2009-02-11 12:19:42 UTC (rev 18924) +++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators.c 2009-02-11 12:32:29 UTC (rev 18925) @@ -183,13 +183,42 @@ if(source_slot->slottype != dest_slot->slottype) return; - if(dest_slot->slottype > BMOP_OPSLOT_VEC){ - /*do buffer copy*/ - dest_slot->data.buf = NULL; - dest_slot->len = source_slot->len; - if(dest_slot->len){ - dest_slot->data.buf = BLI_memarena_alloc(dest_op->arena, BMOP_OPSLOT_TYPEINFO[dest_slot->slottype] * dest_slot->len); - memcpy(dest_slot->data.buf, source_slot->data.buf, BMOP_OPSLOT_TYPEINFO[dest_slot->slottype] * dest_slot->len); + if (dest_slot->slottype > BMOP_OPSLOT_VEC) { + if (dest_slot->slottype != BMOP_OPSLOT_MAPPING) { + /*do buffer copy*/ + dest_slot->data.buf = NULL; + dest_slot->len = source_slot->len; + if(dest_slot->len){ + dest_slot->data.buf = BLI_memarena_alloc(dest_op->arena, BMOP_OPSLOT_TYPEINFO[dest_slot->slottype] * dest_slot->len); + memcpy(dest_slot->data.buf, source_slot->data.buf, BMOP_OPSLOT_TYPEINFO[dest_slot->slottype] * dest_slot->len); + } + } else { + GHashIterator it; + element_mapping *srcmap, *dstmap; + + /*sanity check*/ + if (!source_slot->data.ghash) return; + + if (!dest_slot->data.ghash) { + dest_slot->data.ghash = + BLI_ghash_new(BLI_ghashutil_ptrhash, + BLI_ghashutil_ptrcmp); + } + + BLI_ghashIterator_init(&it, source_slot->data.ghash); + for (;srcmap=BLI_ghashIterator_getValue(&it); + BLI_ghashIterator_step(&it)) + { + dstmap = BLI_memarena_alloc(dest_op->arena, + sizeof(*dstmap) + srcmap->len); + + dstmap->element = srcmap->element; + dstmap->len = srcmap->len; + memcpy(dstmap+1, srcmap+1, srcmap->len); + + BLI_ghash_insert(dest_slot->data.ghash, + dstmap->element, dstmap); + } } } else { dest_slot->data = source_slot->data; @@ -401,6 +430,12 @@ BMO_Insert_Mapping(bm, op, slotcode, element, &val, sizeof(float)); } +void BMO_Insert_MapPointer(BMesh *bm, BMOperator *op, int slotcode, + void *element, void *val) +{ + BMO_Insert_Mapping(bm, op, slotcode, element, &val, sizeof(void*)); +} + void *BMO_Get_MapData(BMesh *bm, BMOperator *op, int slotcode, void *element) { @@ -425,6 +460,15 @@ return 0.0f; } +void *BMO_Get_MapPointer(BMesh *bm, BMOperator *op, int slotcode, + void *element) +{ + void **val = BMO_Get_MapData(bm, op, slotcode, element); + if (val) return *val; + + return NULL; +} + static void *alloc_slot_buffer(BMOperator *op, int slotcode, int len){ /*check if its actually a buffer*/ Modified: branches/bmesh/blender/source/blender/bmesh/operators/bmesh_dupeops.c =================================================================== --- branches/bmesh/blender/source/blender/bmesh/operators/bmesh_dupeops.c 2009-02-11 12:19:42 UTC (rev 18924) +++ branches/bmesh/blender/source/blender/bmesh/operators/bmesh_dupeops.c 2009-02-11 12:32:29 UTC (rev 18925) @@ -11,9 +11,10 @@ #include "bmesh_operators_private.h" /*local flag defines*/ -#define DUPE_INPUT 1 /*input from operator*/ +#define DUPE_INPUT 1 /*input from operator*/ #define DUPE_NEW 2 #define DUPE_DONE 4 +#define DUPE_MAPPED 8 /* * COPY VERTEX @@ -46,17 +47,43 @@ * Copy an existing edge from one bmesh to another. * */ -static BMEdge *copy_edge(BMesh *source_mesh, BMEdge *source_edge, BMesh *target_mesh, GHash *vhash, GHash *ehash) +static BMEdge *copy_edge(BMOperator *op, BMesh *source_mesh, + BMEdge *source_edge, BMesh *target_mesh, + GHash *vhash, GHash *ehash) { BMEdge *target_edge = NULL; BMVert *target_vert1, *target_vert2; - + BMFace *face; + BMIter fiter; + int found, rlen; + + /*see if any of the neighboring faces are + not being duplicated. in that case, + add it to the new/old map.*/ + found = rlen = 0; + for (face=BMIter_New(&fiter,source_mesh, BM_FACES_OF_EDGE,source_edge); + face; face=BMIter_Step(&fiter)) { + if (!BMO_TestFlag(source_mesh, face, DUPE_INPUT)) { + found = 1; + break; + } + rlen++; + } + /*Lookup v1 and v2*/ target_vert1 = BLI_ghash_lookup(vhash, source_edge->v1); target_vert2 = BLI_ghash_lookup(vhash, source_edge->v2); /*Create a new edge*/ target_edge = BM_Make_Edge(target_mesh, target_vert1, target_vert2, NULL, 0); + + /*add to new/old edge map if necassary*/ + if (rlen > 0 && rlen <= 2 && found) { + /*not sure what non-manifold cases of greater then three + radial should do.*/ + BMO_Insert_MapPointer(source_mesh,op,BMOP_DUPE_BOUNDS_EDGEMAP, + source_edge, target_edge); + } /*Insert new edge into the edge hash*/ BLI_ghash_insert(ehash, source_edge, target_edge); @@ -119,7 +146,7 @@ * Internal Copy function. */ -static void copy_mesh(BMesh *source, BMesh *target) +static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) { BMVert *v = NULL; @@ -160,7 +187,7 @@ /*edge pass*/ for(e = BMIter_New(&edges, source, BM_EDGES_OF_FACE, f); e; e = BMIter_Step(&edges)){ if(!BMO_TestFlag(source, (BMHeader*)e, DUPE_DONE)){ - copy_edge(source, e, target, vhash, ehash); + copy_edge(op, source, e, target, vhash, ehash); BMO_SetFlag(source, (BMHeader*)e, DUPE_DONE); } } @@ -182,7 +209,7 @@ BMO_SetFlag(source, (BMHeader*)e->v2, DUPE_DONE); } /*now copy the actual edge*/ - copy_edge(source, e, target, vhash, ehash); + copy_edge(op, source, e, target, vhash, ehash); BMO_SetFlag(source, (BMHeader*)e, DUPE_DONE); } } @@ -264,7 +291,7 @@ /*flag input*/ BMO_Flag_Buffer(bm, dupeop, BMOP_DUPE_MULTIN, DUPE_INPUT); /*use the internal copy function*/ - copy_mesh(bm, bm); + copy_mesh(dupeop, bm, bm); /*Output*/ /*First copy the input buffers to output buffers - original data*/ @@ -329,6 +356,8 @@ /*now we make our outputs by copying the dupe outputs*/ BMO_CopySlot(&dupeop, splitop, BMOP_DUPE_NEW, BMOP_SPLIT_MULTOUT); + BMO_CopySlot(&dupeop, splitop, BMOP_DUPE_BOUNDS_EDGEMAP, + BMOP_SPLIT_BOUNDS_EDGEMAP); /*cleanup*/ BMO_Finish_Op(bm, &delop); Modified: branches/bmesh/blender/source/blender/bmesh/operators/subdivideop.c =================================================================== --- branches/bmesh/blender/source/blender/bmesh/operators/subdivideop.c 2009-02-11 12:19:42 UTC (rev 18924) +++ branches/bmesh/blender/source/blender/bmesh/operators/subdivideop.c 2009-02-11 12:32:29 UTC (rev 18925) @@ -592,12 +592,11 @@ rad = BMO_GetSlot(op, BMOP_ESUBDIVIDE_RADIUS)->data.f; einput = BMO_GetSlot(op, BMOP_ESUBDIVIDE_EDGES); - /*first go through and tag edges*/ - for (i=0; i<einput->len; i++) { - edge = ((BMEdge**)einput->data.p)[i]; - BMO_SetFlag(bmesh, edge, SUBD_SPLIT); - } + /*first go through and tag edges*/ + BMO_Flag_To_Slot(bmesh, op, BMOP_ESUBDIVIDE_EDGES, + SUBD_SPLIT, BM_EDGE); + params.flag = flag; params.numcuts = numcuts; params.op = op; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs