Add inverse-square falloff to bmesh, mask & compo.
authorCampbell Barton <ideasman42@gmail.com>
Sun, 26 Apr 2015 08:31:54 +0000 (18:31 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 26 Apr 2015 08:31:54 +0000 (18:31 +1000)
source/blender/blenkernel/intern/mask_rasterize.c
source/blender/bmesh/intern/bmesh_operators.h
source/blender/bmesh/intern/bmesh_queries.c
source/blender/compositor/operations/COM_BlurBaseOperation.cpp
source/blender/makesrna/intern/rna_scene.c

index 387d093051e2164f96cda65f563871c5e64d6f0a..13ec970c65c67f701cb3b57386f3a2acbb1132c1 100644 (file)
@@ -1360,6 +1360,9 @@ float BKE_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float x
                                case PROP_SHARP:
                                        value_layer = value_layer * value_layer;
                                        break;
+                               case PROP_INVSQUARE:
+                                       value_layer = value_layer * (2.0f - value_layer);
+                                       break;
                                case PROP_LIN:
                                default:
                                        /* nothing */
index d2ce2faf09d2577d24865614c8553d585f71f743..d9961e589da8c3a312465c64d46cf0e1264b2efd 100644 (file)
@@ -46,6 +46,7 @@ enum {
        SUBD_FALLOFF_ROOT,
        SUBD_FALLOFF_SHARP,
        SUBD_FALLOFF_LIN,
+       SUBD_FALLOFF_INVSQUARE = 7,  /* matching PROP_INVSQUARE */
 };
 
 enum {
index 1e0b1f213815c6780f8a89b861980c7c32e3ad2d..61328a525f1e7c1698f6b8c886ab5e228f9e5560 100644 (file)
@@ -2419,6 +2419,9 @@ float bmesh_subd_falloff_calc(const int falloff, float val)
                        break;
                case SUBD_FALLOFF_LIN:
                        break;
+               case SUBD_FALLOFF_INVSQUARE:
+                       val = val * (2.0f - val);
+                       break;
                default:
                        BLI_assert(0);
                        break;
index cbf9bb211c139a9270779d5714cd762e055e500d..07669b1a814fe340386330528050cdfcbabf2dd5 100644 (file)
@@ -133,6 +133,8 @@ float *BlurBaseOperation::make_dist_fac_inverse(float rad, int size, int falloff
                        case PROP_SHARP:
                                val = val * val;
                                break;
+                       case PROP_INVSQUARE:
+                               val = val * (2.0f - val);
                        case PROP_LIN:
                                /* fall-through */
 #ifndef NDEBUG
index f67af39d381374c125d5e182adc9f5c25ab18b1f..f671a4b29e503038dcc5036d20c4b9bc461d5ec7 100644 (file)
@@ -134,6 +134,7 @@ EnumPropertyItem proportional_falloff_curve_only_items[] = {
        {PROP_SMOOTH, "SMOOTH", ICON_SMOOTHCURVE, "Smooth", "Smooth falloff"},
        {PROP_SPHERE, "SPHERE", ICON_SPHERECURVE, "Sphere", "Spherical falloff"},
        {PROP_ROOT, "ROOT", ICON_ROOTCURVE, "Root", "Root falloff"},
+       {PROP_INVSQUARE, "INVERSE_SQUARE", ICON_ROOTCURVE, "Inverse Square", "Inverse Square falloff"},
        {PROP_SHARP, "SHARP", ICON_SHARPCURVE, "Sharp", "Sharp falloff"},
        {PROP_LIN, "LINEAR", ICON_LINCURVE, "Linear", "Linear falloff"},
        {0, NULL, 0, NULL, NULL}