[Bf-blender-cvs] [7bba304c57b] temp_bmesh_multires: * Dyntopo now has its own brush spacing. This is a huge performance boost for brushes with fine spacing, e.g. the clay brush.
Joseph Eagar
noreply at git.blender.org
Thu Apr 1 23:52:14 CEST 2021
Commit: 7bba304c57b9473db421407f82000656c88d6683
Author: Joseph Eagar
Date: Thu Apr 1 14:51:10 2021 -0700
Branches: temp_bmesh_multires
https://developer.blender.org/rB7bba304c57b9473db421407f82000656c88d6683
* Dyntopo now has its own brush spacing. This is a huge performance
boost for brushes with fine spacing, e.g. the clay brush.
===================================================================
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/blenkernel/intern/brush.c
M source/blender/blenkernel/intern/paint.c
M source/blender/editors/sculpt_paint/paint_intern.h
M source/blender/editors/sculpt_paint/paint_stroke.c
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_intern.h
M source/blender/makesdna/DNA_brush_defaults.h
M source/blender/makesdna/DNA_brush_enums.h
M source/blender/makesdna/DNA_brush_types.h
M source/blender/makesdna/DNA_scene_types.h
M source/blender/makesrna/intern/rna_brush.c
M source/blender/makesrna/intern/rna_sculpt_paint.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 6cbf2fd4533..fb4553bd820 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -807,6 +807,8 @@ class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
col.prop(sculpt, "use_smooth_shading")
col.prop(sculpt, "use_flat_vcol_shading")
+ col.prop(sculpt, "dyntopo_spacing")
+
class VIEW3D_PT_sculpt_voxel_remesh(Panel, View3DPaintPanel):
bl_context = ".sculpt_mode" # dot on purpose (access from topbar)
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index f42f46bda79..ae9a9ca6731 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -2595,7 +2595,7 @@ void BKE_brush_get_dyntopo(Brush *brush, Sculpt *sd, DynTopoSettings *out)
int inherit = out->inherit;
if (out->inherit & DYNTOPO_INHERIT_ALL) {
- inherit = 0x7FFF;
+ inherit = 0x7FFFFFF;
}
if (inherit & DYNTOPO_INHERIT_MODE) {
@@ -2621,6 +2621,10 @@ void BKE_brush_get_dyntopo(Brush *brush, Sculpt *sd, DynTopoSettings *out)
out->detail_percent = sd->detail_percent;
}
+ if (inherit & DYNTOPO_INHERIT_SPACING) {
+ out->spacing = sd->dyntopo_spacing;
+ }
+
if (inherit & DYNTOPO_INHERIT_CONSTANT_DETAIL) {
out->constant_detail = sd->constant_detail;
}
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 66033199ea6..e37a12841ee 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -1913,6 +1913,11 @@ void BKE_sculpt_toolsettings_data_ensure(struct Scene *scene)
if (!sd->detail_percent) {
sd->detail_percent = 25;
}
+
+ if (!sd->dyntopo_spacing) {
+ sd->dyntopo_spacing = 25;
+ }
+
if (sd->constant_detail == 0.0f) {
sd->constant_detail = 3.0f;
}
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index 3ca0d853d6a..c19679284b8 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -51,6 +51,10 @@ typedef struct CoNo {
float no[3];
} CoNo;
+#include "ED_view3d.h"
+#include "DNA_listBase.h"
+#include "DNA_scene_types.h"
+
/* paint_stroke.c */
typedef bool (*StrokeGetLocation)(struct bContext *C, float location[3], const float mouse[2]);
typedef bool (*StrokeTestStart)(struct bContext *C, struct wmOperator *op, const float mouse[2]);
@@ -60,6 +64,81 @@ typedef void (*StrokeUpdateStep)(struct bContext *C,
typedef void (*StrokeRedraw)(const struct bContext *C, struct PaintStroke *stroke, bool final);
typedef void (*StrokeDone)(const struct bContext *C, struct PaintStroke *stroke);
+
+typedef struct PaintSample {
+ float mouse[2];
+ float pressure;
+} PaintSample;
+
+typedef struct PaintStroke {
+ void *mode_data;
+ void *stroke_cursor;
+ struct wmTimer *timer;
+ struct RNG *rng;
+
+ /* Cached values */
+ struct ViewContext vc;
+ struct Brush *brush;
+ struct UnifiedPaintSettings *ups;
+
+ /* used for lines and curves */
+ ListBase line;
+
+ /* Paint stroke can use up to PAINT_MAX_INPUT_SAMPLES prior inputs
+ * to smooth the stroke */
+ PaintSample samples[PAINT_MAX_INPUT_SAMPLES];
+ int num_samples;
+ int cur_sample;
+ int tot_samples;
+
+ float last_mouse_position[2];
+ float last_world_space_position[3];
+ bool stroke_over_mesh;
+ /* space distance covered so far */
+ float stroke_distance;
+ float stroke_distance_t; //divided by brush radius
+
+ /* Set whether any stroke step has yet occurred
+ * e.g. in sculpt mode, stroke doesn't start until cursor
+ * passes over the mesh */
+ bool stroke_started;
+ /* Set when enough motion was found for rake rotation */
+ bool rake_started;
+ /* event that started stroke, for modal() return */
+ int event_type;
+ /* check if stroke variables have been initialized */
+ bool stroke_init;
+ /* check if various brush mapping variables have been initialized */
+ bool brush_init;
+ float initial_mouse[2];
+ /* cached_pressure stores initial pressure for size pressure influence mainly */
+ float cached_size_pressure;
+ /* last pressure will store last pressure value for use in interpolation for space strokes */
+ float last_pressure;
+ int stroke_mode;
+
+ float last_tablet_event_pressure;
+
+ float zoom_2d;
+ int pen_flip;
+
+ /* Tilt, as read from the event. */
+ float x_tilt;
+ float y_tilt;
+
+ /* line constraint */
+ bool constrain_line;
+ float constrained_pos[2];
+
+ StrokeGetLocation get_location;
+ StrokeTestStart test_start;
+ StrokeUpdateStep update_step;
+ StrokeRedraw redraw;
+ StrokeDone done;
+
+ float spacing;
+} PaintStroke;
+
struct PaintStroke *paint_stroke_new(struct bContext *C,
struct wmOperator *op,
StrokeGetLocation get_location,
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 57b1102219e..d1604e01610 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -67,77 +67,6 @@
# include "PIL_time_utildefines.h"
#endif
-typedef struct PaintSample {
- float mouse[2];
- float pressure;
-} PaintSample;
-
-typedef struct PaintStroke {
- void *mode_data;
- void *stroke_cursor;
- wmTimer *timer;
- struct RNG *rng;
-
- /* Cached values */
- ViewContext vc;
- Brush *brush;
- UnifiedPaintSettings *ups;
-
- /* used for lines and curves */
- ListBase line;
-
- /* Paint stroke can use up to PAINT_MAX_INPUT_SAMPLES prior inputs
- * to smooth the stroke */
- PaintSample samples[PAINT_MAX_INPUT_SAMPLES];
- int num_samples;
- int cur_sample;
- int tot_samples;
-
- float last_mouse_position[2];
- float last_world_space_position[3];
- bool stroke_over_mesh;
- /* space distance covered so far */
- float stroke_distance;
-
- /* Set whether any stroke step has yet occurred
- * e.g. in sculpt mode, stroke doesn't start until cursor
- * passes over the mesh */
- bool stroke_started;
- /* Set when enough motion was found for rake rotation */
- bool rake_started;
- /* event that started stroke, for modal() return */
- int event_type;
- /* check if stroke variables have been initialized */
- bool stroke_init;
- /* check if various brush mapping variables have been initialized */
- bool brush_init;
- float initial_mouse[2];
- /* cached_pressure stores initial pressure for size pressure influence mainly */
- float cached_size_pressure;
- /* last pressure will store last pressure value for use in interpolation for space strokes */
- float last_pressure;
- int stroke_mode;
-
- float last_tablet_event_pressure;
-
- float zoom_2d;
- int pen_flip;
-
- /* Tilt, as read from the event. */
- float x_tilt;
- float y_tilt;
-
- /* line constraint */
- bool constrain_line;
- float constrained_pos[2];
-
- StrokeGetLocation get_location;
- StrokeTestStart test_start;
- StrokeUpdateStep update_step;
- StrokeRedraw redraw;
- StrokeDone done;
-} PaintStroke;
-
/*** Cursors ***/
static void paint_draw_smooth_cursor(bContext *C, int x, int y, void *customdata)
{
@@ -430,11 +359,13 @@ static bool paint_brush_update(bContext *C,
ups->anchored_size /= 2.0f;
ups->pixel_radius /= 2.0f;
stroke->stroke_distance = ups->pixel_radius;
+ stroke->stroke_distance_t = 1.0f;
}
else {
copy_v2_v2(ups->anchored_initial_mouse, stroke->initial_mouse);
copy_v2_v2(mouse, stroke->initial_mouse);
stroke->stroke_distance = ups->pixel_radius;
+ stroke->stroke_distance_t = 1.0f;
}
ups->pixel_radius /= stroke->zoom_2d;
ups->draw_anchored = true;
@@ -868,6 +799,8 @@ static int paint_space_stroke(bContext *C,
spacing / no_pressure_spacing);
stroke->stroke_distance += spacing / stroke->zoom_2d;
+ stroke->stroke_distance_t += (spacing / stroke->zoom_2d) / stroke->ups->pixel_radius;
+
paint_brush_stroke_add_step(C, op, mouse, pressure);
length -= spacing;
@@ -1204,6 +1137,8 @@ static void paint_line_strokes_spacing(bContext *C,
length += *length_residue;
*length_residue = 0.0;
+ stroke->spacing = spacing;
+
if (length >= spacing) {
mouse[0] = stroke->last_mouse_position[0] + dmouse[0] * spacing_final;
mouse[1] = stroke->last_mouse_position[1] + dmouse[1] * spacing_final;
@@ -1211,6 +1146,8 @@ static void paint_line_strokes_spacing(bContext *C,
ups->overlap_factor = paint_stroke_integrate_overlap(stroke->brush, 1.0);
stroke->stroke_distance += spacing / stroke->zoom_2d;
+ stroke->stroke_distance_t += (spacing / stroke->zoom_2d) / stroke->ups->pixel_radius;
+
paint_brush_stroke_add_step(C, op, mouse, 1.0);
length -= spacing;
@@ -1426,6 +1363,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* one time stroke initialization */
if (!stroke->stroke_started) {
stroke->last_pressure = sample_average.pressure;
+
copy_v2_v2(stroke->last_mouse_position, sample_average.mouse);
if (paint_stroke_use_scene_spacing(br, mode)) {
stroke->stroke_over_mesh = SCULPT_stroke_get_location(
@@ -1512,6 +1450,8 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
float dmouse[2];
sub_v2_v2v2(dmouse, mouse, stroke->last_mouse_position);
stroke->stroke_distance += len_v2(dmouse);
+ stroke->stroke_distance_t += len_v2(dmouse) / stroke->ups->pixel_radius;
+
paint_brush_stroke_add_step(C, op, mouse, pressure);
redraw = true;
}
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 36b8a11b255..e7b51d363aa 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -6204,6 +6204,16 @@ static v
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list