diff options
author | Joshua Leung <aligorith@gmail.com> | 2016-08-26 06:59:38 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2016-08-26 07:15:47 +0300 |
commit | 56360a3ddf5cb2f10b2613dfa0e5d7bb77d4891d (patch) | |
tree | 594e95a3bfce9de802acb0e9d73c908a4903b1ea | |
parent | 50a44edca4838d6589f1072a2af4bff3dad02873 (diff) |
GPencil RNA: Set pressure and strength to 1.0 by default for new stroke points added via stroke.points.add()
This commit adds optional "pressure" and "strength" arguments to the
stroke.points.add() method. These are given default values of 1.0,
so that old scripts can be ported over to the new API with less effort
while reducing confusion about why auto generated strokes won't appear.
-rw-r--r-- | source/blender/makesrna/intern/rna_gpencil.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 3ecaec75c77..167e1e93976 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -439,12 +439,23 @@ static void rna_GPencil_stroke_point_select_set(PointerRNA *ptr, const int value } } -static void rna_GPencil_stroke_point_add(bGPDstroke *stroke, int count) +static void rna_GPencil_stroke_point_add(bGPDstroke *stroke, int count, float pressure, float strength) { if (count > 0) { + /* create space at the end of the array for extra points */ stroke->points = MEM_recallocN_id(stroke->points, sizeof(bGPDspoint) * (stroke->totpoints + count), "gp_stroke_points"); + + /* init the pressure and strength values so that old scripts won't need to + * be modified to give these initial values... + */ + for (int i = 0; i < count; i++) { + bGPDspoint *pt = stroke->points + (stroke->totpoints + i); + pt->pressure = pressure; + pt->strength = strength; + } + stroke->totpoints += count; } } @@ -890,7 +901,7 @@ static void rna_def_gpencil_stroke_points_api(BlenderRNA *brna, PropertyRNA *cpr StructRNA *srna; FunctionRNA *func; - /* PropertyRNA *parm; */ + PropertyRNA *parm; RNA_def_property_srna(cprop, "GPencilStrokePoints"); srna = RNA_def_struct(brna, "GPencilStrokePoints", NULL); @@ -900,6 +911,8 @@ static void rna_def_gpencil_stroke_points_api(BlenderRNA *brna, PropertyRNA *cpr func = RNA_def_function(srna, "add", "rna_GPencil_stroke_point_add"); RNA_def_function_ui_description(func, "Add a new grease pencil stroke point"); RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the stroke", 0, INT_MAX); + RNA_def_float(func, "pressure", 1.0f, 0.0f, 1.0f, "Pressure", "Pressure for newly created points", 0.0f, 1.0f); + RNA_def_float(func, "strength", 1.0f, 0.0f, 1.0f, "Strength", "Color intensity (alpha factor) for newly created points", 0.0f, 1.0f); func = RNA_def_function(srna, "pop", "rna_GPencil_stroke_point_pop"); RNA_def_function_ui_description(func, "Remove a grease pencil stroke point"); |