[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56382] trunk/blender/source/blender/ editors: avoid calling BKE_brush_alpha_get() when project painting onto each pixel,

Campbell Barton ideasman42 at gmail.com
Mon Apr 29 15:26:43 CEST 2013


Revision: 56382
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56382
Author:   campbellbarton
Date:     2013-04-29 13:26:43 +0000 (Mon, 29 Apr 2013)
Log Message:
-----------
avoid calling BKE_brush_alpha_get() when project painting onto each pixel,
also increase the epsilon for ruler thickness offset.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c
    trunk/blender/source/blender/editors/space_view3d/view3d_ruler.c

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c	2013-04-29 13:18:29 UTC (rev 56381)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c	2013-04-29 13:26:43 UTC (rev 56382)
@@ -3763,8 +3763,9 @@
 	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 @@
 				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;

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_ruler.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_ruler.c	2013-04-29 13:18:29 UTC (rev 56381)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_ruler.c	2013-04-29 13:26:43 UTC (rev 56382)
@@ -718,6 +718,7 @@
 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 @@
 			{
 				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);
 			}




More information about the Bf-blender-cvs mailing list