diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-01-16 15:50:17 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-01-16 15:50:17 +0400 |
commit | 944dfa23c451464c72ffd82f6987490a47ff3b02 (patch) | |
tree | 9ca3b7df7f3df21c5b403589262b8f73965f99e3 /source/blender/editors/sculpt_paint | |
parent | 03b43a0db02028a0a41f0c141cd5ef1b661e5766 (diff) | |
parent | 3123ad12a395031a1bf5a964582762a3831e9b1c (diff) |
svn merge ^/trunk/blender -r43392:43420
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_ops.c | 73 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_stroke.c | 49 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_utils.c | 2 |
4 files changed, 40 insertions, 86 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index a5e68f9a244..2fc7d569d63 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -126,7 +126,7 @@ void paint_calc_redraw_planes(float planes[4][4], const struct rcti *screen_rect); void projectf(struct bglMats *mats, const float v[3], float p[2]); -float paint_calc_object_space_radius(struct ViewContext *vc, float center[3], float pixel_radius); +float paint_calc_object_space_radius(struct ViewContext *vc, const float center[3], float pixel_radius); float paint_get_tex_pixel(struct Brush* br, float u, float v); int imapaint_pick_face(struct ViewContext *vc, struct Mesh *me, const int mval[2], unsigned int *index); void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, const int xy[2], float uv[2]); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index e81e1f6dc77..2a0ebb8316d 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -395,67 +395,14 @@ void ED_operatortypes_paint(void) static void ed_keymap_paint_brush_switch(wmKeyMap *keymap, const char *mode) { wmKeyMapItem *kmi; - - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", ONEKEY, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "index", 0); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", TWOKEY, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "index", 1); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", THREEKEY, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "index", 2); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", FOURKEY, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "index", 3); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", FIVEKEY, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "index", 4); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", SIXKEY, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "index", 5); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", SEVENKEY, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "index", 6); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", EIGHTKEY, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "index", 7); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", NINEKEY, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "index", 8); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", ZEROKEY, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "index", 9); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", ONEKEY, KM_PRESS, KM_SHIFT, 0); - RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "index", 10); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", TWOKEY, KM_PRESS, KM_SHIFT, 0); - RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "index", 11); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", THREEKEY, KM_PRESS, KM_SHIFT, 0); - RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "index", 12); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", FOURKEY, KM_PRESS, KM_SHIFT, 0); - RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "index", 13); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", FIVEKEY, KM_PRESS, KM_SHIFT, 0); - RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "index", 14); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", SIXKEY, KM_PRESS, KM_SHIFT, 0); - RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "index", 15); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", SEVENKEY, KM_PRESS, KM_SHIFT, 0); - RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "index", 16); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", EIGHTKEY, KM_PRESS, KM_SHIFT, 0); - RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "index", 17); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", NINEKEY, KM_PRESS, KM_SHIFT, 0); - RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "index", 18); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", ZEROKEY, KM_PRESS, KM_SHIFT, 0); - RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "index", 19); + int i; + /* index 0-9 (zero key is tenth), shift key for index 10-19 */ + for (i = 0; i < 20; i++) { + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", + ZEROKEY + ((i + 1) % 10), KM_PRESS, i < 10 ? 0 : KM_SHIFT, 0); + RNA_string_set(kmi->ptr, "mode", mode); + RNA_int_set(kmi->ptr, "index", i); + } } static void ed_keymap_paint_brush_size(wmKeyMap *keymap, const char *UNUSED(path)) @@ -556,11 +503,11 @@ void ED_keymap_paint(wmKeyConfig *keyconf) /* multires switch */ kmi= WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", PAGEUPKEY, KM_PRESS, 0, 0); RNA_int_set(kmi->ptr, "level", 1); - RNA_boolean_set(kmi->ptr, "relative", 1); + RNA_boolean_set(kmi->ptr, "relative", TRUE); kmi= WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", PAGEDOWNKEY, KM_PRESS, 0, 0); RNA_int_set(kmi->ptr, "level", -1); - RNA_boolean_set(kmi->ptr, "relative", 1); + RNA_boolean_set(kmi->ptr, "relative", TRUE); ed_keymap_paint_brush_switch(keymap, "sculpt"); ed_keymap_paint_brush_size(keymap, "tool_settings.sculpt.brush.size"); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index c3e0c35f524..67bd6ca9255 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -510,31 +510,33 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush, /* Special actions taken when paint cursor goes over mesh */ /* TODO: sculpt only for now */ static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc, - float location[3], float *visual_strength) + const float location[3]) { float unprojected_radius, projected_radius; - /* TODO: check whether this should really only be done when - brush is over mesh? */ - if(sd->draw_pressure && brush_use_alpha_pressure(vc->scene, brush)) - (*visual_strength) *= sd->pressure_value; - - if(sd->draw_anchored) - projected_radius = sd->anchored_size; - else { - if(brush->flag & BRUSH_ANCHORED) - projected_radius = 8; - else - projected_radius = brush_size(vc->scene, brush); - } - unprojected_radius = paint_calc_object_space_radius(vc, location, - projected_radius); + /* update the brush's cached 3D radius */ + if(!brush_use_locked_size(vc->scene, brush)) { + /* get 2D brush radius */ + if(sd->draw_anchored) + projected_radius = sd->anchored_size; + else { + if(brush->flag & BRUSH_ANCHORED) + projected_radius = 8; + else + projected_radius = brush_size(vc->scene, brush); + } + + /* convert brush radius from 2D to 3D */ + unprojected_radius = paint_calc_object_space_radius(vc, location, + projected_radius); - if(sd->draw_pressure && brush_use_size_pressure(vc->scene, brush)) - unprojected_radius *= sd->pressure_value; + /* scale 3D brush radius by pressure */ + if(sd->draw_pressure && brush_use_size_pressure(vc->scene, brush)) + unprojected_radius *= sd->pressure_value; - if(!brush_use_locked_size(vc->scene, brush)) + /* set cached value in either Brush or UnifiedPaintSettings */ brush_set_unprojected_radius(vc->scene, brush, unprojected_radius); + } } static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) @@ -613,8 +615,13 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) outline_col = brush->sub_col; /* only do if brush is over the mesh */ - if(hit) - paint_cursor_on_hit(sd, brush, &vc, location, &visual_strength); + if(hit) { + /* scale the alpha by pen pressure */ + if(sd->draw_pressure && brush_use_alpha_pressure(vc.scene, brush)) + visual_strength *= sd->pressure_value; + + paint_cursor_on_hit(sd, brush, &vc, location); + } /* don't show effect of strength past the soft limit */ if(visual_strength > 1) diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 6b863757932..70293765813 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -152,7 +152,7 @@ void projectf(bglMats *mats, const float v[3], float p[2]) p[1]= uy; } -float paint_calc_object_space_radius(ViewContext *vc, float center[3], +float paint_calc_object_space_radius(ViewContext *vc, const float center[3], float pixel_radius) { Object *ob = vc->obact; |