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-11-28 21:19:01 +0300
committerAntonioya <blendergit@gmail.com>2018-11-28 21:19:53 +0300
commit303b49ea37b7e1be96f357436428806b950897c1 (patch)
treeefbbab9298dd67125a5cd220fff0c1a6527c09d8 /source/blender/editors/gpencil/annotate_draw.c
parent565de7750b95db4296c421de9e96a8d334319e03 (diff)
Add Onion Skin support to Annotations
The old onion skinning used in 2.7x has been ported and converted to 2.8. Only basic features have been included. For more advanced onion skin features, use grease pencil objects. Onion Skin is supported in View 3D and Sequencer.
Diffstat (limited to 'source/blender/editors/gpencil/annotate_draw.c')
-rw-r--r--source/blender/editors/gpencil/annotate_draw.c98
1 files changed, 91 insertions, 7 deletions
diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c
index c83015675a0..345a623a234 100644
--- a/source/blender/editors/gpencil/annotate_draw.c
+++ b/source/blender/editors/gpencil/annotate_draw.c
@@ -242,7 +242,7 @@ static void gp_draw_stroke_point(
/* draw a given stroke in 3d (i.e. in 3d-space), using simple ogl lines */
static void gp_draw_stroke_3d(
- const bGPDspoint *points, int totpoints, short thickness, bool UNUSED(debug),
+ const bGPDspoint *points, int totpoints, short thickness,
short UNUSED(sflag), const float ink[4], bool cyclic)
{
float curpressure = points[0].pressure;
@@ -323,7 +323,7 @@ static void gp_draw_stroke_3d(
/* draw a given stroke in 2d */
static void gp_draw_stroke_2d(
const bGPDspoint *points, int totpoints, short thickness_s, short dflag, short sflag,
- bool UNUSED(debug), int offsx, int offsy, int winx, int winy, const float ink[4])
+ int offsx, int offsy, int winx, int winy, const float ink[4])
{
/* otherwise thickness is twice that of the 3D view */
float thickness = (float)thickness_s * 0.5f;
@@ -521,7 +521,7 @@ static bool gp_can_draw_stroke(const bGPDstroke *gps, const int dflag)
/* draw a set of strokes */
static void gp_draw_strokes(
bGPdata *UNUSED(gpd), bGPDlayer *UNUSED(gpl), const bGPDframe *gpf, int offsx, int offsy, int winx, int winy,
- int dflag, bool debug, short lthick, const float color[4])
+ int dflag, short lthick, const float color[4])
{
GPU_enable_program_point_size();
@@ -552,7 +552,7 @@ static void gp_draw_strokes(
}
else {
gp_draw_stroke_3d(
- gps->points, gps->totpoints, lthick, debug, gps->flag,
+ gps->points, gps->totpoints, lthick, gps->flag,
color, gps->flag & GP_STROKE_CYCLIC);
}
@@ -570,7 +570,7 @@ static void gp_draw_strokes(
}
else {
gp_draw_stroke_2d(
- gps->points, gps->totpoints, lthick, dflag, gps->flag, debug,
+ gps->points, gps->totpoints, lthick, dflag, gps->flag,
offsx, offsy, winx, winy, color);
}
}
@@ -714,6 +714,86 @@ static void gp_draw_strokes_edit(
}
/* ----- General Drawing ------ */
+/* draw onion-skinning for a layer */
+static void gp_draw_onionskins(
+ bGPdata *gpd, bGPDlayer *gpl, bGPDframe *gpf, int offsx, int offsy, int winx, int winy,
+ int UNUSED(cfra), int dflag)
+{
+ const float alpha = 1.0f;
+ float color[4];
+
+ /* 1) Draw Previous Frames First */
+ copy_v3_v3(color, gpl->gcolor_prev);
+
+ if (gpl->gstep > 0) {
+ bGPDframe *gf;
+ float fac;
+
+ /* draw previous frames first */
+ for (gf = gpf->prev; gf; gf = gf->prev) {
+ /* check if frame is drawable */
+ if ((gpf->framenum - gf->framenum) <= gpl->gstep) {
+ /* alpha decreases with distance from curframe index */
+ fac = 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpl->gstep + 1));
+ color[3] = alpha * fac * 0.66f;
+ gp_draw_strokes(
+ gpd, gpl, gf, offsx, offsy, winx, winy, dflag,
+ gpl->thickness, color);
+ }
+ else
+ break;
+ }
+ }
+ else if (gpl->gstep == 0) {
+ /* draw the strokes for the ghost frames (at half of the alpha set by user) */
+ if (gpf->prev) {
+ color[3] = (alpha / 7);
+ gp_draw_strokes(
+ gpd, gpl, gpf->prev, offsx, offsy, winx, winy, dflag,
+ gpl->thickness, color);
+ }
+ }
+ else {
+ /* don't draw - disabled */
+ }
+
+
+ /* 2) Now draw next frames */
+ copy_v3_v3(color, gpl->gcolor_next);
+
+ if (gpl->gstep_next > 0) {
+ bGPDframe *gf;
+ float fac;
+
+ /* now draw next frames */
+ for (gf = gpf->next; gf; gf = gf->next) {
+ /* check if frame is drawable */
+ if ((gf->framenum - gpf->framenum) <= gpl->gstep_next) {
+ /* alpha decreases with distance from curframe index */
+ fac = 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(gpl->gstep_next + 1));
+ color[3] = alpha * fac * 0.66f;
+ gp_draw_strokes(
+ gpd, gpl, gf, offsx, offsy, winx, winy, dflag,
+ gpl->thickness, color);
+ }
+ else
+ break;
+ }
+ }
+ else if (gpl->gstep_next == 0) {
+ /* draw the strokes for the ghost frames (at half of the alpha set by user) */
+ if (gpf->next) {
+ color[3] = (alpha / 4);
+ gp_draw_strokes(
+ gpd, gpl, gpf->next, offsx, offsy, winx, winy, dflag,
+ gpl->thickness, color);
+ }
+ }
+ else {
+ /* don't draw - disabled */
+ }
+
+}
/* loop over gpencil data layers, drawing them */
static void gp_draw_data_layers(
@@ -723,7 +803,6 @@ static void gp_draw_data_layers(
float ink[4];
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- bool debug = (gpl->flag & GP_LAYER_DRAWDEBUG);
short lthick = gpl->thickness;
/* apply layer opacity */
@@ -750,8 +829,13 @@ static void gp_draw_data_layers(
/* xray... */
SET_FLAG_FROM_TEST(dflag, gpl->flag & GP_LAYER_NO_XRAY, GP_DRAWDATA_NO_XRAY);
+ /* Draw 'onionskins' (frame left + right) */
+ if (gpl->onion_flag & GP_LAYER_ONIONSKIN) {
+ gp_draw_onionskins(gpd, gpl, gpf, offsx, offsy, winx, winy, cfra, dflag);
+ }
+
/* draw the strokes already in active frame */
- gp_draw_strokes(gpd, gpl, gpf, offsx, offsy, winx, winy, dflag, debug, lthick, ink);
+ gp_draw_strokes(gpd, gpl, gpf, offsx, offsy, winx, winy, dflag, lthick, ink);
/* Draw verts of selected strokes
* - when doing OpenGL renders, we don't want to be showing these, as that ends up flickering