[Bf-blender-cvs] [86616c6] master: Bevel Modifier: add width type and profile control.

Howard Trickey noreply at git.blender.org
Tue Jan 14 17:14:31 CET 2014


Commit: 86616c675aeaccec060f9ac7a98fbff67816516b
Author: Howard Trickey
Date:   Tue Jan 14 11:00:44 2014 -0500
https://developer.blender.org/rB86616c675aeaccec060f9ac7a98fbff67816516b

Bevel Modifier: add width type and profile control.

This adds to the modifier the new controls that have been
added to the bevel tool.

===================================================================

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_bevel.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 59b369d..f968479 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -126,6 +126,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         col = split.column()
         col.prop(md, "width")
         col.prop(md, "segments")
+        col.prop(md, "profile")
 
         col = split.column()
         col.prop(md, "use_only_vertices")
@@ -138,8 +139,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         elif md.limit_method == 'VGROUP':
             layout.label(text="Vertex Group:")
             layout.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
-        # elif md.limit_method == 'WEIGHT':
-        #    layout.row().prop(md, "edge_weight_method", expand=True)
+ 
+        layout.label(text="Width Method:")
+        layout.row().prop(md, "offset_type", expand=True)
 
     def BOOLEAN(self, layout, ob, md):
         split = layout.split()
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index d8e3e02..06355d3 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 b8849f3..6756a18 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 eb01f47..4de9615 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 87b3c23..0a0f97f 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);




More information about the Bf-blender-cvs mailing list