[Bf-blender-cvs] [cb5505e8a0d] greasepencil-experimental: GP: Speed Guides: Add object reference option

Charlie Jolly noreply at git.blender.org
Sun Jan 6 15:38:12 CET 2019


Commit: cb5505e8a0d9efd2a2615cf98d56df0f899f649d
Author: Charlie Jolly
Date:   Sun Jan 6 14:37:52 2019 +0000
Branches: greasepencil-experimental
https://developer.blender.org/rBcb5505e8a0d9efd2a2615cf98d56df0f899f649d

GP: Speed Guides: Add object reference option

+ Reference point has three options, cursor, custom and object location

Also based on feedback from @pepeland
+ Remove preset angle buttons from UI
+ Make 3d cursor default reference point
+ UI tidying
+ Fix interpolation on circles. This is determined by brush samples option but for Circle guides this option is overridden.

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

M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/blenkernel/intern/library_query.c
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_sculpt_paint.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 41fbe71587f..e4c03c95f45 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -5357,23 +5357,33 @@ class VIEW3D_PT_gpencil_guide(Panel):
         
         col.prop(settings, "guide_type", expand=True)
         
+        
         if settings.guide_type in {'PARALLEL'}:
             col.prop(settings, "guide_angle")
             row = col.row(align=True)
-            op = row.operator("gpencil.guide_rotate", text="0", emboss=True)
-            op.increment = False
-            op.angle = 0.0            
-            row.operator("gpencil.guide_rotate", text="+90", emboss=True).angle = pi * 0.5
-            row.operator("gpencil.guide_rotate", text="+45", emboss=True).angle = pi * 0.25
+            #op = row.operator("gpencil.guide_rotate", text="0", emboss=True)
+            #op.increment = False
+            #op.angle = 0.0            
+            #row.operator("gpencil.guide_rotate", text="+90", emboss=True).angle = pi * 0.5
+            #row.operator("gpencil.guide_rotate", text="+45", emboss=True).angle = pi * 0.25
         
         col.prop(settings, "use_snapping")        
         if settings.use_snapping:
-            col.prop(settings, "guide_spacing")
-            col.prop(settings, "guide_angle_snap")
+            
+            if settings.guide_type in {'RADIAL'}:
+                col.prop(settings, "guide_angle_snap")
+            else:
+                col.prop(settings, "guide_spacing")
         
-        col.prop(settings, "use_cursor")       
-        if not settings.use_cursor:
-            col.prop(settings, "guide_origin")        
+        col.label(text="Reference Point")
+        row = col.row(align=True)
+        row.prop(settings, "guide_reference_point", expand=True)    
+        if settings.guide_reference_point in {'CUSTOM'}:
+            col.prop(settings, "guide_origin", text="Custom Location")        
+        if settings.guide_reference_point in {'OBJECT'}:
+            col.prop(settings, "guide_reference_object", text="Object Location")
+        if settings.guide_reference_point in {'CURSOR'}:
+            col.prop(context.scene, "cursor_location", text="Cursor Location")
 
         
 class VIEW3D_PT_overlay_gpencil_options(Panel):
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index 2134c02b63d..5e4e950cf9d 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -471,6 +471,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
 					CALLBACK_INVOKE(toolsett->particle.scene, IDWALK_CB_NOP);
 					CALLBACK_INVOKE(toolsett->particle.object, IDWALK_CB_NOP);
 					CALLBACK_INVOKE(toolsett->particle.shape_object, IDWALK_CB_NOP);
+					CALLBACK_INVOKE(toolsett->gp_sculpt.guide_reference_object, IDWALK_CB_NOP);
 
 					library_foreach_paint(&data, &toolsett->imapaint.paint);
 					CALLBACK_INVOKE(toolsett->imapaint.stencil, IDWALK_CB_USER);
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index ca33abd3245..309412ae08b 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -189,6 +189,7 @@ ToolSettings *BKE_toolsettings_copy(ToolSettings *toolsettings, const int flag)
 	/* duplicate Grease Pencil multiframe fallof */
 	ts->gp_sculpt.cur_falloff = curvemapping_copy(ts->gp_sculpt.cur_falloff);
 	ts->gp_sculpt.cur_primitive = curvemapping_copy(ts->gp_sculpt.cur_primitive);
