forked from bartvdbraak/blender
Support position jittering on new texpaint code using the stroke system.
This commit is contained in:
parent
53b7bc8f1f
commit
65869589b6
@ -54,6 +54,16 @@ extern const char PAINT_CURSOR_VERTEX_PAINT[3];
|
|||||||
extern const char PAINT_CURSOR_WEIGHT_PAINT[3];
|
extern const char PAINT_CURSOR_WEIGHT_PAINT[3];
|
||||||
extern const char PAINT_CURSOR_TEXTURE_PAINT[3];
|
extern const char PAINT_CURSOR_TEXTURE_PAINT[3];
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
PAINT_SCULPT,
|
||||||
|
PAINT_VERTEX,
|
||||||
|
PAINT_WEIGHT,
|
||||||
|
PAINT_TEXTURE_PROJECTIVE,
|
||||||
|
PAINT_TEXTURE_2D,
|
||||||
|
PAINT_SCULPT_UV,
|
||||||
|
PAINT_INVALID
|
||||||
|
} PaintMode;
|
||||||
|
|
||||||
void BKE_paint_init(struct Paint *p, const char col[3]);
|
void BKE_paint_init(struct Paint *p, const char col[3]);
|
||||||
void BKE_paint_free(struct Paint *p);
|
void BKE_paint_free(struct Paint *p);
|
||||||
void BKE_paint_copy(struct Paint *src, struct Paint *tar);
|
void BKE_paint_copy(struct Paint *src, struct Paint *tar);
|
||||||
@ -61,6 +71,7 @@ void BKE_paint_copy(struct Paint *src, struct Paint *tar);
|
|||||||
/* TODO, give these BKE_ prefix too */
|
/* TODO, give these BKE_ prefix too */
|
||||||
struct Paint *paint_get_active(struct Scene *sce);
|
struct Paint *paint_get_active(struct Scene *sce);
|
||||||
struct Paint *paint_get_active_from_context(const struct bContext *C);
|
struct Paint *paint_get_active_from_context(const struct bContext *C);
|
||||||
|
PaintMode paintmode_get_active_from_context(const struct bContext *C);
|
||||||
struct Brush *paint_brush(struct Paint *paint);
|
struct Brush *paint_brush(struct Paint *paint);
|
||||||
void paint_brush_set(struct Paint *paint, struct Brush *br);
|
void paint_brush_set(struct Paint *paint, struct Brush *br);
|
||||||
|
|
||||||
|
@ -137,6 +137,55 @@ Paint *paint_get_active_from_context(const bContext *C)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PaintMode paintmode_get_active_from_context(const bContext *C)
|
||||||
|
{
|
||||||
|
Scene *sce = CTX_data_scene(C);
|
||||||
|
SpaceImage *sima;
|
||||||
|
|
||||||
|
if (sce) {
|
||||||
|
ToolSettings *ts = sce->toolsettings;
|
||||||
|
Object *obact = NULL;
|
||||||
|
|
||||||
|
if (sce->basact && sce->basact->object)
|
||||||
|
obact = sce->basact->object;
|
||||||
|
|
||||||
|
if ((sima = CTX_wm_space_image(C)) != NULL) {
|
||||||
|
if (obact && obact->mode == OB_MODE_EDIT) {
|
||||||
|
if (sima->mode == SI_MODE_PAINT)
|
||||||
|
return PAINT_TEXTURE_2D;
|
||||||
|
else if (ts->use_uv_sculpt)
|
||||||
|
return PAINT_SCULPT_UV;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return PAINT_TEXTURE_2D;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (obact) {
|
||||||
|
switch (obact->mode) {
|
||||||
|
case OB_MODE_SCULPT:
|
||||||
|
return PAINT_SCULPT;
|
||||||
|
case OB_MODE_VERTEX_PAINT:
|
||||||
|
return PAINT_VERTEX;
|
||||||
|
case OB_MODE_WEIGHT_PAINT:
|
||||||
|
return PAINT_WEIGHT;
|
||||||
|
case OB_MODE_TEXTURE_PAINT:
|
||||||
|
return PAINT_TEXTURE_PROJECTIVE;
|
||||||
|
case OB_MODE_EDIT:
|
||||||
|
if (ts->use_uv_sculpt)
|
||||||
|
return PAINT_SCULPT_UV;
|
||||||
|
else
|
||||||
|
return PAINT_TEXTURE_2D;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* default to image paint */
|
||||||
|
return PAINT_TEXTURE_2D;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return PAINT_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
Brush *paint_brush(Paint *p)
|
Brush *paint_brush(Paint *p)
|
||||||
{
|
{
|
||||||
return p ? p->brush : NULL;
|
return p ? p->brush : NULL;
|
||||||
|
@ -4936,14 +4936,14 @@ static int image_paint_2d_clone_poll(bContext *C)
|
|||||||
|
|
||||||
/************************ paint operator ************************/
|
/************************ paint operator ************************/
|
||||||
|
|
||||||
typedef enum PaintMode {
|
typedef enum TexPaintMode {
|
||||||
PAINT_MODE_2D,
|
PAINT_MODE_2D,
|
||||||
PAINT_MODE_3D,
|
PAINT_MODE_3D,
|
||||||
PAINT_MODE_3D_PROJECT
|
PAINT_MODE_3D_PROJECT
|
||||||
} PaintMode;
|
} TexPaintMode;
|
||||||
|
|
||||||
typedef struct PaintOperation {
|
typedef struct PaintOperation {
|
||||||
PaintMode mode;
|
TexPaintMode mode;
|
||||||
|
|
||||||
BrushPainter *painter;
|
BrushPainter *painter;
|
||||||
ImagePaintState s;
|
ImagePaintState s;
|
||||||
|
@ -4803,13 +4803,13 @@ static int image_paint_poll(bContext *C)
|
|||||||
|
|
||||||
/************************ paint operator ************************/
|
/************************ paint operator ************************/
|
||||||
|
|
||||||
typedef enum PaintMode {
|
typedef enum TexPaintMode {
|
||||||
PAINT_MODE_2D,
|
PAINT_MODE_2D,
|
||||||
PAINT_MODE_3D_PROJECT
|
PAINT_MODE_3D_PROJECT
|
||||||
} PaintMode;
|
} TexPaintMode;
|
||||||
|
|
||||||
typedef struct PaintOperation {
|
typedef struct PaintOperation {
|
||||||
PaintMode mode;
|
TexPaintMode mode;
|
||||||
|
|
||||||
BrushPainter *painter;
|
BrushPainter *painter;
|
||||||
ImagePaintState s;
|
ImagePaintState s;
|
||||||
@ -5060,10 +5060,10 @@ static void paint_stroke_update_step(bContext *C, struct PaintStroke *stroke, Po
|
|||||||
mouse[1] = (int)(mousef[1]);
|
mouse[1] = (int)(mousef[1]);
|
||||||
pressure = RNA_float_get(itemptr, "pressure");
|
pressure = RNA_float_get(itemptr, "pressure");
|
||||||
|
|
||||||
if (pop->first)
|
|
||||||
project_paint_begin_clone(&pop->ps, mouse);
|
|
||||||
|
|
||||||
if (pop->mode == PAINT_MODE_3D_PROJECT) {
|
if (pop->mode == PAINT_MODE_3D_PROJECT) {
|
||||||
|
if (pop->first)
|
||||||
|
project_paint_begin_clone(&pop->ps, mouse);
|
||||||
|
|
||||||
redraw = project_paint_stroke(&pop->ps, pop->prevmouse, mouse, pressure);
|
redraw = project_paint_stroke(&pop->ps, pop->prevmouse, mouse, pressure);
|
||||||
pop->prevmouse[0] = mouse[0];
|
pop->prevmouse[0] = mouse[0];
|
||||||
pop->prevmouse[1] = mouse[1];
|
pop->prevmouse[1] = mouse[1];
|
||||||
|
@ -143,6 +143,7 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev
|
|||||||
{
|
{
|
||||||
Scene *scene = CTX_data_scene(C);
|
Scene *scene = CTX_data_scene(C);
|
||||||
Paint *paint = paint_get_active_from_context(C);
|
Paint *paint = paint_get_active_from_context(C);
|
||||||
|
PaintMode mode = paintmode_get_active_from_context(C);
|
||||||
Brush *brush = paint_brush(paint);
|
Brush *brush = paint_brush(paint);
|
||||||
PaintStroke *stroke = op->customdata;
|
PaintStroke *stroke = op->customdata;
|
||||||
float mouse_out[2];
|
float mouse_out[2];
|
||||||
@ -156,7 +157,7 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev
|
|||||||
|
|
||||||
/* TODO: as sculpt and other paint modes are unified, this
|
/* TODO: as sculpt and other paint modes are unified, this
|
||||||
* separation will go away */
|
* separation will go away */
|
||||||
if (stroke->vc.obact->sculpt) {
|
if (ELEM(mode, PAINT_SCULPT, PAINT_TEXTURE_PROJECTIVE)) {
|
||||||
float delta[2];
|
float delta[2];
|
||||||
|
|
||||||
BKE_brush_jitter_pos(scene, brush, mouse_in, mouse_out);
|
BKE_brush_jitter_pos(scene, brush, mouse_in, mouse_out);
|
||||||
|
Loading…
Reference in New Issue
Block a user