Revision: 15082
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15082
Author:   briggs
Date:     2008-06-01 20:02:29 +0200 (Sun, 01 Jun 2008)

Log Message:
-----------
-> Beginning of Custom Data support for BMesh

Now that new allocator is in place, Custom Data
can be effeciently added to BMesh. The plan is to
make all data not directly related to topology
Custom Data and allow callers to decide precisely
what information a mesh should have in order to
make the best tradeoff between memory usage/speed.

Right now not much to look at, just some structure
definitions and commented out code. More to come
soon...

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_bmesh.h
    trunk/blender/source/blender/blenkernel/intern/BME_mesh.c
    trunk/blender/source/blender/blenkernel/intern/bmesh_private.h

Modified: trunk/blender/source/blender/blenkernel/BKE_bmesh.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_bmesh.h 2008-06-01 17:15:03 UTC 
(rev 15081)
+++ trunk/blender/source/blender/blenkernel/BKE_bmesh.h 2008-06-01 18:02:29 UTC 
(rev 15082)
@@ -41,18 +41,79 @@
 #include "BLI_ghash.h"
 #include "BLI_memarena.h"
 #include "DNA_customdata_types.h"
+#include "DNA_image_types.h"
 #include "BLI_editVert.h"
 #include "BKE_DerivedMesh.h"
 #include "transform.h"
 
+/*forward declerations*/
 struct BME_Vert;
 struct BME_Edge;
 struct BME_Poly;
 struct BME_Loop;
 
+
 struct BME_mempool;
 typedef struct BME_mempool BME_mempool;
 
+/*Custom Data Types and defines
+       Eventual plan is to move almost everything to custom data and let caller
+       decide when making the mesh what layers they want to store in the mesh
+
+       This stuff should probably go in a seperate file....
+*/
+typedef struct BME_CustomDataLayer {
+       int type;                                       /* type of data in 
layer */
+       int offset;                                     /* offset of layer in 
block */
+       int active;                                     /* offset of active 
layer*/
+       char name[32];                                  /* layer name */
+} BME_CustomDataLayer;
+
+typedef struct BME_CustomData {
+       BME_CustomDataLayer *layers;    /*Custom Data Layers*/
+       BME_mempool *pool;                              /*pool for alloc of 
blocks*/
+       int totlayer, totsize;          /*total layers and total size in bytes 
of each block*/
+} BME_CustomData;
+
+#define BME_CD_FACETEX         1               /*Image texture/texface*/
+#define BME_CD_LOOPTEX         2               /*UV coordinates*/
+#define BME_CD_LOOPCOL         3               /*Vcolors*/
+#define BME_CD_DEFORMVERT      4               /*Vertex Group/Weights*/
+#define BME_CD_NUMTYPES                5
+
+typedef struct BME_DeformWeight {
+       int                             def_nr;
+       float                   weight;
+} BME_DeformWeight;
+
+typedef struct BME_DeformVert {
+       struct BME_DeformWeight *dw;
+       int totweight;
+} BME_DeformVert;
+
+typedef struct BME_facetex{
+       struct Image *tpage;
+       char flag, transp;
+       short mode, tile, unwrap;
+}BME_facetex;
+
+typedef struct BME_looptex{
+       float u, v;
+}BME_looptex;
+
+typedef struct BME_loopcol{
+       char r, g, b, a;
+}BME_loopcol;
+
+/*Notes on further structure Cleanup:
+       -Remove the tflags, they belong in custom data layers
+       -Remove the eflags completely, they are mostly not used
+       -Remove the selection/vis/bevel weight flag/values ect and move them to 
custom data
+       -Remove EID member and move to custom data
+       -Add a radial cycle length, disk cycle length and loop cycle lenght 
attributes to custom data and have eulers maintain/use them if present.
+       -Move data such as vertex coordinates/normals to custom data and leave 
pointers in structures to active layer data.
+       -Remove BME_CycleNode structure?
+*/
 typedef struct BME_CycleNode{
        struct BME_CycleNode *next, *prev;
        void *data;
@@ -72,9 +133,9 @@
        struct BME_Loop **lpar;
        struct BME_Poly **plar;
        int vtarlen, edarlen, lparlen, plarlen;
-       int totvert, totedge, totpoly, totloop;                 /*record 
keeping*/
-       int nextv, nexte, nextp, nextl;                                 /*Next 
element ID for verts/edges/faces/loops. Never reused*/
-       //struct CustomData vdata, edata, pdata, ldata; /*Custom Data Layer 
information*/
+       int totvert, totedge, totpoly, totloop;                         
/*record keeping*/
+       int nextv, nexte, nextp, nextl;                                         
/*Next element ID for verts/edges/faces/loops. Never reused*/
+       struct BME_CustomData vdata, edata, pdata, ldata;       /*Custom Data 
Layer information*/
 } BME_Mesh;
 
 typedef struct BME_Vert

