diff options
author | Howard Trickey <howard.trickey@gmail.com> | 2014-01-14 20:00:44 +0400 |
---|---|---|
committer | Howard Trickey <howard.trickey@gmail.com> | 2014-01-14 20:07:45 +0400 |
commit | 86616c675aeaccec060f9ac7a98fbff67816516b (patch) | |
tree | 8624307b426ead258531394d75658f50963a5da4 /source | |
parent | dfac6c4189b0497f19c988d536464703fda09c39 (diff) |
Bevel Modifier: add width type and profile control.
This adds to the modifier the new controls that have been
added to the bevel tool.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenloader/intern/versioning_260.c | 15 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_modifier_types.h | 13 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 22 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_bevel.c | 8 |
4 files changed, 52 insertions, 6 deletions
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c index d8e3e02b196..06355d3a812 100644 --- a/source/blender/blenloader/intern/versioning_260.c +++ b/source/blender/blenloader/intern/versioning_260.c @@ -2655,4 +2655,19 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main) } } } + + if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "float", "profile")) { + 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_Bevel) { + BevelModifierData *bmd = (BevelModifierData *)md; + bmd->profile = 0.5f; + bmd->val_flags = MOD_BEVEL_AMT_OFFSET; + } + } + } + } } diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index b8849f333e7..6756a18e382 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -295,17 +295,18 @@ typedef struct BevelModifierData { float value; /* the "raw" bevel value (distance/amount to bevel) */ int res; /* the resolution (as originally coded, it is the number of recursive bevels) */ - int pad; short flags; /* general option flags */ - short val_flags; /* flags used to interpret the bevel value */ + short val_flags; /* used to interpret the bevel value */ short lim_flags; /* flags to tell the tool how to limit the bevel */ short e_flags; /* flags to direct how edge weights are applied to verts */ + float profile; /* controls profile shape (0->1, .5 is round) */ /* if the MOD_BEVEL_ANGLE is set, this will be how "sharp" an edge must be before it gets beveled */ float bevel_angle; /* if the MOD_BEVEL_VWEIGHT option is set, this will be the name of the vert group, MAX_VGROUP_NAME */ char defgrp_name[64]; } BevelModifierData; +/* BevelModifierData->flags and BevelModifierData->lim_flags */ enum { MOD_BEVEL_VERT = (1 << 1), /* MOD_BEVEL_RADIUS = (1 << 2), */ @@ -324,6 +325,14 @@ enum { MOD_BEVEL_OVERLAP_OK = (1 << 13), }; +/* BevelModifierData->val_flags (not used as flags any more) */ +enum { + MOD_BEVEL_AMT_OFFSET = 0, + MOD_BEVEL_AMT_WIDTH = 1, + MOD_BEVEL_AMT_DEPTH = 2, + MOD_BEVEL_AMT_PERCENT = 3, +}; + typedef struct SmokeModifierData { ModifierData modifier; diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index eb01f47098f..4de9615d24c 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -2322,6 +2322,14 @@ static void rna_def_modifier_bevel(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; + static EnumPropertyItem prop_val_type_items[] = { + {MOD_BEVEL_AMT_OFFSET, "OFFSET", 0, "Offset", "Amount is offset of new edges from original"}, + {MOD_BEVEL_AMT_WIDTH, "WIDTH", 0, "Width", "Amount is width of new face"}, + {MOD_BEVEL_AMT_DEPTH, "DEPTH", 0, "Depth", "Amount is perpendicular distance from original edge to bevel face"}, + {MOD_BEVEL_AMT_PERCENT, "PERCENT", 0, "Percent", "Amount is percent of adjacent edge length"}, + {0, NULL, 0, NULL, NULL} + }; + /* TO BE DEPRECATED */ static EnumPropertyItem prop_edge_weight_method_items[] = { {0, "AVERAGE", 0, "Average", ""}, @@ -2338,7 +2346,7 @@ static void rna_def_modifier_bevel(BlenderRNA *brna) prop = RNA_def_property(srna, "width", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "value"); RNA_def_property_range(prop, 0, FLT_MAX); - RNA_def_property_ui_range(prop, 0, 10, 0.1, 4); + RNA_def_property_ui_range(prop, 0.0f, 100.0f, 0.1, 4); RNA_def_property_ui_text(prop, "Width", "Bevel value/amount"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -2383,6 +2391,18 @@ static void rna_def_modifier_bevel(BlenderRNA *brna) RNA_def_property_boolean_negative_sdna(prop, NULL, "flags", MOD_BEVEL_OVERLAP_OK); RNA_def_property_ui_text(prop, "Clamp Overlap", "Clamp the width to avoid overlap"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "offset_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "val_flags"); + RNA_def_property_enum_items(prop, prop_val_type_items); + RNA_def_property_ui_text(prop, "Amount Type", "What distance Width measures"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "profile", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_range(prop, 0.15f, 1.0f, 0.05, 2); + RNA_def_property_ui_text(prop, "Profile", "Controls profile shape (0.5 = round)"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); } static void rna_def_modifier_shrinkwrap(BlenderRNA *brna) diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index 87b3c230b75..0a0f97fdcbe 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -58,9 +58,10 @@ static void initData(ModifierData *md) bmd->value = 0.1f; bmd->res = 1; bmd->flags = 0; - bmd->val_flags = 0; + bmd->val_flags = MOD_BEVEL_AMT_OFFSET; bmd->lim_flags = 0; bmd->e_flags = 0; + bmd->profile = 0.5f; bmd->bevel_angle = DEG2RADF(30.0f); bmd->defgrp_name[0] = '\0'; } @@ -76,6 +77,7 @@ static void copyData(ModifierData *md, ModifierData *target) tbmd->val_flags = bmd->val_flags; tbmd->lim_flags = bmd->lim_flags; tbmd->e_flags = bmd->e_flags; + tbmd->profile = bmd->profile; tbmd->bevel_angle = bmd->bevel_angle; BLI_strncpy(tbmd->defgrp_name, bmd->defgrp_name, sizeof(tbmd->defgrp_name)); } @@ -110,6 +112,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *ob, const float threshold = cosf(bmd->bevel_angle + 0.000000175f); const bool vertex_only = (bmd->flags & MOD_BEVEL_VERT) != 0; const bool do_clamp = !(bmd->flags & MOD_BEVEL_OVERLAP_OK); + const int offset_type = bmd->val_flags; bm = DM_to_bmesh(dm, true); @@ -158,8 +161,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *ob, } } - /* TODO: add offset_kind to modifier properties to, and pass in as 3rd arg here */ - BM_mesh_bevel(bm, bmd->value, 0, bmd->res, 0.5f, + BM_mesh_bevel(bm, bmd->value, offset_type, bmd->res, bmd->profile, vertex_only, bmd->lim_flags & MOD_BEVEL_WEIGHT, do_clamp, dvert, vgroup); |