diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-04-07 21:28:09 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-04-07 21:28:09 +0400 |
commit | e94abda66dae7d01260839a7c5c5ff271f3ae33d (patch) | |
tree | beba13ff569e188bc6c2a9c21762c9765abd6d09 /source | |
parent | 8ea8b6a1baecdbc3271a65cc9089b43aaeae743e (diff) |
New options in the Parameter Editor mode for controling the position of stroke thickness.
The new options enable a better control on the position of stroke thickness with
respect to stroke backbone geometry. Three predefined positions are:
* center: thickness is evenly split to the left and right side of the stroke geometry.
* inside: strokes are drawn within object boundary.
* outside: strokes are drawn outside the object boundary.
Another option called "relative" allows users to specify the relative position by a
number between 0 (inside) and 1 (outside).
The thickness position options are applied only to strokes of the edge types SILHOUETTE
and BORDER, since these are the only edge types defined in terms of object boundary.
Strokes of other edge types are always using the "center" option.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/linestyle.c | 4 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 4 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_linestyle_types.h | 8 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_linestyle.c | 18 |
4 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c index dcacfeea5bc..b2c2cb27e31 100644 --- a/source/blender/blenkernel/intern/linestyle.c +++ b/source/blender/blenkernel/intern/linestyle.c @@ -75,6 +75,8 @@ static void default_linestyle_settings(FreestyleLineStyle *linestyle) linestyle->r = linestyle->g = linestyle->b = 0.0; linestyle->alpha = 1.0; linestyle->thickness = 1.0; + linestyle->thickness_position = LS_THICKNESS_CENTER; + linestyle->thickness_ratio = 0.5f; linestyle->chaining = LS_CHAINING_PLAIN; linestyle->rounds = 3; linestyle->min_angle = 0.0f; @@ -135,6 +137,8 @@ FreestyleLineStyle *FRS_copy_linestyle(FreestyleLineStyle *linestyle) new_linestyle->b = linestyle->b; new_linestyle->alpha = linestyle->alpha; new_linestyle->thickness = linestyle->thickness; + new_linestyle->thickness_position = linestyle->thickness_position; + new_linestyle->thickness_ratio = linestyle->thickness_ratio; new_linestyle->flag = linestyle->flag; new_linestyle->caps = linestyle->caps; new_linestyle->chaining = linestyle->chaining; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index ccff9ce02ff..dbb09022ddb 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -13566,6 +13566,10 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } for(linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) { + if (linestyle->thickness_position == 0) { + linestyle->thickness_position= LS_THICKNESS_CENTER; + linestyle->thickness_ratio= 0.5f; + } if (linestyle->chaining == 0) linestyle->chaining= LS_CHAINING_PLAIN; if (linestyle->rounds == 0) diff --git a/source/blender/makesdna/DNA_linestyle_types.h b/source/blender/makesdna/DNA_linestyle_types.h index 1c82443e357..9ffb53e83b6 100644 --- a/source/blender/makesdna/DNA_linestyle_types.h +++ b/source/blender/makesdna/DNA_linestyle_types.h @@ -400,12 +400,20 @@ typedef struct LineStyleThicknessModifier_Calligraphy { #define LS_CAPS_ROUND 2 #define LS_CAPS_SQUARE 3 +/* FreestyleLineStyle::thickness_position */ +#define LS_THICKNESS_CENTER 1 +#define LS_THICKNESS_INSIDE 2 +#define LS_THICKNESS_OUTSIDE 3 +#define LS_THICKNESS_RELATIVE 4 /* thickness_ratio is used */ + typedef struct FreestyleLineStyle { ID id; struct AnimData *adt; float r, g, b, alpha; float thickness; + int thickness_position; + float thickness_ratio; int flag, caps; int chaining; unsigned int rounds; diff --git a/source/blender/makesrna/intern/rna_linestyle.c b/source/blender/makesrna/intern/rna_linestyle.c index dc1942b23b4..abb715f2471 100644 --- a/source/blender/makesrna/intern/rna_linestyle.c +++ b/source/blender/makesrna/intern/rna_linestyle.c @@ -875,6 +875,12 @@ static void rna_def_linestyle(BlenderRNA *brna) {LS_CAPS_ROUND, "ROUND", 0, "Round", "Round cap (half-circle)"}, {LS_CAPS_SQUARE, "SQUARE", 0, "Square", "Square cap (flat and extended)"}, {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem thickness_position_items[] = { + {LS_THICKNESS_CENTER, "CENTER", 0, "Center", "Stroke is centered along stroke geometry"}, + {LS_THICKNESS_INSIDE, "INSIDE", 0, "Inside", "Stroke is drawn inside stroke geometry"}, + {LS_THICKNESS_OUTSIDE, "OUTSIDE", 0, "Outside", "Stroke is drawn outside stroke geometry"}, + {LS_THICKNESS_RELATIVE, "RELATIVE", 0, "Relative", "Stroke thinkness is split by a user-defined ratio"}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "FreestyleLineStyle", "ID"); RNA_def_struct_ui_text(srna, "Freestyle Line Style", "Freestyle line style, reusable by multiple line sets"); @@ -904,6 +910,18 @@ static void rna_def_linestyle(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Thickness", "Base line thickness, possibly modified by line thickness modifiers"); RNA_def_property_update(prop, NC_LINESTYLE, NULL); + prop= RNA_def_property(srna, "thickness_position", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "thickness_position"); + RNA_def_property_enum_items(prop, thickness_position_items); + RNA_def_property_ui_text(prop, "Thickness Position", "Select the position of stroke thickness"); + RNA_def_property_update(prop, NC_LINESTYLE, NULL); + + prop= RNA_def_property(srna, "thickness_ratio", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "thickness_ratio"); + RNA_def_property_range(prop, 0.f, 1.f); + RNA_def_property_ui_text(prop, "Thickness Ratio", "A number between 0 (inside) and 1 (outside) specifying the relative position of stroke thickness"); + RNA_def_property_update(prop, NC_LINESTYLE, NULL); + prop= RNA_def_property(srna, "color_modifiers", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "color_modifiers", NULL); RNA_def_property_struct_type(prop, "LineStyleColorModifier"); |