+	ts->gp_sculpt.guide_reference_object = NULL;
 	return ts;
 }
 
@@ -715,6 +716,8 @@ void BKE_scene_init(Scene *sce)
 	        CURVE_PRESET_BELL,
 	        CURVEMAP_SLOPE_POSITIVE);
 
+	sce->toolsettings->gp_sculpt.guide_reference_object = NULL;
+
 	sce->physics_settings.gravity[0] = 0.0f;
 	sce->physics_settings.gravity[1] = 0.0f;
 	sce->physics_settings.gravity[2] = -9.81f;
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index bcf480c1e9f..22920b3d00a 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6001,6 +6001,7 @@ static void lib_link_scene(FileData *fd, Main *main)
 				        newlibadr_us(fd, sce->id.lib, sce->toolsettings->imapaint.canvas);
 
 			sce->toolsettings->particle.shape_object = newlibadr(fd, sce->id.lib, sce->toolsettings->particle.shape_object);
+			sce->toolsettings->gp_sculpt.guide_reference_object = newlibadr(fd, sce->id.lib, sce->toolsettings->gp_sculpt.guide_reference_object);
 
 			for (Base *base_legacy_next, *base_legacy = sce->base.first; base_legacy; base_legacy = base_legacy_next) {
 				base_legacy_next = base_legacy->next;
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 85bb68f0e21..a38a71b426f 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -427,14 +427,18 @@ GPUBatch *DRW_gpencil_get_buffer_ctrlpoint_geom(bGPdata *gpd)
 		float size = 10 * 0.8f;
 		float color[4];
 		float position[3];
-		if (ts->gp_sculpt.use_cursor) {
-			UI_GetThemeColor4fv(TH_REDALERT, color);
-			copy_v3_v3(position, scene->cursor.location);
-		}
-		else {
+		if (ts->gp_sculpt.guide_reference_point == 1) {			
 			UI_GetThemeColor4fv(TH_GIZMO_PRIMARY, color);
 			copy_v3_v3(position, ts->gp_sculpt.guide_origin);
 		}
+		else if (ts->gp_sculpt.guide_reference_point == 2 && ts->gp_sculpt.guide_reference_object != NULL) {
+			UI_GetThemeColor4fv(TH_GIZMO_SECONDARY, color);
+			copy_v3_v3(position, ts->gp_sculpt.guide_reference_object->loc);
+		}
+		else {
+			UI_GetThemeColor4fv(TH_REDALERT, color);
+			copy_v3_v3(position, scene->cursor.location);
+		}
 		GPU_vertbuf_attr_set(vbo, pos_id, idx, position);
 		GPU_vertbuf_attr_set(vbo, size_id, idx, &size);
 		GPU_vertbuf_attr_set(vbo, color_id, idx, color);
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 5868c0877df..70cbb68b1ad 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -122,6 +122,13 @@ typedef enum eGPencil_PaintFlags {
 	GP_PAINTFLAG_REQ_VECTOR     = (1 << 6),
 } eGPencil_PaintFlags;
 
+/* Runtime flags */
+typedef enum eGPencil_Guide_Reference {
+	GP_GUIDE_REF_CURSOR = 0,
+	GP_GUIDE_REF_CUSTOM,
+	GP_GUIDE_REF_OBJECT
+} eGPencil_Guide_Reference;
+
 
 /* Temporary 'Stroke' Operation data
  *   "p" = op->customdata
@@ -2577,10 +2584,10 @@ static void gp_origin_set(wmOperator *op, const int mval[2])
 	float point[3];
 	copy_v2fl_v2i(origin, mval);
 	gp_stroke_convertcoords(p, origin, point, NULL);
-	if (ts->gp_sculpt.use_cursor)
-		copy_v3_v3(p->scene->cursor.location, point);
-	else
+	if (ts->gp_sculpt.guide_reference_point == GP_GUIDE_REF_CUSTOM)
 		copy_v3_v3(ts->gp_sculpt.guide_origin, point);
+	else if (ts->gp_sculpt.guide_reference_point == GP_GUIDE_REF_CURSOR)
+		copy_v3_v3(p->scene->cursor.location, point);
 }
 
 /* get reference point - buffer coords to screen coords */
@@ -2589,10 +2596,12 @@ static void gp_origin_get(wmOperator *op, float origin[2])
 	tGPsdata *p = op->customdata;
 	ToolSettings *ts = p->scene->toolsettings;
 	float location[3];
-	if (ts->gp_sculpt.use_cursor)
-		copy_v3_v3(location, p->scene->cursor.location);
-	else 
+	if (ts->gp_sculpt.guide_reference_point == GP_GUIDE_REF_CUSTOM)
 		copy_v3_v3(location, ts->gp_sculpt.guide_origin);
+	else if (ts->gp_sculpt.guide_reference_point == GP_GUIDE_REF_OBJECT && ts->gp_sculpt.guide_reference_object != NULL)
+		copy_v3_v3(location, ts->gp_sculpt.guide_reference_object->loc);
+	else 
+		copy_v3_v3(location, p->scene->cursor.location);
 	GP_SpaceConversion *gsc = &p->gsc;
 	gp_point_3d_to_xy(gsc, p->gpd->runtime.sbuffer_sflag, location, origin);
 }
@@ -2960,7 +2969,7 @@ static void gpencil_guide_event_handling(bContext *C, wmOperator *op, const wmEv
 
 	/* Enter or exit set center point mode */
 	if ((event->type == OKEY) && (event->val == KM_RELEASE)) {
-		if (p->paintmode == GP_PAINTMODE_DRAW) {
+		if (p->paintmode == GP_PAINTMODE_DRAW && ts->gp_sculpt.guide_reference_point != GP_GUIDE_REF_OBJECT) {
 			add_notifier = true; 
 			p->paintmode = GP_PAINTMODE_SET_CP;
 			ED_gpencil_toggle_brush_cursor(C, false, NULL);			
@@ -3216,12 +3225,19 @@ static void gpencil_move_last_stroke_to_back(bContext *C)
 static void gpencil_add_missing_events(bContext *C, wmOperator *op, const wmEvent *event, tGPsdata *p)
 {
 	Brush *brush = p->brush;
-	if (brush->gpencil_settings->input_samples == 0) {
+	ToolSettings *ts = p->scene->toolsettings;
+	int input_samples = brush->gpencil_settings->input_samples;
+
+	/* ensure sampling when using circular guide */
+	if (ts->gp_sculpt.use_speed_guide && (ts->gp_sculpt.guide_type == GP_GUIDE_CIRCULAR))
+		input_samples = GP_MAX_INPUT_SAMPLES;
+
+	if (input_samples == 0)
 		return;
-	}
+		
 	RegionView3D *rv3d = p->ar->regiondata;
 	float defaultpixsize = rv3d->pixsize * 1000.0f;
-	int samples = (GP_MAX_INPUT_SAMPLES - brush->gpencil_settings->input_samples + 1);
+	int samples = (GP_MAX_INPUT_SAMPLES - input_samples + 1);
 	float thickness = (float)brush->size;
 
 	float pt[2], a[2], b[2];
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 104e01e2bba..c667a07b888 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1036,13 +1036,14 @@ typedef struct GP_Sculpt_Settings {
 	/* guides */
 	char use_speed_guide;
 	char use_snapping;
-	char use_cursor;
+	char guide_reference_point;
 	char guide_type;
 	char _pad2[4];
 	float guide_angle;
 	float guide_angle_snap;
 	float guide_spacing;
 	float guide_origin[3];
+	struct Object *guide_reference_object;
 
 } GP_Sculpt_Settings;
 
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 333450f52d1..940173e008c 100644
--- a/sour

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list