[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59841] trunk/blender/source/blender: Ctr-Alt-F radial control operator for texture painting, controls the
Antony Riakiotakis
kalast at gmail.com
Thu Sep 5 16:02:59 CEST 2013
Revision: 59841
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59841
Author: psy-fi
Date: 2013-09-05 14:02:59 +0000 (Thu, 05 Sep 2013)
Log Message:
-----------
Ctr-Alt-F radial control operator for texture painting, controls the
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.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/BKE_brush.h
trunk/blender/source/blender/blenkernel/intern/brush.c
trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c
trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
trunk/blender/source/blender/windowmanager/intern/wm_operators.c
Modified: trunk/blender/source/blender/blenkernel/BKE_brush.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_brush.h 2013-09-05 13:37:53 UTC (rev 59840)
+++ trunk/blender/source/blender/blenkernel/BKE_brush.h 2013-09-05 14:02:59 UTC (rev 59841)
@@ -76,10 +76,10 @@
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 */
Modified: trunk/blender/source/blender/blenkernel/intern/brush.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/brush.c 2013-09-05 13:37:53 UTC (rev 59840)
+++ trunk/blender/source/blender/blenkernel/intern/brush.c 2013-09-05 14:02:59 UTC (rev 59841)
@@ -970,10 +970,10 @@
}
/* 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 @@
/**** 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 @@
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;
Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c 2013-09-05 13:37:53 UTC (rev 59840)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c 2013-09-05 14:02:59 UTC (rev 59841)
@@ -1011,7 +1011,8 @@
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 @@
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 @@
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 @@
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,8 +1088,13 @@
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);
+ }
}
static void paint_partial_visibility_keys(wmKeyMap *keymap)
@@ -1265,7 +1280,7 @@
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);
Modified: trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/sculpt.c 2013-09-05 13:37:53 UTC (rev 59840)
+++ trunk/blender/source/blender/editors/sculpt_paint/sculpt.c 2013-09-05 14:02:59 UTC (rev 59841)
@@ -3427,7 +3427,7 @@
/* 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();
}
Modified: trunk/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_operators.c 2013-09-05 13:37:53 UTC (rev 59840)
+++ trunk/blender/source/blender/windowmanager/intern/wm_operators.c 2013-09-05 14:02:59 UTC (rev 59841)
@@ -3391,6 +3391,7 @@
int initial_mouse[2];
unsigned int gltex;
ListBase orig_paintcursors;
+ bool use_secondary_tex;
void *cursor;
} RadialControl;
@@ -3434,7 +3435,7 @@
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 @@
}
}
+ rc->use_secondary_tex = RNA_boolean_get(op->ptr, "secondary_tex");
+
return 1;
}
@@ -3900,6 +3903,7 @@
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 ***************** */
More information about the Bf-blender-cvs
mailing list