Modified: trunk/blender/source/blender/blenkernel/intern/BME_mesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/BME_mesh.c   2008-06-01 
17:15:03 UTC (rev 15081)
+++ trunk/blender/source/blender/blenkernel/intern/BME_mesh.c   2008-06-01 
18:02:29 UTC (rev 15082)
@@ -62,8 +62,7 @@
  *  Allocates a new BME_Mesh structure
 */
 
-
-
+//BME_Mesh *BME_make_mesh(int valloc, int ealloc, int lalloc, int palloc, int 
vdata[BME_CD_NUMTYPES], int edata[BME_CD_NUMTYPES], int ldata[BME_CD_NUMTYPES], 
int pdata[BME_CD_NUMTYPES])
 BME_Mesh *BME_make_mesh(int valloc, int ealloc, int lalloc, int palloc){
        /*allocate the structure*/
        BME_Mesh *bm = MEM_callocN(sizeof(BME_Mesh),"BMesh");
@@ -72,11 +71,17 @@
        bm->epool = BME_mempool_create(sizeof(BME_Edge), ealloc, ealloc);
        bm->ppool = BME_mempool_create(sizeof(BME_Poly), palloc, palloc);
        bm->lpool = BME_mempool_create(sizeof(BME_Loop), lalloc, lalloc);
-       /*allocate the customdata pools*/
+
+       /*Setup Custom data structs and layers*/
+       /*      
+               BME_CD_Create(bm, &bm->vdata, vdata);
+               BME_CD_Create(bm, &bm->edata, edata);
+               BME_CD_Create(bm, &bm->ldata, ldata);
+               BME_CD_Create(bm, &bm->pdata, pdata);
+
+       */
        return bm;
 }
-
-
 /*     
  *     BME FREE MESH
  *
@@ -90,8 +95,12 @@
        BME_mempool_destroy(bm->epool);
        BME_mempool_destroy(bm->ppool);
        BME_mempool_destroy(bm->lpool);
-       /*destroy custom data pools*/
-
+       /*
+               BME_CD_Free(bm, &bm->vdata);
+               BME_CD_Free(bm, &bm->edata);
+               BME_CD_Free(bm, &bm->ldata);
+               BME_CD_Free(bm, &bm->pdata);
+       */
        MEM_freeN(bm);  
 }
 
@@ -156,6 +165,13 @@
        }
 }
 
+/*note, this needs to be turned on for debugging only.
+       We need two levels of debugging,
+       1: Mesh level
+       2: Euler level
+       Both need to be turned off in production builds (they really slow 
things down)
+*/
+
 /*     
  *     BME VALIDATE MESH
  *

Modified: trunk/blender/source/blender/blenkernel/intern/bmesh_private.h
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/bmesh_private.h      
2008-06-01 17:15:03 UTC (rev 15081)
+++ trunk/blender/source/blender/blenkernel/intern/bmesh_private.h      
2008-06-01 18:02:29 UTC (rev 15082)
@@ -39,10 +39,6 @@
 
 #include "BKE_bmesh.h"
 
-/*MEMORY MANAGMENT*/
-struct BME_mempool;
-typedef struct BME_mempool BME_mempool;
-
 struct BME_mempool *BME_mempool_create(int esize, int tote, int pchunk);
 void BME_mempool_destroy(struct BME_mempool *pool);
 void *BME_mempool_alloc(struct BME_mempool *pool);


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

Reply via email to