Add inverse-square blending for PET and warp
authorCampbell Barton <ideasman42@gmail.com>
Tue, 3 Feb 2015 18:35:09 +0000 (05:35 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 3 Feb 2015 18:45:30 +0000 (05:45 +1100)
Similar to 'Root' but without noticeable spike/pinch in the center.

source/blender/editors/transform/transform_generics.c
source/blender/makesdna/DNA_modifier_types.h
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_modifier.c
source/blender/makesrna/intern/rna_scene.c
source/blender/modifiers/intern/MOD_warp.c

index fcf789546e8cdffb3b66f285b94774358ec6033a..903b3f124ee635a0be2d3f6d8795d31f7d4149ce 100644 (file)
@@ -1937,6 +1937,9 @@ void calculatePropRatio(TransInfo *t)
                                        case PROP_RANDOM:
                                                td->factor = BLI_frand() * dist;
                                                break;
+                                       case PROP_INVSQUARE:
+                                               td->factor = dist * (2.0f - dist);
+                                               break;
                                        default:
                                                td->factor = 1;
                                                break;
@@ -1965,6 +1968,9 @@ void calculatePropRatio(TransInfo *t)
                        case PROP_RANDOM:
                                strcpy(t->proptext, IFACE_("(Random)"));
                                break;
+                       case PROP_INVSQUARE:
+                               strcpy(t->proptext, IFACE_("(InvSquare)"));
+                               break;
                        default:
                                t->proptext[0] = '\0';
                                break;
index 43d7b45675c253cc33fadd7d068ff9cd04e6d6d8..2d8c3b23da75209a9eecc3f85981a6b55f9295ac 100644 (file)
@@ -978,6 +978,7 @@ typedef enum {
        eWarp_Falloff_Linear = 5, /* PROP_LIN */
        eWarp_Falloff_Const  = 6, /* PROP_CONST */
        eWarp_Falloff_Sphere = 7, /* PROP_SPHERE */
+       eWarp_Falloff_InvSquare = 8, /* PROP_INVSQUARE */
        /* PROP_RANDOM not used */
 } WarpModifierFalloff;
 
index fabfa7653f2ff529d6a14e8b28e11f2bf73d9084..9ac506696ad9444e76475628f53cd76b26fe168e 100644 (file)
@@ -1625,7 +1625,8 @@ extern const char *RE_engine_id_CYCLES;
 #define PROP_LIN               4
 #define PROP_CONST             5
 #define PROP_RANDOM            6
-#define PROP_MODE_MAX          7
+#define PROP_INVSQUARE         7
+#define PROP_MODE_MAX          8
 
 /* toolsettings->proportional */
 #define PROP_EDIT_OFF                  0
index a7e0ed272993f5cc3b5da631a9f264880b66b0c0..12b6d74e4a58f82896fb219f6d7d0ab380494673 100644 (file)
@@ -1117,6 +1117,7 @@ static void rna_def_modifier_warp(BlenderRNA *brna)
                {eWarp_Falloff_Smooth,  "SMOOTH", ICON_SMOOTHCURVE, "Smooth", ""},
                {eWarp_Falloff_Sphere,  "SPHERE", ICON_SPHERECURVE, "Sphere", ""},
                {eWarp_Falloff_Root,    "ROOT", ICON_ROOTCURVE, "Root", ""},
+               {eWarp_Falloff_InvSquare, "INVERSE_SQUARE", ICON_ROOTCURVE, "Inverse Square", ""},
                {eWarp_Falloff_Sharp,   "SHARP", ICON_SHARPCURVE, "Sharp", ""},
                {eWarp_Falloff_Linear,  "LINEAR", ICON_LINCURVE, "Linear", ""},
                {eWarp_Falloff_Const,   "CONSTANT", ICON_NOCURVE, "Constant", ""},
index e830e86a57328c6d6788998d641dbf1f17bbe90e..7ebbf0b132dba3fd118e5580fd5ccd67d517a995 100644 (file)
@@ -112,6 +112,7 @@ EnumPropertyItem proportional_falloff_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"},
        {PROP_CONST, "CONSTANT", ICON_NOCURVE, "Constant", "Constant falloff"},
index ed0d18fc4846f20f026645744cf53bcc0be52986..3eb34e56700f87107098262ae3ab098c713948e7 100644 (file)
@@ -265,6 +265,9 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob,
                                case eWarp_Falloff_Sphere:
                                        fac = sqrtf(2 * fac - fac * fac);
                                        break;
+                               case eWarp_Falloff_InvSquare:
+                                       fac = fac * (2.0f - fac);
+                                       break;
                        }
 
                        fac *= weight;