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:
authorJoshua Leung <aligorith@gmail.com>2014-01-16 15:13:36 +0400
committerJoshua Leung <aligorith@gmail.com>2014-01-17 05:53:04 +0400
commit5c74ac2c2a41e70b487321fc6e1afb2625704b1c (patch)
treec69246c3c0f197fd9bef025d63b7c5f3bcb7bf95
parent607df8090b4eeb2d7762734a2adb83e67e83124f (diff)
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)
-rw-r--r--release/scripts/startup/bl_ui/properties_data_modifier.py1
-rw-r--r--source/blender/blenloader/intern/versioning_260.c16
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h11
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c7
-rw-r--r--source/blender/modifiers/intern/MOD_build.c12
5 files changed, 41 insertions, 6 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index f9684794b79..bca613be866 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 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);
}