Revision: 50223
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50223
Author:   campbellbarton
Date:     2012-08-26 13:41:40 +0000 (Sun, 26 Aug 2012)
Log Message:
-----------
code cleanup: split out mask spline evaluation into its own file.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_mask.h
    trunk/blender/source/blender/blenkernel/CMakeLists.txt
    trunk/blender/source/blender/blenkernel/intern/mask.c

Added Paths:
-----------
    trunk/blender/source/blender/blenkernel/intern/mask_evaluate.c

Modified: trunk/blender/source/blender/blenkernel/BKE_mask.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_mask.h  2012-08-26 13:34:17 UTC 
(rev 50222)
+++ trunk/blender/source/blender/blenkernel/BKE_mask.h  2012-08-26 13:41:40 UTC 
(rev 50223)
@@ -19,7 +19,8 @@
  * All rights reserved.
  *
  * Contributor(s): Blender Foundation,
- *                 Sergey Sharybin
+ *                 Sergey Sharybin,
+ *                 Campbell Barton
  *
  * ***** END GPL LICENSE BLOCK *****
  */
@@ -63,29 +64,12 @@
 
 /* splines */
 struct MaskSpline *BKE_mask_spline_add(struct MaskLayer *masklay);
-
-unsigned int BKE_mask_spline_resolution(struct MaskSpline *spline, int width, 
int height);
-unsigned int BKE_mask_spline_feather_resolution(struct MaskSpline *spline, int 
width, int height);
-
-int BKE_mask_spline_differentiate_calc_total(const struct MaskSpline *spline, 
const unsigned int resol);
-
-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_with_resolution_ex(struct MaskSpline 
*spline, int *tot_diff_point,
-                                                         const unsigned int 
resol))[2];
-void    BKE_mask_spline_feather_collapse_inner_loops(struct MaskSpline 
*spline, float (*feather_points)[2], const int tot_feather_point);
-float (*BKE_mask_spline_differentiate_with_resolution(struct MaskSpline 
*spline, int width, int height, int *tot_diff_point))[2];
-float 
(*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(struct 
MaskSpline *spline, int *tot_feather_point,
-                                                                         const 
unsigned int resol, const int do_feather_isect))[2];
-float (*BKE_mask_spline_feather_differentiated_points_with_resolution(struct 
MaskSpline *spline, int width, int height,
-                                                                      int 
*tot_feather_point, const int do_feather_isect))[2];
-
-float (*BKE_mask_spline_feather_points(struct MaskSpline *spline, int 
*tot_feather_point))[2];
-
 void BKE_mask_point_direction_switch(struct MaskSplinePoint *point);
 void BKE_mask_spline_direction_switch(struct MaskLayer *masklay, struct 
MaskSpline *spline);
 
+struct BezTriple *BKE_mask_spline_point_next_bezt(struct MaskSpline *spline, 
struct MaskSplinePoint *points_array,
+                                                  struct MaskSplinePoint 
*point);
+
 typedef enum {
        MASK_PROJ_NEG = -1,
        MASK_PROJ_ANY = 0,
@@ -205,6 +189,26 @@
 
 #define MASK_RESOL_MAX 128
 
+/* mask_evaluate.c */
+unsigned int BKE_mask_spline_resolution(struct MaskSpline *spline, int width, 
int height);
+unsigned int BKE_mask_spline_feather_resolution(struct MaskSpline *spline, int 
width, int height);
+int          BKE_mask_spline_differentiate_calc_total(const struct MaskSpline 
*spline, const unsigned int resol);
+
+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_with_resolution_ex(struct MaskSpline 
*spline, int *tot_diff_point,
+                                                         const unsigned int 
resol))[2];
+void    BKE_mask_spline_feather_collapse_inner_loops(struct MaskSpline 
*spline, float (*feather_points)[2], const int tot_feather_point);
+float (*BKE_mask_spline_differentiate_with_resolution(struct MaskSpline 
*spline, int width, int height, int *tot_diff_point))[2];
+float 
(*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(struct 
MaskSpline *spline, int *tot_feather_point,
+                                                                         const 
unsigned int resol, const int do_feather_isect))[2];
+float (*BKE_mask_spline_feather_differentiated_points_with_resolution(struct 
MaskSpline *spline, int width, int height,
+                                                                      int 
*tot_feather_point, const int do_feather_isect))[2];
+
+float (*BKE_mask_spline_feather_points(struct MaskSpline *spline, int 
*tot_feather_point))[2];
+
+
 /* mask_rasterize.c */
 struct MaskRasterHandle;
 typedef struct MaskRasterHandle MaskRasterHandle;

