Use paint mask when calculating sculpt strength.

This commit is contained in:
Nicholas Bishop 2012-05-10 20:34:54 +00:00
parent 41b5206270
commit 72de988d0f

@ -702,7 +702,8 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3],
const float len,
const float sculpt_normal[3],
const short vno[3],
const float fno[3])
const float fno[3],
const float mask)
{
MTex *mtex = &br->mtex;
float avg = 1;
@ -797,6 +798,9 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3],
avg *= frontface(br, sculpt_normal, vno, fno);
/* Paint mask */
avg *= 1.0f - mask;
return avg;
}
@ -1028,7 +1032,7 @@ static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node,
BLI_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) {
if (sculpt_brush_test(&test, vd.co)) {
const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist,
ss->cache->view_normal, vd.no, vd.fno);
ss->cache->view_normal, vd.no, vd.fno, *vd.mask);
float avg[3], val[3];
neighbor_average(ss, avg, vd.vert_indices[vd.i]);
@ -1108,6 +1112,7 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no
for (x = 0; x < gridsize; ++x) {
float *co;
float *fno;
float *mask;
int index;
if (x == 0 && adj->index[0] == -1)
@ -1125,10 +1130,11 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no
index = x + y*gridsize;
co = CCG_elem_offset_co(&key, data, index);
fno = CCG_elem_offset_no(&key, data, index);
mask = CCG_elem_offset_no(&key, data, index);
if (sculpt_brush_test(&test, co)) {
const float fade = bstrength*tex_strength(ss, brush, co, test.dist,
ss->cache->view_normal, NULL, fno);
ss->cache->view_normal, NULL, fno, *mask);
float *avg, val[3];
float n;
@ -1226,7 +1232,7 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
if (sculpt_brush_test(&test, vd.co)) {
/* offset vertex */
float fade = tex_strength(ss, brush, vd.co, test.dist,
area_normal, vd.no, vd.fno);
area_normal, vd.no, vd.fno, *vd.mask);
mul_v3_v3fl(proxy[vd.i], offset, fade);
@ -1282,7 +1288,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
if (sculpt_brush_test(&test, vd.co)) {
/* offset vertex */
const float fade = tex_strength(ss, brush, vd.co, test.dist,
area_normal, vd.no, vd.fno);
area_normal, vd.no, vd.fno, *vd.mask);
float val1[3];
float val2[3];
@ -1323,7 +1329,8 @@ static void do_pinch_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
if (sculpt_brush_test(&test, vd.co)) {
float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist,
ss->cache->view_normal, vd.no, vd.fno);
ss->cache->view_normal, vd.no,
vd.fno, *vd.mask);
float val[3];
sub_v3_v3v3(val, test.location, vd.co);
@ -1385,7 +1392,7 @@ static void do_grab_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
if (sculpt_brush_test(&test, origco[vd.i])) {
const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist,
an, origno[vd.i], NULL);
an, origno[vd.i], NULL, *vd.mask);
mul_v3_v3fl(proxy[vd.i], grab_delta, fade);
@ -1427,7 +1434,7 @@ static void do_nudge_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
if (sculpt_brush_test(&test, vd.co)) {
const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist,
an, vd.no, vd.fno);
an, vd.no, vd.fno, *vd.mask);
mul_v3_v3fl(proxy[vd.i], cono, fade);
@ -1477,7 +1484,7 @@ static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
if (sculpt_brush_test(&test, vd.co)) {
const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist,
an, vd.no, vd.fno);
an, vd.no, vd.fno, *vd.mask);
mul_v3_v3fl(proxy[vd.i], grab_delta, fade);
@ -1526,7 +1533,7 @@ static void do_thumb_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
if (sculpt_brush_test(&test, origco[vd.i])) {
const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist,
an, origno[vd.i], NULL);
an, origno[vd.i], NULL, *vd.mask);
mul_v3_v3fl(proxy[vd.i], cono, fade);
@ -1580,7 +1587,7 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
if (sculpt_brush_test(&test, origco[vd.i])) {
const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist,
an, origno[vd.i], NULL);
an, origno[vd.i], NULL, *vd.mask);
mul_v3_m4v3(proxy[vd.i], m, origco[vd.i]);
sub_v3_v3(proxy[vd.i], origco[vd.i]);
@ -1633,7 +1640,7 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
if (sculpt_brush_test(&test, origco[vd.i])) {
const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist,
area_normal, vd.no, vd.fno);
area_normal, vd.no, vd.fno, *vd.mask);
float *disp = &layer_disp[vd.i];
float val[3];
@ -1685,7 +1692,7 @@ static void do_inflate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
if (sculpt_brush_test(&test, vd.co)) {
const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist,
ss->cache->view_normal, vd.no, vd.fno);
ss->cache->view_normal, vd.no, vd.fno, *vd.mask);
float val[3];
if (vd.fno) copy_v3_v3(val, vd.fno);
@ -2021,7 +2028,7 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
if (plane_trim(ss->cache, brush, val)) {
const float fade = bstrength*tex_strength(ss, brush, vd.co, sqrt(test.dist),
an, vd.no, vd.fno);
an, vd.no, vd.fno, *vd.mask);
mul_v3_v3fl(proxy[vd.i], val, fade);
@ -2094,7 +2101,7 @@ static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
if (plane_trim(ss->cache, brush, val)) {
const float fade = bstrength*tex_strength(ss, brush, vd.co,
sqrt(test.dist),
an, vd.no, vd.fno);
an, vd.no, vd.fno, *vd.mask);
mul_v3_v3fl(proxy[vd.i], val, fade);
@ -2195,7 +2202,7 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t
if (plane_trim(ss->cache, brush, val)) {
const float fade = bstrength*tex_strength(ss, brush, vd.co,
ss->cache->radius*test.dist,
an, vd.no, vd.fno);
an, vd.no, vd.fno, *vd.mask);
mul_v3_v3fl(proxy[vd.i], val, fade);
@ -2258,7 +2265,7 @@ static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
if (plane_trim(ss->cache, brush, val)) {
const float fade = bstrength*tex_strength(ss, brush, vd.co,
sqrt(test.dist),
an, vd.no, vd.fno);
an, vd.no, vd.fno, *vd.mask);
mul_v3_v3fl(proxy[vd.i], val, fade);
@ -2321,7 +2328,7 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
if (plane_trim(ss->cache, brush, val)) {
const float fade = bstrength*tex_strength(ss, brush, vd.co,
sqrt(test.dist),
an, vd.no, vd.fno);
an, vd.no, vd.fno, *vd.mask);
mul_v3_v3fl(proxy[vd.i], val, fade);