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.
This commit is contained in:
@@ -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="")
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 ------------------ */
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user