diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenloader/intern/versioning_260.c | 16 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_modifier_types.h | 11 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 7 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_build.c | 12 |
4 files changed, 40 insertions, 6 deletions
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c index 768e0ba5e68..218313ebb44 100644 --- a/source/blender/blenloader/intern/versioning_260.c +++ b/source/blender/blenloader/intern/versioning_260.c @@ -2655,6 +2655,22 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } } + + if (!MAIN_VERSION_ATLEAST(main, 269, 9)) { + Object *ob; + + for (ob = main->object.first; ob; ob = ob->id.next) { + ModifierData *md; + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Build) { + BuildModifierData *bmd = (BuildModifierData *)md; + if (bmd->randomize) { + bmd->flag |= MOD_BUILD_FLAG_RANDOMIZE; + } + } + } + } + } if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "float", "profile")) { Object *ob; diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 6756a18e382..06e75ca62de 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -167,9 +167,18 @@ typedef struct BuildModifierData { ModifierData modifier; float start, length; - int randomize, seed; + short flag; + + short randomize; /* (bool) whether order of vertices is randomized - legacy files (for readfile conversion) */ + int seed; /* (int) random seed */ } BuildModifierData; +/* Build Modifier -> flag */ +enum { + MOD_BUILD_FLAG_RANDOMIZE = (1 << 0), /* order of vertices is randomized */ + MOD_BUILD_FLAG_REVERSE = (1 << 1), /* frame range is reversed, resulting in a deconstruction effect */ +}; + /* Mask Modifier */ typedef struct MaskModifierData { ModifierData modifier; diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 73db7adb8cb..89fb24145a6 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -1092,8 +1092,13 @@ static void rna_def_modifier_build(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Length", "Total time the build effect requires"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop = RNA_def_property(srna, "use_reverse", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_BUILD_FLAG_REVERSE); + RNA_def_property_ui_text(prop, "Reversed", "Deconstruct the mesh instead of building it"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop = RNA_def_property(srna, "use_random_order", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "randomize", 1); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_BUILD_FLAG_RANDOMIZE); RNA_def_property_ui_text(prop, "Randomize", "Randomize the faces or edges during build"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c index d74044fa1ef..58fcbf76e8d 100644 --- a/source/blender/modifiers/intern/MOD_build.c +++ b/source/blender/modifiers/intern/MOD_build.c @@ -119,7 +119,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), frac = (BKE_scene_frame_get(md->scene) - bmd->start) / bmd->length; CLAMP(frac, 0.0f, 1.0f); - + + if (bmd->flag & MOD_BUILD_FLAG_REVERSE) { + frac = 1.0 - frac; + } + numFaces_dst = numPoly_src * frac; numEdges_dst = numEdge_src * frac; @@ -129,7 +133,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), MLoop *ml, *mloop; MEdge *medge; - if (bmd->randomize) { + if (bmd->flag & MOD_BUILD_FLAG_RANDOMIZE) { BLI_array_randomize(faceMap, sizeof(*faceMap), numPoly_src, bmd->seed); } @@ -174,7 +178,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), else if (numEdges_dst) { MEdge *medge, *me; - if (bmd->randomize) + if (bmd->flag & MOD_BUILD_FLAG_RANDOMIZE) BLI_array_randomize(edgeMap, sizeof(*edgeMap), numEdge_src, bmd->seed); @@ -207,7 +211,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), else { int numVerts = numVert_src * frac; - if (bmd->randomize) { + if (bmd->flag & MOD_BUILD_FLAG_RANDOMIZE) { BLI_array_randomize(vertMap, sizeof(*vertMap), numVert_src, bmd->seed); } |