[Bf-blender-cvs] [b31f3c556d6] greasepencil-object: WIP: Reorganize parameters in old draw mode
Antonio Vazquez
noreply at git.blender.org
Sun Jan 7 20:27:35 CET 2018
Commit: b31f3c556d6bfd852cd8eb346beb9cb38758561d
Author: Antonio Vazquez
Date: Sun Jan 7 17:22:08 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rBb31f3c556d6bfd852cd8eb346beb9cb38758561d
WIP: Reorganize parameters in old draw mode
The list of parameters was too long and it's better pass a struct.
This is the first step to use the new shaders with the same functions of Draw manager. This is used in interpolations, filling and primitives while the operator is running.
===================================================================
M source/blender/editors/gpencil/drawgpencil.c
M source/blender/editors/include/ED_gpencil.h
M source/blender/editors/render/render_opengl.c
===================================================================
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index f5d25b7fad9..7cb262abb04 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -713,16 +713,14 @@ static void gp_draw_stroke_point(
}
/* draw a given stroke in 3d (i.e. in 3d-space) */
-static void gp_draw_stroke_3d(
- const bGPDspoint *points, int totpoints, short thickness, bool UNUSED(debug),
- short UNUSED(sflag), const float diff_mat[4][4], const float ink[4], bool cyclic,
- int winx, int winy, int offsx, int offsy)
+static void gp_draw_stroke_3d(tGPDdraw *tgpw, short thickness, const float ink[4], bool cyclic)
{
- float viewport[2] = { winx, winy };
- float offset[2] = { offsx, offsy };
+ bGPDspoint *points = tgpw->gps->points;
+ int totpoints = tgpw->gps->totpoints;
+
+ float viewport[2] = { tgpw->winx, tgpw->winy };
float curpressure = points[0].pressure;
float fpt[3];
- UNUSED_VARS(offset);
/* if cyclic needs more vertex */
int cyclic_add = (cyclic) ? 1 : 0;
@@ -747,10 +745,10 @@ static void gp_draw_stroke_3d(
gp_set_point_varying_color(points, ink, color);
immAttrib1f(thickattrib, max_ff(curpressure * thickness, 1.0f));
if ((cyclic) && (totpoints > 2)) {
- mul_v3_m4v3(fpt, diff_mat, &(points + totpoints - 1)->x);
+ mul_v3_m4v3(fpt, tgpw->diff_mat, &(points + totpoints - 1)->x);
}
else {
- mul_v3_m4v3(fpt, diff_mat, &(points + 1)->x);
+ mul_v3_m4v3(fpt, tgpw->diff_mat, &(points + 1)->x);
}
mul_v3_fl(fpt, -1.0f);
immVertex3fv(pos, fpt);
@@ -758,7 +756,7 @@ static void gp_draw_stroke_3d(
/* set point */
gp_set_point_varying_color(pt, ink, color);
immAttrib1f(thickattrib, max_ff(curpressure * thickness, 1.0f));
- mul_v3_m4v3(fpt, diff_mat, &pt->x);
+ mul_v3_m4v3(fpt, tgpw->diff_mat, &pt->x);
immVertex3fv(pos, fpt);
curpressure = pt->pressure;
@@ -767,19 +765,19 @@ static void gp_draw_stroke_3d(
if (cyclic && totpoints > 2) {
/* draw line to first point to complete the cycle */
immAttrib1f(thickattrib, max_ff(points->pressure * thickness, 1.0f));
- mul_v3_m4v3(fpt, diff_mat, &points->x);
+ mul_v3_m4v3(fpt, tgpw->diff_mat, &points->x);
immVertex3fv(pos, fpt);
/* now add adjacency point (not drawn) */
immAttrib1f(thickattrib, max_ff((points + 1)->pressure * thickness, 1.0f));
- mul_v3_m4v3(fpt, diff_mat, &(points + 1)->x);
+ mul_v3_m4v3(fpt, tgpw->diff_mat, &(points + 1)->x);
immVertex3fv(pos, fpt);
}
/* last adjacency point (not drawn) */
else {
gp_set_point_varying_color(points + totpoints - 1, ink, color);
immAttrib1f(thickattrib, max_ff(curpressure * thickness, 1.0f));
- mul_v3_m4v3(fpt, diff_mat, &(points + totpoints - 2)->x);
+ mul_v3_m4v3(fpt, tgpw->diff_mat, &(points + totpoints - 2)->x);
mul_v3_fl(fpt, -1.0f);
immVertex3fv(pos, fpt);
}
@@ -999,10 +997,7 @@ static bool gp_can_draw_stroke(const bGPDstroke *gps, const int dflag)
}
/* draw a set of strokes */
-static void gp_draw_strokes(
- bGPdata *gpd, const bGPDframe *gpf, int offsx, int offsy, int winx, int winy, int dflag,
- bool debug, short lthick, const float opacity, const float tintcolor[4],
- const bool onion, const bool custonion, const float diff_mat[4][4])
+static void gp_draw_strokes(tGPDdraw *tgpw)
{
float tcolor[4];
float tfill[4];
@@ -1011,9 +1006,9 @@ static void gp_draw_strokes(
GPU_enable_program_point_size();
- for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
+ for (bGPDstroke *gps = tgpw->t_gpf->strokes.first; gps; gps = gps->next) {
/* check if stroke can be drawn */
- if (gp_can_draw_stroke(gps, dflag) == false) {
+ if (gp_can_draw_stroke(gps, tgpw->dflag) == false) {
continue;
}
/* check if the color is visible */
@@ -1021,21 +1016,21 @@ static void gp_draw_strokes(
if ((palcolor == NULL) ||
(palcolor->flag & PC_COLOR_HIDE) ||
/* if onion and ghost flag do not draw*/
- (onion && (palcolor->flag & PC_COLOR_ONIONSKIN)))
+ (tgpw->onion && (palcolor->flag & PC_COLOR_ONIONSKIN)))
{
continue;
}
/* calculate thickness */
- sthickness = gps->thickness + lthick;
+ sthickness = gps->thickness + tgpw->lthick;
if (sthickness <= 0) {
continue;
}
/* check which stroke-drawer to use */
- if (dflag & GP_DRAWDATA_ONLY3D) {
- const int no_xray = (dflag & GP_DRAWDATA_NO_XRAY);
+ if (tgpw->dflag & GP_DRAWDATA_ONLY3D) {
+ const int no_xray = (tgpw->dflag & GP_DRAWDATA_NO_XRAY);
int mask_orig = 0;
if (no_xray) {
@@ -1052,39 +1047,39 @@ static void gp_draw_strokes(
//if ((dflag & GP_DRAWDATA_FILL) && (gps->totpoints >= 3)) {
if (gps->totpoints >= 3) {
/* set color using palette, tint color and opacity */
- interp_v3_v3v3(tfill, palcolor->fill, tintcolor, tintcolor[3]);
- tfill[3] = palcolor->fill[3] * opacity;
+ interp_v3_v3v3(tfill, palcolor->fill, tgpw->tintcolor, tgpw->tintcolor[3]);
+ tfill[3] = palcolor->fill[3] * tgpw->opacity;
if ((tfill[3] > GPENCIL_ALPHA_OPACITY_THRESH) || (palcolor->fill_style > 0)) {
const float *color;
- if (!onion) {
+ if (!tgpw->onion) {
color = tfill;
}
else {
- if (custonion) {
- color = tintcolor;
+ if (tgpw->custonion) {
+ color = tgpw->tintcolor;
}
else {
- ARRAY_SET_ITEMS(tfill, UNPACK3(palcolor->fill), tintcolor[3]);
+ ARRAY_SET_ITEMS(tfill, UNPACK3(palcolor->fill), tgpw->tintcolor[3]);
color = tfill;
}
}
- gp_draw_stroke_fill(gpd, gps, offsx, offsy, winx, winy, diff_mat, color);
+ gp_draw_stroke_fill(tgpw->gpd, gps, tgpw->offsx, tgpw->offsy, tgpw->winx, tgpw->winy, tgpw->diff_mat, color);
}
}
/* 3D Stroke */
/* set color using palette, tint color and opacity */
- if (!onion) {
- interp_v3_v3v3(tcolor, palcolor->rgb, tintcolor, tintcolor[3]);
- tcolor[3] = palcolor->rgb[3] * opacity;
+ if (!tgpw->onion) {
+ interp_v3_v3v3(tcolor, palcolor->rgb, tgpw->tintcolor, tgpw->tintcolor[3]);
+ tcolor[3] = palcolor->rgb[3] * tgpw->opacity;
copy_v4_v4(ink, tcolor);
}
else {
- if (custonion) {
- copy_v4_v4(ink, tintcolor);
+ if (tgpw->custonion) {
+ copy_v4_v4(ink, tgpw->tintcolor);
}
else {
- ARRAY_SET_ITEMS(tcolor, palcolor->rgb[0], palcolor->rgb[1], palcolor->rgb[2], opacity);
+ ARRAY_SET_ITEMS(tcolor, palcolor->rgb[0], palcolor->rgb[1], palcolor->rgb[2], tgpw->opacity);
copy_v4_v4(ink, tcolor);
}
}
@@ -1095,13 +1090,13 @@ static void gp_draw_strokes(
else {
/* 3D Lines - OpenGL primitives-based */
if (gps->totpoints == 1) {
- gp_draw_stroke_point(gps->points, sthickness, dflag, gps->flag, offsx, offsy, winx, winy,
- diff_mat, ink);
+ gp_draw_stroke_point(gps->points, sthickness, tgpw->dflag, gps->flag,
+ tgpw->offsx, tgpw->offsy, tgpw->winx, tgpw->winy,
+ tgpw->diff_mat, ink);
}
else {
- gp_draw_stroke_3d(gps->points, gps->totpoints, sthickness, debug, gps->flag,
- diff_mat, ink, gps->flag & GP_STROKE_CYCLIC,
- winx, winy, offsx, offsy);
+ tgpw->gps = gps;
+ gp_draw_stroke_3d(tgpw, sthickness, ink, gps->flag & GP_STROKE_CYCLIC);
}
}
if (no_xray) {
@@ -1115,57 +1110,57 @@ static void gp_draw_strokes(
/* 2D - Fill */
if (gps->totpoints >= 3) {
/* set color using palette, tint color and opacity */
- interp_v3_v3v3(tfill, palcolor->fill, tintcolor, tintcolor[3]);
- tfill[3] = palcolor->fill[3] * opacity;
+ interp_v3_v3v3(tfill, palcolor->fill, tgpw->tintcolor, tgpw->tintcolor[3]);
+ tfill[3] = palcolor->fill[3] * tgpw->opacity;
if ((tfill[3] > GPENCIL_ALPHA_OPACITY_THRESH) || (palcolor->fill_style > 0)) {
const float *color;
- if (!onion) {
+ if (!tgpw->onion) {
color = tfill;
}
else {
- if (custonion) {
- color = tintcolor;
+ if (tgpw->custonion) {
+ color = tgpw->tintcolor;
}
else {
ARRAY_SET_ITEMS(tfill, palcolor->fill[0], palcolor->fill[1], palcolor->fill[2],
- tintcolor[3]);
+ tgpw->tintcolor[3]);
color = tfill;
}
}
- gp_draw_stroke_fill(gpd, gps, offsx, offsy, winx, winy, diff_mat, color);
+ gp_draw_stroke_fill(tgpw->gpd, gps, tgpw->offsx, tgpw->offsy, tgpw->winx, tgpw->winy, tgpw->diff_mat, color);
}
}
/* 2D Strokes... */
/* set color using palette, tint color and opacity */
- if (!onion) {
- interp_v3_v3v3(tcolor, palcolor->rgb, tintcolor, tintcolor[3]);
- tcolor[3] = palcolor->rgb[3] * opacity;
+ if (!tgpw->onion) {
+ interp_v3_v3v3(tcolor, palcolor->rgb, tgpw->tintcolor, tgpw->tintcolor[3]);
+ tcolor[3] = palcolor->rgb[3] * tgpw->opacity;
copy_v4_v4(ink, tcolor);
}
else {
- if (custonion) {
- copy_v4_v4(ink, tintcolor);
+ if (tgpw->custonion) {
+ copy_v4_v4(ink, tgpw->tintcolor);
}
else {
- ARRAY_SET_ITEMS(tcolor, palcolor->rgb[0], palcolor->rgb[1], palcolor->rgb[2], opacity);
+ ARRAY_SET_ITEMS(tcolor, palcolor->rgb[0], palcolor->rgb[1], palcolor->rgb[2], tgpw->opacity);
copy_v4_v4(ink, tcolor);
}
}
if (palcolor->flag & PAC_COLOR_DOT) {
/* blob/disk-based "volumetric" drawing */
- gp_draw_stroke_volumetric_2d(gps->points, gps->totpoints, sthickness, dflag, gps->flag,
- offsx, offsy, winx, winy, diff_mat, ink);
+ gp_draw_stroke_volumetric_2d(gps->points, gps->totpoints, sthickness, tgpw->dflag, gps->flag,
+ tgpw->offsx, tgpw->offsy, tgpw->winx, tgpw->winy, tgpw->diff_mat, ink);
}
else {
/* normal 2D strokes */
if (gps->totpoints == 1) {
- gp_draw_stroke_point(gps->points, sthickness, dflag, gps->flag, offsx, offsy, winx, winy,
- diff_mat, ink);
+ gp_draw_stroke_point(gps->points, sthickness, tgpw->dflag, gps->flag, tgpw->offsx, tgpw->offsy, tgpw->winx, tgpw->winy,
+ tgpw->diff_mat, ink);
}
else {
- gp_draw_stroke_2d(gps->points, gps->totpoints, sthic
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list