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:
authorPablo Dobarro <pablodp606@gmail.com>2019-07-31 13:58:50 +0300
committerPablo Dobarro <pablodp606@gmail.com>2019-07-31 14:04:55 +0300
commit4bb9fbd3a852c24db928f393467e1eab3a71af6c (patch)
treeba244e420c7758f114a0cf62e907b0e68b000933 /source/blender/blenkernel
parent03f652b2c1fc7de685185190ff95bdd240540388 (diff)
Sculpt/Paint: Brush curve presets
This patch introduces the same presets that are used for proportional editing in the brush falloff menu. The user can select any of these presets or use the regular custom falloff curve. The presets are hardcoded formulas, so the falloff curve is not used when they are active. This change improves the general feeling of the brushes and it is more convenient and simpler to use. The CUSTOM curve option should now be used in the case that an unusual deformation is needed, in other cases, the hardcoded curve presets should be the default. The smooth curve presets is a must in the grab brush, as it fixes the deformation issue with the current custom curve setting. The user may try to adjust the deformation by tweaking the curve, but it is nearly impossible to replicate this desired behavior. {F7636217} Other brushes that are included in the sculpt branch also rely on this as they need specific hardcoded falloffs to produce the desired effect. Reviewers: brecht, billreynish Reviewed By: brecht Subscribers: JulienKaspar Differential Revision: https://developer.blender.org/D5367
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/brush.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index ec9a774a65c..709f74808a3 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -1400,16 +1400,45 @@ void BKE_brush_randomize_texture_coords(UnifiedPaintSettings *ups, bool mask)
/* Uses the brush curve control to find a strength value */
float BKE_brush_curve_strength(const Brush *br, float p, const float len)
{
- float strength;
+ float strength = 1.0f;
if (p >= len) {
return 0;
}
else {
p = p / len;
+ p = 1.0f - p;
}
- strength = curvemapping_evaluateF(br->curve, 0, p);
+ switch (br->curve_preset) {
+ case BRUSH_CURVE_CUSTOM:
+ strength = curvemapping_evaluateF(br->curve, 0, 1.0f - p);
+ break;
+ case BRUSH_CURVE_SHARP:
+ strength = p * p;
+ break;
+ case BRUSH_CURVE_SMOOTH:
+ strength = 3.0f * p * p - 2.0f * p * p * p;
+ break;
+ case BRUSH_CURVE_ROOT:
+ strength = sqrtf(p);
+ break;
+ case BRUSH_CURVE_LIN:
+ strength = p;
+ break;
+ case BRUSH_CURVE_CONSTANT:
+ strength = 1.0f;
+ break;
+ case BRUSH_CURVE_SPHERE:
+ strength = sqrtf(2 * p - p * p);
+ break;
+ case BRUSH_CURVE_POW4:
+ strength = p * p * p * p;
+ break;
+ case BRUSH_CURVE_INVSQUARE:
+ strength = p * (2.0f - p);
+ break;
+ }
return strength;
}