[Bf-blender-cvs] [c5d1923c441] greasepencil-experimental: GP: Guides: Move guide data to struct
Charlie Jolly
noreply at git.blender.org
Sun Jan 6 23:27:38 CET 2019
Commit: c5d1923c441829cca124761a58f2806d889017bf
Author: Charlie Jolly
Date: Sun Jan 6 22:27:16 2019 +0000
Branches: greasepencil-experimental
https://developer.blender.org/rBc5d1923c441829cca124761a58f2806d889017bf
GP: Guides: Move guide data to struct
+ Address comments from code review by @antonioya, thanks
+ Fix viewport update when changing reference point uses (rna_ImaPaint_viewport_update)
===================================================================
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_paint.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/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 2ff9e92ca09..ffddc689a34 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -248,11 +248,11 @@ class VIEW3D_HT_header(Header):
if object_mode in {'PAINT_GPENCIL'}:
if context.workspace.tools.from_space_view3d_mode(object_mode).name == "Draw":
- settings = tool_settings.gpencil_sculpt
+ settings = tool_settings.gpencil_sculpt.guide
row = layout.row(align=True)
- row.prop(settings, "use_speed_guide", text="", icon='GRID')
+ row.prop(settings, "use_guide", text="", icon='GRID')
sub = row.row(align=True)
- sub.active = settings.use_speed_guide
+ sub.active = settings.use_guide
sub.popover(
panel="VIEW3D_PT_gpencil_guide",
text="Guides"
@@ -5342,22 +5342,21 @@ class VIEW3D_PT_gpencil_guide(Panel):
@staticmethod
def draw(self, context):
from math import pi
- settings = context.tool_settings.gpencil_sculpt
+ settings = context.tool_settings.gpencil_sculpt.guide
layout = self.layout
layout.label(text="Guides")
col = layout.column()
- col.prop(settings, "use_speed_guide")
+ col.prop(settings, "use_guide")
col = col.column()
- col.active = settings.use_speed_guide
-
- col.prop(settings, "guide_type", expand=True)
-
+ col.active = settings.use_guide
- if settings.guide_type in {'PARALLEL'}:
- col.prop(settings, "guide_angle")
+ 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
@@ -5368,19 +5367,19 @@ class VIEW3D_PT_gpencil_guide(Panel):
col.prop(settings, "use_snapping")
if settings.use_snapping:
- if settings.guide_type in {'RADIAL'}:
- col.prop(settings, "guide_angle_snap")
+ if settings.type in {'RADIAL'}:
+ col.prop(settings, "angle_snap")
else:
- col.prop(settings, "guide_spacing")
+ col.prop(settings, "spacing")
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'}:
+ 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")
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index 5e4e950cf9d..c902aa8c5d5 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -466,12 +466,11 @@ 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);
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);
@@ -494,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 309412ae08b..1bae41ce035 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -189,7 +189,6 @@ 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;
}
@@ -716,7 +715,7 @@ void BKE_scene_init(Scene *sce)
CURVE_PRESET_BELL,
CURVEMAP_SLOPE_POSITIVE);
- sce->toolsettings->gp_sculpt.guide_reference_object = NULL;
+ sce->toolsettings->gp_sculpt.guide.spacing = 20.0f;
sce->physics_settings.gravity[0] = 0.0f;
sce->physics_settings.gravity[1] = 0.0f;
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 443bbf5bb5c..78c061ffdc8 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6003,8 +6003,9 @@ 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);
+ 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 a38a71b426f..3cfe2673618 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -394,7 +394,7 @@ GPUBatch *DRW_gpencil_get_buffer_ctrlpoint_geom(bGPdata *gpd)
Scene *scene = draw_ctx->scene;
ToolSettings *ts = scene->toolsettings;
- if (ts->gp_sculpt.use_speed_guide) {
+ if (ts->gp_sculpt.guide.use_guide) {
totpoints++;
}
@@ -423,17 +423,17 @@ GPUBatch *DRW_gpencil_get_buffer_ctrlpoint_geom(bGPdata *gpd)
idx++;
}
- if (ts->gp_sculpt.use_speed_guide) {
+ 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 == 1) {
+ 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_origin);
+ copy_v3_v3(position, ts->gp_sculpt.guide.location);
}
- else if (ts->gp_sculpt.guide_reference_point == 2 && ts->gp_sculpt.guide_reference_object != NULL) {
+ 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);
+ copy_v3_v3(position, ts->gp_sculpt.guide.reference_object->loc);
}
else {
UI_GetThemeColor4fv(TH_REDALERT, color);
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 5f37e0be006..8d6ac04bdda 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -1244,7 +1244,7 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data, void *vedata, T
/* 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.use_speed_guide && (draw_ctx->object_mode == OB_MODE_PAINT_GPENCIL));
+ const bool is_speed_guide = (ts->gp_sculpt.guide.use_guide && (draw_ctx->object_mode == OB_MODE_PAINT_GPENCIL));
const bool is_show_gizmo = (((v3d->gizmo_flag & V3D_GIZMO_HIDE) == 0) && ((v3d->gizmo_flag & V3D_GIZMO_HIDE_TOOL) == 0));
if ((overlay) && (is_cppoint || is_speed_guide) && (is_show_gizmo) &&
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 70cbb68b1ad..e146ab20d95 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -122,14 +122,6 @@ 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
*/
@@ -2445,7 +2437,14 @@ static void gpencil_draw_status_indicators(bContext *C, tGPsdata *p)
"Esc/RMB to cancel"));
break;
case GP_PAINTMODE_DRAW:
- ED_workspace_status_text(C, IFACE_("Grease Pencil Freehand Session: Hold and drag LMB to draw"));
+ GP_Sculpt_Guide guide = p->scene->toolsettings->gp_sculpt.guide;
+ if (guide.use_guide) {
+ ED_workspace_status
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list