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
path: root/source
diff options
context:
space:
mode:
authorAntonio Vazquez <blendergit@gmail.com>2020-08-12 13:05:11 +0300
committerAntonio Vazquez <blendergit@gmail.com>2020-08-12 23:47:43 +0300
commit9abdafe840e5eaa29153565bd7c121f02e1d1fb1 (patch)
treeeaf8a1c9903199f0fe4b34122cd83f867c79babd /source
parent19cef4073dd7b17a156fbb0feb1838417bf7ff30 (diff)
GPencil: Add parameters to scale thickness when convert Curves
This parameter allows to scale the thickness.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_gpencil_curve.h3
-rw-r--r--source/blender/blenkernel/intern/gpencil_curve.c13
-rw-r--r--source/blender/editors/object/object_add.c2
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c20
4 files changed, 26 insertions, 12 deletions
diff --git a/source/blender/blenkernel/BKE_gpencil_curve.h b/source/blender/blenkernel/BKE_gpencil_curve.h
index 3fbd0ce1a51..952f5115707 100644
--- a/source/blender/blenkernel/BKE_gpencil_curve.h
+++ b/source/blender/blenkernel/BKE_gpencil_curve.h
@@ -37,7 +37,8 @@ void BKE_gpencil_convert_curve(struct Main *bmain,
struct Object *ob_cu,
const bool gpencil_lines,
const bool use_collections,
- const bool only_stroke);
+ const bool only_stroke,
+ const float scale_thickness);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c
index 988ae05e323..3ee74ed11c9 100644
--- a/source/blender/blenkernel/intern/gpencil_curve.c
+++ b/source/blender/blenkernel/intern/gpencil_curve.c
@@ -172,6 +172,7 @@ static void gpencil_convert_spline(Main *bmain,
Object *ob_cu,
const bool gpencil_lines,
const bool only_stroke,
+ const float scale_thickness,
bGPDframe *gpf,
Nurb *nu)
{
@@ -342,8 +343,11 @@ static void gpencil_convert_spline(Main *bmain,
copy_v3_v3(init_co, &coord_array[0]);
}
/* Add points to the stroke */
+ float radius_start = prevbezt->radius * scale_thickness;
+ float radius_end = bezt->radius * scale_thickness;
+
gpencil_add_new_points(
- gps, coord_array, prevbezt->radius, bezt->radius, init, resolu, init_co, last);
+ gps, coord_array, radius_start, radius_end, init, resolu, init_co, last);
/* Free memory. */
MEM_SAFE_FREE(coord_array);
@@ -403,6 +407,7 @@ static void gpencil_convert_spline(Main *bmain,
* \param gpencil_lines: Use lines for strokes.
* \param use_collections: Create layers using collection names.
* \param only_stroke: The material must be only stroke without fill.
+ * \param scale_thickness: Scale thickness factor.
*/
void BKE_gpencil_convert_curve(Main *bmain,
Scene *scene,
@@ -410,7 +415,8 @@ void BKE_gpencil_convert_curve(Main *bmain,
Object *ob_cu,
const bool gpencil_lines,
const bool use_collections,
- const bool only_stroke)
+ const bool only_stroke,
+ const float scale_thickness)
{
if (ELEM(NULL, ob_gp, ob_cu) || (ob_gp->type != OB_GPENCIL) || (ob_gp->data == NULL)) {
return;
@@ -448,7 +454,8 @@ void BKE_gpencil_convert_curve(Main *bmain,
/* Read all splines of the curve and create a stroke for each. */
LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
- gpencil_convert_spline(bmain, ob_gp, ob_cu, gpencil_lines, only_stroke, gpf, nu);
+ gpencil_convert_spline(
+ bmain, ob_gp, ob_cu, gpencil_lines, only_stroke, scale_thickness, gpf, nu);
}
/* Tag for recalculation */
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 81b8cd70353..41757579817 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -2647,7 +2647,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
ob_gpencil = ED_gpencil_add_object(C, ob->loc, local_view_bits);
copy_v3_v3(ob_gpencil->rot, ob->rot);
copy_v3_v3(ob_gpencil->scale, ob->scale);
- BKE_gpencil_convert_curve(bmain, scene, ob_gpencil, ob, false, false, true);
+ BKE_gpencil_convert_curve(bmain, scene, ob_gpencil, ob, false, false, true, 1.0f);
gpencilConverted = true;
}
}
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index 3b80714bcc5..9e698b2b398 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -714,7 +714,8 @@ bool rna_Object_generate_gpencil_strokes(Object *ob,
ReportList *reports,
Object *ob_gpencil,
bool gpencil_lines,
- bool use_collections)
+ bool use_collections,
+ float scale_thickness)
{
if (ob->type != OB_CURVE) {
BKE_reportf(reports,
@@ -726,7 +727,8 @@ bool rna_Object_generate_gpencil_strokes(Object *ob,
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- BKE_gpencil_convert_curve(bmain, scene, ob_gpencil, ob, gpencil_lines, use_collections, false);
+ BKE_gpencil_convert_curve(
+ bmain, scene, ob_gpencil, ob, gpencil_lines, use_collections, false, scale_thickness);
WM_main_add_notifier(NC_GPENCIL | ND_DATA, NULL);
@@ -1190,12 +1192,16 @@ void RNA_api_object(StructRNA *srna)
RNA_def_function_ui_description(func, "Convert a curve object to grease pencil strokes.");
RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
- parm = RNA_def_pointer(
- func, "ob_gpencil", "Object", "", "Grease Pencil object used to create new strokes");
+ parm = RNA_def_pointer(func,
+ "grease_pencil_object",
+ "Object",
+ "",
+ "Grease Pencil object used to create new strokes");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
- parm = RNA_def_boolean(func, "gpencil_lines", 0, "", "Create Lines");
- parm = RNA_def_boolean(func, "use_collections", 1, "", "Use Collections");
-
+ parm = RNA_def_boolean(func, "gpencil_lines", false, "", "Create Lines");
+ parm = RNA_def_boolean(func, "use_collections", true, "", "Use Collections");
+ parm = RNA_def_float(
+ func, "scale_thickness", 1.0f, 0.0f, FLT_MAX, "", "Thickness scaling factor", 0.0f, 100.0f);
parm = RNA_def_boolean(func, "result", 0, "", "Result");
RNA_def_function_return(func, parm);
}