Revision: 18212
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18212
Author:   joeedh
Date:     2009-01-01 11:49:53 +0100 (Thu, 01 Jan 2009)

Log Message:
-----------
added option for operators to not allocate flag layers

Modified Paths:
--------------
    branches/bmesh/bmesh/bmesh.h
    branches/bmesh/bmesh/bmesh_operators.h
    branches/bmesh/bmesh/intern/bmesh_operators.c

Modified: branches/bmesh/bmesh/bmesh.h
===================================================================
--- branches/bmesh/bmesh/bmesh.h        2009-01-01 08:08:55 UTC (rev 18211)
+++ branches/bmesh/bmesh/bmesh.h        2009-01-01 10:49:53 UTC (rev 18212)
@@ -116,6 +116,7 @@
        short mask, pflag;
 }BMFlagLayer;
 
+struct BMOperator;
 typedef struct BMesh
 {
        ListBase verts, edges, polys;
@@ -123,6 +124,7 @@
        struct BLI_mempool *epool;
        struct BLI_mempool *lpool;
        struct BLI_mempool *ppool;
+       struct BMOperator *currentop;
        struct BMVert **vtar;
        struct BMEdge **edar;
        struct BMLoop **lpar;
@@ -178,7 +180,7 @@
        unsigned short mat_nr;                                                  
                /*custom data again, and get rid of the unsigned short 
nonsense...*/
 }BMFace;
 
-/*stub*/
+/*stub */
 void bmesh_error(void);
 
 /*Mesh Level Ops */

Modified: branches/bmesh/bmesh/bmesh_operators.h
===================================================================
--- branches/bmesh/bmesh/bmesh_operators.h      2009-01-01 08:08:55 UTC (rev 
18211)
+++ branches/bmesh/bmesh/bmesh_operators.h      2009-01-01 10:49:53 UTC (rev 
18212)
@@ -37,12 +37,20 @@
 
 typedef struct BMOperator{
        int type;
-       int slottype;                                                   
+       int slottype;
+       int needflag;
        struct BMOpSlot slots[BMOP_MAX_SLOTS];
        void (*exec)(struct BMesh *bm, struct BMOperator *op);
        MemArena *arena;
 }BMOperator;
 
+/*need to refactor code to use this*/
+typedef struct BMOpDefine {
+       int slottypes[BMOP_MAX_SLOTS];
+       int totslots;
+       int flag;
+} BMOpDefine;
+
 /*API for operators*/
 void BMO_Init_Op(struct BMOperator *op, int opcode);
 void BMO_Exec_Op(struct BMesh *bm, struct BMOperator *op);
@@ -60,7 +68,10 @@
 void BMO_Flag_To_Slot(struct BMesh *bm, struct BMOperator *op, int slotcode, 
int flag, int type);
 void BMO_Flag_Buffer(struct BMesh *bm, struct BMOperator *op, int slotcode, 
int flag);
 
-/*defines for individual operators*/
+/*operator option flags*/
+#define NEEDFLAGS      1
+
+/*--------------------begin operator defines------------------------*/
 /*split op*/
 #define BMOP_SPLIT                             0
 #define BMOP_SPLIT_VINPUT              1
@@ -81,7 +92,8 @@
        BMOP_OPSLOT_PNT_BUF,
 };
 
-/*--------------------begin operator defines------------------------*/
+#define SPLIT_OPTIONS  NEEDFLAGS
+
 /*dupe op*/
 #define BMOP_DUPE                              1
 
@@ -107,6 +119,7 @@
        BMOP_OPSLOT_PNT_BUF,
        BMOP_OPSLOT_PNT_BUF,
 };
+#define DUPE_OPTIONS           NEEDFLAGS
 
 /*delete op*/
 #define BMOP_DEL                       2
@@ -130,6 +143,8 @@
        BMOP_OPSLOT_INT
 };
 
+#define DEL_OPTIONS            NEEDFLAGS
+
 /*editmesh->bmesh op*/
 #define BMOP_FROM_EDITMESH             3
 #define BMOP_FROM_EDITMESH_EM  0
