Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--release/scripts/startup/bl_ui/space_clip.py1
-rw-r--r--source/blender/blenkernel/intern/mask_rasterize.c29
-rw-r--r--source/blender/makesdna/DNA_mask_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_mask.c7
4 files changed, 35 insertions, 4 deletions
diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py
index 874405bd66b..ac724518e85 100644
--- a/release/scripts/startup/bl_ui/space_clip.py
+++ b/release/scripts/startup/bl_ui/space_clip.py
@@ -707,6 +707,7 @@ class CLIP_PT_mask_layers(Panel):
row.prop(active_layer, "invert", text="", icon='IMAGE_ALPHA')
layout.prop(active_layer, "blend")
+ layout.prop(active_layer, "falloff")
class CLIP_PT_active_mask_spline(Panel):
diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c
index cd3b6c71c09..b415e9f1ba8 100644
--- a/source/blender/blenkernel/intern/mask_rasterize.c
+++ b/source/blender/blenkernel/intern/mask_rasterize.c
@@ -32,6 +32,7 @@
#include "DNA_vec_types.h"
#include "DNA_mask_types.h"
+#include "DNA_scene_types.h"
#include "BLI_utildefines.h"
#include "BLI_scanfill.h"
@@ -93,6 +94,7 @@ typedef struct MaskRasterLayer {
float alpha;
char blend;
char blend_flag;
+ char falloff;
} MaskRasterLayer;
@@ -832,6 +834,7 @@ void BLI_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas
layer->alpha = masklay->alpha;
layer->blend = masklay->blend;
layer->blend_flag = masklay->blend_flag;
+ layer->falloff = masklay->falloff;
}
/* printf("tris %d, feather tris %d\n", sf_tri_tot, tot_feather_quads); */
@@ -976,11 +979,29 @@ float BLI_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float x
float value_layer;
if (BLI_in_rctf_v(&layer->bounds, xy)) {
- const float dist = 1.0f - layer_bucket_depth_from_xy(layer, xy);
- const float dist_ease = (3.0f * dist * dist - 2.0f * dist * dist * dist);
+ float val = 1.0f - layer_bucket_depth_from_xy(layer, xy);
+
+ switch (layer->falloff) {
+ case PROP_SMOOTH:
+ /* ease - gives less hard lines for dilate/erode feather */
+ val = (3.0f * val * val - 2.0f * val * val * val);
+ break;
+ case PROP_SPHERE:
+ val = sqrtf(2.0f * val - val * val);
+ break;
+ case PROP_ROOT:
+ val = sqrtf(val);
+ break;
+ case PROP_SHARP:
+ val = val * val;
+ break;
+ case PROP_LIN:
+ default:
+ /* nothing */
+ break;
+ }
- /* apply alpha */
- value_layer = dist_ease * layer->alpha;
+ value_layer = val * layer->alpha;
}
else {
value_layer = 0.0f;
diff --git a/source/blender/makesdna/DNA_mask_types.h b/source/blender/makesdna/DNA_mask_types.h
index 4c2330965ee..dd9ea508723 100644
--- a/source/blender/makesdna/DNA_mask_types.h
+++ b/source/blender/makesdna/DNA_mask_types.h
@@ -127,6 +127,8 @@ typedef struct MaskLayer {
float alpha;
char blend;
char blend_flag;
+ char falloff;
+ char pad[7];
char flag; /* for animation */
char restrictflag; /* matching 'Object' flag of the same name - eventually use in the outliner */
diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c
index e6fd47985cb..2b89dd02dae 100644
--- a/source/blender/makesrna/intern/rna_mask.c
+++ b/source/blender/makesrna/intern/rna_mask.c
@@ -35,6 +35,7 @@
#include "BKE_tracking.h"
#include "RNA_define.h"
+#include "RNA_enum_types.h"
#include "rna_internal.h"
@@ -653,6 +654,12 @@ static void rna_def_mask_layer(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Restrict View", "Invert the mask black/white");
RNA_def_property_update(prop, NC_MASK | NA_EDITED, NULL);
+ prop = RNA_def_property(srna, "falloff", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "falloff");
+ RNA_def_property_enum_items(prop, proportional_falloff_curve_only_items);
+ RNA_def_property_ui_text(prop, "Falloff", "Falloff type the feather");
+ RNA_def_property_update(prop, NC_MASK | NA_EDITED, NULL);
+
}
static void rna_def_masklayers(BlenderRNA *brna, PropertyRNA *cprop)