Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonioya <blendergit@gmail.com>2018-10-30 14:59:36 +0300
committerAntonioya <blendergit@gmail.com>2018-10-30 14:59:58 +0300
commit500fbfd02a1cae02ecf34d6fe49748b3c1b8ac05 (patch)
tree3976828b8b7a0bae7041d1b9c5d1522e6d21341b /source/blender/editors
parent5f0cee26f059af47877f69c3e0d782d25455a2ad (diff)
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.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c18
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c30
-rw-r--r--source/blender/editors/include/ED_gpencil.h3
-rw-r--r--source/blender/editors/render/render_opengl.c4
4 files changed, 36 insertions, 19 deletions
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");