[Bf-blender-cvs] [7a3cf91a010] greasepencil-object: New Onion modes
Antonio Vazquez
noreply at git.blender.org
Mon Aug 21 11:24:09 CEST 2017
Commit: 7a3cf91a010d280ca740a46fa65fbb5b3bb7c544
Author: Antonio Vazquez
Date: Mon Aug 21 11:09:10 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB7a3cf91a010d280ca740a46fa65fbb5b3bb7c544
New Onion modes
Add options to set the range of frames in absolute or relative mode. Reorganized UI panel too.
===================================================================
M release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M source/blender/makesdna/DNA_gpencil_types.h
M source/blender/makesrna/intern/rna_gpencil.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index 520fea615c5..a42600850c3 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -1193,23 +1193,24 @@ class GreasePencilOnionPanel:
row.active = gpl.use_ghost_custom_colors
row.prop(gpl, "before_color", text="")
- row = sub.row(align=True)
- row.active = not gpl.onion_only_selected
- row.prop(gpl, "ghost_before_range", text="Before")
-
# - After Frames
sub = split.column(align=True)
row = sub.row(align=True)
row.active = gpl.use_ghost_custom_colors
row.prop(gpl, "after_color", text="")
- row = sub.row(align=True)
- row.active = not gpl.onion_only_selected
- row.prop(gpl, "ghost_after_range", text="After")
-
row = layout.row(align=True)
row.active = gpl.use_onion_skinning
- row.prop(gpl, "onion_only_selected", text="Only selected frames")
+ row.prop(gpl, "onion_mode", text="Mode")
+
+ split = layout.split(percentage=0.5)
+ split.active = gpl.onion_mode in ('ABSOLUTE', 'RELATIVE')
+ sub = split.column(align=True)
+ sub.prop(gpl, "ghost_before_range", text="Before")
+
+ sub = split.column(align=True)
+ sub.prop(gpl, "ghost_after_range", text="After")
+
class GreasePencilParentLayerPanel:
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 32df4143ff1..3bb0dede7b4 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -789,9 +789,12 @@ static void gpencil_draw_onionskins(GpencilBatchCache *cache, GPENCIL_e_data *e_
const float default_color[3] = { UNPACK3(U.gpencil_new_layer_col) };
const float alpha = 1.0f;
float color[4];
- bool selected = (bool)(gpl->flag & GP_LAYER_ONION_SELECTED);
+ int idx;
+ float fac = 1.0f;
- /* 1) Draw Previous Frames First */
+ /* -------------------------------
+ * 1) Draw Previous Frames First
+ * ------------------------------- */
if (gpl->flag & GP_LAYER_GHOST_PREVCOL) {
copy_v3_v3(color, gpl->gcolor_prev);
}
@@ -799,47 +802,56 @@ static void gpencil_draw_onionskins(GpencilBatchCache *cache, GPENCIL_e_data *e_
copy_v3_v3(color, default_color);
}
- if ((gpl->gstep > 0) || (selected)) {
- /* draw previous frames first */
+ if (gpl->onion_mode != GP_ONION_MODE_ZERO) {
+ idx = 0;
for (bGPDframe *gf = gpf->prev; gf; gf = gf->prev) {
/* only selected frames */
- if ((selected) && ((gf->flag & GP_FRAME_SELECT) == 0)) {
+ if ((gpl->onion_mode == GP_ONION_MODE_SELECTED) && ((gf->flag & GP_FRAME_SELECT) == 0)) {
continue;
}
- if (gf == gpl->actframe) {
- continue;
+ /* absolute range */
+ if (gpl->onion_mode == GP_ONION_MODE_ABSOLUTE) {
+ if ((gpf->framenum - gf->framenum) > gpl->gstep) {
+ continue;
+ }
}
+ /* relative range */
+ if (gpl->onion_mode == GP_ONION_MODE_RELATIVE) {
+ ++idx;
+ if (idx > gpl->gstep) {
+ continue;
+ }
- /* check if frame is drawable */
- if (((gpf->framenum - gf->framenum) <= gpl->gstep) || (selected)) {
- /* alpha decreases with distance from curframe index */
- if (!selected) {
- float fac = 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpl->gstep + 1));
- color[3] = alpha * fac * 0.66f;
+ }
+ /* alpha decreases with distance from curframe index */
+ if (gpl->onion_mode != GP_ONION_MODE_SELECTED) {
+ if (gpl->onion_mode == GP_ONION_MODE_ABSOLUTE) {
+ fac = 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpl->gstep + 1));
}
else {
- color[3] = 0.66f;
+ fac = 1.0f - ((float)idx / (float)(gpl->gstep + 1));
}
- BKE_gpencil_batch_cache_dirty(gpd);
- gpencil_draw_strokes(cache, e_data, vedata, ts, ob, gpd, gpl, gf, gf, 1.0f, color, true, gpl->flag & GP_LAYER_GHOST_PREVCOL);
+ color[3] = alpha * fac * 0.66f;
+ }
+ else {
+ color[3] = 0.66f;
}
- else
- break;
+ CLAMP_MIN(color[3], 0.66f);
+ /* draw */
+ BKE_gpencil_batch_cache_dirty(gpd);
+ gpencil_draw_strokes(cache, e_data, vedata, ts, ob, gpd, gpl, gf, gf, 1.0f, color, true, gpl->flag & GP_LAYER_GHOST_PREVCOL);
}
}
- else if (gpl->gstep == 0) {
- /* draw the strokes for the ghost frames (at half of the alpha set by user) */
+ else {
if (gpf->prev) {
color[3] = alpha * 0.7f;
BKE_gpencil_batch_cache_dirty(gpd);
gpencil_draw_strokes(cache, e_data, vedata, ts, ob, gpd, gpl, gpf->prev, gpf->prev, 1.0f, color, true, gpl->flag & GP_LAYER_GHOST_PREVCOL);
}
}
- else {
- /* don't draw - disabled */
- }
-
- /* 2) Now draw next frames */
+ /* -------------------------------
+ * 2) Now draw next frames
+ * ------------------------------- */
if (gpl->flag & GP_LAYER_GHOST_NEXTCOL) {
copy_v3_v3(color, gpl->gcolor_next);
}
@@ -847,43 +859,51 @@ static void gpencil_draw_onionskins(GpencilBatchCache *cache, GPENCIL_e_data *e_
copy_v3_v3(color, default_color);
}
- if ((gpl->gstep_next > 0) || (selected)) {
- /* now draw next frames */
+ if (gpl->onion_mode != GP_ONION_MODE_ZERO) {
+ idx = 0;
for (bGPDframe *gf = gpf->next; gf; gf = gf->next) {
/* only selected frames */
- if ((selected) && ((gf->flag & GP_FRAME_SELECT) == 0)) {
+ if ((gpl->onion_mode == GP_ONION_MODE_SELECTED) && ((gf->flag & GP_FRAME_SELECT) == 0)) {
continue;
}
- if (gf == gpl->actframe) {
- continue;
+ /* absolute range */
+ if (gpl->onion_mode == GP_ONION_MODE_ABSOLUTE) {
+ if ((gf->framenum - gpf->framenum) > gpl->gstep_next) {
+ continue;
+ }
+ }
+ /* relative range */
+ if (gpl->onion_mode == GP_ONION_MODE_RELATIVE) {
+ ++idx;
+ if (idx > gpl->gstep) {
+ continue;
+ }
+
}
- /* check if frame is drawable */
- if (((gf->framenum - gpf->framenum) <= gpl->gstep_next) || (selected)) {
- if (!selected) {
- /* alpha decreases with distance from curframe index */
- float fac = 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(gpl->gstep_next + 1));
- color[3] = alpha * fac * 0.66f;
+ /* alpha decreases with distance from curframe index */
+ if (gpl->onion_mode != GP_ONION_MODE_SELECTED) {
+ if (gpl->onion_mode == GP_ONION_MODE_ABSOLUTE) {
+ fac = 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(gpl->gstep_next + 1));
}
else {
- color[3] = 0.66f;
+ fac = 1.0f - ((float)idx / (float)(gpl->gstep + 1));
}
- BKE_gpencil_batch_cache_dirty(gpd);
- gpencil_draw_strokes(cache, e_data, vedata, ts, ob, gpd, gpl, gf, gf, 1.0f, color, true, gpl->flag & GP_LAYER_GHOST_NEXTCOL);
+ color[3] = alpha * fac * 0.66f;
}
- else
- break;
+ else {
+ color[3] = 0.66f;
+ }
+ CLAMP_MIN(color[3], 0.66f);
+ BKE_gpencil_batch_cache_dirty(gpd);
+ gpencil_draw_strokes(cache, e_data, vedata, ts, ob, gpd, gpl, gf, gf, 1.0f, color, true, gpl->flag & GP_LAYER_GHOST_NEXTCOL);
}
}
- else if (gpl->gstep_next == 0) {
- /* draw the strokes for the ghost frames (at half of the alpha set by user) */
+ else {
if (gpf->next) {
color[3] = alpha * 0.7f;
gpencil_draw_strokes(cache, e_data, vedata, ts, ob, gpd, gpl, gpf->next, gpf->next, 1.0f, color, true, gpl->flag & GP_LAYER_GHOST_NEXTCOL);
}
}
- else {
- /* don't draw - disabled */
- }
}
/* helper for populate a complete grease pencil datablock */
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index e147ae97fc5..c504781a263 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -268,6 +268,8 @@ typedef struct bGPDlayer {
float tintcolor[4]; /* Color used to tint layer, alpha value is used as factor */
float opacity; /* Opacity of the layer */
+ int onion_mode; /* onion mode */
+ char pad2[4];
struct GHash *derived_data; /* runtime data created by modifiers */
} bGPDlayer;
@@ -301,9 +303,6 @@ typedef enum eGPDlayer_Flag {
GP_LAYER_GHOST_ALWAYS = (1 << 13),
/* draw new strokes using last stroke location (only in 3d view) */
GP_LAYER_USE_LOCATION = (1 << 14),
- /* only onion of selected frames */
- GP_LAYER_ONION_SELECTED = (1 << 15),
-
} eGPDlayer_Flag;
/* xray modes */
@@ -313,6 +312,14 @@ typedef enum eGP_Xraymodes_Types {
GP_XRAY_BACK = 2
} eGP_Xraymodes_Types;
+/* onion modes */
+typedef enum eGP_onion_modes_Types {
+ GP_ONION_MODE_ZERO = 0,
+ GP_ONION_MODE_ABSOLUTE = 1,
+ GP_ONION_MODE_RELATIVE = 2,
+ GP_ONION_MODE_SELECTED = 3,
+} eGP_onion_modes_Types;
+
/* Grease-Pencil Annotations - 'DataBlock' */
typedef struct bGPdata {
ID id; /* Grease Pencil data is a datablock */
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 4cbf6b5fa30..ac91753e1b9 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -61,6 +61,14 @@ static EnumPropertyItem rna_enum_gpencil_xraymodes_items[] = {
{ GP_XRAY_BACK, "BACK", 0, "Back", "Draw all strokes on back" },
{ 0, NULL, 0, NULL, NULL }
};
+
+static EnumPropertyItem rna_enum_gpencil_onion_modes_items[] = {
+ { GP_ONION_MODE_ZERO, "ZERO", 0, "Previous/Next", "Previous and Next frame" },
+ { GP_ONION_MODE_ABSOLUTE, "ABSOLUTE", 0, "Absolute", "Frames in absolute range of scene frame number" },
+ { GP_ONION_MODE_RELATIVE, "RELATIVE", 0, "Relative", "Frames in relative range of grease pencil keyframes" },
+ { GP_ONION_MODE_SELECTED, "SELECTED", 0, "Selected", "Only Selected Frames" },
+ { 0, NULL, 0, NULL, NULL }
+};
#endif
#ifdef RNA_RUNTIME
@@ -1133,9 +1141,11 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Is Parented", "True when the layer parent object is set");
- prop = RNA_def_property(srna, "onion_only_selected", PROP_BOOLEAN, PROP_NONE);
- RNA_def_
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list