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:
authorAntony Riakiotakis <kalast@gmail.com>2013-03-25 05:00:16 +0400
committerAntony Riakiotakis <kalast@gmail.com>2013-03-25 05:00:16 +0400
commitceb3225db77c5a86b8cb8cce555251c1dffdd033 (patch)
tree8f709801c59f683c2cb50ea67841c5f15861b075 /source/blender/editors
parent48a256c910e85405747ad47a62bcb70159aee638 (diff)
Alpha mask textures porting part 1: Support for projective texturing.
Also add random mapping to brushes.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c6
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c17
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c12
3 files changed, 27 insertions, 8 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 4f935ebdd8c..4478d68d3be 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -407,6 +407,9 @@ void paint_brush_init_tex(Brush *brush)
MTex *mtex = &brush->mtex;
if (mtex->tex && mtex->tex->nodetree)
ntreeTexBeginExecTree(mtex->tex->nodetree); /* has internal flag to detect it only does it once */
+ mtex = &brush->mask_mtex;
+ if (mtex->tex && mtex->tex->nodetree)
+ ntreeTexBeginExecTree(mtex->tex->nodetree);
}
}
@@ -416,6 +419,9 @@ void paint_brush_exit_tex(Brush *brush)
MTex *mtex = &brush->mtex;
if (mtex->tex && mtex->tex->nodetree)
ntreeTexEndExecTree(mtex->tex->nodetree->execdata);
+ mtex = &brush->mask_mtex;
+ if (mtex->tex && mtex->tex->nodetree)
+ ntreeTexEndExecTree(mtex->tex->nodetree->execdata);
}
}
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 7a0f7b817b3..5dcfa181fa2 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -264,7 +264,8 @@ typedef struct ProjPaintState {
short is_ortho;
bool do_masking; /* use masking during painting. Some operations such as airbrush may disable */
- short is_texbrush; /* only to avoid running */
+ bool is_texbrush; /* only to avoid running */
+ bool is_maskbrush;
#ifndef PROJ_DEBUG_NOSEAMBLEED
float seam_bleed_px;
#endif
@@ -3905,6 +3906,10 @@ static void *do_projectpaint_thread(void *ph_v)
alpha = 1.0f;
}
+ if (ps->is_maskbrush) {
+ alpha *= BKE_brush_sample_masktex(ps->scene, ps->brush, projPixel->projCoSS, thread_index, pool);
+ }
+
if (!ps->do_masking) {
/* for an aurbrush there is no real mask, so just multiply the alpha by it */
alpha *= falloff * BKE_brush_alpha_get(ps->scene, brush);
@@ -4153,14 +4158,15 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int
ps->blend = brush->blend;
/* disable for 3d mapping also because painting on mirrored mesh can create "stripes" */
- ps->do_masking = (brush->flag & BRUSH_AIRBRUSH || brush->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW ||
- brush->mtex.brush_map_mode == MTEX_MAP_MODE_3D) ? false : true;
- ps->is_texbrush = (brush->mtex.tex && brush->imagepaint_tool == PAINT_TOOL_DRAW) ? 1 : 0;
+ ps->do_masking = (brush->flag & BRUSH_AIRBRUSH || brush->mtex.brush_map_mode != MTEX_MAP_MODE_TILED) ? false : true;
+ ps->is_texbrush = (brush->mtex.tex && brush->imagepaint_tool == PAINT_TOOL_DRAW) ? true : false;
+ ps->is_maskbrush = (brush->flag & BRUSH_USE_MASK && brush->mask_mtex.tex) ? true : false;
}
else {
/* brush may be NULL*/
ps->do_masking = false;
ps->is_texbrush = false;
+ ps->is_maskbrush = false;
}
/* sizeof(ProjPixel), since we alloc this a _lot_ */
@@ -4321,7 +4327,8 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
}
/* override */
- ps.is_texbrush = 0;
+ ps.is_texbrush = false;
+ ps.is_maskbrush = false;
ps.do_masking = false;
orig_brush_size = BKE_brush_size_get(scene, ps.brush);
BKE_brush_size_set(scene, ps.brush, 32); /* cover the whole image */
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 8c5552f48bc..4ee31c8ebe2 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -178,14 +178,20 @@ static void paint_brush_update(bContext *C, Brush *brush, PaintMode mode,
ELEM4(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK,
SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE)))
{
- copy_v2_v2(ups->tex_mouse, mouse);
-
- if ((brush->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW) &&
+ if (((brush->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW) ||
+ (brush->mtex.brush_map_mode == MTEX_MAP_MODE_RANDOM)) &&
(brush->flag & BRUSH_RANDOM_ROTATION) &&
!(brush->flag & BRUSH_RAKE))
{
ups->brush_rotation = 2.0f * (float)M_PI * BLI_frand();
}
+
+ if ((brush->mtex.brush_map_mode == MTEX_MAP_MODE_RANDOM)) {
+ ups->tex_mouse[0] = BLI_frand() * stroke->vc.ar->sizex;
+ ups->tex_mouse[1] = BLI_frand() * stroke->vc.ar->sizey;;
+ } else {
+ copy_v2_v2(ups->tex_mouse, mouse);
+ }
}
if (brush->flag & BRUSH_ANCHORED) {