svn merge ^/trunk/blender -r48749:48754
[blender.git] / source / blender / blenkernel / intern / customdata.c
index 645267fce3470fd00b974e92efd2dc2506bdfeb2..8dd3b3da705e5d108695876ba2623fe21716d7f8 100644 (file)
@@ -337,12 +337,12 @@ static void layerSwap_tface(void *data, const int *corner_indices)
 
                copy_v2_v2(uv[j], tf->uv[source_index]);
 
-               // swap pinning flags around
+               /* swap pinning flags around */
                if (tf->unwrap & pin_flags[source_index]) {
                        unwrap |= pin_flags[j];
                }
 
-               // swap selection flags around
+               /* swap selection flags around */
                if (tf->flag & sel_flags[source_index]) {
                        flag |= sel_flags[j];
                }
@@ -997,22 +997,22 @@ static void layerDefault_mvert_skin(void *data, int count)
        MVertSkin *vs = data;
        int i;
        
-       for(i = 0; i < count; i++) {
+       for (i = 0; i < count; i++) {
                copy_v3_fl(vs[i].radius, 0.25f);
                vs[i].flag = 0;
        }
 }
+
 static void layerInterp_mvert_skin(void **sources, float *weights,
-                                                                  float *UNUSED(sub_weights),
-                                                                  int count, void *dest)
+                                   float *UNUSED(sub_weights),
+                                   int count, void *dest)
 {
        float radius[3], w;
        MVertSkin *vs;
        int i;
 
        zero_v3(radius);
-       for(i = 0; i < count; i++) {
+       for (i = 0; i < count; i++) {
                w = weights ? weights[i] : 1.0f;
                vs = sources[i];
 
@@ -1168,7 +1168,7 @@ const CustomDataMask CD_MASK_DERIVEDMESH =
     CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MTEXPOLY | CD_MASK_PREVIEW_MLOOPCOL |
     CD_MASK_PROP_STR | CD_MASK_ORIGSPACE | CD_MASK_ORIGSPACE_MLOOP | CD_MASK_ORCO | CD_MASK_TANGENT |
     CD_MASK_PREVIEW_MCOL | CD_MASK_NORMAL | CD_MASK_SHAPEKEY | CD_MASK_RECAST |
-    CD_MASK_ORIGINDEX | CD_MASK_POLYINDEX;
+    CD_MASK_ORIGINDEX | CD_MASK_POLYINDEX | CD_MASK_MVERT_SKIN;
 const CustomDataMask CD_MASK_BMESH =
     CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MTEXPOLY |
     CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_PROP_FLT | CD_MASK_PROP_INT |
@@ -1193,6 +1193,18 @@ static const char *layerType_getName(int type)
        return LAYERTYPENAMES[type];
 }
 
+void customData_mask_layers__print(CustomDataMask mask)
+{
+       int i;
+
+       printf("mask=0x%lx:\n", (long unsigned int)mask);
+       for (i = 0; i < CD_NUMTYPES; i++) {
+               if (mask & CD_TYPE_AS_MASK(i)) {
+                       printf("  %s\n", layerType_getName(i));
+               }
+       }
+}
+
 /********************* CustomData functions *********************/
 static void customData_update_offsets(CustomData *data);
 
@@ -2207,6 +2219,48 @@ void CustomData_bmesh_update_active_layers(CustomData *fdata, CustomData *pdata,
        }
 }
 
+/* update active indices for active/render/clone/stencil custom data layers
+ * based on indices from fdata layers
+ * used by do_versions in readfile.c when creating pdata and ldata for pre-bmesh
+ * meshes and needed to preserve active/render/clone/stencil flags set in pre-bmesh files
+ */
+void CustomData_bmesh_do_versions_update_active_layers(CustomData *fdata, CustomData *pdata, CustomData *ldata)
+{
+       int act;
+
+       if (CustomData_has_layer(fdata, CD_MTFACE)) {
+               act = CustomData_get_active_layer(fdata, CD_MTFACE);
+               CustomData_set_layer_active(pdata, CD_MTEXPOLY, act);
+               CustomData_set_layer_active(ldata, CD_MLOOPUV, act);
+
+               act = CustomData_get_render_layer(fdata, CD_MTFACE);
+               CustomData_set_layer_render(pdata, CD_MTEXPOLY, act);
+               CustomData_set_layer_render(ldata, CD_MLOOPUV, act);
+
+               act = CustomData_get_clone_layer(fdata, CD_MTFACE);
+               CustomData_set_layer_clone(pdata, CD_MTEXPOLY, act);
+               CustomData_set_layer_clone(ldata, CD_MLOOPUV, act);
+
+               act = CustomData_get_stencil_layer(fdata, CD_MTFACE);
+               CustomData_set_layer_stencil(pdata, CD_MTEXPOLY, act);
+               CustomData_set_layer_stencil(ldata, CD_MLOOPUV, act);
+       }
+
+       if (CustomData_has_layer(fdata, CD_MCOL)) {
+               act = CustomData_get_active_layer(fdata, CD_MCOL);
+               CustomData_set_layer_active(ldata, CD_MLOOPCOL, act);
+
+               act = CustomData_get_render_layer(fdata, CD_MCOL);
+               CustomData_set_layer_render(ldata, CD_MLOOPCOL, act);
+
+               act = CustomData_get_clone_layer(fdata, CD_MCOL);
+               CustomData_set_layer_clone(ldata, CD_MLOOPCOL, act);
+
+               act = CustomData_get_stencil_layer(fdata, CD_MCOL);
+               CustomData_set_layer_stencil(ldata, CD_MLOOPCOL, act);
+       }
+}
+
 void CustomData_bmesh_init_pool(CustomData *data, int totelem, const char htype)
 {
        int chunksize;