[Bf-blender-cvs] [431e7349e75] greasepencil-object: GP: Guides: Speedline drawing guides
Charlie Jolly
noreply at git.blender.org
Mon Jan 7 00:08:05 CET 2019
Commit: 431e7349e7506c309dec2521a0c43d1fd332c7cc
Author: Charlie Jolly
Date: Sun Jan 6 23:07:43 2019 +0000
Branches: greasepencil-object
https://developer.blender.org/rB431e7349e7506c309dec2521a0c43d1fd332c7cc
GP: Guides: Speedline drawing guides
Initial commit for final testing
===================================================================
M release/scripts/presets/keyconfig/keymap_data/blender_default.py
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/draw/engines/gpencil/gpencil_draw_utils.c
M source/blender/editors/gpencil/gpencil_intern.h
M source/blender/editors/gpencil/gpencil_ops.c
M source/blender/editors/gpencil/gpencil_paint.c
M source/blender/editors/gpencil/gpencil_primitive.c
M source/blender/editors/gpencil/gpencil_utils.c
M source/blender/makesdna/DNA_scene_types.h
M source/blender/makesrna/RNA_access.h
M source/blender/makesrna/intern/rna_sculpt_paint.c
===================================================================
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 289db8e23bb..47d7c290cad 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -3047,7 +3047,25 @@ def km_grease_pencil_stroke_paint_draw_brush(params):
# Erase
("gpencil.draw", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
{"properties": [("mode", 'ERASER'), ("wait_for_input", False)]}),
-
+ # Constrain Guides Speedlines
+ # Freehand
+ ("gpencil.draw", {"type": 'O', "value": 'PRESS'}, None),
+ ("gpencil.draw", {"type": 'J', "value": 'PRESS'}, None),
+ ("gpencil.draw", {"type": 'J', "value": 'PRESS', "alt": True}, None),
+ ("gpencil.draw", {"type": 'J', "value": 'PRESS', "shift": True}, None),
+ ("gpencil.draw", {"type": 'K', "value": 'PRESS'}, None),
+ ("gpencil.draw", {"type": 'K', "value": 'PRESS', "alt": True}, None),
+ ("gpencil.draw", {"type": 'K', "value": 'PRESS', "shift": True}, None),
+ ("gpencil.draw", {"type": 'L', "value": 'PRESS'}, None),
+ ("gpencil.draw", {"type": 'L', "value": 'PRESS', "alt": True}, None),
+ ("gpencil.draw", {"type": 'L', "value": 'PRESS', "ctrl": True}, None),
+ ("gpencil.draw", {"type": 'V', "value": 'PRESS'}, None),
+ # Mirror or flip
+ ("gpencil.draw", {"type": 'M', "value": 'PRESS'}, None),
+ # Mode
+ ("gpencil.draw", {"type": 'C', "value": 'PRESS'}, None),
+ # Set reference point
+ ("gpencil.draw", {"type": 'C', "value": 'PRESS', "alt": True}, None),
# Tablet Mappings for Drawing ------------------ */
# For now, only support direct drawing using the eraser, as most users using a tablet
# may still want to use that as their primary pointing device!
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index b0fe98e4ff8..ffddc689a34 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -245,6 +245,18 @@ class VIEW3D_HT_header(Header):
text=lk_name,
icon=lk_icon,
)
+
+ if object_mode in {'PAINT_GPENCIL'}:
+ if context.workspace.tools.from_space_view3d_mode(object_mode).name == "Draw":
+ settings = tool_settings.gpencil_sculpt.guide
+ row = layout.row(align=True)
+ row.prop(settings, "use_guide", text="", icon='GRID')
+ sub = row.row(align=True)
+ sub.active = settings.use_guide
+ sub.popover(
+ panel="VIEW3D_PT_gpencil_guide",
+ text="Guides"
+ )
layout.separator_spacer()
@@ -5321,7 +5333,56 @@ class VIEW3D_PT_gpencil_lock(Panel):
col = row.column()
col.prop(context.tool_settings.gpencil_sculpt, "lock_axis", expand=True)
+
+class VIEW3D_PT_gpencil_guide(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_label = "Guides"
+
+ @staticmethod
+ def draw(self, context):
+ from math import pi
+ settings = context.tool_settings.gpencil_sculpt.guide
+ layout = self.layout
+ layout.label(text="Guides")
+
+ col = layout.column()
+ col.prop(settings, "use_guide")
+
+ col = col.column()
+ col.active = settings.use_guide
+
+ col.prop(settings, "type", expand=True)
+
+ if settings.type in {'PARALLEL'}:
+ col.prop(settings, "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
+
+ col.prop(settings, "use_snapping")
+ if settings.use_snapping:
+
+ if settings.type in {'RADIAL'}:
+ col.prop(settings, "angle_snap")
+ else:
+ col.prop(settings, "spacing")
+
+ col.label(text="Reference Point")
+ row = col.row(align=True)
+ row.prop(settings, "reference_point", expand=True)
+ if settings.reference_point in {'CUSTOM'}:
+ col.prop(settings, "location", text="Custom Location")
+ if settings.reference_point in {'OBJECT'}:
+ col.prop(settings, "reference_object", text="Object Location")
+ if settings.reference_point in {'CURSOR'}:
+ col.prop(context.scene, "cursor_location", text="Cursor Location")
+
+
class VIEW3D_PT_overlay_gpencil_options(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
@@ -5792,6 +5853,7 @@ classes = (
VIEW3D_PT_snapping,
VIEW3D_PT_gpencil_origin,
VIEW3D_PT_gpencil_lock,
+ VIEW3D_PT_gpencil_guide,
VIEW3D_PT_transform_orientations,
VIEW3D_PT_overlay_gpencil_options,
VIEW3D_PT_context_properties,
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index 2134c02b63d..c902aa8c5d5 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -466,7 +466,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
for (TimeMarker *marker = scene->markers.first; marker; marker = marker->next) {
CALLBACK_INVOKE(marker->camera, IDWALK_CB_NOP);
}
-
+
if (toolsett) {
CALLBACK_INVOKE(toolsett->particle.scene, IDWALK_CB_NOP);
CALLBACK_INVOKE(toolsett->particle.object, IDWALK_CB_NOP);
@@ -493,6 +493,9 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
if (toolsett->gp_paint) {
library_foreach_paint(&data, &toolsett->gp_paint->paint);
}
+
+ CALLBACK_INVOKE(toolsett->gp_sculpt.guide.reference_object, IDWALK_CB_NOP);
+
}
if (scene->rigidbody_world) {
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index ca33abd3245..1bae41ce035 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -715,6 +715,8 @@ void BKE_scene_init(Scene *sce)
CURVE_PRESET_BELL,
CURVEMAP_SLOPE_POSITIVE);
+ sce->toolsettings->gp_sculpt.guide.spacing = 20.0f;
+
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 2817f3abac0..78c061ffdc8 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6004,6 +6004,8 @@ static void lib_link_scene(FileData *fd, Main *main)
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 d5927ebca9a..3cfe2673618 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -390,6 +390,14 @@ GPUBatch *DRW_gpencil_get_buffer_ctrlpoint_geom(bGPdata *gpd)
bGPDcontrolpoint *cps = gpd->runtime.cp_points;
int totpoints = gpd->runtime.tot_cp_points;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ Scene *scene = draw_ctx->scene;
+ ToolSettings *ts = scene->toolsettings;
+
+ if (ts->gp_sculpt.guide.use_guide) {
+ totpoints++;
+ }
+
static GPUVertFormat format = { 0 };
static uint pos_id, color_id, size_id;
if (format.attr_len == 0) {
@@ -415,6 +423,27 @@ GPUBatch *DRW_gpencil_get_buffer_ctrlpoint_geom(bGPdata *gpd)
idx++;
}
+ if (ts->gp_sculpt.guide.use_guide) {
+ float size = 10 * 0.8f;
+ float color[4];
+ float position[3];
+ if (ts->gp_sculpt.guide.reference_point == GP_GUIDE_REF_CUSTOM) {
+ UI_GetThemeColor4fv(TH_GIZMO_PRIMARY, color);
+ copy_v3_v3(position, ts->gp_sculpt.guide.location);
+ }
+ else if (ts->gp_sculpt.guide.reference_point == GP_GUIDE_REF_OBJECT && 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);
+ }
+
return GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO);
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 52320f426c6..8d6ac04bdda 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -1242,13 +1242,14 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data, void *vedata, T
}
}
- /* control points */
- if ((overlay) && (gpd->runtime.tot_cp_points > 0) &&
- ((gpd->runtime.sbuffer_sflag & GP_STROKE_ERASER) == 0) &&
- ((v3d->gizmo_flag & V3D_GIZMO_HIDE) == 0) &&
- ((v3d->gizmo_flag & V3D_GIZMO_HIDE_TOOL) == 0))
- {
+ /* control points for primitives and speed guide */
+ const bool is_cppoint = (gpd->runtime.tot_cp_points > 0);
+ const bool is_speed_guide = (ts->gp_sculpt.guide.use_guide && (draw
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list