@@ -139,6 +154,8 @@
        BMOP_OPSLOT_PNT
 };
 
+#define FROMEDIT_OPTIONS               NEEDFLAGS
+
 /*bmesh->editmesh op*/
 #define BMOP_TO_EDITMESH               4
 #define BMOP_TO_EDITMESH_EM            0
@@ -148,6 +165,8 @@
        BMOP_OPSLOT_PNT
 };
 
+#define TOEDIT_OPTIONS                 NEEDFLAGS
+
 #define BMOP_ESUBDIVIDE                        5
 #define BMOP_ESUBDIVIDE_EDGES  0
 #define BMOP_ESUBDIVIDE_TOTSLOT        1
@@ -156,25 +175,38 @@
        BMOP_OPSLOT_PNT_BUF
 };
 
+#define SUBD_OPTIONS           NEEDFLAGS
+
 /*keep this updated!*/
 #define BMOP_TOTAL_OPS                         6
 /*-------------------------------end operator 
defines-------------------------------*/
 
 /*Following arrays are used by the init functions to init operator slot 
typecodes*/
-const int *BMOP_TYPEINFO[BMOP_TOTAL_OPS] = {
+static const int *BMOP_TYPEINFO[] = {
        BMOP_SPLIT_TYPEINFO,
+       BMOP_DUPE_TYPEINFO,
        BMOP_DEL_TYPEINFO,
        BMOP_FROM_EDITMESH_TYPEINFO,
        BMOP_TO_EDITMESH_TYPEINFO,
        BMOP_ESUBDIVIDE_TYPEINFO
 };
 
-const int BMOP_TYPETOTALS[BMOP_TOTAL_OPS] = {
+static const int BMOP_TYPETOTALS[] = {
        BMOP_SPLIT_TOTSLOT,
+       BMOP_DUPE_TOTSLOT,
        BMOP_DEL_TOTSLOT,
        BMOP_FROM_EDITMESH_TOTSLOT,
        BMOP_TO_EDITMESH_TOTSLOT,
        BMOP_ESUBDIVIDE_TOTSLOT
 };
 
+static const int BMOP_OPTIONS[] = {
+       SPLIT_OPTIONS,
+       DUPE_OPTIONS,
+       DEL_OPTIONS,
+       FROMEDIT_OPTIONS,
+       TOEDIT_OPTIONS,
+       SUBD_OPTIONS,   
+};
+
 #endif

Modified: branches/bmesh/bmesh/intern/bmesh_operators.c
===================================================================
--- branches/bmesh/bmesh/intern/bmesh_operators.c       2009-01-01 08:08:55 UTC 
(rev 18211)
+++ branches/bmesh/bmesh/intern/bmesh_operators.c       2009-01-01 10:49:53 UTC 
(rev 18212)
@@ -45,8 +45,10 @@
 void BMO_push(BMesh *bm, BMOperator *op)
 {
        bm->stackdepth++;
+       bm->currentop = op;
+
        /*add flag layer, if appropriate*/
-       if(bm->stackdepth > 1)
+       if(bm->stackdepth > 1 && op->needflag)
                alloc_flag_layer(bm);
 }
 
@@ -62,7 +64,7 @@
 void BMO_pop(BMesh *bm)
 {
        bm->stackdepth--;
-       if(bm->stackdepth > 1)
+       if(bm->stackdepth > 1 && bm->currentop->needflag)
                free_flag_layer(bm);
 }
 
@@ -81,6 +83,8 @@
        memset(op, 0, sizeof(BMOperator));
        op->type = opcode;
 
+       if (BMOP_OPTIONS[opcode] & NEEDFLAGS) op->needflag = 1;
+
        /*initialize the operator slot types*/
        for(i = 0; i < BMOP_TYPETOTALS[opcode]; i++) {
                op->slots[i].slottype = BMOP_TYPEINFO[opcode][i];


_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to