From 312b0803979768725041d197ca61dc8a7762c1cf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 28 Dec 2011 13:15:17 +0000 Subject: [PATCH] initial merge of bmesh customdata layer code into trunk, ifdef'd out for now with USE_BMESH_FORWARD_COMPAT. --- source/blender/blenkernel/intern/customdata.c | 31 ++++++++++++++++ .../blender/makesdna/DNA_customdata_types.h | 36 +++++++++++++++++++ source/blender/makesdna/DNA_defs.h | 2 ++ source/blender/makesdna/DNA_mesh_types.h | 2 ++ source/blender/makesdna/DNA_meshdata_types.h | 21 +++++++++++ 5 files changed, 92 insertions(+) diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 166f9735dc4..7873637c4c2 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -867,6 +867,30 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { {sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, /* 24: CD_RECAST */ {sizeof(MRecast), "MRecast", 1,"Recast",NULL,NULL,NULL,NULL} + +#ifdef USE_BMESH_FORWARD_COMPAT + , +/* BMESH ONLY */ + /* 25: CD_MPOLY */ + {sizeof(MPoly), "MPoly", 1, "NGon Face", NULL, NULL, NULL, NULL, NULL}, + /* 26: CD_MLOOP */ + {sizeof(MLoop), "MLoop", 1, "NGon Face-Vertex", NULL, NULL, NULL, NULL, NULL}, + /* 27: CD_SHAPE_KEYINDEX */ + {sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, + /* 28: CD_SHAPEKEY */ + {sizeof(float)*3, "", 0, "ShapeKey", NULL, NULL, layerInterp_shapekey}, + /* 29: CD_BWEIGHT */ + {sizeof(float), "", 0, "BevelWeight", NULL, NULL, layerInterp_bweight}, + /* 30: CD_CREASE */ + {sizeof(float), "", 0, "SubSurfCrease", NULL, NULL, layerInterp_bweight}, + /* 31: CD_WEIGHT_MLOOPCOL */ + {sizeof(MLoopCol), "MLoopCol", 1, "WeightLoopCol", NULL, NULL, layerInterp_mloopcol, NULL, + layerDefault_mloopcol, layerEqual_mloopcol, layerMultiply_mloopcol, layerInitMinMax_mloopcol, + layerAdd_mloopcol, layerDoMinMax_mloopcol, layerCopyValue_mloopcol}, +/* END BMESH ONLY */ + +#endif /* USE_BMESH_FORWARD_COMPAT */ + }; static const char *LAYERTYPENAMES[CD_NUMTYPES] = { @@ -875,6 +899,13 @@ static const char *LAYERTYPENAMES[CD_NUMTYPES] = { /* 10-14 */ "CDMFloatProperty", "CDMIntProperty","CDMStringProperty", "CDOrigSpace", "CDOrco", /* 15-19 */ "CDMTexPoly", "CDMLoopUV", "CDMloopCol", "CDTangent", "CDMDisps", /* 20-24 */"CDWeightMCol", "CDIDMCol", "CDTextureMCol", "CDClothOrco", "CDMRecast" + +#ifdef USE_BMESH_FORWARD_COMPAT + , + /* 25-29 */ "CDMPoly", "CDMLoop", "CDShapeKeyIndex", "CDShapeKey", "CDBevelWeight", + /* 30-31 */ "CDSubSurfCrease", "CDWeightLoopCol" + +#endif /* USE_BMESH_FORWARD_COMPAT */ }; const CustomDataMask CD_MASK_BAREMESH = diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h index a3b735f0fe1..0b0ffb42ba8 100644 --- a/source/blender/makesdna/DNA_customdata_types.h +++ b/source/blender/makesdna/DNA_customdata_types.h @@ -29,6 +29,7 @@ * \ingroup DNA */ + #ifndef DNA_CUSTOMDATA_TYPES_H #define DNA_CUSTOMDATA_TYPES_H @@ -36,6 +37,8 @@ extern "C" { #endif +#include "DNA_defs.h" /* USE_BMESH_FORWARD_COMPAT */ + /** descriptor and storage for a custom data layer */ typedef struct CustomDataLayer { int type; /* type of data in layer */ @@ -94,8 +97,27 @@ typedef struct CustomData { #define CD_TEXTURE_MCOL 22 #define CD_CLOTH_ORCO 23 #define CD_RECAST 24 + +#ifdef USE_BMESH_FORWARD_COMPAT + +/* BMESH ONLY START */ +#define CD_MPOLY 25 +#define CD_MLOOP 26 +#define CD_SHAPE_KEYINDEX 27 +#define CD_SHAPEKEY 28 +#define CD_BWEIGHT 29 +#define CD_CREASE 30 +#define CD_WEIGHT_MLOOPCOL 31 +/* BMESH ONLY END */ + +#define CD_NUMTYPES 32 + +#else + #define CD_NUMTYPES 25 +#endif + /* Bits for CustomDataMask */ #define CD_MASK_MVERT (1 << CD_MVERT) #define CD_MASK_MSTICKY (1 << CD_MSTICKY) @@ -121,6 +143,20 @@ typedef struct CustomData { #define CD_MASK_CLOTH_ORCO (1 << CD_CLOTH_ORCO) #define CD_MASK_RECAST (1 << CD_RECAST) +#ifdef USE_BMESH_FORWARD_COMPAT + +/* BMESH ONLY START */ +#define CD_MASK_MPOLY (1 << CD_MPOLY) +#define CD_MASK_MLOOP (1 << CD_MLOOP) +#define CD_MASK_SHAPE_KEYINDEX (1 << CD_SHAPE_KEYINDEX) +#define CD_MASK_SHAPEKEY (1 << CD_SHAPEKEY) +#define CD_MASK_BWEIGHT (1 << CD_BWEIGHT) +#define CD_MASK_CREASE (1 << CD_CREASE) +#define CD_MASK_WEIGHT_MLOOPCOL (1 << CD_WEIGHT_MLOOPCOL) +/* BMESH ONLY END */ + +#endif + /* CustomData.flag */ /* indicates layer should not be copied by CustomData_from_template or diff --git a/source/blender/makesdna/DNA_defs.h b/source/blender/makesdna/DNA_defs.h index 25d95419605..95247daa6af 100644 --- a/source/blender/makesdna/DNA_defs.h +++ b/source/blender/makesdna/DNA_defs.h @@ -45,4 +45,6 @@ /* hrmf, we need a better include then this */ #include "../blenloader/BLO_sys_types.h" /* needed for int64_t only! */ +// #define USE_BMESH_FORWARD_COMPAT + #endif /* DNA_DEFS_H */ diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index 4bca7e7a77f..8e8c3b8743a 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -36,6 +36,8 @@ #include "DNA_ID.h" #include "DNA_customdata_types.h" +#include "DNA_defs.h" /* USE_BMESH_FORWARD_COMPAT */ + struct DerivedMesh; struct Ipo; struct Key; diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h index 52a9a6017f7..ab4b560943f 100644 --- a/source/blender/makesdna/DNA_meshdata_types.h +++ b/source/blender/makesdna/DNA_meshdata_types.h @@ -72,6 +72,27 @@ typedef struct MCol { char a, r, g, b; } MCol; +#ifdef USE_BMESH_FORWARD_COMPAT + +/*new face structure, replaces MFace, which is now + only used for storing tesselations.*/ +typedef struct MPoly { + /* offset into loop array and number of loops in the face */ + int loopstart; + int totloop; /* keep signed since we need to subtract when getting the previous loop */ + short mat_nr; + char flag, pad; +} MPoly; + +/*the e here is because we want to move away from + relying on edge hashes.*/ +typedef struct MLoop { + unsigned int v; /*vertex index*/ + unsigned int e; /*edge index*/ +} MLoop; + +#endif /* USE_BMESH_FORWARD_COMPAT */ + /*bmesh custom data stuff*/ typedef struct MTexPoly { struct Image *tpage;