From 903f9b98f5e5bd93938220e301b7f27d97d103aa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 29 Apr 2013 13:26:43 +0000 Subject: [PATCH] avoid calling BKE_brush_alpha_get() when project painting onto each pixel, also increase the epsilon for ruler thickness offset. --- .../blender/editors/sculpt_paint/paint_image_proj.c | 11 ++++++----- source/blender/editors/space_view3d/view3d_ruler.c | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 320f9092c09..aa43287a551 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -3763,8 +3763,9 @@ static void *do_projectpaint_thread(void *ph_v) float pos_ofs[2] = {0}; float co[2]; unsigned short mask_short; - const float radius = (float)BKE_brush_size_get(ps->scene, brush); - const float radius_squared = radius * radius; /* avoid a square root with every dist comparison */ + const float brush_alpha = BKE_brush_alpha_get(ps->scene, brush); + const float brush_radius = (float)BKE_brush_size_get(ps->scene, brush); + const float brush_radius_sq = brush_radius * brush_radius; /* avoid a square root with every dist comparison */ short lock_alpha = ELEM(brush->blend, IMB_BLEND_ERASE_ALPHA, IMB_BLEND_ADD_ALPHA) ? 0 : brush->flag & BRUSH_LOCK_ALPHA; @@ -3852,14 +3853,14 @@ static void *do_projectpaint_thread(void *ph_v) dist_nosqrt = len_squared_v2v2(projPixel->projCoSS, pos); /*if (dist < radius) {*/ /* correct but uses a sqrtf */ - if (dist_nosqrt <= radius_squared) { + if (dist_nosqrt <= brush_radius_sq) { dist = sqrtf(dist_nosqrt); - falloff = BKE_brush_curve_strength_clamp(ps->brush, dist, radius); + falloff = BKE_brush_curve_strength_clamp(ps->brush, dist, brush_radius); if (falloff > 0.0f) { float texrgb[3]; - float mask = falloff * BKE_brush_alpha_get(ps->scene, brush); + float mask = falloff * brush_alpha; if (ps->is_texbrush) { MTex *mtex = &brush->mtex; diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index ba37986b44c..576badf601e 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -718,6 +718,7 @@ static void view3d_ruler_item_project(RulerInfo *ruler_info, float r_co[3], static bool view3d_ruler_item_mousemove(bContext *C, RulerInfo *ruler_info, const int mval[2], const bool do_thickness, const bool do_snap) { + const float eps_bias = 0.0002f; RulerItem *ruler_item = ruler_item_active_get(ruler_info); ruler_info->snap_flag &= ~RULER_SNAP_OK; @@ -740,7 +741,7 @@ static bool view3d_ruler_item_mousemove(bContext *C, RulerInfo *ruler_info, cons { negate_v3(ray_normal); /* add some bias */ - madd_v3_v3v3fl(ray_start, co, ray_normal, 0.0001f); + madd_v3_v3v3fl(ray_start, co, ray_normal, eps_bias); ED_view3d_snap_ray(C, co_other, ray_start, ray_normal); }