[Bf-blender-cvs] [500fbfd02a1] blender2.8: GP: Back Stroke projection mode
Antonioya
noreply at git.blender.org
Tue Oct 30 13:00:08 CET 2018
Commit: 500fbfd02a1cae02ecf34d6fe49748b3c1b8ac05
Author: Antonioya
Date: Tue Oct 30 12:59:36 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB500fbfd02a1cae02ecf34d6fe49748b3c1b8ac05
GP: Back Stroke projection mode
Back the old 2.7x stroke mode when drawing. This mode try to project the new strokes over the previous strokes.
===================================================================
M release/scripts/startup/bl_ui/space_topbar.py
M release/scripts/startup/bl_ui/space_view3d.py
M source/blender/editors/gpencil/drawgpencil.c
M source/blender/editors/gpencil/gpencil_paint.c
M source/blender/editors/include/ED_gpencil.h
M source/blender/editors/render/render_opengl.c
M source/blender/makesrna/intern/rna_scene.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index db6c6037e47..31d01fcc891 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -215,6 +215,8 @@ class TOPBAR_HT_lower_bar(Header):
layout.prop(tool_settings, "use_gpencil_draw_onback", text="", icon='XRAY')
layout.prop(tool_settings, "use_gpencil_weight_data_add", text="", icon='WPAINT_HLT')
layout.prop(tool_settings, "use_gpencil_additive_drawing", text="", icon='FREEZE')
+ if tool_settings.gpencil_stroke_placement_view3d == 'STROKE':
+ layout.prop(tool_settings, "use_gpencil_stroke_endpoints", text="", icon='CURVE_DATA')
elif tool_space_type == 'IMAGE_EDITOR':
if tool_mode == 'PAINT':
layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".imagepaint_2d", category="")
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 4fa971b77cf..c00028495be 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -233,7 +233,9 @@ class VIEW3D_HT_header(Header):
lk_icon = getattr(gp_lock, "icon", "BLANK1")
lk_name = getattr(gp_lock, "name", "None")
- layout.popover(
+ row = layout.row()
+ row.enabled = tool_settings.gpencil_stroke_placement_view3d in {'ORIGIN', 'CURSOR'}
+ row.popover(
panel="VIEW3D_PT_gpencil_lock",
text=lk_name,
icon=lk_icon,
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index d64c3faae1b..5b1b8d8a884 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -750,7 +750,7 @@ static void gp_draw_stroke_3d(tGPDdraw *tgpw, short thickness, const float ink[4
immBindBuiltinProgram(GPU_SHADER_GPENCIL_STROKE);
immUniform2fv("Viewport", viewport);
immUniform1f("pixsize", tgpw->rv3d->pixsize);
- float obj_scale = (tgpw->ob->size[0] + tgpw->ob->size[1] + tgpw->ob->size[2]) / 3.0f;
+ float obj_scale = tgpw->ob ? (tgpw->ob->size[0] + tgpw->ob->size[1] + tgpw->ob->size[2]) / 3.0f : 1.0f;
immUniform1f("objscale", obj_scale);
int keep_size = (int)((tgpw->gpd) && (tgpw->gpd->flag & GP_DATA_STROKE_KEEPTHICKNESS));
@@ -1674,12 +1674,14 @@ static void gp_draw_data(RegionView3D *rv3d,
/* if we have strokes for scenes (3d view)/clips (movie clip editor)
* and objects/tracks, multiple data blocks have to be drawn */
static void gp_draw_data_all(
- RegionView3D *rv3d, Scene *scene, bGPdata *gpd, int offsx, int offsy, int winx, int winy,
+ ViewLayer *view_layer, RegionView3D *rv3d, Scene *scene, bGPdata *gpd,
+ int offsx, int offsy, int winx, int winy,
int cfra, int dflag, const char UNUSED(spacetype))
{
bGPdata *gpd_source = NULL;
ToolSettings *ts = NULL;
Brush *brush = NULL;
+ Object *ob = OBACT(view_layer);
if (scene) {
ts = scene->toolsettings;
brush = BKE_brush_getactive_gpencil(ts);
@@ -1687,7 +1689,7 @@ static void gp_draw_data_all(
if (gpd_source) {
if (brush != NULL) {
gp_draw_data(
- rv3d, brush, 1.0f, NULL, gpd_source,
+ rv3d, brush, 1.0f, ob, gpd_source,
offsx, offsy, winx, winy, cfra, dflag);
}
}
@@ -1698,7 +1700,7 @@ static void gp_draw_data_all(
if (gpd_source == NULL || (gpd_source && gpd_source != gpd)) {
if (brush != NULL) {
gp_draw_data(
- rv3d, brush, 1.0f, NULL, gpd,
+ rv3d, brush, 1.0f, ob, gpd,
offsx, offsy, winx, winy, cfra, dflag);
}
}
@@ -1768,7 +1770,7 @@ void ED_gpencil_draw_view3d(
}
/* draw it! */
- gp_draw_data_all(rv3d, scene, gpd, offsx, offsy, winx, winy, CFRA, dflag, v3d->spacetype);
+ gp_draw_data_all(view_layer, rv3d, scene, gpd, offsx, offsy, winx, winy, CFRA, dflag, v3d->spacetype);
}
/* draw grease-pencil sketches to specified 3d-view for gp object
@@ -1832,9 +1834,11 @@ void ED_gpencil_draw_view3d_object(wmWindowManager *wm, Scene *scene, Depsgraph
}
}
-void ED_gpencil_draw_ex(RegionView3D *rv3d, Scene *scene, bGPdata *gpd, int winx, int winy, const int cfra, const char spacetype)
+void ED_gpencil_draw_ex(
+ ViewLayer *view_layer, RegionView3D *rv3d, Scene *scene,
+ bGPdata *gpd, int winx, int winy, const int cfra, const char spacetype)
{
int dflag = GP_DRAWDATA_NOSTATUS | GP_DRAWDATA_ONLYV2D;
- gp_draw_data_all(rv3d, scene, gpd, 0, 0, winx, winy, cfra, dflag, spacetype);
+ gp_draw_data_all(view_layer, rv3d, scene, gpd, 0, 0, winx, winy, cfra, dflag, spacetype);
}
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 4e45db6aa76..a812b7377c3 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -708,12 +708,11 @@ static short gp_stroke_addpoint(
gp_get_3d_reference(p, origin);
/* reproject current */
ED_gpencil_tpoint_to_point(p->ar, origin, pt, &spt);
- ED_gp_project_point_to_plane(obact, rv3d, origin, ts->gp_sculpt.lock_axis - 1, &spt);
+ ED_gp_project_point_to_plane(obact, rv3d, origin, p->lock_axis - 1, &spt);
/* reproject previous */
ED_gpencil_tpoint_to_point(p->ar, origin, ptb, &spt2);
- ED_gp_project_point_to_plane(obact, rv3d, origin, ts->gp_sculpt.lock_axis - 1, &spt2);
-
+ ED_gp_project_point_to_plane(obact, rv3d, origin, p->lock_axis - 1, &spt2);
p->totpixlen += len_v3v3(&spt.x, &spt2.x) / pixsize;
pt->uv_fac = p->totpixlen;
if ((gp_style) && (gp_style->sima)) {
@@ -1042,26 +1041,30 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
}
else {
if (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE_ENDPOINTS) {
- /* remove all info between the valid endpoints */
int first_valid = 0;
int last_valid = 0;
+ /* find first valid contact point */
for (i = 0; i < gpd->runtime.sbuffer_size; i++) {
if (depth_arr[i] != FLT_MAX)
break;
}
first_valid = i;
+ /* find last valid contact point */
for (i = gpd->runtime.sbuffer_size - 1; i >= 0; i--) {
if (depth_arr[i] != FLT_MAX)
break;
}
last_valid = i;
- /* invalidate non-endpoints, so only blend between first and last */
- for (i = first_valid + 1; i < last_valid; i++)
- depth_arr[i] = FLT_MAX;
-
+ /* invalidate any point other point, to interpolate between
+ * first and last contact in an imaginary line between them */
+ for (i = 0; i < gpd->runtime.sbuffer_size; i++) {
+ if ((i != first_valid) && (i != last_valid)) {
+ depth_arr[i] = FLT_MAX;
+ }
+ }
interp_depth = true;
}
@@ -1872,8 +1875,15 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
gp_init_colors(p);
}
- /* lock axis */
- p->lock_axis = ts->gp_sculpt.lock_axis;
+ /* lock axis (in some modes, disable) */
+ if (((*p->align_flag & GP_PROJECT_DEPTH_VIEW) == 0) &&
+ ((*p->align_flag & GP_PROJECT_DEPTH_STROKE) == 0))
+ {
+ p->lock_axis = ts->gp_sculpt.lock_axis;
+ }
+ else {
+ p->lock_axis = 0;
+ }
/* region where paint was originated */
p->gpd->runtime.ar = CTX_wm_region(C);
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index f00063755d2..0b69ebeb758 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -162,7 +162,8 @@ void ED_gpencil_draw_view3d_object(
struct ARegion *ar,
bool only3d);
void ED_gpencil_draw_ex(
- struct RegionView3D *rv3d, struct Scene *scene, struct bGPdata *gpd, int winx, int winy,
+ struct ViewLayer *view_layer, struct RegionView3D *rv3d, struct Scene *scene,
+ struct bGPdata *gpd, int winx, int winy,
const int cfra, const char spacetype);
/* ----------- Grease-Pencil AnimEdit API ------------------ */
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index ed7950f3993..3609ea51c28 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -269,6 +269,7 @@ static void screen_opengl_views_setup(OGLRender *oglrender)
static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, RenderResult *rr)
{
Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
Scene *scene = oglrender->scene;
ARegion *ar = oglrender->ar;
View3D *v3d = oglrender->v3d;
@@ -329,7 +330,8 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
GPU_matrix_translate_2f(sizex / 2, sizey / 2);
G.f |= G_RENDER_OGL;
- ED_gpencil_draw_ex(rv3d, scene, gpd, sizex, sizey, scene->r.cfra, SPACE_SEQ);
+ ED_gpencil_draw_ex(
+ view_layer, rv3d, scene, gpd, sizex, sizey, scene->r.cfra, SPACE_SEQ);
G.f &= ~G_RENDER_OGL;
gp_rect = MEM_mallocN(sizex * sizey * sizeof(unsigned char) * 4, "offscreen rect");
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 94349c5835a..46f29267929 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2225,6 +2225,7 @@ static void rna_def_tool_settings(BlenderRNA *brna)
{GP_PROJECT_VIEWSPACE, "ORIGIN", ICON_OBJECT_ORIGIN, "Origin", "Draw stroke at Object origin"},
{GP_PROJECT_VIEWSPACE | GP_PROJECT_CURSOR, "CURSOR", ICON_PIVOT_CURSOR, "3D Cursor", "Draw stroke at 3D cursor location" },
{GP_PROJECT_VIEWSPACE | GP_PROJECT_DEPTH_VIEW, "SURFACE", ICON_SNAP_FACE, "Surface", "Stick stroke to surfaces"},
+ {GP_PROJECT_VIEWSPACE | GP_PROJECT_DEPTH_STROKE, "STROKE", ICON_GP_STROKE, "Stroke", "Stick stroke to other strokes"},
{0, NULL, 0, NULL, NULL}
};
More information about the Bf-blender-cvs
mailing list