diff options
Diffstat (limited to 'source/blender/modifiers/intern/MOD_cloth.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_cloth.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c index 7d0f245ecad..8f876213cd6 100644 --- a/source/blender/modifiers/intern/MOD_cloth.c +++ b/source/blender/modifiers/intern/MOD_cloth.c @@ -30,6 +30,7 @@ #include "BLT_translation.h" #include "DNA_cloth_types.h" +#include "DNA_defaults.h" #include "DNA_key_types.h" #include "DNA_mesh_types.h" #include "DNA_object_types.h" @@ -65,8 +66,12 @@ static void initData(ModifierData *md) { ClothModifierData *clmd = (ClothModifierData *)md; - clmd->sim_parms = MEM_callocN(sizeof(ClothSimSettings), "cloth sim parms"); - clmd->coll_parms = MEM_callocN(sizeof(ClothCollSettings), "cloth coll parms"); + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(clmd, modifier)); + + MEMCPY_STRUCT_AFTER(clmd, DNA_struct_default_get(ClothModifierData), modifier); + clmd->sim_parms = DNA_struct_default_alloc(ClothSimSettings); + clmd->coll_parms = DNA_struct_default_alloc(ClothCollSettings); + clmd->point_cache = BKE_ptcache_add(&clmd->ptcaches); /* check for alloc failing */ @@ -74,7 +79,13 @@ static void initData(ModifierData *md) return; } - cloth_init(clmd); + if (!clmd->sim_parms->effector_weights) { + clmd->sim_parms->effector_weights = BKE_effector_add_weights(NULL); + } + + if (clmd->point_cache) { + clmd->point_cache->step = 1; + } } static void deformVerts(ModifierData *md, @@ -102,7 +113,7 @@ static void deformVerts(ModifierData *md, else { /* Not possible to use get_mesh() in this case as we'll modify its vertices * and get_mesh() would return 'mesh' directly. */ - BKE_id_copy_ex(NULL, (ID *)mesh, (ID **)&mesh_src, LIB_ID_COPY_LOCALIZE); + mesh_src = (Mesh *)BKE_id_copy_ex(NULL, (ID *)mesh, NULL, LIB_ID_COPY_LOCALIZE); } /* TODO(sergey): For now it actually duplicates logic from DerivedMesh.c @@ -284,9 +295,11 @@ ModifierTypeInfo modifierType_Cloth = { /* name */ "Cloth", /* structName */ "ClothModifierData", /* structSize */ sizeof(ClothModifierData), + /* srna */ &RNA_ClothModifier, /* type */ eModifierTypeType_OnlyDeform, /* flags */ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_UsesPointCache | eModifierTypeFlag_Single, + /* icon */ ICON_MOD_CLOTH, /* copyData */ copyData, @@ -306,7 +319,6 @@ ModifierTypeInfo modifierType_Cloth = { /* updateDepsgraph */ updateDepsgraph, /* dependsOnTime */ dependsOnTime, /* dependsOnNormals */ NULL, - /* foreachObjectLink */ NULL, /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ NULL, /* freeRuntimeData */ NULL, |