Modified: trunk/blender/source/blender/blenkernel/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/blenkernel/CMakeLists.txt      2012-08-26 
13:34:17 UTC (rev 50222)
+++ trunk/blender/source/blender/blenkernel/CMakeLists.txt      2012-08-26 
13:41:40 UTC (rev 50223)
@@ -101,6 +101,7 @@
        intern/lamp.c
        intern/lattice.c
        intern/library.c
+       intern/mask_evaluate.c
        intern/mask_rasterize.c
        intern/mask.c
        intern/material.c

Modified: trunk/blender/source/blender/blenkernel/intern/mask.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/mask.c       2012-08-26 
13:34:17 UTC (rev 50222)
+++ trunk/blender/source/blender/blenkernel/intern/mask.c       2012-08-26 
13:41:40 UTC (rev 50223)
@@ -19,7 +19,8 @@
  * All rights reserved.
  *
  * Contributor(s): Blender Foundation,
- *                 Sergey Sharybin
+ *                 Sergey Sharybin,
+ *                 Campbell Barton
  *
  * ***** END GPL LICENSE BLOCK *****
  */
@@ -41,12 +42,8 @@
 
 #include "DNA_mask_types.h"
 #include "DNA_node_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_object_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
-#include "DNA_movieclip_types.h"
-#include "DNA_tracking_types.h"
 #include "DNA_sequence_types.h"
 
 #include "BKE_curve.h"
@@ -58,7 +55,6 @@
 #include "BKE_sequencer.h"
 #include "BKE_tracking.h"
 #include "BKE_movieclip.h"
-#include "BKE_utildefines.h"
 
 static MaskSplinePoint *mask_spline_point_next(MaskSpline *spline, 
MaskSplinePoint *points_array, MaskSplinePoint *point)
 {
@@ -90,7 +86,7 @@
        }
 }
 
