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:
authorPablo Dobarro <pablodp606@gmail.com>2019-12-01 22:29:11 +0300
committerPablo Dobarro <pablodp606@gmail.com>2019-12-09 18:57:39 +0300
commit448669a630d318a5cd090af3083c985740a68e8e (patch)
tree80183ed40a349268fa97dd42969f90843258c91f /source
parent40e2f4469a76f7fab5501b877c929db181dbc6a4 (diff)
Fix T72092: Clay Strips Brush stroke crash with Brush Detail Size
Some other areas in the brush code outside sculpt mode assume that pressure is multiplied directly on top of the initial size. This patch calculates the pixel radius correctly using the brush size from sculpt mode to get the dyntopo detail size. When the new brush input system is in place, all these values will come directly from the brush input code with all the custom curves applied per brush, so all paint modes will have a correct brush behavior and all this sculpt mode specific code won't be necessary. Reviewed By: jbakker Maniphest Tasks: T72092 Differential Revision: https://developer.blender.org/D6339
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c1
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c10
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h4
-rw-r--r--source/blender/makesdna/DNA_scene_types.h3
4 files changed, 11 insertions, 7 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index fc0c6d748cb..372ea954630 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -335,6 +335,7 @@ static bool paint_brush_update(bContext *C,
ups->size_pressure_value = stroke->cached_size_pressure;
ups->pixel_radius = BKE_brush_size_get(scene, brush);
+ ups->initial_pixel_radius = BKE_brush_size_get(scene, brush);
if (BKE_brush_use_size_pressure(brush) && paint_supports_dynamic_size(brush, mode)) {
ups->pixel_radius *= stroke->cached_size_pressure;
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 8be44066741..b35fc11aedc 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -6730,11 +6730,12 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, Po
if (BKE_brush_use_size_pressure(brush) &&
paint_supports_dynamic_size(brush, PAINT_MODE_SCULPT)) {
cache->radius = sculpt_brush_dynamic_size_get(brush, cache, cache->initial_radius);
- cache->dyntopo_radius = cache->initial_radius * cache->pressure;
+ cache->dyntopo_pixel_radius = sculpt_brush_dynamic_size_get(
+ brush, cache, ups->initial_pixel_radius);
}
else {
cache->radius = cache->initial_radius;
- cache->dyntopo_radius = cache->initial_radius;
+ cache->dyntopo_pixel_radius = ups->initial_pixel_radius;
}
cache->radius_squared = cache->radius * cache->radius;
@@ -7345,12 +7346,11 @@ static void sculpt_stroke_update_step(bContext *C,
BKE_pbvh_bmesh_detail_size_set(ss->pbvh, object_space_constant_detail);
}
else if (sd->flags & SCULPT_DYNTOPO_DETAIL_BRUSH) {
- BKE_pbvh_bmesh_detail_size_set(ss->pbvh,
- ss->cache->dyntopo_radius * sd->detail_percent / 100.0f);
+ BKE_pbvh_bmesh_detail_size_set(ss->pbvh, ss->cache->radius * sd->detail_percent / 100.0f);
}
else {
BKE_pbvh_bmesh_detail_size_set(ss->pbvh,
- (ss->cache->dyntopo_radius / (float)ups->pixel_radius) *
+ (ss->cache->radius / ss->cache->dyntopo_pixel_radius) *
(float)(sd->detail_size * U.pixelsize) / 0.4f);
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 324ca250c86..e9ad31d6f25 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -319,8 +319,8 @@ typedef struct StrokeCache {
float location[3];
float last_location[3];
- /* This radius variable is not affected by pressure curves */
- float dyntopo_radius;
+ /* Original pixel radius with the pressure curve applied for dyntopo detail size */
+ float dyntopo_pixel_radius;
bool is_last_valid;
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 5336ea381c3..980fbfa72e0 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1277,6 +1277,9 @@ typedef struct UnifiedPaintSettings {
/* radius of brush, premultiplied with pressure.
* In case of anchored brushes contains the anchored radius */
float pixel_radius;
+ float initial_pixel_radius;
+
+ char _pad[4];
/* drawing pressure */
float size_pressure_value;