[Bf-blender-cvs] [6a9f45163ef] greasepencil-object: GPencil: Add sample distance to trace
Antonio Vazquez
noreply at git.blender.org
Thu Apr 9 19:40:17 CEST 2020
Commit: 6a9f45163ef6b929eca703b8be2be1d970a03272
Author: Antonio Vazquez
Date: Thu Apr 9 19:23:27 2020 +0200
Branches: greasepencil-object
https://developer.blender.org/rB6a9f45163ef6b929eca703b8be2be1d970a03272
GPencil: Add sample distance to trace
===================================================================
M release/scripts/startup/bl_operators/gpencil_trace_image.py
M source/blender/editors/gpencil/gpencil_trace.h
M source/blender/editors/gpencil/gpencil_trace_ops.c
M source/blender/editors/gpencil/gpencil_trace_utils.c
===================================================================
diff --git a/release/scripts/startup/bl_operators/gpencil_trace_image.py b/release/scripts/startup/bl_operators/gpencil_trace_image.py
index eb58b54a10c..ecb370db802 100644
--- a/release/scripts/startup/bl_operators/gpencil_trace_image.py
+++ b/release/scripts/startup/bl_operators/gpencil_trace_image.py
@@ -75,9 +75,20 @@ class GPENCIL_OT_trace(Operator):
max=100.0,
default=1.0,
)
+ sample: FloatProperty(
+ name="Sample Distance",
+ description="Determine distance between points",
+ soft_min=0.001, soft_max=100.0,
+ min=0.001, max=100.0,
+ default=0.05,
+ precision=3,
+ step=1,
+ subtype='DISTANCE',
+ unit='LENGTH',
+ )
threshold: FloatProperty(
- name="Colot Threshold",
- description="Determine what is considered white and what blackl",
+ name="Color Threshold",
+ description="Determine what is considered white and what black",
soft_min=0.0, soft_max=1.0,
min=0.0, max=1.0,
default=0.5,
@@ -96,6 +107,7 @@ class GPENCIL_OT_trace(Operator):
thickness=self.thickness,
resolution=self.resolution,
scale=self.scale,
+ sample=self.sample,
threshold=self.threshold
)
diff --git a/source/blender/editors/gpencil/gpencil_trace.h b/source/blender/editors/gpencil/gpencil_trace.h
index dfbf1ccd8a8..54a14fd1c38 100644
--- a/source/blender/editors/gpencil/gpencil_trace.h
+++ b/source/blender/editors/gpencil/gpencil_trace.h
@@ -69,6 +69,7 @@ void ED_gpencil_trace_data_to_gp(potrace_state_t *st,
struct bGPDframe *gpf,
int offset[2],
const float scale,
+ const float sample,
const int resolution,
const int thickness);
diff --git a/source/blender/editors/gpencil/gpencil_trace_ops.c b/source/blender/editors/gpencil/gpencil_trace_ops.c
index 6916399d0bd..cc1e97b357c 100644
--- a/source/blender/editors/gpencil/gpencil_trace_ops.c
+++ b/source/blender/editors/gpencil/gpencil_trace_ops.c
@@ -89,6 +89,7 @@ static int gp_trace_image_exec(bContext *C, wmOperator *op)
const int frame_target = RNA_int_get(op->ptr, "frame_target");
const float threshold = RNA_float_get(op->ptr, "threshold");
const float scale = RNA_float_get(op->ptr, "scale");
+ const float sample = RNA_float_get(op->ptr, "sample");
const int resolution = RNA_int_get(op->ptr, "resolution");
const int thickness = RNA_int_get(op->ptr, "thickness");
@@ -166,7 +167,7 @@ static int gp_trace_image_exec(bContext *C, wmOperator *op)
int offset[2];
offset[0] = ibuf->x / 2;
offset[1] = ibuf->y / 2;
- ED_gpencil_trace_data_to_gp(st, ob_gpencil, gpf, offset, scale, resolution, thickness);
+ ED_gpencil_trace_data_to_gp(st, ob_gpencil, gpf, offset, scale, sample, resolution, thickness);
/* Free memory. */
potrace_state_free(st);
@@ -225,6 +226,15 @@ void GPENCIL_OT_trace_image(wmOperatorType *ot)
"Scale of the final stroke",
0.001f,
100.0f);
+ RNA_def_float(ot->srna,
+ "sample",
+ 0.05f,
+ 0.001f,
+ 100.0f,
+ "Sample",
+ "Distance to sample points",
+ 0.001f,
+ 100.0f);
RNA_def_float_factor(ot->srna,
"threshold",
0.5f,
diff --git a/source/blender/editors/gpencil/gpencil_trace_utils.c b/source/blender/editors/gpencil/gpencil_trace_utils.c
index f69fb9b4a97..abb30c5ad49 100644
--- a/source/blender/editors/gpencil/gpencil_trace_utils.c
+++ b/source/blender/editors/gpencil/gpencil_trace_utils.c
@@ -231,12 +231,17 @@ static void add_bezier(bGPDstroke *gps,
* \param ob: Target grease pencil object
* \param gpf: Currect grease pencil frame
* \param offset: Offset to center
+ * \param scale: Scale of the output
+ * \param sample: Sample distance to distribute points
+ * \param resolution: Resolution of curves
+ * \param thickness: Thickness of the stroke
*/
void ED_gpencil_trace_data_to_gp(potrace_state_t *st,
Object *ob,
bGPDframe *gpf,
int offset[2],
const float scale,
+ const float sample,
const int resolution,
const int thickness)
{
@@ -304,6 +309,8 @@ void ED_gpencil_trace_data_to_gp(potrace_state_t *st,
break;
}
}
+ /* Resample stroke. */
+ BKE_gpencil_stroke_sample(gps, sample, false);
/* Update geometry. */
BKE_gpencil_stroke_geometry_update(gps);
More information about the Bf-blender-cvs
mailing list