GPencil: Add `offset` parameter to reproject operator Redo Panel
Now it's possible to set an offset in the surface reprojection. Before, this was only possible while drawing, but not in the reproject operator. Differential Revision: https://developer.blender.org/D15610
This commit is contained in:
parent
afe91903af
commit
5c33704ffa
|
@ -327,7 +327,7 @@ static int gpencil_bake_grease_pencil_animation_exec(bContext *C, wmOperator *op
|
|||
/* Reproject stroke. */
|
||||
if (project_type != GP_REPROJECT_KEEP) {
|
||||
ED_gpencil_stroke_reproject(
|
||||
depsgraph, &gsc, sctx, gpl_dst, gpf_dst, gps, project_type, false);
|
||||
depsgraph, &gsc, sctx, gpl_dst, gpf_dst, gps, project_type, false, 0.0f);
|
||||
}
|
||||
else {
|
||||
BKE_gpencil_stroke_geometry_update(gpd_dst, gps);
|
||||
|
|
|
@ -3905,6 +3905,7 @@ static int gpencil_strokes_reproject_exec(bContext *C, wmOperator *op)
|
|||
const bool keep_original = RNA_boolean_get(op->ptr, "keep_original");
|
||||
const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
|
||||
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
|
||||
const float offset = RNA_float_get(op->ptr, "offset");
|
||||
|
||||
/* Init snap context for geometry projection. */
|
||||
SnapObjectContext *sctx = NULL;
|
||||
|
@ -3944,7 +3945,8 @@ static int gpencil_strokes_reproject_exec(bContext *C, wmOperator *op)
|
|||
BKE_scene_graph_update_for_newframe(depsgraph);
|
||||
}
|
||||
|
||||
ED_gpencil_stroke_reproject(depsgraph, &gsc, sctx, gpl, gpf, gps, mode, keep_original);
|
||||
ED_gpencil_stroke_reproject(
|
||||
depsgraph, &gsc, sctx, gpl, gpf, gps, mode, keep_original, offset);
|
||||
|
||||
if (is_curve_edit && gps->editcurve != NULL) {
|
||||
BKE_gpencil_stroke_editcurve_update(gpd, gpl, gps);
|
||||
|
@ -3984,6 +3986,26 @@ static int gpencil_strokes_reproject_exec(bContext *C, wmOperator *op)
|
|||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static void gpencil_strokes_reproject_ui(bContext *UNUSED(C), wmOperator *op)
|
||||
{
|
||||
uiLayout *layout = op->layout;
|
||||
uiLayout *row;
|
||||
|
||||
const eGP_ReprojectModes type = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
uiLayoutSetPropDecorate(layout, false);
|
||||
row = uiLayoutRow(layout, true);
|
||||
uiItemR(row, op->ptr, "type", 0, NULL, ICON_NONE);
|
||||
|
||||
if (type == GP_REPROJECT_SURFACE) {
|
||||
row = uiLayoutRow(layout, true);
|
||||
uiItemR(row, op->ptr, "offset", 0, NULL, ICON_NONE);
|
||||
}
|
||||
row = uiLayoutRow(layout, true);
|
||||
uiItemR(row, op->ptr, "keep_original", 0, NULL, ICON_NONE);
|
||||
}
|
||||
|
||||
void GPENCIL_OT_reproject(wmOperatorType *ot)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
@ -4024,6 +4046,7 @@ void GPENCIL_OT_reproject(wmOperatorType *ot)
|
|||
ot->invoke = WM_menu_invoke;
|
||||
ot->exec = gpencil_strokes_reproject_exec;
|
||||
ot->poll = gpencil_strokes_edit3d_poll;
|
||||
ot->ui = gpencil_strokes_reproject_ui;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
@ -4039,6 +4062,8 @@ void GPENCIL_OT_reproject(wmOperatorType *ot)
|
|||
"Keep Original",
|
||||
"Keep original strokes and create a copy before reprojecting instead of reproject them");
|
||||
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_MOVIECLIP);
|
||||
|
||||
RNA_def_float(ot->srna, "offset", 0.0f, 0.0f, 10.0f, "Surface Offset", "", 0.0f, 10.0f);
|
||||
}
|
||||
|
||||
static int gpencil_recalc_geometry_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
|
|
|
@ -315,7 +315,7 @@ static int gpencil_bake_mesh_animation_exec(bContext *C, wmOperator *op)
|
|||
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
|
||||
if ((gps->flag & GP_STROKE_TAG) == 0) {
|
||||
ED_gpencil_stroke_reproject(
|
||||
depsgraph, &gsc, sctx, gpl, gpf, gps, project_type, false);
|
||||
depsgraph, &gsc, sctx, gpl, gpf, gps, project_type, false, 0.0f);
|
||||
gps->flag |= GP_STROKE_TAG;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1038,7 +1038,8 @@ void ED_gpencil_stroke_reproject(Depsgraph *depsgraph,
|
|||
bGPDframe *gpf,
|
||||
bGPDstroke *gps,
|
||||
const eGP_ReprojectModes mode,
|
||||
const bool keep_original)
|
||||
const bool keep_original,
|
||||
const float offset)
|
||||
{
|
||||
ToolSettings *ts = gsc->scene->toolsettings;
|
||||
ARegion *region = gsc->region;
|
||||
|
@ -1156,7 +1157,13 @@ void ED_gpencil_stroke_reproject(Depsgraph *depsgraph,
|
|||
&depth,
|
||||
&location[0],
|
||||
&normal[0])) {
|
||||
copy_v3_v3(&pt->x, location);
|
||||
/* Apply offset over surface. */
|
||||
float normal_vector[3];
|
||||
sub_v3_v3v3(normal_vector, ray_start, location);
|
||||
normalize_v3(normal_vector);
|
||||
mul_v3_fl(normal_vector, offset);
|
||||
|
||||
add_v3_v3v3(&pt->x, location, normal_vector);
|
||||
}
|
||||
else {
|
||||
/* Default to planar */
|
||||
|
|
|
@ -475,7 +475,8 @@ void ED_gpencil_stroke_reproject(struct Depsgraph *depsgraph,
|
|||
struct bGPDframe *gpf,
|
||||
struct bGPDstroke *gps,
|
||||
eGP_ReprojectModes mode,
|
||||
bool keep_original);
|
||||
bool keep_original,
|
||||
const float offset);
|
||||
|
||||
/**
|
||||
* Turn brush cursor in on/off.
|
||||
|
|
Loading…
Reference in New Issue