From c3238bd50010e43ad97edb07ca1b2fe04ddf7f45 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 1 Oct 2020 12:56:34 -0500 Subject: Cleanup: Use DNA defaults for cloth modifier Followup for rB8398050695 This requires moving a few enum definitions to DNA instead of BKE, and adding default definitions for the two structs the cloth modifier where the cloth modifier stores its settings. The defaults are also reordered to be consistent with the order of each item in the struct. --- source/blender/modifiers/intern/MOD_cloth.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'source/blender/modifiers/intern/MOD_cloth.c') diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c index defba78c66c..2968bcda9b7 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, -- cgit v1.2.3