[Bf-blender-cvs] [3f59135c114] greasepencil-object: GPencil: Export only Seam Edges
Antonio Vazquez
noreply at git.blender.org
Tue Mar 31 16:49:29 CEST 2020
Commit: 3f59135c11400de6c97c44fe8abec1404771f2eb
Author: Antonio Vazquez
Date: Tue Mar 31 16:28:05 2020 +0200
Branches: greasepencil-object
https://developer.blender.org/rB3f59135c11400de6c97c44fe8abec1404771f2eb
GPencil: Export only Seam Edges
===================================================================
M source/blender/blenkernel/BKE_gpencil_geom.h
M source/blender/blenkernel/intern/gpencil_geom.c
M source/blender/editors/object/object_add.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_gpencil_geom.h b/source/blender/blenkernel/BKE_gpencil_geom.h
index 9d1f422e16b..658b4d3e673 100644
--- a/source/blender/blenkernel/BKE_gpencil_geom.h
+++ b/source/blender/blenkernel/BKE_gpencil_geom.h
@@ -111,10 +111,9 @@ void BKE_gpencil_convert_mesh(struct Main *bmain,
struct Scene *scene,
struct Object *ob_gp,
struct Object *ob_mesh,
- const bool gpencil_lines,
- const bool only_stroke,
const float angle,
- const int thickness);
+ const int thickness,
+ const bool use_seams);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c
index cb0c1843009..4c01e9788d1 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.c
+++ b/source/blender/blenkernel/intern/gpencil_geom.c
@@ -2068,7 +2068,8 @@ static int gpencil_walk_edge(GHash *v_table,
static void gpencil_generate_edgeloops(Object *ob,
bGPDframe *gpf_stroke,
const float angle,
- const int thickness)
+ const int thickness,
+ const bool use_seams)
{
Mesh *me = (Mesh *)ob->data;
if (me->totedge == 0) {
@@ -2095,6 +2096,11 @@ static void gpencil_generate_edgeloops(Object *ob,
copy_v3_v3(gped->v2_co, mv2->co);
sub_v3_v3v3(gped->vec, mv1->co, mv2->co);
+
+ /* If use seams, mark as done if not a seam. */
+ if ((use_seams) && ((ed->flag & ME_SEAM) == 0)) {
+ gped->flag = 1;
+ }
}
/* Loop edges to find edgeloops */
@@ -2185,21 +2191,18 @@ static void gpencil_generate_edgeloops(Object *ob,
* \param scene: Original scene.
* \param ob_gp: Grease pencil object to add strokes.
* \param ob_mesh: Mesh to convert.
- * \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 angle: Limit angle to consider a edgeloop ends.
* \param thickness: Thickness of the strokes.
+ * \param only_seams: Only export seam edges.
*/
void BKE_gpencil_convert_mesh(Main *bmain,
Depsgraph *depsgraph,
Scene *scene,
Object *ob_gp,
Object *ob_mesh,
- const bool gpencil_lines,
- const bool only_stroke,
const float angle,
- const int thickness)
+ const int thickness,
+ const bool use_seams)
{
if (ELEM(NULL, ob_gp, ob_mesh) || (ob_gp->type != OB_GPENCIL) || (ob_gp->data == NULL)) {
return;
@@ -2271,7 +2274,7 @@ void BKE_gpencil_convert_mesh(Main *bmain,
/* Create stroke from edges. */
bGPDlayer *gpl_stroke = BKE_gpencil_layer_addnew(gpd, DATA_("Lines"), true);
bGPDframe *gpf_stroke = BKE_gpencil_layer_frame_get(gpl_stroke, CFRA, GP_GETFRAME_ADD_COPY);
- gpencil_generate_edgeloops(ob_eval, gpf_stroke, angle, thickness);
+ gpencil_generate_edgeloops(ob_eval, gpf_stroke, angle, thickness, use_seams);
/* Tag for recalculation */
DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 12fdf1f128c..089f59ea220 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -2222,8 +2222,10 @@ static int convert_exec(bContext *C, wmOperator *op)
Object *gpencil_ob = NULL;
const short target = RNA_enum_get(op->ptr, "target");
bool keep_original = RNA_boolean_get(op->ptr, "keep_original");
+
const float angle = RNA_float_get(op->ptr, "angle");
const int thickness = RNA_int_get(op->ptr, "thickness");
+ const bool use_seams = RNA_boolean_get(op->ptr, "seams");
int a, mballConverted = 0;
bool gpencilConverted = false;
@@ -2351,7 +2353,7 @@ static int convert_exec(bContext *C, wmOperator *op)
copy_v3_v3(gpencil_ob->scale, size);
BKE_gpencil_convert_mesh(
- bmain, depsgraph, scene, gpencil_ob, ob, false, true, angle, thickness);
+ bmain, depsgraph, scene, gpencil_ob, ob, angle, thickness, use_seams);
gpencilConverted = true;
}
else if (ob->type == OB_MESH) {
@@ -2643,6 +2645,7 @@ static void convert_ui(bContext *C, wmOperator *op)
if (RNA_enum_get(&ptr, "target") == OB_GPENCIL) {
uiItemR(layout, &ptr, "angle", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "thickness", 0, NULL, ICON_NONE);
+ uiItemR(layout, &ptr, "seams", 0, NULL, ICON_NONE);
}
}
@@ -2686,6 +2689,7 @@ void OBJECT_OT_convert(wmOperatorType *ot)
RNA_def_property_float_default(prop, DEG2RADF(70.0f));
RNA_def_int(ot->srna, "thickness", 5, 1, 10000, "Thickness", "", 1, 200);
+ RNA_def_boolean(ot->srna, "seams", 0, "Only Seams", "Convert only seam edges");
}
/** \} */
More information about the Bf-blender-cvs
mailing list