[Bf-blender-cvs] [34c99fa] master: Curve draw fix w/ surface offset + only-first enabled

Campbell Barton noreply at git.blender.org
Fri Apr 15 22:47:49 CEST 2016


Commit: 34c99fa30ade70d7677972ab18acc4c6ad52558b
Author: Campbell Barton
Date:   Sat Apr 16 06:43:53 2016 +1000
Branches: master
https://developer.blender.org/rB34c99fa30ade70d7677972ab18acc4c6ad52558b

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.

===================================================================

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

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 01b46eb..7748618 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 4af123c..5c74a3e 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;




More information about the Bf-blender-cvs mailing list