Ctr-Alt-F radial control operator for texture painting, controls the
authorAntony Riakiotakis <kalast@gmail.com>
Thu, 5 Sep 2013 14:02:59 +0000 (14:02 +0000)
committerAntony Riakiotakis <kalast@gmail.com>
Thu, 5 Sep 2013 14:02:59 +0000 (14:02 +0000)
rotation of the brush mask texture.

Unfortunately secondary path does not work here because we do not have a
permanent switch to choose between primary-secondary brush texture. Use
operator property instead.

source/blender/blenkernel/BKE_brush.h
source/blender/blenkernel/intern/brush.c
source/blender/editors/sculpt_paint/paint_ops.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/windowmanager/intern/wm_operators.c

index edf710ef7c90cc3ca088dd4e748a6ade7a61eeee..b4c5f47cf25ac2d8396756fbac991f01cf2cb167 100644 (file)
@@ -76,10 +76,10 @@ float BKE_brush_sample_masktex(const Scene *scene, struct Brush *br, const float
                                const int thread, struct ImagePool *pool);
 
 /* texture */
-unsigned int *BKE_brush_gen_texture_cache(struct Brush *br, int half_side);
+unsigned int *BKE_brush_gen_texture_cache(struct Brush *br, int half_side, bool use_secondary);
 
 /* radial control */
-struct ImBuf *BKE_brush_gen_radial_control_imbuf(struct Brush *br);
+struct ImBuf *BKE_brush_gen_radial_control_imbuf(struct Brush *br, bool secondary);
 
 /* unified strength and size */
 
index 9812c49f08be1a68e87911fa9c545aa84bcaea9e..790c1f09ff087327022aaf3d6364a4d66807f0a5 100644 (file)
@@ -970,10 +970,10 @@ float BKE_brush_curve_strength(Brush *br, float p, const float len)
 }
 
 /* TODO: should probably be unified with BrushPainter stuff? */
-unsigned int *BKE_brush_gen_texture_cache(Brush *br, int half_side)
+unsigned int *BKE_brush_gen_texture_cache(Brush *br, int half_side, bool use_secondary)
 {
        unsigned int *texcache = NULL;
-       MTex *mtex = &br->mtex;
+       MTex *mtex = (use_secondary) ? &br->mask_mtex : &br->mtex;
        TexResult texres = {0};
        int hasrgb, ix, iy;
        int side = half_side * 2;
@@ -1014,7 +1014,7 @@ unsigned int *BKE_brush_gen_texture_cache(Brush *br, int half_side)
 
 
 /**** Radial Control ****/
-struct ImBuf *BKE_brush_gen_radial_control_imbuf(Brush *br)
+struct ImBuf *BKE_brush_gen_radial_control_imbuf(Brush *br, bool secondary)
 {
        ImBuf *im = MEM_callocN(sizeof(ImBuf), "radial control texture");
        unsigned int *texcache;
@@ -1023,7 +1023,7 @@ struct ImBuf *BKE_brush_gen_radial_control_imbuf(Brush *br)
        int i, j;
 
        curvemapping_initialize(br->curve);
-       texcache = BKE_brush_gen_texture_cache(br, half);
+       texcache = BKE_brush_gen_texture_cache(br, half, secondary);
        im->rect_float = MEM_callocN(sizeof(float) * side * side, "radial control rect");
        im->x = im->y = side;
 
index bdf542526eed05ce71895b75bc36bebdd471a4a1..0b0607babc10b146bde2a64603d84007263ecb6b 100644 (file)
@@ -1011,7 +1011,8 @@ typedef enum {
        RC_COLOR    = 1,
        RC_ROTATION = 2,
        RC_ZOOM     = 4,
-       RC_WEIGHT   = 8
+       RC_WEIGHT   = 8,
+       RC_SECONDARY_ROTATION = 16
 } RCFlags;
 
 static void set_brush_rc_path(PointerRNA *ptr, const char *brush_path,
@@ -1043,7 +1044,10 @@ static void set_brush_rc_props(PointerRNA *ptr, const char *paint,
                RNA_string_set(ptr, "data_path_secondary", "");
        }
        set_brush_rc_path(ptr, brush_path, "color_path", "cursor_color_add");
-       set_brush_rc_path(ptr, brush_path, "rotation_path", "texture_slot.angle");
+       if (flags & RC_SECONDARY_ROTATION)
+               set_brush_rc_path(ptr, brush_path, "rotation_path", "mask_texture_slot.angle");
+       else
+               set_brush_rc_path(ptr, brush_path, "rotation_path", "texture_slot.angle");
        RNA_string_set(ptr, "image_id", brush_path);
 
        if (flags & RC_COLOR)
@@ -1055,6 +1059,11 @@ static void set_brush_rc_props(PointerRNA *ptr, const char *paint,
        else
                RNA_string_set(ptr, "zoom_path", "");
 
+       if (flags & RC_SECONDARY_ROTATION)
+               RNA_boolean_set(ptr, "secondary_tex", true);
+       else
+               RNA_boolean_set(ptr, "secondary_tex", false);
+
        MEM_freeN(brush_path);
 }
 
@@ -1064,6 +1073,7 @@ static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *p
        wmKeyMapItem *kmi;
        /* only size needs to follow zoom, strength shows fixed size circle */
        int flags_nozoom = flags & (~RC_ZOOM);
+       int flags_noradial_secondary = flags & (~(RC_SECONDARY_ROTATION | RC_ZOOM));
 
        kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, 0, 0);
        set_brush_rc_props(kmi->ptr, paint, "size", "use_unified_size", flags);
@@ -1078,7 +1088,12 @@ static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *p
 
        if (flags & RC_ROTATION) {
                kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0);
-               set_brush_rc_props(kmi->ptr, paint, "texture_slot.angle", NULL, flags_nozoom);
+               set_brush_rc_props(kmi->ptr, paint, "texture_slot.angle", NULL, flags_noradial_secondary);
+       }
+
+       if (flags & RC_SECONDARY_ROTATION) {
+               kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
+               set_brush_rc_props(kmi->ptr, paint, "mask_texture_slot.angle", NULL, flags_nozoom);
        }
 }
 
