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.c131
-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.c36
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c187
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h3
8 files changed, 322 insertions, 97 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 72ddbeef735..6118fdb4a02 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -223,6 +223,7 @@ typedef struct ProjPaintState {
DerivedMesh *dm;
int dm_totface;
int dm_totvert;
+ int dm_release;
MVert *dm_mvert;
MFace *dm_mface;
@@ -625,19 +626,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 +734,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 +858,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 +1134,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 +1179,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 +1304,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 +1338,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 +1356,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 +1891,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 +1925,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 +2184,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 +2445,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 +2661,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)) {
@@ -2960,12 +2935,26 @@ static void project_paint_begin(ProjPaintState *ps)
/* ---- end defines ---- */
/* paint onto the derived mesh */
- ps->dm = mesh_get_derived_final(ps->scene, ps->ob, ps->v3d->customdata_mask);
+
+ /* Workaround for subsurf selection, try the display mesh first */
+ if(ps->ob->derivedFinal && CustomData_has_layer( &ps->ob->derivedFinal->faceData, CD_MTFACE)) {
+ ps->dm = ps->ob->derivedFinal;
+ ps->dm_release= FALSE;
+ }
+ else {
+ ps->dm = mesh_get_derived_final(ps->scene, ps->ob, ps->v3d->customdata_mask);
+ ps->dm_release= TRUE;
+ }
if ( !CustomData_has_layer( &ps->dm->faceData, CD_MTFACE) ) {
+
+ if(ps->dm_release)
+ ps->dm->release(ps->dm);
+
ps->dm = NULL;
return;
}
+
ps->dm_mvert = ps->dm->getVertArray(ps->dm);
ps->dm_mface = ps->dm->getTessFaceArray(ps->dm);
ps->dm_mtface= ps->dm->getTessFaceDataArray(ps->dm, CD_MTFACE);
@@ -3428,7 +3417,8 @@ static void project_paint_end(ProjPaintState *ps)
BLI_memarena_free(ps->arena_mt[a]);
}
- ps->dm->release(ps->dm);
+ if(ps->dm_release)
+ ps->dm->release(ps->dm);
}
/* 1= an undo, -1 is a redo. */
@@ -3757,7 +3747,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 +4433,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 +4713,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 +4723,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 +4738,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 +4754,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 +4889,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 +4956,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 +5211,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 +5230,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..11dbeffdb22 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(wmKeyConfig *keyconf)
+{
+ wmKeyMap *keymap;
+
+ /* Sculpt mode */
+ keymap= WM_keymap_find(keyconf, "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(keyconf, "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(keyconf, "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(keyconf, "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 3c648a193e4..4a45df9eb91 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -120,7 +120,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)) {
@@ -134,7 +134,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);
@@ -1121,7 +1121,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');
@@ -1190,14 +1190,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)
@@ -1215,14 +1219,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)
@@ -1235,7 +1243,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;
@@ -1251,7 +1259,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;
@@ -1539,7 +1547,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);
@@ -1557,7 +1565,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;
@@ -1604,7 +1612,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);
}
@@ -1957,7 +1965,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);
@@ -1974,7 +1982,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 58868a0c2cd..ca9656250c8 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -91,6 +91,7 @@
#include "RE_shader_ext.h" /*for multitex_ext*/
#include "GPU_draw.h"
+#include "gpu_buffers.h"
#include <math.h>
#include <stdlib.h>
@@ -305,20 +306,33 @@ static void do_draw_brush(Sculpt *sd, SculptSession *ss, const ListBase* active_
{
float area_normal[3];
ActiveData *node= active_verts->first;
+ float* buffer;
calc_area_normal(sd, ss, area_normal, active_verts);
+ buffer = ss->drawobject!=0?(float *)GPU_buffer_lock( ss->drawobject->vertices ):0;
+
while(node){
float *co= ss->mvert[node->Index].co;
const float val[3]= {co[0]+area_normal[0]*ss->cache->radius*node->Fade*ss->cache->scale[0],
co[1]+area_normal[1]*ss->cache->radius*node->Fade*ss->cache->scale[1],
co[2]+area_normal[2]*ss->cache->radius*node->Fade*ss->cache->scale[2]};
-
+
+ if( buffer != 0 ) {
+ IndexLink *cur = &ss->drawobject->indices[node->Index];
+ while( cur != 0 && cur->element != -1 ) {
+ sculpt_clip(sd, ss, &buffer[cur->element*3], val);
+ cur = cur->next;
+ }
+ }
+
sculpt_clip(sd, ss, co, val);
-
+
node= node->next;
}
+ if( buffer != 0 )
+ GPU_buffer_unlock( ss->drawobject->vertices );
}
/* For the smooth brush, uses the neighboring vertices around vert to calculate
@@ -368,6 +382,7 @@ static void neighbor_average(SculptSession *ss, float avg[3], const int vert)
static void do_smooth_brush(Sculpt *s, SculptSession *ss, const ListBase* active_verts)
{
ActiveData *node= active_verts->first;
+ float *buffer = ss->drawobject!=0?(float *)GPU_buffer_lock( ss->drawobject->vertices ):0;
int i;
for(i = 0; i < 2; ++i) {
@@ -380,24 +395,45 @@ static void do_smooth_brush(Sculpt *s, SculptSession *ss, const ListBase* active
val[1] = co[1]+(avg[1]-co[1])*node->Fade;
val[2] = co[2]+(avg[2]-co[2])*node->Fade;
- sculpt_clip(s, ss, co, val);
+ sculpt_clip(s, ss, co, val);
+ if( buffer != 0 ) {
+ IndexLink *cur = &ss->drawobject->indices[node->Index];
+ while( cur != 0 && cur->element != -1 ) {
+ sculpt_clip(s, ss, &buffer[cur->element*3], val);
+ cur = cur->next;
+ }
+ }
node= node->next;
}
}
+ if( buffer != 0 )
+ GPU_buffer_unlock( ss->drawobject->vertices );
}
static void do_pinch_brush(Sculpt *s, SculptSession *ss, const ListBase* active_verts)
{
ActiveData *node= active_verts->first;
+ float *buffer = ss->drawobject!=0?(float *)GPU_buffer_lock( ss->drawobject->vertices ):0;
while(node) {
float *co= ss->mvert[node->Index].co;
const float val[3]= {co[0]+(ss->cache->location[0]-co[0])*node->Fade,
co[1]+(ss->cache->location[1]-co[1])*node->Fade,
co[2]+(ss->cache->location[2]-co[2])*node->Fade};
+
+ if( buffer != 0 ) {
+ IndexLink *cur = &ss->drawobject->indices[node->Index];
+ while( cur != 0 && cur->element != -1 ) {
+ sculpt_clip(s, ss, &buffer[cur->element*3], val);
+ cur = cur->next;
+ }
+ }
+
sculpt_clip(s, ss, co, val);
node= node->next;
}
+ if( buffer != 0 )
+ GPU_buffer_unlock( ss->drawobject->vertices );
}
static void do_grab_brush(Sculpt *sd, SculptSession *ss)
@@ -405,6 +441,7 @@ static void do_grab_brush(Sculpt *sd, SculptSession *ss)
ActiveData *node= ss->cache->grab_active_verts[ss->cache->symmetry].first;
float add[3];
float grab_delta[3];
+ float *buffer = ss->drawobject!=0?(float *)GPU_buffer_lock( ss->drawobject->vertices ):0;
VecCopyf(grab_delta, ss->cache->grab_delta_symmetry);
@@ -414,10 +451,21 @@ static void do_grab_brush(Sculpt *sd, SculptSession *ss)
VecCopyf(add, grab_delta);
VecMulf(add, node->Fade);
VecAddf(add, add, co);
+
+ if( buffer != 0 ) {
+ IndexLink *cur = &ss->drawobject->indices[node->Index];
+ while( cur != 0 && cur->element != -1 ) {
+ sculpt_clip(sd, ss, &buffer[cur->element*3], add);
+ cur = cur->next;
+ }
+ }
+
sculpt_clip(sd, ss, co, add);
node= node->next;
}
+ if( buffer != 0 )
+ GPU_buffer_unlock( ss->drawobject->vertices );
}
@@ -425,6 +473,7 @@ static void do_layer_brush(Sculpt *sd, SculptSession *ss, const ListBase *active
{
float area_normal[3];
ActiveData *node= active_verts->first;
+ float *buffer;
float lim= ss->cache->radius / 4;
if(ss->cache->flip)
@@ -432,6 +481,7 @@ static void do_layer_brush(Sculpt *sd, SculptSession *ss, const ListBase *active
calc_area_normal(sd, ss, area_normal, active_verts);
+ buffer = ss->drawobject!=0?(float *)GPU_buffer_lock( ss->drawobject->vertices ):0;
while(node){
float *disp= &ss->layer_disps[node->Index];
float *co= ss->mvert[node->Index].co;
@@ -447,17 +497,28 @@ static void do_layer_brush(Sculpt *sd, SculptSession *ss, const ListBase *active
val[1] = ss->mesh_co_orig[node->Index][1]+area_normal[1] * *disp*ss->cache->scale[1];
val[2] = ss->mesh_co_orig[node->Index][2]+area_normal[2] * *disp*ss->cache->scale[2];
+ if( buffer != 0 ) {
+ IndexLink *cur = &ss->drawobject->indices[node->Index];
+ while( cur != 0 && cur->element != -1 ) {
+ sculpt_clip(sd, ss, &buffer[cur->element*3], val);
+ cur = cur->next;
+ }
+ }
+
sculpt_clip(sd, ss, co, val);
node= node->next;
}
+ if( buffer != 0 )
+ GPU_buffer_unlock( ss->drawobject->vertices );
}
static void do_inflate_brush(Sculpt *s, SculptSession *ss, const ListBase *active_verts)
{
ActiveData *node= active_verts->first;
float add[3];
-
+ float *buffer = ss->drawobject!=0?(float *)GPU_buffer_lock( ss->drawobject->vertices ):0;
+
while(node) {
float *co= ss->mvert[node->Index].co;
short *no= ss->mvert[node->Index].no;
@@ -471,10 +532,20 @@ static void do_inflate_brush(Sculpt *s, SculptSession *ss, const ListBase *activ
add[2]*= ss->cache->scale[2];
VecAddf(add, add, co);
+ if( buffer != 0 ) {
+ IndexLink *cur = &ss->drawobject->indices[node->Index];
+ while( cur != 0 && cur->element != -1 ) {
+ sculpt_clip(s, ss, &buffer[cur->element*3], add);
+ cur = cur->next;
+ }
+ }
+
sculpt_clip(s, ss, co, add);
node= node->next;
}
+ if( buffer != 0 )
+ GPU_buffer_unlock( ss->drawobject->vertices );
}
static void calc_flatten_center(SculptSession *ss, ActiveData *node, float co[3])
@@ -535,7 +606,7 @@ static void do_flatten_clay_brush(Sculpt *sd, SculptSession *ss, const ListBase
float area_normal[3];
float cntr[3], cntr2[3], bstr = 0;
int flip = 0;
-
+ float *buffer;
calc_area_normal(sd, ss, area_normal, active_verts);
calc_flatten_center(ss, node, cntr);
@@ -547,7 +618,9 @@ static void do_flatten_clay_brush(Sculpt *sd, SculptSession *ss, const ListBase
cntr2[2]=cntr[2]+area_normal[2]*bstr*ss->cache->scale[2];
flip = bstr < 0;
}
-
+
+ buffer = ss->drawobject!=0?(float *)GPU_buffer_lock( ss->drawobject->vertices ):0;
+
while(node){
float *co= ss->mvert[node->Index].co;
float intr[3], val[3];
@@ -573,11 +646,21 @@ static void do_flatten_clay_brush(Sculpt *sd, SculptSession *ss, const ListBase
VecAddf(val, val, co);
+ if( buffer != 0 ) {
+ IndexLink *cur = &ss->drawobject->indices[node->Index];
+ while( cur != 0 && cur->element != -1 ) {
+ sculpt_clip(sd, ss, &buffer[cur->element*3], val);
+ cur = cur->next;
+ }
+ }
sculpt_clip(sd, ss, co, val);
+
}
node= node->next;
}
+ if( buffer != 0 )
+ GPU_buffer_unlock( ss->drawobject->vertices );
}
/* Uses symm to selectively flip any axis of a coordinate. */
@@ -898,7 +981,8 @@ static void add_face_normal(vec3f *norm, MVert *mvert, const MFace* face, float
static void update_damaged_vert(SculptSession *ss, ListBase *lb)
{
ActiveData *vert;
-
+
+ float *buffer = ss->drawobject!=0?(float *)GPU_buffer_lock( ss->drawobject->normals ):0;
for(vert= lb->first; vert; vert= vert->next) {
vec3f norm= {0,0,0};
IndexNode *face= ss->fmap[vert->Index].first;
@@ -915,7 +999,44 @@ static void update_damaged_vert(SculptSession *ss, ListBase *lb)
ss->mvert[vert->Index].no[0]=norm.x*32767;
ss->mvert[vert->Index].no[1]=norm.y*32767;
ss->mvert[vert->Index].no[2]=norm.z*32767;
+
+ if( buffer != 0 ) {
+ IndexLink *cur = &ss->drawobject->indices[vert->Index];
+ while( cur != 0 && cur->element != -1 ) {
+ int i = ss->drawobject->faceRemap[cur->element/3];
+ if( ss->mface[i].flag & ME_SMOOTH ) {
+ VECCOPY(&buffer[cur->element*3],ss->mvert[vert->Index].no);
+ }
+ else {
+ float norm[3];
+ if( ss->mface[i].v4 )
+ CalcNormFloat4(ss->mvert[ss->mface[i].v1].co, ss->mvert[ss->mface[i].v2].co, ss->mvert[ss->mface[i].v3].co, ss->mvert[ss->mface[i].v4].co, norm);
+ else
+ CalcNormFloat(ss->mvert[ss->mface[i].v1].co, ss->mvert[ss->mface[i].v2].co, ss->mvert[ss->mface[i].v3].co, norm);
+ VECCOPY(&buffer[(cur->element-cur->element%3)*3],norm);
+ VECCOPY(&buffer[(cur->element-cur->element%3+1)*3],norm);
+ VECCOPY(&buffer[(cur->element-cur->element%3+2)*3],norm);
+
+ /* maybe this was a quad - need to update the other triangle of the quad */
+ if( ss->drawobject->faceRemap[cur->element/3-1] == i ) {
+ VECCOPY(&buffer[(cur->element-cur->element%3-3)*3],norm);
+ VECCOPY(&buffer[(cur->element-cur->element%3-2)*3],norm);
+ VECCOPY(&buffer[(cur->element-cur->element%3-1)*3],norm);
+ }
+ if( ss->drawobject->faceRemap[cur->element/3+1] == i ) {
+ VECCOPY(&buffer[(cur->element-cur->element%3+3)*3],norm);
+ VECCOPY(&buffer[(cur->element-cur->element%3+4)*3],norm);
+ VECCOPY(&buffer[(cur->element-cur->element%3+5)*3],norm);
+ }
+ }
+
+ //VECCOPY(&buffer[cur->element*3],ss->mvert[vert->Index].no);
+ cur = cur->next;
+ }
+ }
}
+ if( buffer != 0 )
+ GPU_buffer_unlock( ss->drawobject->normals );
}
static void calc_damaged_verts(SculptSession *ss)
@@ -989,8 +1110,16 @@ static struct MultiresModifierData *sculpt_multires_active(Object *ob)
ModifierData *md;
for(md= modifiers_getVirtualModifierList(ob); md; md= md->next) {
- if(md->type == eModifierType_Multires && !md->next) {
- MultiresModifierData *mmd = (MultiresModifierData*)md;
+ if(md->type == eModifierType_Multires) {
+ MultiresModifierData *mmd= (MultiresModifierData*)md;
+
+ /* Check if any of the modifiers after multires are active
+ * if not it can use the multires struct */
+ for (md= md->next; md; md= md->next) {
+ if(md->mode & eModifierMode_Realtime)
+ return NULL;
+ }
+
if(mmd->lvl != 1)
return mmd;
}
@@ -1004,11 +1133,12 @@ static void sculpt_update_mesh_elements(bContext *C)
Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
int oldtotvert = ss->totvert;
+ DerivedMesh *dm = mesh_get_derived_final(CTX_data_scene(C), ob, CD_MASK_BAREMESH);
if((ss->multires = sculpt_multires_active(ob))) {
- DerivedMesh *dm = mesh_get_derived_final(CTX_data_scene(C), ob, CD_MASK_BAREMESH);
+ //DerivedMesh *dm = mesh_get_derived_final(CTX_data_scene(C), ob, CD_MASK_BAREMESH);
ss->totvert = dm->getNumVerts(dm);
- ss->totface = dm->getNumFaces(dm);
+ ss->totface = dm->getNumTessFaces(dm);
ss->mvert = dm->getVertDataArray(dm, CD_MVERT);
ss->mface = dm->getTessFaceDataArray(dm, CD_MFACE);
ss->face_normals = dm->getTessFaceDataArray(dm, CD_NORMAL);
@@ -1021,6 +1151,12 @@ static void sculpt_update_mesh_elements(bContext *C)
ss->mface = me->mface;
ss->face_normals = NULL;
}
+ if( GPU_buffer_legacy( dm ) ) {
+ ss->drawobject = 0;
+ }
+ else {
+ ss->drawobject = dm->drawObject;
+ }
if(ss->totvert != oldtotvert) {
if(ss->projverts) MEM_freeN(ss->projverts);
@@ -1039,7 +1175,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);
}
@@ -1091,8 +1227,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);
+
+ WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush);
- return brush_radial_control_exec(op, brush, 1);
+ return ret;
}
static void SCULPT_OT_radial_control(wmOperatorType *ot)
@@ -1329,16 +1468,30 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss)
{
StrokeCache *cache = ss->cache;
Brush *brush = paint_brush(&sd->paint);
+ float *buffer= NULL;
int i;
-
+
/* Restore the mesh before continuing with anchored stroke */
if((brush->flag & BRUSH_ANCHORED) && ss->mesh_co_orig) {
+
+ if(ss->drawobject)
+ buffer= (float *)GPU_buffer_lock(ss->drawobject->normals);
+
for(i = 0; i < ss->totvert; ++i) {
VecCopyf(ss->mvert[i].co, ss->mesh_co_orig[i]);
ss->mvert[i].no[0] = cache->orig_norms[i][0];
ss->mvert[i].no[1] = cache->orig_norms[i][1];
ss->mvert[i].no[2] = cache->orig_norms[i][2];
+ if( buffer != 0 ) {
+ IndexLink *cur = &ss->drawobject->indices[i];
+ while( cur != 0 && cur->element != -1 ) {
+ VECCOPY(&buffer[cur->element*3],cache->orig_norms[i]);
+ cur = cur->next;
+ }
+ }
}
+ if( buffer != 0 )
+ GPU_buffer_unlock( ss->drawobject->normals );
if(ss->face_normals) {
float *fn = ss->face_normals;
@@ -1437,7 +1590,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);
@@ -1566,10 +1719,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 *);