Commit: 17f17a701320ec9775e3dd41be1135287269b56b
Author: Joshua Leung
Date:   Tue Jul 7 02:34:21 2015 +1200
Branches: GPencil_Editing_Stage3
https://developer.blender.org/rB17f17a701320ec9775e3dd41be1135287269b56b

GP Stroke Sculpting: Fix bug with falloff calculation

Falloff calculation was incorrect as it could produce invalid values if the
distance to a point exceeeded the radius of the brush, resulting in "large
negative values".

===================================================================

M       source/blender/editors/gpencil/gpencil_brush.c

===================================================================

diff --git a/source/blender/editors/gpencil/gpencil_brush.c 
b/source/blender/editors/gpencil/gpencil_brush.c
index 3933748..af8a60f 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -171,8 +171,15 @@ static float gp_brush_influence_calc(tGP_BrushEditData 
*gso, const int radius,
        
        /* distance fading */
        if (brush->flag & GP_EDITBRUSH_FLAG_USE_FALLOFF) {
-               float distance = sqrtf((mx - x0) * (mx - x0) + (my - y0) * (my 
- y0));
-               float fac    = 1.0f - (distance / (float)radius); 
+               // XXX: these should just get passed in like this (and then we 
can use the len_v2v2_int version?)
+               const float mvec[2] = {(float)mx, (float)my};
+               const float pvec[2] = {(float)x0, (float)y0};
+               
+               float distance = len_v2v2(mvec, pvec);
+               float fac;
+               
+               CLAMP(distance, 0.0f, (float)radius);
+               fac = 1.0f - (distance / (float)radius);
                
                influence *= fac;
        }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to