[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18298] branches/bmesh/bmesh: -> Cleanup up of API flags
joe
joeedh at gmail.com
Sun Jan 4 01:08:18 CET 2009
So, should every mesh flag be translated to a BMesh flag? Before I had it
just copy over the flags from mesh elements, which is why BM_FGON, BM_SHARP,
etc started after the first 16 bits, since they aren't originally stored in
the flag.
Joe
On Sat, Jan 3, 2009 at 1:26 PM, Geoffrey Bantle <hairbat at yahoo.com> wrote:
> Revision: 18298
>
> http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18298
> Author: briggs
> Date: 2009-01-03 21:26:29 +0100 (Sat, 03 Jan 2009)
>
> Log Message:
> -----------
> -> Cleanup up of API flags
>
> API flags now use dynamically allocated flag layers isntead
> of the persistent flag reserverd for 'marking' elements
> (hide, select, sharp, ect).
>
> Modified Paths:
> --------------
> branches/bmesh/bmesh/bmesh.h
> branches/bmesh/bmesh/intern/bmesh_construct.c
> branches/bmesh/bmesh/intern/bmesh_mesh.c
> branches/bmesh/bmesh/intern/bmesh_queries.c
>
> Modified: branches/bmesh/bmesh/bmesh.h
> ===================================================================
> --- branches/bmesh/bmesh/bmesh.h 2009-01-03 20:20:09 UTC (rev 18297)
> +++ branches/bmesh/bmesh/bmesh.h 2009-01-03 20:26:29 UTC (rev 18298)
> @@ -47,86 +47,68 @@
> struct BMEdge;
> struct BMFace;
> struct BMLoop;
> +
> /*
> - all mesh elements should share this beginning layout
> - we can pack this a little tighter now...
> -
> - BMHeader *next, *prev;
> - int EID;
> - int eflag1, eflag2;
> - short systemflag, type;
> - struct BMFlagLayer *flags;
> + * BMHeader
> + *
> + * All mesh elements begin with a BMHeader. This structure
> + * hold several types of data
> + *
> + * 1: The type of the element (vert, edge, loop or face)
> + * 2: Persistant flags/markings (sharp, seam, select, hidden, ect)
> + * 3: Unique ID in the bmesh.
> + * 4: some elements for internal record keeping.
> + *
> */
>
> -/* Defines for BMHeader->type*/
> +/*BMHeader->type*/
> #define BM_VERT 1
> #define BM_EDGE 2
> #define BM_FACE 4
> #define BM_LOOP 8
> #define BM_ALL BM_VERT | BM_EDGE | BM_FACE
> | BM_LOOP
>
> -/*Masks for BMHeader->flag
> - Note: Its entirely possible that any temporal flags should be moved
> - into the dynamically allocated flag layers and only reserve
> BMHeader->flag
> - for things like select, hide, ect.
> +/*BMHeader->flag*/
> +#define BM_SELECT (1<<0)
> +#define BM_SEAM (1<<1)
> +#define BM_FGON (1<<2)
> +#define BM_HIDDEN (1<<3)
> +#define BM_SHARP (1<<4)
> +#define BM_SMOOTH (1<<5)
>
> - The first 16 bits are reserved for the original element flags.
> - The next 5 (till BM_SMOOTH) are bmesh-added ones that replace
> - single variable flags. The rest after that are temporary flags.
> -*/
> -
> -#define BM_SELECT 1 //redefinition of SELECT
> -
> -/*auxillery bmesh flags. note, these should
> - become internal to the api eventually.
> -
> - start at the 17th flag.
> - */
> -#define BM_SEAM (1<<16)
> -#define BM_FGON (1<<17)
> -#define BM_HIDDEN (1<<18)
> -#define BM_SHARP (1<<19)
> -#define BM_SMOOTH (1<<20) /* for faces */
> -
> -#define BM_DIRTY (1<<21) /*Not used yet*/
> -#define BM_NEW (1<<22)
> -#define BM_OVERLAP (1<<23) /*used by
> bmesh_verts_in_face*/
> -#define BM_EDGEVERT (1<<24) /*used by
> bmesh_make_ngon*/
> -#define BM_DELETE (1<<25)
> -#define BM_AUX1 (1<<26)
> /*different for edges/verts/faces/ect*/
> -#define BM_AUX2 (1<<27)
> /*different for edges/verts/faces/ect*/
> -#define BM_AUX3 (1<<28)
> /*different for edges/verts/faces/ect*/
> -#define BM_TEMP_FLAGS BM_DIRTY|BM_NEW|BM_OVERLAP|BM_EDGEVERT|BM_DELETE
> -
> -/*All Mesh elements start with this structure*/
> typedef struct BMHeader
> {
> struct BMHeader *next, *prev;
> - int EID;
> - int flag;
> /*mesh flags, never to be (ab)used by the api itself!*/
> + int EID;
> /*Consider removing this/making it ifdeffed for debugging*/
> + short flag, type;
> int eflag1, eflag2;
> /*Flags used by eulers. Try and get rid of/minimize some of
> these*/
> - short type, pad1, pad2, pad3;
> /*Type of element this is head to*/
> - struct BMFlagLayer *flags;
> /*Dynamically allocated block of flag layers for operators to use*/
> + struct BMFlagLayer *flags;
> /*Dynamically allocated block of flag layers for operators to use*/
> } BMHeader;
>
> +typedef struct BMFlagLayer{
> + int f1;
> + short mask, pflag;
> +}BMFlagLayer;
>
> -/*Used for circular linked list functions*/
> +#define BM_OVERLAP (1<<0) /*used by
> bmesh_verts_in_face*/
> +#define BM_EDGEVERT (1<<1) /*used by bmesh_make_ngon*/
> +
> +
> +/*
> + * BMNode
> + *
> + * Used for circular/linked list functions that form basis of
> + * adjacency system in BMesh. This should probably be hidden
> + * somewhere since tool authors never need to know about it.
> + *
> +*/
> +
> typedef struct BMNode{
> struct BMNode *next, *prev;
> void *data;
> }BMNode;
>
> -/*Used by operator API to give each operator private flag space
> - -Perhaps want to change this to have a union for storing
> float/long/pointer/ect
> - -pflag should be used for system/API stuff
> -*/
>
> -typedef struct BMFlagLayer{
> - int f1;
> - short mask, pflag;
> -}BMFlagLayer;
> -
> -struct BMOperator;
> typedef struct BMesh
> {
> ListBase verts, edges, polys;
> @@ -143,9 +125,9 @@
> int nextv, nexte, nextp, nextl;
> struct CustomData vdata, edata, pdata, ldata;
> int selectmode;
> - struct BLI_mempool *flagpool; /*memory pool for dynamically
> allocated flag layers*/
> - int stackdepth; /*current depth of operator
> stack*/
> - int totflags, walkers; /*total number of tool flag
> layers*/
> + struct BLI_mempool *flagpool;
> /*memory pool for dynamically allocated flag layers*/
> + int stackdepth;
> /*current depth of operator stack*/
> + int totflags, walkers;
> /*total number of tool flag layers*/
> }BMesh;
>
> typedef struct BMVert
>
> Modified: branches/bmesh/bmesh/intern/bmesh_construct.c
> ===================================================================
> --- branches/bmesh/bmesh/intern/bmesh_construct.c 2009-01-03 20:20:09
> UTC (rev 18297)
> +++ branches/bmesh/bmesh/intern/bmesh_construct.c 2009-01-03 20:26:29
> UTC (rev 18298)
> @@ -187,16 +187,15 @@
> BMFace *f = NULL;
> int overlap = 0, i;
>
> -
> if(nodouble){
> if(len > VERT_BUF_SIZE)
> verts = MEM_callocN(sizeof(BMVert *) * len, "bmesh
> make ngon vertex array");
> for(i = 0; i < len; i++){
> - if(!bmesh_test_sysflag((BMHeader*)(edges[i]->v1),
> BM_EDGEVERT)){
> -
> bmesh_set_sysflag((BMHeader*)(edges[i]->v1), BM_EDGEVERT);
> + if(!BMO_TestFlag(bm, edges[i]->v1, BM_EDGEVERT)){
> + BMO_SetFlag(bm, edges[i]->v1, BM_EDGEVERT);
> verts[i] = edges[i]->v1;
> - } else
> if(!bmesh_test_sysflag((BMHeader*)(edges[i]->v2), BM_EDGEVERT)) {
> -
> bmesh_set_sysflag((BMHeader*)(edges[i]->v2), BM_EDGEVERT);
> + } else if(!BMO_TestFlag(bm, edges[i]->v2,
> BM_EDGEVERT)) {
> + BMO_SetFlag(bm, edges[i]->v2, BM_EDGEVERT);
> verts[i] = edges[i]->v2;
> }
> }
> @@ -205,8 +204,8 @@
>
> /*clear flags*/
> for(i = 0; i < len; i++){
> - bmesh_clear_sysflag((BMHeader*)(edges[i]->v1),
> BM_EDGEVERT);
> - bmesh_clear_sysflag((BMHeader*)(edges[i]->v2),
> BM_EDGEVERT);
> + BMO_ClearFlag(bm, edges[i]->v1, BM_EDGEVERT);
> + BMO_ClearFlag(bm, edges[i]->v2, BM_EDGEVERT);
> }
>
> if(len > VERT_BUF_SIZE)
>
> Modified: branches/bmesh/bmesh/intern/bmesh_mesh.c
> ===================================================================
> --- branches/bmesh/bmesh/intern/bmesh_mesh.c 2009-01-03 20:20:09 UTC
> (rev 18297)
> +++ branches/bmesh/bmesh/intern/bmesh_mesh.c 2009-01-03 20:26:29 UTC
> (rev 18298)
> @@ -88,33 +88,6 @@
> return 0;
> }
>
> -/*
> - * CLEAR TEMP FLAGS
> - *
> - * Clears all temporary flags at end of the modelling loop.
> - * May need to move this to operator finishing function?
> - *
> -*/
> -static void clear_temp_flags(BMesh *bm)
> -{
> - BMIter verts;
> - BMIter edges;
> - BMIter loops;
> - BMIter faces;
> -
> - BMVert *v;
> - BMEdge *e;
> - BMLoop *l;
> - BMFace *f;
> -
> - for(v = BMIter_New(&verts, bm, BM_VERTS, bm ); v; v =
> BMIter_Step(&verts)) bmesh_clear_sysflag(&(v->head), BM_TEMP_FLAGS);
> - for(e = BMIter_New(&edges, bm, BM_EDGES, bm ); e; e =
> BMIter_Step(&edges)) bmesh_clear_sysflag(&(e->head), BM_TEMP_FLAGS);
> - for(f = BMIter_New(&faces, bm, BM_FACES, bm ); f; f =
> BMIter_Step(&faces)){
> - bmesh_clear_sysflag(&(f->head), BM_TEMP_FLAGS);
> - for(l = BMIter_New(&loops, bm, BM_LOOPS_OF_FACE, f ); l; l
> = BMIter_Step(&loops)) bmesh_clear_sysflag(&(l->head), BM_TEMP_FLAGS);
> - }
> -}
> -
> /*
> * BMESH MAKE MESH
> *
> @@ -293,6 +266,5 @@
>
> /*compute normals, clear temp flags and flush selections*/
> BM_Compute_Normals(bm);
> - clear_temp_flags(bm);
> bmesh_selectmode_flush(bm);
> }
>
> Modified: branches/bmesh/bmesh/intern/bmesh_queries.c
> ===================================================================
> --- branches/bmesh/bmesh/intern/bmesh_queries.c 2009-01-03 20:20:09 UTC
> (rev 18297)
> +++ branches/bmesh/bmesh/intern/bmesh_queries.c 2009-01-03 20:26:29 UTC
> (rev 18298)
> @@ -76,21 +76,20 @@
> * that appear in a given face
> *
> */
> -
> -int BM_Verts_In_Face(BMFace *f, BMVert **varr, int len)
> +int BM_Verts_In_Face(BMesh *bm, BMFace *f, BMVert **varr, int len)
> {
> BMLoop *curloop = NULL;
> int i, count = 0;
>
> - for(i=0; i < len; i++) bmesh_set_sysflag(&(varr[i]->head),
> BM_OVERLAP);
> + for(i=0; i < len; i++) BMO_SetFlag(bm, varr[i], BM_OVERLAP);
>
> curloop = f->loopbase;
> do{
> - if(bmesh_test_sysflag(&(curloop->v->head), BM_OVERLAP))
> count++;
> + if(BMO_TestFlag(bm, curloop->v, BM_OVERLAP)) count++;
> curloop = ((BMLoop*)(curloop->head.next));
> } while(curloop = ((BMLoop*)(curloop->head.next)));
>
> - for(i=0; i < len; i++) bmesh_clear_sysflag(&(varr[i]->head),
> BM_OVERLAP);
> + for(i=0; i < len; i++) BMO_ClearFlag(bm, varr[i], BM_OVERLAP);
>
> return count;
> }
> @@ -490,7 +489,7 @@
> for(i=0; i < len; i++){
> f = BMIter_New(&vertfaces, bm, BM_FACES_OF_VERT, varr[i] );
> while(f){
> - amount = BM_Verts_In_Face(f, varr, len);
> + amount = BM_Verts_In_Face(bm, f, varr, len);
> if(amount >= len){
> if((len == f->len) && existface)
> *existface = f;
>
>
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.blender.org/pipermail/bf-committers/attachments/20090103/f32304f6/attachment-0001.htm
More information about the Bf-committers
mailing list