wasnt setting the struct size for normal brush types (was testing smear + clone but not paint)
some disabled WIP too
This commit is contained in:
parent
a331848092
commit
8a61376c65
@ -64,6 +64,7 @@
|
|||||||
#include "DNA_space_types.h"
|
#include "DNA_space_types.h"
|
||||||
#include "DNA_userdef_types.h"
|
#include "DNA_userdef_types.h"
|
||||||
#include "DNA_view3d_types.h"
|
#include "DNA_view3d_types.h"
|
||||||
|
#include "DNA_gpencil_types.h"
|
||||||
|
|
||||||
#include "BKE_brush.h"
|
#include "BKE_brush.h"
|
||||||
#include "BKE_global.h"
|
#include "BKE_global.h"
|
||||||
@ -87,7 +88,7 @@
|
|||||||
|
|
||||||
#include "BDR_imagepaint.h"
|
#include "BDR_imagepaint.h"
|
||||||
#include "BDR_vpaint.h"
|
#include "BDR_vpaint.h"
|
||||||
|
#include "BDR_gpencil.h"
|
||||||
#include "GPU_draw.h"
|
#include "GPU_draw.h"
|
||||||
|
|
||||||
#include "GHOST_Types.h"
|
#include "GHOST_Types.h"
|
||||||
@ -1300,6 +1301,8 @@ static void project_paint_uvpixel_init(ProjectPaintState *ps, ImBuf *ibuf, int x
|
|||||||
}
|
}
|
||||||
} else if (ps->tool==PAINT_TOOL_SMEAR) {
|
} else if (ps->tool==PAINT_TOOL_SMEAR) {
|
||||||
size = sizeof(ProjectPixelClone);
|
size = sizeof(ProjectPixelClone);
|
||||||
|
} else {
|
||||||
|
size = sizeof(ProjectPixel);
|
||||||
}
|
}
|
||||||
|
|
||||||
projPixel = (ProjectPixel *)BLI_memarena_alloc(ps->projectArena, size);
|
projPixel = (ProjectPixel *)BLI_memarena_alloc(ps->projectArena, size);
|
||||||
@ -3013,16 +3016,16 @@ static void imapaint_paint_stroke(ImagePaintState *s, BrushPainter *painter, sho
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void imapaint_paint_stroke_project(ProjectPaintState *ps, BrushPainter *painter, short *prevmval, short *mval, double time, float pressure)
|
static void imapaint_paint_stroke_project(ProjectPaintState *ps, BrushPainter *painter, short *prevmval, short *mval, short redraw, double time, float pressure)
|
||||||
{
|
{
|
||||||
int redraw = 0;
|
int redraw_flag = 0;
|
||||||
|
|
||||||
/* TODO - support more brush operations, airbrush etc */
|
/* TODO - support more brush operations, airbrush etc */
|
||||||
{
|
{
|
||||||
redraw |= imapaint_paint_sub_stroke_project(ps, painter, prevmval, mval, time, 1, pressure);
|
redraw_flag |= imapaint_paint_sub_stroke_project(ps, painter, prevmval, mval, time, 1, pressure);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (redraw) {
|
if (redraw && redraw_flag) {
|
||||||
imapaint_redraw(0, 1/*texpaint*/, NULL);
|
imapaint_redraw(0, 1/*texpaint*/, NULL);
|
||||||
imapaint_clear_partial_redraw();
|
imapaint_clear_partial_redraw();
|
||||||
}
|
}
|
||||||
@ -3038,6 +3041,15 @@ void imagepaint_paint(short mousebutton, short texpaint)
|
|||||||
double time;
|
double time;
|
||||||
float pressure;
|
float pressure;
|
||||||
|
|
||||||
|
/* optional grease pencil stroke path */
|
||||||
|
bGPdata *gpd;
|
||||||
|
bGPDlayer *gpl;
|
||||||
|
int stroke_gp = 0;
|
||||||
|
int index_gp = 0;
|
||||||
|
int tot_gp = 0;
|
||||||
|
float *points_gp=NULL;
|
||||||
|
float *vec_gp;
|
||||||
|
|
||||||
if(!settings->imapaint.brush)
|
if(!settings->imapaint.brush)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -3049,6 +3061,10 @@ void imagepaint_paint(short mousebutton, short texpaint)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO - add UI */
|
||||||
|
stroke_gp = 0;
|
||||||
|
|
||||||
|
|
||||||
/* initialize state */
|
/* initialize state */
|
||||||
memset(&s, 0, sizeof(s));
|
memset(&s, 0, sizeof(s));
|
||||||
memset(&ps, 0, sizeof(ps));
|
memset(&ps, 0, sizeof(ps));
|
||||||
@ -3109,6 +3125,72 @@ void imagepaint_paint(short mousebutton, short texpaint)
|
|||||||
#endif
|
#endif
|
||||||
project_paint_begin(&ps, mval);
|
project_paint_begin(&ps, mval);
|
||||||
|
|
||||||
|
if (stroke_gp && (gpd = gpencil_data_getactive(NULL))) {
|
||||||
|
} else {
|
||||||
|
stroke_gp = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stroke_gp) {
|
||||||
|
|
||||||
|
for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
|
||||||
|
bGPDframe *gpf;
|
||||||
|
bGPDstroke *gps;
|
||||||
|
tGPspoint *pt;
|
||||||
|
|
||||||
|
if (gpl->flag & GP_LAYER_HIDE) continue;
|
||||||
|
|
||||||
|
gpf= gpencil_layer_getframe(gpl, CFRA, 0);
|
||||||
|
if (gpf==NULL) continue;
|
||||||
|
|
||||||
|
for (gps= gpf->strokes.first; gps; gps= gps->next) {
|
||||||
|
//if (gps->flag & GP_STROKE_2DSPACE) {
|
||||||
|
tot_gp += gps->totpoints;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (tot_gp) {
|
||||||
|
points_gp = MEM_mallocN(tot_gp*sizeof(float)*2, "gp_points");
|
||||||
|
vec_gp = points_gp;
|
||||||
|
|
||||||
|
printf("%d\n" ,tot_gp);
|
||||||
|
|
||||||
|
for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
|
||||||
|
bGPDframe *gpf;
|
||||||
|
bGPDstroke *gps;
|
||||||
|
bGPDspoint *pt;
|
||||||
|
|
||||||
|
if (gpl->flag & GP_LAYER_HIDE) continue;
|
||||||
|
|
||||||
|
gpf= gpencil_layer_getframe(gpl, CFRA, 0);
|
||||||
|
if (gpf==NULL) continue;
|
||||||
|
|
||||||
|
for (gps= gpf->strokes.first; gps; gps= gps->next) {
|
||||||
|
//if (gps->flag & GP_STROKE_2DSPACE) {
|
||||||
|
int i;
|
||||||
|
//gp_draw_stroke(gps->points, gps->totpoints, lthick, dflag, gps->flag, debug, offsx, offsy, winx, winy);
|
||||||
|
|
||||||
|
/* fill up the array with points */
|
||||||
|
for (i=0, pt=gps->points; i < gps->totpoints && pt; i++, pt++) {
|
||||||
|
printf("- %f %f\n", pt->x, pt->y);
|
||||||
|
|
||||||
|
vec_gp[0] = pt->x;
|
||||||
|
vec_gp[1] = pt->y;
|
||||||
|
//printf("%f %f\n", vec_gp[0], vec_gp[1]);
|
||||||
|
|
||||||
|
vec_gp+=2;
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vec_gp = points_gp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!((s.brush->flag & (BRUSH_ALPHA_PRESSURE|BRUSH_SIZE_PRESSURE|
|
if (!((s.brush->flag & (BRUSH_ALPHA_PRESSURE|BRUSH_SIZE_PRESSURE|
|
||||||
BRUSH_SPACING_PRESSURE|BRUSH_RAD_PRESSURE)) && (get_activedevice() != 0) && (pressure >= 0.99f)))
|
BRUSH_SPACING_PRESSURE|BRUSH_RAD_PRESSURE)) && (get_activedevice() != 0) && (pressure >= 0.99f)))
|
||||||
@ -3116,7 +3198,16 @@ void imagepaint_paint(short mousebutton, short texpaint)
|
|||||||
}
|
}
|
||||||
/* paint loop */
|
/* paint loop */
|
||||||
do {
|
do {
|
||||||
getmouseco_areawin(mval);
|
if (stroke_gp) {
|
||||||
|
/* Stroke grease pencil path */
|
||||||
|
mval[0]= (short)vec_gp[0];
|
||||||
|
mval[1]= (short)vec_gp[1];
|
||||||
|
//printf("%d %d\n", mval[0], mval[1]);
|
||||||
|
vec_gp+=2;
|
||||||
|
index_gp++;
|
||||||
|
} else {
|
||||||
|
getmouseco_areawin(mval);
|
||||||
|
}
|
||||||
|
|
||||||
pressure = get_pressure();
|
pressure = get_pressure();
|
||||||
s.blend = (get_activedevice() == 2)? BRUSH_BLEND_ERASE_ALPHA: s.brush->blend;
|
s.blend = (get_activedevice() == 2)? BRUSH_BLEND_ERASE_ALPHA: s.brush->blend;
|
||||||
@ -3132,11 +3223,13 @@ void imagepaint_paint(short mousebutton, short texpaint)
|
|||||||
persp(PERSP_VIEW);
|
persp(PERSP_VIEW);
|
||||||
*/
|
*/
|
||||||
if((mval[0] != prevmval[0]) || (mval[1] != prevmval[1])) {
|
if((mval[0] != prevmval[0]) || (mval[1] != prevmval[1])) {
|
||||||
imapaint_paint_stroke_project(&ps, painter, prevmval, mval, time, pressure);
|
imapaint_paint_stroke_project(&ps, painter, prevmval, mval, stroke_gp ? 0 : 1, time, pressure);
|
||||||
prevmval[0]= mval[0];
|
prevmval[0]= mval[0];
|
||||||
prevmval[1]= mval[1];
|
prevmval[1]= mval[1];
|
||||||
} else
|
} else {
|
||||||
BIF_wait_for_statechange();
|
if (stroke_gp==0)
|
||||||
|
BIF_wait_for_statechange();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if((mval[0] != prevmval[0]) || (mval[1] != prevmval[1])) {
|
if((mval[0] != prevmval[0]) || (mval[1] != prevmval[1])) {
|
||||||
imapaint_paint_stroke(&s, painter, texpaint, prevmval, mval, time, pressure);
|
imapaint_paint_stroke(&s, painter, texpaint, prevmval, mval, time, pressure);
|
||||||
@ -3150,7 +3243,8 @@ void imagepaint_paint(short mousebutton, short texpaint)
|
|||||||
}
|
}
|
||||||
/* do mouse checking at the end, so don't check twice, and potentially
|
/* do mouse checking at the end, so don't check twice, and potentially
|
||||||
miss a short tap */
|
miss a short tap */
|
||||||
} while(get_mbut() & mousebutton);
|
} while( (stroke_gp && index_gp < tot_gp) || (stroke_gp==0 && (get_mbut() & mousebutton)));
|
||||||
|
//} while(get_mbut() & mousebutton);
|
||||||
|
|
||||||
/* clean up */
|
/* clean up */
|
||||||
settings->imapaint.flag &= ~IMAGEPAINT_DRAWING;
|
settings->imapaint.flag &= ~IMAGEPAINT_DRAWING;
|
||||||
@ -3161,6 +3255,9 @@ void imagepaint_paint(short mousebutton, short texpaint)
|
|||||||
project_paint_end(&ps);
|
project_paint_end(&ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (points_gp)
|
||||||
|
MEM_freeN(points_gp);
|
||||||
|
|
||||||
imapaint_redraw(1, texpaint, s.image);
|
imapaint_redraw(1, texpaint, s.image);
|
||||||
undo_imagepaint_push_end();
|
undo_imagepaint_push_end();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user