Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/brush.c
| Show First 20 Lines • Show All 1,394 Lines • ▼ Show 20 Lines | else { | ||||
| ups->tex_mouse[0] = BLI_rng_get_float(brush_rng) * ups->pixel_radius; | ups->tex_mouse[0] = BLI_rng_get_float(brush_rng) * ups->pixel_radius; | ||||
| ups->tex_mouse[1] = BLI_rng_get_float(brush_rng) * ups->pixel_radius; | ups->tex_mouse[1] = BLI_rng_get_float(brush_rng) * ups->pixel_radius; | ||||
| } | } | ||||
| } | } | ||||
| /* Uses the brush curve control to find a strength value */ | /* Uses the brush curve control to find a strength value */ | ||||
| float BKE_brush_curve_strength(const Brush *br, float p, const float len) | float BKE_brush_curve_strength(const Brush *br, float p, const float len) | ||||
| { | { | ||||
| float strength; | float strength = 1.0f; | ||||
| if (p >= len) { | if (p >= len) { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| else { | else { | ||||
| p = p / len; | 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; | return strength; | ||||
| } | } | ||||
| /* Uses the brush curve control to find a strength value between 0 and 1 */ | /* Uses the brush curve control to find a strength value between 0 and 1 */ | ||||
| float BKE_brush_curve_strength_clamped(Brush *br, float p, const float len) | float BKE_brush_curve_strength_clamped(Brush *br, float p, const float len) | ||||
| { | { | ||||
| float strength = BKE_brush_curve_strength(br, p, len); | float strength = BKE_brush_curve_strength(br, p, len); | ||||
| ▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines | |||||