Curve draw fix w/ surface offset + only-first enabled
authorCampbell Barton <ideasman42@gmail.com>
Fri, 15 Apr 2016 20:43:53 +0000 (06:43 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 15 Apr 2016 20:47:37 +0000 (06:47 +1000)
In this case the initial offset needs to be applied to the rest of the stroke.

release/scripts/startup/bl_ui/space_view3d_toolbar.py
source/blender/editors/curve/editcurve_paint.c

index 01b46eb6aedf20cd0d4c0ba0b9b45b9d4c12b57e..7748618a0aabcced6e55f13c2c952f2791c7786e 100644 (file)
@@ -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 ****************
 
index 4af123c0f51d730c4ff9748fb97ee18310503814..5c74a3e43c24af7ae31f5b68d6a7ae929b7711ea 100644 (file)
@@ -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;