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:
authorAntony Riakiotakis <kalast@gmail.com>2015-11-24 23:40:18 +0300
committerAntony Riakiotakis <kalast@gmail.com>2015-11-24 23:40:52 +0300
commit697acebeb7f61ece1bd17d129d424b3f470438ba (patch)
tree9c58aa30b2874619c163b9062d7fe689f5d483bc /source/blender/editors/sculpt_paint
parentfe3aaac1184f0a09ba7b367380c03dedbfae86b9 (diff)
Sculpting optimization: Avoid iterating the PBVH for intersection during
the paint cursor drawing when a stroke is underway; this information is already available from the stroke itself. Should improve performance when "show brush" is enabled (which is always, for sane people). Finding an intersection is not always cheap, especially on heavy meshes. Cudos to the dyntopo test thread for the report and the sculpt love :)
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c29
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c5
2 files changed, 22 insertions, 12 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index e19756c6a35..1a12ec3e6bc 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -524,38 +524,45 @@ static int project_brush_radius(ViewContext *vc,
static bool sculpt_get_brush_geometry(
bContext *C, ViewContext *vc,
int x, int y, int *pixel_radius,
- float location[3])
+ float location[3], UnifiedPaintSettings *ups)
{
Scene *scene = CTX_data_scene(C);
Paint *paint = BKE_paint_get_active_from_context(C);
float mouse[2];
- bool hit;
+ bool hit = false;
mouse[0] = x;
mouse[1] = y;
- if (vc->obact->sculpt && vc->obact->sculpt->pbvh &&
- sculpt_stroke_get_location(C, location, mouse))
+ if (vc->obact->sculpt && vc->obact->sculpt->pbvh)
{
+ if (!ups->stroke_active) {
+ hit = sculpt_stroke_get_location(C, location, mouse);
+ }
+ else {
+ hit = ups->last_hit;
+ copy_v3_v3(location, ups->last_location);
+ }
+ }
+
+ if (hit) {
Brush *brush = BKE_paint_brush(paint);
+
*pixel_radius =
- project_brush_radius(vc,
- BKE_brush_unprojected_radius_get(scene, brush),
- location);
+ project_brush_radius(vc,
+ BKE_brush_unprojected_radius_get(scene, brush),
+ location);
if (*pixel_radius == 0)
*pixel_radius = BKE_brush_size_get(scene, brush);
mul_m4_v3(vc->obact->obmat, location);
-
- hit = 1;
}
else {
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
Brush *brush = BKE_paint_brush(&sd->paint);
*pixel_radius = BKE_brush_size_get(scene, brush);
- hit = 0;
}
return hit;
@@ -1020,7 +1027,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
bool hit;
/* test if brush is over the mesh */
- hit = sculpt_get_brush_geometry(C, &vc, x, y, &pixel_radius, location);
+ hit = sculpt_get_brush_geometry(C, &vc, x, y, &pixel_radius, location, ups);
if (BKE_brush_use_locked_size(scene, brush))
BKE_brush_size_set(scene, brush, pixel_radius);
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index db6ee705343..3225d4d4b7e 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -466,7 +466,10 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, const float
copy_v2_v2(mouse_out, mouse_in);
}
- if (!paint_brush_update(C, brush, mode, stroke, mouse_in, mouse_out, pressure, location)) {
+
+ ups->last_hit = paint_brush_update(C, brush, mode, stroke, mouse_in, mouse_out, pressure, location);
+ copy_v3_v3(ups->last_location, location);
+ if (!ups->last_hit) {
return;
}