diff options
-rw-r--r-- | release/scripts/startup/bl_ui/space_view3d_toolbar.py | 4 | ||||
-rw-r--r-- | source/blender/editors/curve/editcurve_paint.c | 30 |
2 files changed, 31 insertions, 3 deletions
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 01b46eb6aed..7748618a0aa 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -597,13 +597,11 @@ class VIEW3D_PT_tools_curveedit_options_stroke(View3DPanel, Panel): col = layout.column() if cps.depth_mode == 'SURFACE': + col.prop(cps, "radius_offset") col.prop(cps, "use_stroke_endpoints") if cps.use_stroke_endpoints: colsub = layout.column(align=True) colsub.prop(cps, "surface_plane", expand=True) - else: - col.prop(cps, "radius_offset") - # ********** default tools for editmode_surface **************** diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index 4af123c0f51..5c74a3e43c2 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -185,6 +185,10 @@ struct CurveDrawData { /* use 'rv3d->depths', note that this will become 'damaged' while drawing, but thats OK. */ bool use_depth; + + /* offset projection by this value */ + bool use_offset; + float offset[3]; /* worldspace */ } project; /* cursor sampling */ @@ -287,6 +291,12 @@ static bool stroke_elem_project( } } + if (is_location_world_set) { + if (cdd->project.use_offset) { + add_v3_v3(r_location_world, cdd->project.offset); + } + } + return is_location_world_set; } @@ -582,6 +592,26 @@ static void curve_draw_event_add_first(wmOperator *op, const wmEvent *event) normalize_v3_v3(cdd->project.plane, normal); cdd->project.plane[3] = -dot_v3v3(cdd->project.plane, cdd->prev.location_world_valid); + + /* Special case for when we only have offset applied on the first-hit, + * the remaining stroke must be offset too. */ + if (cdd->radius.offset != 0.0f) { + const float mval_fl[2] = {UNPACK2(event->mval)}; + + float location_no_offset[3]; + + if (stroke_elem_project( + cdd, event->mval, mval_fl, 0.0f, 0.0f, + location_no_offset)) + { + sub_v3_v3v3(cdd->project.offset, cdd->prev.location_world_valid, location_no_offset); + if (!is_zero_v3(cdd->project.offset)) { + cdd->project.use_offset = true; + } + } + } + /* end special case */ + } cdd->init_event_type = event->type; |