[Bf-blender-cvs] [5c74ac2] master: Build Modifier - Add "Reversed" Option
Joshua Leung
noreply at git.blender.org
Fri Jan 17 02:55:10 CET 2014
Commit: 5c74ac2c2a41e70b487321fc6e1afb2625704b1c
Author: Joshua Leung
Date: Fri Jan 17 00:13:36 2014 +1300
https://developer.blender.org/rB5c74ac2c2a41e70b487321fc6e1afb2625704b1c
Build Modifier - Add "Reversed" Option
This commit introduces the ability to make the Build Modifier operate in reverse,
essentially allowing it to be used as a "deconstruction" effect.
(See D219 for more details about use cases for this)
===================================================================
M release/scripts/startup/bl_ui/properties_data_modifier.py
M source/blender/blenloader/intern/versioning_260.c
M source/blender/makesdna/DNA_modifier_types.h
M source/blender/makesrna/intern/rna_modifier.c
M source/blender/modifiers/intern/MOD_build.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index f968479..bca613b 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -160,6 +160,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
col = split.column()
col.prop(md, "frame_start")
col.prop(md, "frame_duration")
+ col.prop(md, "use_reverse")
col = split.column()
col.prop(md, "use_random_order")
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index 768e0ba..218313e 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 6756a18..06e75ca 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 73db7ad..89fb241 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 d74044f..58fcbf7 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);
}
More information about the Bf-blender-cvs
mailing list