sync customdata layers up with trunk. existing bmesh files will crash on load but...
authorCampbell Barton <ideasman42@gmail.com>
Wed, 28 Dec 2011 13:11:46 +0000 (13:11 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 28 Dec 2011 13:11:46 +0000 (13:11 +0000)
source/blender/blenkernel/intern/customdata.c
source/blender/makesdna/DNA_customdata_types.h

index ae3bbfc333d1f12cbfbb1aedf7e36bfc80a17345..3b7addddc41908dce06fbbae5e23a7bca2a73e5e 100644 (file)
@@ -976,47 +976,54 @@ static void layerDefault_mcol(void *data, int count)
        MCol *mcol = (MCol*)data;
        int i;
 
-       for(i = 0; i < 4*count; i++)
+       for(i = 0; i < 4*count; i++) {
                mcol[i] = default_mcol;
+       }
 }
 
 static void layerInterp_bweight(void **sources, float *weights,
-                             float *UNUSED(sub_weights), int count, void *dest)
+                                float *UNUSED(sub_weights), int count, void *dest)
 {
-       float *f = dest, *src;
+       float *f = dest;
        float **in = (float **)sources;
        int i;
        
        if(count <= 0) return;
 
        *f = 0.0f;
-       
-       for(i = 0; i < count; ++i) {
-               float weight = weights ? weights[i] : 1.0f;
-               
-               src = in[i];
-               *f += *src * weight;
+
+       if (weights) {
+               for(i = 0; i < count; ++i) {
+                       *f += *in[i] * weights[i];
+               }
+       }
+       else {
+               for(i = 0; i < count; ++i) {
+                       *f += *in[i];
+               }
        }
 }
 
 static void layerInterp_shapekey(void **sources, float *weights,
-                             float *UNUSED(sub_weights), int count, void *dest)
+                                 float *UNUSED(sub_weights), int count, void *dest)
 {
-       float *co = dest, *src;
+       float *co = dest;
        float **in = (float **)sources;
        int i;
 
        if(count <= 0) return;
 
-       memset(co, 0, sizeof(float)*3);
-       
-       for(i = 0; i < count; ++i) {
-               float weight = weights ? weights[i] : 1.0f;
-               
-               src = in[i];
-               co[0] += src[0] * weight;
-               co[1] += src[1] * weight;
-               co[2] += src[2] * weight;
+       zero_v3(co);
+
+       if (weights) {
+               for(i = 0; i < count; ++i) {
+                       madd_v3_v3fl(co, in[i], weights[i]);
+               }
+       }
+       else {
+               for(i = 0; i < count; ++i) {
+                       add_v3_v3(co, in[i]);
+               }
        }
 }
 
@@ -1080,34 +1087,55 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
        /* 20: CD_WEIGHT_MCOL */
        {sizeof(MCol)*4, "MCol", 4, "WeightCol", NULL, NULL, layerInterp_mcol,
         layerSwap_mcol, layerDefault_mcol},
-       {sizeof(MPoly), "MPoly", 1, "NGon Face", NULL, NULL, NULL, NULL, NULL},
-       {sizeof(MLoop), "MLoop", 1, "NGon Face-Vertex", NULL, NULL, NULL, NULL, NULL},
-       {sizeof(float)*3, "", 0, "ClothOrco", NULL, NULL, layerInterp_shapekey},
        /* 21: CD_ID_MCOL */
        {sizeof(MCol)*4, "MCol", 4, "IDCol", NULL, NULL, layerInterp_mcol,
         layerSwap_mcol, layerDefault_mcol},
-       {sizeof(MCol)*4, "MCol", 4, "TextureCol", NULL, NULL, layerInterp_mcol,
+       /* 22: CD_TEXTURE_MCOL */
+       {sizeof(MCol)*4, "MCol", 4, "TexturedCol", NULL, NULL, layerInterp_mcol,
         layerSwap_mcol, layerDefault_mcol},
+       /* 23: CD_CLOTH_ORCO */
+       {sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
+       /* 24: CD_RECAST */
+       {sizeof(MRecast), "MRecast", 1,"Recast",NULL,NULL,NULL,NULL}
+
+/* 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},
-       /* 24: CD_RECAST */
-       {sizeof(MRecast), "MRecast", 1,"Recast",NULL,NULL,NULL,NULL}
+/* END BMESH ONLY */
+
+
 };
 
 /* note, numbers are from trunk and need updating for bmesh */
 
 static const char *LAYERTYPENAMES[CD_NUMTYPES] = {
-       /*   0-4 */ "CDMVert", "CDMSticky", "CDMDeformVert", "CDMEdge", "CDMFace", "CDMTFace",
-       /*   5-9 */ "CDMCol", "CDOrigIndex", "CDNormal", "CDPolyIndex","CDMFloatProperty",
-       /* 10-14 */ "CDMIntProperty","CDMStringProperty", "CDOrigSpace", "CDOrco", "CDMTexPoly", "CDMLoopUV",
-       /* 15-19 */ "CDMloopCol", "CDTangent", "CDMDisps", "CDWeightMCol", "CDMPoly", 
-       /* 20-24 */ "CDMLoop", "CDMClothOrco", "CDMLoopCol", "CDIDCol", "CDTextureCol",
-       /* ?-? */ "CDShapeKeyIndex", "CDShapeKey", "CDBevelWeight", "CDSubSurfCrease", "CDMRecast"
+       /*   0-4 */ "CDMVert", "CDMSticky", "CDMDeformVert", "CDMEdge", "CDMFace",
+       /*   5-9 */ "CDMTFace", "CDMCol", "CDOrigIndex", "CDNormal", "CDFlags",
+       /* 10-14 */ "CDMFloatProperty", "CDMIntProperty","CDMStringProperty", "CDOrigSpace", "CDOrco",
+       /* 15-19 */ "CDMTexPoly", "CDMLoopUV", "CDMloopCol", "CDTangent", "CDMDisps",
+       /* 20-24 */"CDWeightMCol", "CDIDMCol", "CDTextureMCol", "CDClothOrco", "CDMRecast"
+
+/* BMESH ONLY */
+       ,
+       /* 25-29 */ "CDMPoly", "CDMLoop", "CDShapeKeyIndex", "CDShapeKey", "CDBevelWeight",
+       /* 30-31 */ "CDSubSurfCrease", "CDWeightLoopCol"
+/* END BMESH ONLY */
+
 };
 
 
index 6d7765edbda5bac1492d667e137f6c01d0f2391a..b3ed49754bae8778afce3bc1e6e0303fe04e86a5 100644 (file)
@@ -90,17 +90,21 @@ typedef struct CustomData {
 #define CD_TANGENT             18
 #define CD_MDISPS              19
 #define CD_WEIGHT_MCOL 20 /* for displaying weightpaint colors */
-#define CD_MPOLY               21
-#define CD_MLOOP               22
+#define CD_ID_MCOL             21
+#define CD_TEXTURE_MCOL        22
 #define CD_CLOTH_ORCO  23
-#define CD_ID_MCOL             24
-#define CD_TEXTURE_MCOL                25
-#define CD_SHAPE_KEYINDEX      26
-#define CD_SHAPEKEY            27
-#define CD_BWEIGHT             28
-#define CD_CREASE              29
-#define CD_WEIGHT_MLOOPCOL     30
-#define CD_RECAST              31
+#define CD_RECAST              24
+
+/* 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
 
 /* Bits for CustomDataMask */
@@ -125,18 +129,18 @@ typedef struct CustomData {
 #define CD_MASK_TANGENT                (1 << CD_TANGENT)
 #define CD_MASK_MDISPS         (1 << CD_MDISPS)
 #define CD_MASK_WEIGHT_MCOL    (1 << CD_WEIGHT_MCOL)
+#define CD_MASK_CLOTH_ORCO     (1 << CD_CLOTH_ORCO)
+#define CD_MASK_RECAST         (1 << CD_RECAST)
+
+/* BMESH ONLY START */
 #define CD_MASK_MPOLY          (1 << CD_MPOLY)
 #define CD_MASK_MLOOP          (1 << CD_MLOOP)
-#define CD_MASK_WEIGHT_MLOOPCOL (1 << CD_WEIGHT_MLOOPCOL)
 #define CD_MASK_SHAPE_KEYINDEX (1 << CD_SHAPE_KEYINDEX)
 #define CD_MASK_SHAPEKEY       (1 << CD_SHAPEKEY)
-#define CD_MASK_CLOTH_ORCO     (1 << CD_CLOTH_ORCO)
-#define CD_MASK_RECAST         (1 << CD_RECAST)
-
-/* derivedmesh wants CustomDataMask for weightpaint too, is not customdata though */
-#define CD_MASK_WEIGHTPAINT    (1 << CD_WEIGHTPAINT)
 #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 */
 
 /* CustomData.flag */