falloff option for mask layers

This commit is contained in:
Campbell Barton
2012-07-15 03:11:07 +00:00
parent 7cc5af4ef3
commit 02bac0bebf
4 changed files with 35 additions and 4 deletions

View File

@@ -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):

View File

@@ -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);
/* apply alpha */
value_layer = dist_ease * layer->alpha;
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;
}
value_layer = val * layer->alpha;
}
else {
value_layer = 0.0f;

View File

@@ -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 */

View File

@@ -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)