@@ -1265,7 +1280,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
 
        ed_keymap_paint_brush_switch(keymap, "image_paint");
        ed_keymap_paint_brush_size(keymap, "tool_settings.image_paint.brush.size");
-       ed_keymap_paint_brush_radial_control(keymap, "image_paint", RC_COLOR | RC_ZOOM | RC_ROTATION);
+       ed_keymap_paint_brush_radial_control(keymap, "image_paint", RC_COLOR | RC_ZOOM | RC_ROTATION | RC_SECONDARY_ROTATION);
 
        ed_keymap_stencil(keymap);
 
index 9046adc6cdfebbf8ec162f7e7ce6c2a93eca7ee9..9ba4f507b69a9e0a1cc900fd4c60e3bea7c34ea2 100644 (file)
@@ -3427,7 +3427,7 @@ static void sculpt_update_tex(const Scene *scene, Sculpt *sd, SculptSession *ss)
        /* Need to allocate a bigger buffer for bigger brush size */
        ss->texcache_side = 2 * radius;
        if (!ss->texcache || ss->texcache_side > ss->texcache_actual) {
-               ss->texcache = BKE_brush_gen_texture_cache(brush, radius);
+               ss->texcache = BKE_brush_gen_texture_cache(brush, radius, false);
                ss->texcache_actual = ss->texcache_side;
                ss->tex_pool = BKE_image_pool_new();
        }
index 52d7b8bc58a7225799b7a1a5de855ebbfd8e5bf2..ad764cda85368909437314e2e7e292444c64c0cb 100644 (file)
@@ -3391,6 +3391,7 @@ typedef struct {
        int initial_mouse[2];
        unsigned int gltex;
        ListBase orig_paintcursors;
+       bool use_secondary_tex;
        void *cursor;
 } RadialControl;
 
@@ -3434,7 +3435,7 @@ static void radial_control_set_tex(RadialControl *rc)
 
        switch (RNA_type_to_ID_code(rc->image_id_ptr.type)) {
                case ID_BR:
-                       if ((ibuf = BKE_brush_gen_radial_control_imbuf(rc->image_id_ptr.data))) {
+                       if ((ibuf = BKE_brush_gen_radial_control_imbuf(rc->image_id_ptr.data, rc->use_secondary_tex))) {
                                glGenTextures(1, &rc->gltex);
                                glBindTexture(GL_TEXTURE_2D, rc->gltex);
                                glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, ibuf->x, ibuf->y, 0,
@@ -3707,6 +3708,8 @@ static int radial_control_get_properties(bContext *C, wmOperator *op)
                }
        }
 
+       rc->use_secondary_tex = RNA_boolean_get(op->ptr, "secondary_tex");
+
        return 1;
 }
 
@@ -3900,6 +3903,7 @@ static void WM_OT_radial_control(wmOperatorType *ot)
        RNA_def_string(ot->srna, "fill_color_path", "", 0, "Fill Color Path", "Path of property used to set the fill color of the control");
        RNA_def_string(ot->srna, "zoom_path", "", 0, "Zoom Path", "Path of property used to set the zoom level for the control");
        RNA_def_string(ot->srna, "image_id", "", 0, "Image ID", "Path of ID that is used to generate an image for the control");
+       RNA_def_boolean(ot->srna, "secondary_tex", 0, "Secondary Texture", "Tweak brush secondary/mask texture");
 }
 
 /* ************************** timer for testing ***************** */