diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-04-15 23:43:53 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-04-15 23:47:37 +0300 |
commit | 34c99fa30ade70d7677972ab18acc4c6ad52558b (patch) | |
tree | 8c1219d9cd4a029a5e7dd8c67340b6a537934122 /source/blender/editors | |
parent | 6bc2ba21117a25c8a7100b282cc2377e1adf7075 (diff) |
Curve draw fix w/ surface offset + only-first enabled
In this case the initial offset needs to be applied to the rest of the stroke.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/curve/editcurve_paint.c | 30 |
1 files changed, 30 insertions, 0 deletions
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; |