[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47286] branches/soc-2011-tomato/source/ blender: Add dynamic mask curve differentiation for more accurate feather gradients .
Peter Larabell
xgl.asyliax at gmail.com
Thu May 31 18:59:26 CEST 2012
Revision: 47286
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47286
Author: xglasyliax
Date: 2012-05-31 16:59:25 +0000 (Thu, 31 May 2012)
Log Message:
-----------
Add dynamic mask curve differentiation for more accurate feather gradients.
Modified Paths:
--------------
branches/soc-2011-tomato/source/blender/blenkernel/BKE_mask.h
branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c
branches/soc-2011-tomato/source/blender/editors/mask/mask_draw.c
Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_mask.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_mask.h 2012-05-31 16:04:07 UTC (rev 47285)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_mask.h 2012-05-31 16:59:25 UTC (rev 47286)
@@ -56,10 +56,10 @@
/* splines */
struct MaskSpline *BKE_mask_spline_add(struct MaskObject *maskobj);
-int BKE_mask_spline_resolution(struct MaskSpline *spline);
+int BKE_mask_spline_resolution(struct MaskSpline *spline, float max_seg_len);
-float (*BKE_mask_spline_differentiate(struct MaskSpline *spline, int *tot_diff_point))[2];
-float (*BKE_mask_spline_feather_differentiated_points(struct MaskSpline *spline, int *tot_feather_point))[2];
+float (*BKE_mask_spline_differentiate(struct MaskSpline *spline, int *tot_diff_point, int dynamic_res, float max_dseg_len))[2];
+float (*BKE_mask_spline_feather_differentiated_points(struct MaskSpline *spline, int *tot_feather_point, int dynamic_res, float max_dseg_len))[2];
float (*BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feather_point))[2];
/* point */
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c 2012-05-31 16:04:07 UTC (rev 47285)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c 2012-05-31 16:59:25 UTC (rev 47286)
@@ -149,9 +149,9 @@
return spline;
}
-int BKE_mask_spline_resolution(MaskSpline *spline)
+int BKE_mask_spline_resolution(MaskSpline *spline, float max_seg_len)
{
- const float max_segment = 0.01;
+ const float max_segment = max_seg_len;
int i, resol = 1;
for (i = 0; i < spline->tot_point; i++) {
@@ -186,10 +186,10 @@
return resol;
}
-int BKE_mask_spline_feather_resolution(MaskSpline *spline)
+int BKE_mask_spline_feather_resolution(MaskSpline *spline, float max_seg_len)
{
const float max_segment = 0.005;
- int resol = BKE_mask_spline_resolution(spline);
+ int resol = BKE_mask_spline_resolution(spline, max_seg_len);
float max_jump = 0.0f;
int i;
@@ -216,14 +216,19 @@
return resol;
}
-float (*BKE_mask_spline_differentiate(MaskSpline *spline, int *tot_diff_point))[2]
+float (*BKE_mask_spline_differentiate(MaskSpline *spline, int *tot_diff_point, int dynamic_res, float max_dseg_len))[2]
{
MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
MaskSplinePoint *point, *prev;
float (*diff_points)[2], (*fp)[2];
- int a, len, resol = BKE_mask_spline_resolution(spline);
+ int a, len, resol;
+ if(!dynamic_res){
+ max_dseg_len = 0.01f;
+ }
+ resol = BKE_mask_spline_resolution(spline, max_dseg_len);
+
if (spline->tot_point <= 1) {
/* nothing to differentiate */
*tot_diff_point = 0;
@@ -279,12 +284,16 @@
return diff_points;
}
-float (*BKE_mask_spline_feather_differentiated_points(MaskSpline *spline, int *tot_feather_point))[2]
+float (*BKE_mask_spline_feather_differentiated_points(MaskSpline *spline, int *tot_feather_point, int dynamic_res, float max_dseg_len))[2]
{
MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
float (*feather)[2], (*fp)[2];
- int i, j, tot, resol = BKE_mask_spline_feather_resolution(spline);
+ int i, j, tot, resol;
+ if(!dynamic_res){
+ max_dseg_len = 0.005f;
+ }
+ resol = BKE_mask_spline_feather_resolution(spline, max_dseg_len);
tot = resol * spline->tot_point;
feather = fp = MEM_mallocN(tot * sizeof(*feather), "mask spline feather diff points");
@@ -429,7 +438,7 @@
float *BKE_mask_point_segment_feather_diff(MaskSpline *spline, MaskSplinePoint *point, int *tot_feather_point)
{
float *feather, *fp;
- int i, resol = BKE_mask_spline_feather_resolution(spline);
+ int i, resol = BKE_mask_spline_feather_resolution(spline, 0.005f);
feather = fp = MEM_callocN(2 * resol * sizeof(float), "mask point spline feather diff points");
@@ -456,7 +465,7 @@
BezTriple *bezt, *next;
float *diff_points, *fp;
- int j, resol = BKE_mask_spline_resolution(spline);
+ int j, resol = BKE_mask_spline_resolution(spline, 0.01f);
bezt = &point->bezt;
@@ -1771,7 +1780,15 @@
/* temp blending buffer */
const int buffer_size = width * height;
float *buffer_tmp = MEM_mallocN(sizeof(float) * buffer_size, __func__);
+ float max_dseg_len = 0.0f;
+ if(width >= height){
+ max_dseg_len = (float)(width);
+ }else{
+ max_dseg_len = (float)(height);
+ }
+ max_dseg_len = 1.0f / max_dseg_len;
+
for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) {
MaskSpline *spline;
float alpha;
@@ -1789,9 +1806,9 @@
float (*diff_feather_points)[2];
int tot_diff_feather_points;
- diff_points = BKE_mask_spline_differentiate(spline, &tot_diff_point);
+ diff_points = BKE_mask_spline_differentiate(spline, &tot_diff_point, 1, max_dseg_len);
if(tot_diff_point){
- diff_feather_points = BKE_mask_spline_feather_differentiated_points(spline, &tot_diff_feather_points);
+ diff_feather_points = BKE_mask_spline_feather_differentiated_points(spline, &tot_diff_feather_points, 1, max_dseg_len);
}
/* TODO, make this optional! */
Modified: branches/soc-2011-tomato/source/blender/editors/mask/mask_draw.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/mask/mask_draw.c 2012-05-31 16:04:07 UTC (rev 47285)
+++ branches/soc-2011-tomato/source/blender/editors/mask/mask_draw.c 2012-05-31 16:59:25 UTC (rev 47286)
@@ -336,7 +336,7 @@
int tot_feather_point;
float (*feather_points)[2];
- diff_points = BKE_mask_spline_differentiate(spline, &tot_diff_point);
+ diff_points = BKE_mask_spline_differentiate(spline, &tot_diff_point, 0, 0.0f);
if (!diff_points)
return;
@@ -347,7 +347,7 @@
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
- feather_points = BKE_mask_spline_feather_differentiated_points(spline, &tot_feather_point);
+ feather_points = BKE_mask_spline_feather_differentiated_points(spline, &tot_feather_point, 0, 0.0f);
/* draw feather */
mask_spline_feather_color_get(maskobj, spline, is_spline_sel, rgb_tmp);
More information about the Bf-blender-cvs
mailing list