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:
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r--source/blender/editors/sculpt_paint/SConscript7
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c111
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h7
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c46
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c44
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c13
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h3
8 files changed, 149 insertions, 84 deletions
diff --git a/source/blender/editors/sculpt_paint/SConscript b/source/blender/editors/sculpt_paint/SConscript
index 01e1d80c24c..3d2ea89f506 100644
--- a/source/blender/editors/sculpt_paint/SConscript
+++ b/source/blender/editors/sculpt_paint/SConscript
@@ -8,4 +8,11 @@ incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include'
incs += ' ../../render/extern/include #/intern/guardedalloc'
incs += ' ../../gpu ../../makesrna'
+if env['OURPLATFORM'] == 'linux2':
+ cflags='-pthread'
+ incs += ' ../../../extern/binreloc/include'
+
+if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
+ incs += ' ' + env['BF_PTHREADS_INC']
+
env.BlenderLib ( 'bf_editors_sculpt_paint', sources, Split(incs), [], libtype=['core'], priority=[40] )
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 870b66cdbbd..d223c423690 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -625,19 +625,6 @@ static void BarycentricWeightsPersp2f(float pt[2], float v1[4], float v2[4], flo
w[0] = w[1] = w[2] = 1.0f/3.0f;
}
-static void VecWeightf(float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3])
-{
- p[0] = v1[0]*w[0] + v2[0]*w[1] + v3[0]*w[2];
- p[1] = v1[1]*w[0] + v2[1]*w[1] + v3[1]*w[2];
- p[2] = v1[2]*w[0] + v2[2]*w[1] + v3[2]*w[2];
-}
-
-static void Vec2Weightf(float p[2], const float v1[2], const float v2[2], const float v3[2], const float w[3])
-{
- p[0] = v1[0]*w[0] + v2[0]*w[1] + v3[0]*w[2];
- p[1] = v1[1]*w[0] + v2[1]*w[1] + v3[1]*w[2];
-}
-
static float VecZDepthOrtho(float pt[2], float v1[3], float v2[3], float v3[3], float w[3])
{
BarycentricWeights2f(pt, v1, v2, v3, w);
@@ -746,10 +733,10 @@ static int project_paint_PickColor(const ProjPaintState *ps, float pt[2], float
tf = ps->dm_mtface + face_index;
if (side == 0) {
- Vec2Weightf(uv, tf->uv[0], tf->uv[1], tf->uv[2], w);
+ Vec2Lerp3f(uv, tf->uv[0], tf->uv[1], tf->uv[2], w);
}
else { /* QUAD */
- Vec2Weightf(uv, tf->uv[0], tf->uv[2], tf->uv[3], w);
+ Vec2Lerp3f(uv, tf->uv[0], tf->uv[2], tf->uv[3], w);
}
ibuf = tf->tpage->ibufs.first; /* we must have got the imbuf before getting here */
@@ -870,8 +857,8 @@ static int project_paint_occlude_ptv_clip(
}
/* Test if we're in the clipped area, */
- if (side) VecWeightf(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v3].co, ps->dm_mvert[mf->v4].co, w);
- else VecWeightf(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v2].co, ps->dm_mvert[mf->v3].co, w);
+ if (side) VecLerp3f(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v3].co, ps->dm_mvert[mf->v4].co, w);
+ else VecLerp3f(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v2].co, ps->dm_mvert[mf->v3].co, w);
Mat4MulVecfl(ps->ob->obmat, wco);
if(!view3d_test_clipping(ps->rv3d, wco)) {
@@ -1146,19 +1133,6 @@ static int check_seam(const ProjPaintState *ps, const int orig_face, const int o
return 1;
}
-/* TODO - move to arithb.c */
-/* Converts an angle to a length that can be used for maintaining an even margin around UV's */
-static float angleToLength(float angle)
-{
- // already accounted for
- if (angle < 0.000001f) {
- return 1.0f;
- }
- else {
- return fabsf(1.0f / cosf(angle * (M_PI/180.0f)));
- }
-}
-
/* Calculate outset UV's, this is not the same as simply scaling the UVs,
* since the outset coords are a margin that keep an even distance from the original UV's,
* note that the image aspect is taken into account */
@@ -1204,15 +1178,15 @@ static void uv_image_outset(float (*orig_uv)[2], float (*outset_uv)[2], const fl
}
if (is_quad) {
- a1 = angleToLength(NormalizedVecAngle2_2D(dir4, dir1));
- a2 = angleToLength(NormalizedVecAngle2_2D(dir1, dir2));
- a3 = angleToLength(NormalizedVecAngle2_2D(dir2, dir3));
- a4 = angleToLength(NormalizedVecAngle2_2D(dir3, dir4));
+ a1 = AngleToLength(NormalizedVecAngle2_2D(dir4, dir1));
+ a2 = AngleToLength(NormalizedVecAngle2_2D(dir1, dir2));
+ a3 = AngleToLength(NormalizedVecAngle2_2D(dir2, dir3));
+ a4 = AngleToLength(NormalizedVecAngle2_2D(dir3, dir4));
}
else {
- a1 = angleToLength(NormalizedVecAngle2_2D(dir3, dir1));
- a2 = angleToLength(NormalizedVecAngle2_2D(dir1, dir2));
- a3 = angleToLength(NormalizedVecAngle2_2D(dir2, dir3));
+ a1 = AngleToLength(NormalizedVecAngle2_2D(dir3, dir1));
+ a2 = AngleToLength(NormalizedVecAngle2_2D(dir1, dir2));
+ a3 = AngleToLength(NormalizedVecAngle2_2D(dir2, dir3));
}
if (is_quad) {
@@ -1329,7 +1303,7 @@ static void screen_px_from_ortho(
float w[3])
{
BarycentricWeights2f(uv, uv1co, uv2co, uv3co, w);
- VecWeightf(pixelScreenCo, v1co, v2co, v3co, w);
+ VecLerp3f(pixelScreenCo, v1co, v2co, v3co, w);
}
/* same as screen_px_from_ortho except we need to take into account
@@ -1363,7 +1337,7 @@ static void screen_px_from_persp(
}
/* done re-weighting */
- VecWeightf(pixelScreenCo, v1co, v2co, v3co, w);
+ VecLerp3f(pixelScreenCo, v1co, v2co, v3co, w);
}
static void project_face_pixel(const MTFace *tf_other, ImBuf *ibuf_other, const float w[3], int side, unsigned char rgba_ub[4], float rgba_f[4])
@@ -1381,7 +1355,7 @@ static void project_face_pixel(const MTFace *tf_other, ImBuf *ibuf_other, const
uvCo3 = (float *)tf_other->uv[2];
}
- Vec2Weightf(uv_other, uvCo1, uvCo2, uvCo3, w);
+ Vec2Lerp3f(uv_other, uvCo1, uvCo2, uvCo3, w);
/* use */
uvco_to_wrapped_pxco(uv_other, ibuf_other->x, ibuf_other->y, &x, &y);
@@ -1916,22 +1890,22 @@ static void rect_to_uvspace_ortho(
uv[0] = bucket_bounds->xmax;
uv[1] = bucket_bounds->ymin;
BarycentricWeights2f(uv, v1coSS, v2coSS, v3coSS, w);
- Vec2Weightf(bucket_bounds_uv[flip?3:0], uv1co, uv2co, uv3co, w);
+ Vec2Lerp3f(bucket_bounds_uv[flip?3:0], uv1co, uv2co, uv3co, w);
//uv[0] = bucket_bounds->xmax; // set above
uv[1] = bucket_bounds->ymax;
BarycentricWeights2f(uv, v1coSS, v2coSS, v3coSS, w);
- Vec2Weightf(bucket_bounds_uv[flip?2:1], uv1co, uv2co, uv3co, w);
+ Vec2Lerp3f(bucket_bounds_uv[flip?2:1], uv1co, uv2co, uv3co, w);
uv[0] = bucket_bounds->xmin;
//uv[1] = bucket_bounds->ymax; // set above
BarycentricWeights2f(uv, v1coSS, v2coSS, v3coSS, w);
- Vec2Weightf(bucket_bounds_uv[flip?1:2], uv1co, uv2co, uv3co, w);
+ Vec2Lerp3f(bucket_bounds_uv[flip?1:2], uv1co, uv2co, uv3co, w);
//uv[0] = bucket_bounds->xmin; // set above
uv[1] = bucket_bounds->ymin;
BarycentricWeights2f(uv, v1coSS, v2coSS, v3coSS, w);
- Vec2Weightf(bucket_bounds_uv[flip?0:3], uv1co, uv2co, uv3co, w);
+ Vec2Lerp3f(bucket_bounds_uv[flip?0:3], uv1co, uv2co, uv3co, w);
}
/* same as above but use BarycentricWeightsPersp2f */
@@ -1950,22 +1924,22 @@ static void rect_to_uvspace_persp(
uv[0] = bucket_bounds->xmax;
uv[1] = bucket_bounds->ymin;
BarycentricWeightsPersp2f(uv, v1coSS, v2coSS, v3coSS, w);
- Vec2Weightf(bucket_bounds_uv[flip?3:0], uv1co, uv2co, uv3co, w);
+ Vec2Lerp3f(bucket_bounds_uv[flip?3:0], uv1co, uv2co, uv3co, w);
//uv[0] = bucket_bounds->xmax; // set above
uv[1] = bucket_bounds->ymax;
BarycentricWeightsPersp2f(uv, v1coSS, v2coSS, v3coSS, w);
- Vec2Weightf(bucket_bounds_uv[flip?2:1], uv1co, uv2co, uv3co, w);
+ Vec2Lerp3f(bucket_bounds_uv[flip?2:1], uv1co, uv2co, uv3co, w);
uv[0] = bucket_bounds->xmin;
//uv[1] = bucket_bounds->ymax; // set above
BarycentricWeightsPersp2f(uv, v1coSS, v2coSS, v3coSS, w);
- Vec2Weightf(bucket_bounds_uv[flip?1:2], uv1co, uv2co, uv3co, w);
+ Vec2Lerp3f(bucket_bounds_uv[flip?1:2], uv1co, uv2co, uv3co, w);
//uv[0] = bucket_bounds->xmin; // set above
uv[1] = bucket_bounds->ymin;
BarycentricWeightsPersp2f(uv, v1coSS, v2coSS, v3coSS, w);
- Vec2Weightf(bucket_bounds_uv[flip?0:3], uv1co, uv2co, uv3co, w);
+ Vec2Lerp3f(bucket_bounds_uv[flip?0:3], uv1co, uv2co, uv3co, w);
}
/* This works as we need it to but we can save a few steps and not use it */
@@ -2209,13 +2183,13 @@ static void project_bucket_clip_face(
if (is_ortho) {
for(i=0; i<(*tot); i++) {
BarycentricWeights2f(isectVCosSS[i], v1coSS, v2coSS, v3coSS, w);
- Vec2Weightf(bucket_bounds_uv[i], uv1co, uv2co, uv3co, w);
+ Vec2Lerp3f(bucket_bounds_uv[i], uv1co, uv2co, uv3co, w);
}
}
else {
for(i=0; i<(*tot); i++) {
BarycentricWeightsPersp2f(isectVCosSS[i], v1coSS, v2coSS, v3coSS, w);
- Vec2Weightf(bucket_bounds_uv[i], uv1co, uv2co, uv3co, w);
+ Vec2Lerp3f(bucket_bounds_uv[i], uv1co, uv2co, uv3co, w);
}
}
}
@@ -2470,7 +2444,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
/* a pitty we need to get the worldspace pixel location here */
if(ps->rv3d->rflag & RV3D_CLIPPING) {
- VecWeightf(wco, ps->dm_mvert[ (*(&mf->v1 + i1)) ].co, ps->dm_mvert[ (*(&mf->v1 + i2)) ].co, ps->dm_mvert[ (*(&mf->v1 + i3)) ].co, w);
+ VecLerp3f(wco, ps->dm_mvert[ (*(&mf->v1 + i1)) ].co, ps->dm_mvert[ (*(&mf->v1 + i2)) ].co, ps->dm_mvert[ (*(&mf->v1 + i3)) ].co, w);
Mat4MulVecfl(ps->ob->obmat, wco);
if(view3d_test_clipping(ps->rv3d, wco)) {
continue; /* Watch out that no code below this needs to run */
@@ -2686,8 +2660,8 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
/* a pitty we need to get the worldspace pixel location here */
if(ps->rv3d->rflag & RV3D_CLIPPING) {
- if (side) VecWeightf(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v3].co, ps->dm_mvert[mf->v4].co, w);
- else VecWeightf(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v2].co, ps->dm_mvert[mf->v3].co, w);
+ if (side) VecLerp3f(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v3].co, ps->dm_mvert[mf->v4].co, w);
+ else VecLerp3f(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v2].co, ps->dm_mvert[mf->v3].co, w);
Mat4MulVecfl(ps->ob->obmat, wco);
if(view3d_test_clipping(ps->rv3d, wco)) {
@@ -3757,7 +3731,7 @@ static void *do_projectpaint_thread(void *ph_v)
/*if (dist < s->brush->size) {*/ /* correct but uses a sqrtf */
if (dist_nosqrt < brush_size_sqared && (dist=sqrtf(dist_nosqrt)) < size_half) {
- falloff = brush_curve_strength(ps->brush, dist, size_half);
+ falloff = brush_curve_strength_clamp(ps->brush, dist, size_half);
if (falloff > 0.0f) {
if (ps->is_texbrush) {
brush_sample_tex(ps->brush, projPixel->projCoSS, rgba);
@@ -4443,6 +4417,7 @@ typedef struct PaintOperation {
int first;
int prevmouse[2];
+ float prev_pressure; /* need this since we dont get tablet events for pressure change */
int brush_size_orig;
double starttime;
@@ -4722,8 +4697,8 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event)
if(wmtab->Active == EVT_TABLET_ERASER)
pop->s.blend= IMB_BLEND_ERASE_ALPHA;
}
- else
- pressure= 1.0f;
+ else /* otherwise airbrush becomes 1.0 pressure instantly */
+ pressure= pop->prev_pressure ? pop->prev_pressure : 1.0f;
if(pop->first) {
pop->prevmouse[0]= mouse[0];
@@ -4732,8 +4707,7 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event)
/* special exception here for too high pressure values on first touch in
windows for some tablets, then we just skip first touch .. */
- if ((pop->s.brush->flag & (BRUSH_ALPHA_PRESSURE|BRUSH_SIZE_PRESSURE|
- BRUSH_SPACING_PRESSURE|BRUSH_RAD_PRESSURE)) && tablet && (pressure >= 0.99f))
+ if ((pop->s.brush->flag & (BRUSH_ALPHA_PRESSURE|BRUSH_SIZE_PRESSURE|BRUSH_SPACING_PRESSURE)) && tablet && (pressure >= 0.99f))
return;
}
@@ -4748,6 +4722,8 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event)
/* apply */
paint_apply(C, op, &itemptr);
+
+ pop->prev_pressure= pressure;
}
static int paint_invoke(bContext *C, wmOperator *op, wmEvent *event)
@@ -4762,7 +4738,7 @@ static int paint_invoke(bContext *C, wmOperator *op, wmEvent *event)
paint_apply_event(C, op, event);
pop= op->customdata;
- WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+ WM_event_add_modal_handler(C, op);
if(pop->s.brush->flag & BRUSH_AIRBRUSH)
pop->timer= WM_event_add_window_timer(CTX_wm_window(C), TIMER, 0.01f);
@@ -4897,12 +4873,15 @@ static int paint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *even
static int paint_radial_control_exec(bContext *C, wmOperator *op)
{
+ Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->imapaint.paint);
float zoom;
int ret;
char str[256];
get_imapaint_zoom(C, &zoom, &zoom);
- ret = brush_radial_control_exec(op, paint_brush(&CTX_data_scene(C)->toolsettings->imapaint.paint), 2.0 / zoom);
+ ret = brush_radial_control_exec(op, brush, 2.0 / zoom);
WM_radial_control_string(op, str, 256);
+
+ WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush);
return ret;
}
@@ -4961,7 +4940,7 @@ static int grab_clone_invoke(bContext *C, wmOperator *op, wmEvent *event)
cmv->starty= event->y;
op->customdata= cmv;
- WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+ WM_event_add_modal_handler(C, op);
return OPERATOR_RUNNING_MODAL;
}
@@ -5216,10 +5195,13 @@ static int texture_paint_radial_control_invoke(bContext *C, wmOperator *op, wmEv
static int texture_paint_radial_control_exec(bContext *C, wmOperator *op)
{
- int ret = brush_radial_control_exec(op, paint_brush(&CTX_data_scene(C)->toolsettings->imapaint.paint), 2);
+ Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->imapaint.paint);
+ int ret = brush_radial_control_exec(op, brush, 2);
char str[256];
WM_radial_control_string(op, str, 256);
+ WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush);
+
return ret;
}
@@ -5232,6 +5214,11 @@ static int texture_paint_poll(bContext *C)
return 0;
}
+int image_texture_paint_poll(bContext *C)
+{
+ return (texture_paint_poll(C) || image_paint_poll(C));
+}
+
void PAINT_OT_texture_paint_radial_control(wmOperatorType *ot)
{
WM_OT_radial_control_partial(ot);
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index ba1b57a1bef..8251d1a5a1a 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -57,7 +57,10 @@ int paint_poll(bContext *C);
void paint_cursor_start(struct bContext *C, int (*poll)(struct bContext *C));
/* paint_vertex.c */
-int vertex_paint_mode_poll(bContext *C);
+int weight_paint_poll(struct bContext *C);
+int vertex_paint_poll(struct bContext *C);
+int vertex_paint_mode_poll(struct bContext *C);
+
void clear_vpaint(Scene *scene, int selected);
void PAINT_OT_weight_paint_toggle(struct wmOperatorType *ot);
@@ -69,6 +72,8 @@ void PAINT_OT_vertex_paint_toggle(struct wmOperatorType *ot);
void PAINT_OT_vertex_paint(struct wmOperatorType *ot);
/* paint_image.c */
+int image_texture_paint_poll(struct bContext *C);
+
void PAINT_OT_image_paint(struct wmOperatorType *ot);
void PAINT_OT_image_paint_radial_control(struct wmOperatorType *ot);
void PAINT_OT_grab_clone(struct wmOperatorType *ot);
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 19b46f5a941..514c80d929d 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -38,6 +38,7 @@
#include "RNA_enum_types.h"
#include "paint_intern.h"
+#include "sculpt_intern.h"
#include <string.h>
@@ -133,3 +134,48 @@ void ED_operatortypes_paint(void)
WM_operatortype_append(PAINT_OT_vertex_color_set);
}
+void ED_keymap_paint(wmWindowManager *wm)
+{
+ wmKeyMap *keymap;
+
+ /* Sculpt mode */
+ keymap= WM_keymap_find(wm, "Sculpt", 0, 0);
+ keymap->poll= sculpt_poll;
+
+ RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE);
+ RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH);
+ RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", WM_RADIALCONTROL_ANGLE);
+
+ WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
+
+ /* Vertex Paint mode */
+ keymap= WM_keymap_find(wm, "Vertex Paint", 0, 0);
+ keymap->poll= vertex_paint_poll;
+
+ RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_vertex_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE);
+ RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_vertex_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH);
+ WM_keymap_verify_item(keymap, "PAINT_OT_vertex_paint", LEFTMOUSE, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0);
+
+ /* Weight Paint mode */
+ keymap= WM_keymap_find(wm, "Weight Paint", 0, 0);
+ keymap->poll= weight_paint_poll;
+
+ RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE);
+ RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH);
+
+ WM_keymap_verify_item(keymap, "PAINT_OT_weight_paint", LEFTMOUSE, KM_PRESS, 0, 0);
+
+ /* Image/Texture Paint mode */
+ keymap= WM_keymap_find(wm, "Image Paint", 0, 0);
+ keymap->poll= image_texture_paint_poll;
+
+ RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_texture_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE);
+ RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_texture_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH);
+
+ WM_keymap_add_item(keymap, "PAINT_OT_image_paint", LEFTMOUSE, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "PAINT_OT_clone_cursor_set", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
+}
+
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index bd9ea50e0f8..b83352ae70c 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -263,7 +263,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
}
/* TODO: fix hardcoded event here */
- if(event->type == LEFTMOUSE && event->val == 0) {
+ if(event->type == LEFTMOUSE && event->val == KM_RELEASE) {
/* Exit stroke, free data */
if(stroke->smooth_stroke_cursor)
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 25ff57ca87f..5afc4954c9c 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -119,7 +119,7 @@ int vertex_paint_mode_poll(bContext *C)
return ob && ob->mode == OB_MODE_VERTEX_PAINT;
}
-static int vp_poll(bContext *C)
+int vertex_paint_poll(bContext *C)
{
if(vertex_paint_mode_poll(C) &&
paint_brush(&CTX_data_tool_settings(C)->vpaint->paint)) {
@@ -133,7 +133,7 @@ static int vp_poll(bContext *C)
return 0;
}
-static int wp_poll(bContext *C)
+int weight_paint_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
@@ -710,7 +710,9 @@ static int sample_backbuf_area(ViewContext *vc, int *indexar, int totface, int x
if(totface+4>=MAXINDEX) return 0;
- if(size>64.0) size= 64.0;
+ /* brecht: disabled this because it obviously failes for
+ brushes with size > 64, why is this here? */
+ /*if(size>64.0) size= 64.0;*/
ibuf= view3d_read_backbuf(vc, x-size, y-size, x+size, y+size);
if(ibuf) {
@@ -1058,7 +1060,7 @@ static int set_wpaint(bContext *C, wmOperator *op) /* toggle */
wp= scene->toolsettings->wpaint= new_vpaint(1);
paint_init(&wp->paint, PAINT_CURSOR_WEIGHT_PAINT);
- paint_cursor_start(C, wp_poll);
+ paint_cursor_start(C, weight_paint_poll);
mesh_octree_table(ob, NULL, NULL, 's');
@@ -1127,14 +1129,18 @@ static int vpaint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *eve
{
int ret = WM_radial_control_modal(C, op, event);
if(ret != OPERATOR_RUNNING_MODAL)
- paint_cursor_start(C, vp_poll);
+ paint_cursor_start(C, vertex_paint_poll);
return ret;
}
static int vpaint_radial_control_exec(bContext *C, wmOperator *op)
{
Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->vpaint->paint);
- return brush_radial_control_exec(op, brush, 1);
+ int ret = brush_radial_control_exec(op, brush, 1);
+
+ WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush);
+
+ return ret;
}
static int wpaint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
@@ -1152,14 +1158,18 @@ static int wpaint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *eve
{
int ret = WM_radial_control_modal(C, op, event);
if(ret != OPERATOR_RUNNING_MODAL)
- paint_cursor_start(C, wp_poll);
+ paint_cursor_start(C, weight_paint_poll);
return ret;
}
static int wpaint_radial_control_exec(bContext *C, wmOperator *op)
{
Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->wpaint->paint);
- return brush_radial_control_exec(op, brush, 1);
+ int ret = brush_radial_control_exec(op, brush, 1);
+
+ WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush);
+
+ return ret;
}
void PAINT_OT_weight_paint_radial_control(wmOperatorType *ot)
@@ -1172,7 +1182,7 @@ void PAINT_OT_weight_paint_radial_control(wmOperatorType *ot)
ot->invoke= wpaint_radial_control_invoke;
ot->modal= wpaint_radial_control_modal;
ot->exec= wpaint_radial_control_exec;
- ot->poll= wp_poll;
+ ot->poll= weight_paint_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
@@ -1188,7 +1198,7 @@ void PAINT_OT_vertex_paint_radial_control(wmOperatorType *ot)
ot->invoke= vpaint_radial_control_invoke;
ot->modal= vpaint_radial_control_modal;
ot->exec= vpaint_radial_control_exec;
- ot->poll= vp_poll;
+ ot->poll= vertex_paint_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
@@ -1492,7 +1502,7 @@ static int wpaint_invoke(bContext *C, wmOperator *op, wmEvent *event)
wpaint_stroke_done);
/* add modal handler */
- WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+ WM_event_add_modal_handler(C, op);
op->type->modal(C, op, event);
@@ -1510,7 +1520,7 @@ void PAINT_OT_weight_paint(wmOperatorType *ot)
ot->invoke= wpaint_invoke;
ot->modal= paint_stroke_modal;
/* ot->exec= vpaint_exec; <-- needs stroke property */
- ot->poll= wp_poll;
+ ot->poll= weight_paint_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
@@ -1557,7 +1567,7 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */
if(vp==NULL)
vp= scene->toolsettings->vpaint= new_vpaint(0);
- paint_cursor_start(C, vp_poll);
+ paint_cursor_start(C, vertex_paint_poll);
paint_init(&vp->paint, PAINT_CURSOR_VERTEX_PAINT);
}
@@ -1732,6 +1742,10 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
}
Mat4SwapMat4(vc->rv3d->persmat, mat);
+
+ /* was disabled because it is slow, but necessary for blur */
+ if(vp->mode == VP_BLUR)
+ do_shared_vertexcol(me);
ED_region_tag_redraw(vc->ar);
@@ -1761,7 +1775,7 @@ static int vpaint_invoke(bContext *C, wmOperator *op, wmEvent *event)
vpaint_stroke_done);
/* add modal handler */
- WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+ WM_event_add_modal_handler(C, op);
op->type->modal(C, op, event);
@@ -1778,7 +1792,7 @@ void PAINT_OT_vertex_paint(wmOperatorType *ot)
ot->invoke= vpaint_invoke;
ot->modal= paint_stroke_modal;
/* ot->exec= vpaint_exec; <-- needs stroke property */
- ot->poll= vp_poll;
+ ot->poll= vertex_paint_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index be31ab45af4..e41231442ba 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -1155,7 +1155,7 @@ static int sculpt_mode_poll(bContext *C)
return ob && ob->mode & OB_MODE_SCULPT;
}
-static int sculpt_poll(bContext *C)
+int sculpt_poll(bContext *C)
{
return sculpt_mode_poll(C) && paint_poll(C);
}
@@ -1207,8 +1207,11 @@ static int sculpt_radial_control_modal(bContext *C, wmOperator *op, wmEvent *eve
static int sculpt_radial_control_exec(bContext *C, wmOperator *op)
{
Brush *brush = paint_brush(&CTX_data_tool_settings(C)->sculpt->paint);
+ int ret = brush_radial_control_exec(op, brush, 1);
- return brush_radial_control_exec(op, brush, 1);
+ WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush);
+
+ return ret;
}
static void SCULPT_OT_radial_control(wmOperatorType *ot)
@@ -1564,7 +1567,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even
sculpt_stroke_done);
/* add modal handler */
- WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+ WM_event_add_modal_handler(C, op);
op->type->modal(C, op, event);
@@ -1693,10 +1696,10 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *op)
paint_init(&ts->sculpt->paint, PAINT_CURSOR_SCULPT);
paint_cursor_start(C, sculpt_poll);
-
- WM_event_add_notifier(C, NC_SCENE|ND_MODE, CTX_data_scene(C));
}
+ WM_event_add_notifier(C, NC_SCENE|ND_MODE, CTX_data_scene(C));
+
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 25f97b862e6..15ccacc294a 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -33,6 +33,7 @@
#include "DNA_listBase.h"
#include "DNA_vec_types.h"
+struct bContext;
struct Brush;
struct Mesh;
struct Object;
@@ -53,6 +54,8 @@ struct Brush *sculptmode_brush(void);
char sculpt_modifiers_active(struct Object *ob);
void sculpt(Sculpt *sd);
+int sculpt_poll(struct bContext *C);
+
/* Stroke */
struct SculptStroke *sculpt_stroke_new(const int max);
void sculpt_stroke_free(struct SculptStroke *);