-static BezTriple *mask_spline_point_next_bezt(MaskSpline *spline, 
MaskSplinePoint *points_array, MaskSplinePoint *point)
+BezTriple *BKE_mask_spline_point_next_bezt(MaskSpline *spline, MaskSplinePoint 
*points_array, MaskSplinePoint *point)
 {
        if (point == &points_array[spline->tot_point - 1]) {
                if (spline->flag & MASK_SPLINE_CYCLIC) {
@@ -269,588 +265,6 @@
        return spline;
 }
 
-unsigned int BKE_mask_spline_resolution(MaskSpline *spline, int width, int 
height)
-{
-       float max_segment = 0.01f;
-       unsigned int i, resol = 1;
-
-       if (width != 0 && height != 0) {
-               if (width >= height)
-                       max_segment = 1.0f / (float) width;
-               else
-                       max_segment = 1.0f / (float) height;
-       }
-
-       for (i = 0; i < spline->tot_point; i++) {
-               MaskSplinePoint *point = &spline->points[i];
-               BezTriple *bezt, *bezt_next;
-               float a, b, c, len;
-               unsigned int cur_resol;
-
-               bezt = &point->bezt;
-               bezt_next = mask_spline_point_next_bezt(spline, spline->points, 
point);
-
-               if (bezt_next == NULL) {
-                       break;
-               }
-
-               a = len_v3v3(bezt->vec[1], bezt->vec[2]);
-               b = len_v3v3(bezt->vec[2], bezt_next->vec[0]);
-               c = len_v3v3(bezt_next->vec[0], bezt_next->vec[1]);
-
-               len = a + b + c;
-               cur_resol = len / max_segment;
-
-               resol = MAX2(resol, cur_resol);
-
-               if (resol >= MASK_RESOL_MAX) {
-                       break;
-               }
-       }
-
-       return CLAMPIS(resol, 1, MASK_RESOL_MAX);
-}
-
-unsigned int BKE_mask_spline_feather_resolution(MaskSpline *spline, int width, 
int height)
-{
-       const float max_segment = 0.005;
-       unsigned int resol = BKE_mask_spline_resolution(spline, width, height);
-       float max_jump = 0.0f;
-       int i;
-
-       /* avoid checking the featrher if we already hit the maximum value */
-       if (resol >= MASK_RESOL_MAX) {
-               return MASK_RESOL_MAX;
-       }
-
-       for (i = 0; i < spline->tot_point; i++) {
-               MaskSplinePoint *point = &spline->points[i];
-               float prev_u, prev_w;
-               int j;
-
-               prev_u = 0.0f;
-               prev_w = point->bezt.weight;
-
-               for (j = 0; j < point->tot_uw; j++) {
-                       const float w_diff = (point->uw[j].w - prev_w);
-                       const float u_diff = (point->uw[j].u - prev_u);
-
-                       /* avoid divide by zero and very high values,
-                        * though these get clamped eventually */
-                       if (u_diff > FLT_EPSILON) {
-                               float jump = fabsf(w_diff / u_diff);
-
-                               max_jump = MAX2(max_jump, jump);
-                       }
-
-                       prev_u = point->uw[j].u;
-                       prev_w = point->uw[j].w;
-               }
-       }
-
-       resol += max_jump / max_segment;
-
-       return CLAMPIS(resol, 1, MASK_RESOL_MAX);
-}
-
-int BKE_mask_spline_differentiate_calc_total(const MaskSpline *spline, const 
unsigned int resol)
-{
-       if (spline->flag & MASK_SPLINE_CYCLIC) {
-               return spline->tot_point * resol;
-       }
-       else {
-               return ((spline->tot_point - 1) * resol) + 1;
-       }
-}
-
-float (*BKE_mask_spline_differentiate_with_resolution_ex(MaskSpline *spline,
-                                                         int *tot_diff_point,
-                                                         const unsigned int 
resol
-                                                         ))[2]
-{
-       MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
-
-       MaskSplinePoint *point, *prev;
-       float (*diff_points)[2], (*fp)[2];
-       const int tot = BKE_mask_spline_differentiate_calc_total(spline, resol);
-       int a;
-
-       if (spline->tot_point <= 1) {
-               /* nothing to differentiate */
-               *tot_diff_point = 0;
-               return NULL;
-       }
-
-       /* len+1 because of 'forward_diff_bezier' function */
-       *tot_diff_point = tot;
-       diff_points = fp = MEM_mallocN((tot + 1) * sizeof(*diff_points), "mask 
spline vets");
-
-       a = spline->tot_point - 1;
-       if (spline->flag & MASK_SPLINE_CYCLIC)
-               a++;
-
-       prev = points_array;
-       point = prev + 1;
-
-       while (a--) {
-               BezTriple *prevbezt;
-               BezTriple *bezt;
-               int j;
-
-               if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC))
-                       point = points_array;
-
-               prevbezt = &prev->bezt;
-               bezt = &point->bezt;
-
-               for (j = 0; j < 2; j++) {
-                       BKE_curve_forward_diff_bezier(prevbezt->vec[1][j], 
prevbezt->vec[2][j],
-                                                     bezt->vec[0][j], 
bezt->vec[1][j],
-                                                     &(*fp)[j], resol, 2 * 
sizeof(float));
-               }
-
-               fp += resol;
-
-               if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC) == 0) {
-                       copy_v2_v2(*fp, bezt->vec[1]);
-               }
-
-               prev = point;
-               point++;
-       }
-
-       return diff_points;
-}
-
-float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, int 
width, int height,

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to