[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49970] branches/soc-2012-bratwurst: Texture Paint Alpha Masks
Antony Riakiotakis
kalast at gmail.com
Fri Aug 17 22:48:11 CEST 2012
Revision: 49970
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49970
Author: psy-fi
Date: 2012-08-17 20:48:11 +0000 (Fri, 17 Aug 2012)
Log Message:
-----------
Texture Paint Alpha Masks
=========================
* Add rotation for masks
* Fix rotation for projection painting.
* For now mask acts only as stencil for the cursor (ie non projective)
This can change though based on user input
Modified Paths:
--------------
branches/soc-2012-bratwurst/release/scripts/startup/bl_ui/properties_paint_common.py
branches/soc-2012-bratwurst/release/scripts/startup/bl_ui/space_view3d_toolbar.py
branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c
branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_image.c
Modified: branches/soc-2012-bratwurst/release/scripts/startup/bl_ui/properties_paint_common.py
===================================================================
--- branches/soc-2012-bratwurst/release/scripts/startup/bl_ui/properties_paint_common.py 2012-08-17 20:00:50 UTC (rev 49969)
+++ branches/soc-2012-bratwurst/release/scripts/startup/bl_ui/properties_paint_common.py 2012-08-17 20:48:11 UTC (rev 49970)
@@ -106,15 +106,15 @@
def brush_mask_texture_settings(layout, brush):
mask_tex_slot = brush.mask_texture_slot
- layout.label(text="Brush Mapping:")
+ if(brush.mask_texture):
+ layout.label(text="Mask Mapping:")
+ col = layout.column()
+ col.active = brush.paint_capabilities.has_texture_angle
+ col.prop(mask_tex_slot, "angle", text="")
- col = layout.column()
- col.active = brush.paint_capabilities.has_texture_angle
- col.prop(mask_tex_slot, "angle", text="")
+ # scale and offset
+ split = layout.split()
+ split.prop(mask_tex_slot, "offset")
+ split.prop(mask_tex_slot, "scale")
- # scale and offset
- split = layout.split()
- split.prop(mask_tex_slot, "offset")
- split.prop(mask_tex_slot, "scale")
-
Modified: branches/soc-2012-bratwurst/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2012-bratwurst/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2012-08-17 20:00:50 UTC (rev 49969)
+++ branches/soc-2012-bratwurst/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2012-08-17 20:48:11 UTC (rev 49970)
@@ -724,7 +724,6 @@
settings = self.paint_settings(context)
brush = settings.brush
tex_slot = brush.texture_slot
- tex_slot_alpha = brush.mask_texture_slot
col = layout.column()
Modified: branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c
===================================================================
--- branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c 2012-08-17 20:00:50 UTC (rev 49969)
+++ branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c 2012-08-17 20:48:11 UTC (rev 49970)
@@ -186,12 +186,11 @@
char do_tiled_texpaint = (br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED_TEXPAINT);
char do_tiled = (br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED) || do_tiled_texpaint;
*/
+
int alpha_size;
int j;
int refresh;
- //if (do_tiled && !br->mask_mtex.tex) return 0;
-
refresh =
(snap.BKE_brush_size_get != BKE_brush_size_get(vc->scene, br)) ||
!br->curve ||
@@ -251,6 +250,7 @@
float len;
for (i = 0; i < alpha_size; i++) {
+ const float rotation = -br->mask_mtex.rot;
int index = j * alpha_size + i;
float x;
float avg;
@@ -267,15 +267,22 @@
len = sqrtf(x * x + y * y);
if (len <= 1) {
- x *= br->mtex.size[0];
- y *= br->mtex.size[1];
+ avg = BKE_brush_curve_strength(br, len, 1); /* Falloff curve */
- x += br->mtex.ofs[0];
- y += br->mtex.ofs[1];
+ if(br->flag & BRUSH_USE_MASK) {
+ if (rotation > 0.001f || rotation < -0.001f) {
+ const float angle = atan2f(y, x) + rotation;
- avg = BKE_brush_curve_strength(br, len, 1); /* Falloff curve */
+ x = len * cosf(angle);
+ y = len * sinf(angle);
+ }
- if(br->flag & BRUSH_USE_MASK) {
+ x *= br->mask_mtex.size[0];
+ y *= br->mask_mtex.size[1];
+
+ x += br->mask_mtex.ofs[0];
+ y += br->mask_mtex.ofs[1];
+
avg *= br->mask_mtex.tex ? paint_get_tex_pixel(br, x, y, TRUE) : 1;
}
CLAMP(avg, 0.0, 1.0);
Modified: branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_image.c 2012-08-17 20:00:50 UTC (rev 49969)
+++ branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_image.c 2012-08-17 20:48:11 UTC (rev 49970)
@@ -3852,8 +3852,6 @@
const float *lastpos = ((ProjectHandle *)ph_v)->prevmval;
const float *pos = ((ProjectHandle *)ph_v)->mval;
const int thread_index = ((ProjectHandle *)ph_v)->thread_index;
- Scene *scene = ps->scene;
- UnifiedPaintSettings *unified_paint_settings = &scene->toolsettings->unified_paint_settings;
/* Done with args from ProjectHandle */
LinkNode *node;
@@ -3928,12 +3926,15 @@
/*if (dist < radius) {*/ /* correct but uses a sqrtf */
if (dist_nosqrt <= radius_squared) {
float samplecos[2];
+ float masksamplecos[2];
dist = sqrtf(dist_nosqrt);
falloff = BKE_brush_curve_strength_clamp(ps->brush, dist, radius);
- /* will eventuallly be separated when mask textures get their own attributes */
- if (ps->is_texbrush || ps->is_maskbrush) {
+ if(ps->is_maskbrush) {
+ sub_v2_v2v2(masksamplecos, projPixel->projCoSS, pos);
+ }
+ if (ps->is_texbrush) {
if(ps->brush->flag & (BRUSH_RAKE | BRUSH_RANDOM_ROTATION)) {
sub_v2_v2v2(samplecos, projPixel->projCoSS, pos);
} else {
@@ -3950,6 +3951,9 @@
else {
alpha = 1.0f;
}
+ if(ps->is_maskbrush) {
+ alpha *= BKE_brush_sample_masktex(ps->scene, ps->brush, masksamplecos, thread_index, -ps->rotation + ps->brush->mask_mtex.rot);
+ }
if (ps->is_airbrush || (ps->brush->flag & (BRUSH_RANDOM_ROTATION | BRUSH_RAKE))) {
/* for an airbrush or rake brush there is no real mask, so just multiply the alpha by it */
@@ -3974,10 +3978,6 @@
}
}
- if(ps->is_maskbrush) {
- alpha *= BKE_brush_sample_masktex(ps->scene, ps->brush, samplecos, thread_index, unified_paint_settings->last_angle);
- }
-
if (alpha > 0.0f) {
if (last_index != projPixel->image_index) {
More information about the Bf-blender-cvs
mailing list