Merging trunk up to r39447.
[blender.git] / source / blender / modifiers / intern / MOD_cloth.c
index 4d850e1bd95351e3c2e1da10b0ba57206b361d6d..f5493162322784264874579eedb07be35384b0be 100644 (file)
 *
 */
 
+/** \file blender/modifiers/intern/MOD_cloth.c
+ *  \ingroup modifiers
+ */
+
+
 #include "DNA_cloth_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_object_types.h"
 
+#include "MEM_guardedalloc.h"
+
+#include "BLI_utildefines.h"
+
+
 #include "BKE_cloth.h"
 #include "BKE_cdderivedmesh.h"
 #include "BKE_global.h"
@@ -42,6 +52,7 @@
 
 #include "depsgraph_private.h"
 
+#include "MOD_util.h"
 
 static void initData(ModifierData *md) 
 {
@@ -59,7 +70,9 @@ static void initData(ModifierData *md)
 }
 
 static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
-               DerivedMesh *derivedData, int useRenderParams, int isFinalCalc)
+                                               DerivedMesh *dm,
+                                               int UNUSED(useRenderParams),
+                                               int UNUSED(isFinalCalc))
 {
        ClothModifierData *clmd = (ClothModifierData*) md;
        DerivedMesh *result=NULL;
@@ -70,17 +83,17 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
                initData(md);
                
                if(!clmd->sim_parms || !clmd->coll_parms)
-                       return derivedData;
+                       return dm;
        }
 
-       result = clothModifier_do(clmd, md->scene, ob, derivedData, useRenderParams, isFinalCalc);
+       result = clothModifier_do(clmd, md->scene, ob, dm);
 
        if(result)
        {
                CDDM_calc_normals(result);
                return result;
        }
-       return derivedData;
+       return dm;
 }
 
 static void updateDepgraph(
@@ -109,16 +122,16 @@ static void updateDepgraph(
        }
 }
 
-static CustomDataMask requiredDataMask(Object *ob, ModifierData *md)
+static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
 {
        CustomDataMask dataMask = 0;
        ClothModifierData *clmd = (ClothModifierData*)md;
 
        if(cloth_uses_vgroup(clmd))
-               dataMask |= (1 << CD_MDEFORMVERT);
+               dataMask |= CD_MASK_MDEFORMVERT;
 
        if(clmd->sim_parms->shapekey_rest != 0)
-               dataMask |= (1 << CD_CLOTH_ORCO);
+               dataMask |= CD_MASK_CLOTH_ORCO;
 
        return dataMask;
 }
@@ -148,7 +161,7 @@ static void copyData(ModifierData *md, ModifierData *target)
        tclmd->clothObject = NULL;
 }
 
-static int dependsOnTime(ModifierData *md)
+static int dependsOnTime(ModifierData *UNUSED(md))
 {
        return 1;
 }
@@ -177,6 +190,19 @@ static void freeData(ModifierData *md)
        }
 }
 
+static void foreachIDLink(ModifierData *md, Object *ob,
+                                          IDWalkFunc walk, void *userData)
+{
+       ClothModifierData *clmd = (ClothModifierData*) md;
+
+       if(clmd->coll_parms) {
+               walk(userData, ob, (ID **)&clmd->coll_parms->group);
+       }
+
+       if(clmd->sim_parms && clmd->sim_parms->effector_weights) {
+               walk(userData, ob, (ID **)&clmd->sim_parms->effector_weights->group);
+       }
+}
 
 ModifierTypeInfo modifierType_Cloth = {
        /* name */              "Cloth",
@@ -188,17 +214,20 @@ ModifierTypeInfo modifierType_Cloth = {
                                                        | eModifierTypeFlag_Single,
 
        /* copyData */          copyData,
-       /* deformVerts */       0,
-       /* deformVertsEM */     0,
-       /* deformMatricesEM */  0,
+       /* deformVerts */       NULL,
+       /* deformMatrices */    NULL,
+       /* deformVertsEM */     NULL,
+       /* deformMatricesEM */  NULL,
        /* applyModifier */     applyModifier,
-       /* applyModifierEM */   0,
+       /* applyModifierEM */   NULL,
        /* initData */          initData,
        /* requiredDataMask */  requiredDataMask,
        /* freeData */          freeData,
-       /* isDisabled */        0,
+       /* isDisabled */        NULL,
        /* updateDepgraph */    updateDepgraph,
        /* dependsOnTime */     dependsOnTime,
-       /* foreachObjectLink */ 0,
-       /* foreachIDLink */     0,
+       /* dependsOnNormals */  NULL,
+       /* foreachObjectLink */ NULL,
+       /* foreachIDLink */     foreachIDLink,
+       /* foreachTexLink */    NULL,
 };