Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2020-10-01 20:56:34 +0300
committerHans Goudey <h.goudey@me.com>2020-10-01 20:56:34 +0300
commitc3238bd50010e43ad97edb07ca1b2fe04ddf7f45 (patch)
treefa43f6fba52cde9fad9c4931c970861b675e7ae9 /source/blender/modifiers/intern/MOD_cloth.c
parent4c0ef4f788a1037888d5cb0a87ac23d6fe84573e (diff)
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.
Diffstat (limited to 'source/blender/modifiers/intern/MOD_cloth.c')
-rw-r--r--source/blender/modifiers/intern/MOD_cloth.c17
1 files changed, 14 insertions, 3 deletions
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,