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
path: root/source
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2013-09-14 03:58:00 +0400
committerAntony Riakiotakis <kalast@gmail.com>2013-09-14 03:58:00 +0400
commitb1179c4752395b5b3247e5a22587f4b65e45d72d (patch)
treefba66b5fa5940f8f7c9777c33548de4f3cf30f33 /source
parent8f3a40830d6679c8ad3d1c5ecc60bf8f49a21ec0 (diff)
Sculpting:
* Cleanup for previous commit and reduce some local variable referencing * Add support for brushes that operate on frontfaces only and do not show the option for those brushes. Currently only clay strips is in the list but this may change according to artist feedback. This should take care of the "sticky" surface problem completely.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_brush.h3
-rw-r--r--source/blender/blenkernel/BKE_paint.h1
-rw-r--r--source/blender/blenkernel/intern/brush.c5
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c51
-rw-r--r--source/blender/makesrna/intern/rna_brush.c7
5 files changed, 38 insertions, 29 deletions
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index b4c5f47cf25..ea2aa9c8bd3 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -111,5 +111,8 @@ void BKE_brush_scale_size(int *BKE_brush_size_get,
/* debugging only */
void BKE_brush_debug_print_state(struct Brush *br);
+/* sculpt */
+bool BKE_sculpt_brush_frontface_only(struct Brush *);
+
#endif
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 2baa8b78e47..1d81dfefe65 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -173,5 +173,4 @@ void free_sculptsession(struct Object *ob);
void free_sculptsession_deformMats(struct SculptSession *ss);
void sculptsession_bm_to_me(struct Object *ob, int reorder);
void sculptsession_bm_to_me_for_render(struct Object *object);
-
#endif
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 790c1f09ff0..0c79b8860d9 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -1048,3 +1048,8 @@ struct ImBuf *BKE_brush_gen_radial_control_imbuf(Brush *br, bool secondary)
return im;
}
+
+bool BKE_sculpt_brush_frontface_only(struct Brush *br)
+{
+ return br->sculpt_tool != SCULPT_TOOL_CLAY_STRIPS;
+}
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index dfe8e91f2f6..03e5e6672bf 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -318,6 +318,8 @@ typedef struct StrokeCache {
float plane_trim_squared;
rcti previous_r; /* previous redraw rectangle */
+
+ bool frontface; /* use front face */
} StrokeCache;
/************** Access to original unmodified vertex data *************/
@@ -669,10 +671,10 @@ static int sculpt_brush_test_cube(SculptBrushTest *test, float co[3], float loca
}
}
-static float frontface(Brush *brush, const float sculpt_normal[3],
+static float frontface(bool ff, const float sculpt_normal[3],
const short no[3], const float fno[3])
{
- if (brush->flag & BRUSH_FRONTFACE) {
+ if (ff) {
float dot;
if (no) {
@@ -949,7 +951,8 @@ static float tex_strength(SculptSession *ss, Brush *br,
const float fno[3],
const float mask)
{
- const Scene *scene = ss->cache->vc->scene;
+ const StrokeCache *cache = ss->cache;
+ const Scene *scene = cache->vc->scene;
MTex *mtex = &br->mtex;
float avg = 1;
float rgba[4];
@@ -971,12 +974,12 @@ static float tex_strength(SculptSession *ss, Brush *br,
* position in order to project it. This insures that the
* brush texture will be oriented correctly. */
- flip_v3_v3(symm_point, point, ss->cache->mirror_symmetry_pass);
+ flip_v3_v3(symm_point, point, cache->mirror_symmetry_pass);
- if (ss->cache->radial_symmetry_pass)
- mul_m4_v3(ss->cache->symm_rot_mat_inv, symm_point);
+ if (cache->radial_symmetry_pass)
+ mul_m4_v3(cache->symm_rot_mat_inv, symm_point);
- ED_view3d_project_float_v2_m4(ss->cache->vc->ar, symm_point, point_2d, ss->cache->projection_mat);
+ ED_view3d_project_float_v2_m4(cache->vc->ar, symm_point, point_2d, cache->projection_mat);
/* still no symmetry supported for other paint modes.
* Sculpt does it DIY */
@@ -984,7 +987,7 @@ static float tex_strength(SculptSession *ss, Brush *br,
/* Similar to fixed mode, but projects from brush angle
* rather than view direction */
- mul_m4_v3(ss->cache->brush_local_mat, symm_point);
+ mul_m4_v3(cache->brush_local_mat, symm_point);
x = symm_point[0];
y = symm_point[1];
@@ -1006,9 +1009,9 @@ static float tex_strength(SculptSession *ss, Brush *br,
}
/* Falloff curve */
- avg *= BKE_brush_curve_strength(br, len, ss->cache->radius);
+ avg *= BKE_brush_curve_strength(br, len, cache->radius);
- avg *= frontface(br, sculpt_normal, vno, fno);
+ avg *= frontface(cache->frontface, sculpt_normal, vno, fno);
/* Paint mask */
avg *= 1.0f - mask;
@@ -2307,11 +2310,9 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
{
if (sculpt_brush_test_fast(&test, unode->co[vd.i])) {
float fno[3];
- float dot_result;
normal_short_to_float_v3(fno, unode->no[vd.i]);
- dot_result = dot_v3v3(ss->cache->view_normal, fno);
- if (dot_result > 0) {
+ if (dot_v3v3(ss->cache->view_normal, fno) > 0) {
add_v3_v3(private_fc, unode->co[vd.i]);
private_count++;
}
@@ -2327,16 +2328,13 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
BKE_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test_fast(&test, vd.co)) {
- float dot_result;
-
/* for area normal */
if (vd.no) {
float fno[3];
normal_short_to_float_v3(fno, vd.no);
- dot_result = dot_v3v3(ss->cache->view_normal, fno);
- if (dot_result > 0) {
+ if (dot_v3v3(ss->cache->view_normal, fno) > 0) {
add_v3_v3(private_fc, vd.co);
private_count++;
}
@@ -2346,8 +2344,7 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
}
}
else {
- dot_result = dot_v3v3(ss->cache->view_normal, vd.fno);
- if (dot_result > 0) {
+ if (dot_v3v3(ss->cache->view_normal, vd.fno) > 0) {
add_v3_v3(private_fc, vd.co);
private_count++;
}
@@ -2423,11 +2420,10 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob,
if (sculpt_brush_test_fast(&test, unode->co[vd.i])) {
/* for area normal */
float fno[3];
- float dot_result;
normal_short_to_float_v3(fno, unode->no[vd.i]);
- dot_result = dot_v3v3(ss->cache->view_normal, fno);
- if (dot_result > 0) {
+
+ if (dot_v3v3(ss->cache->view_normal, fno) > 0) {
add_v3_v3(private_an, fno);
add_v3_v3(private_fc, unode->co[vd.i]);
private_count++;
@@ -2445,16 +2441,13 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob,
BKE_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test_fast(&test, vd.co)) {
- float dot_result;
-
/* for area normal */
if (vd.no) {
float fno[3];
normal_short_to_float_v3(fno, vd.no);
- dot_result = dot_v3v3(ss->cache->view_normal, fno);
- if (dot_result > 0) {
+ if (dot_v3v3(ss->cache->view_normal, fno) > 0) {
add_v3_v3(private_an, fno);
add_v3_v3(private_fc, vd.co);
private_count++;
@@ -2466,8 +2459,7 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob,
}
}
else {
- dot_result = dot_v3v3(ss->cache->view_normal, vd.fno);
- if (dot_result > 0) {
+ if (dot_v3v3(ss->cache->view_normal, vd.fno) > 0) {
add_v3_v3(private_an, vd.fno);
add_v3_v3(private_fc, vd.co);
private_count++;
@@ -3930,6 +3922,9 @@ static void sculpt_update_cache_invariants(bContext *C, Sculpt *sd, SculptSessio
cache->previous_vertex_rotation = 0;
cache->init_dir_set = false;
+ cache->frontface = ((brush->flag & BRUSH_FRONTFACE) != 0) ||
+ BKE_sculpt_brush_frontface_only(brush);
+
sculpt_omp_start(sd, ss);
}
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 405d38e9683..820a4605052 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -237,6 +237,12 @@ static int rna_SculptToolCapabilities_has_strength_get(PointerRNA *ptr)
return !ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK);
}
+static int rna_SculptToolCapabilities_has_frontface_get(PointerRNA *ptr)
+{
+ Brush *br = (Brush *)ptr->data;
+ return BKE_sculpt_brush_frontface_only(br);
+}
+
static int rna_BrushCapabilities_has_texture_angle_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
@@ -556,6 +562,7 @@ static void rna_def_sculpt_capabilities(BlenderRNA *brna)
SCULPT_TOOL_CAPABILITY(has_smooth_stroke, "Has Smooth Stroke");
SCULPT_TOOL_CAPABILITY(has_space_attenuation, "Has Space Attenuation");
SCULPT_TOOL_CAPABILITY(has_strength, "Has Strength");
+ SCULPT_TOOL_CAPABILITY(has_frontface, "Has Strength");
#undef SCULPT_CAPABILITY
}