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:
authorCampbell Barton <ideasman42@gmail.com>2012-06-04 17:24:10 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-06-04 17:24:10 +0400
commitc357041e0a3a6291f9f07180b37ea80064cf23c5 (patch)
treeba1fa0a3408423fce73a2dd3a5117d9ae9058bac /source/blender/blenkernel
parent90d7e25b4fe6191b0b433d4e1cf900b90811bd83 (diff)
operator to switch direction
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_mask.h5
-rw-r--r--source/blender/blenkernel/intern/mask.c78
2 files changed, 82 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h
index a26934f103b..32493e4e445 100644
--- a/source/blender/blenkernel/BKE_mask.h
+++ b/source/blender/blenkernel/BKE_mask.h
@@ -63,10 +63,13 @@ float (*BKE_mask_spline_feather_differentiated_points(struct MaskSpline *spline,
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(struct MaskSpline *spline,
- int width, int height, int *tot_feather_point))[2];
+ int width, int height, int *tot_feather_point))[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);
+
/* point */
int BKE_mask_point_has_handle(struct MaskSplinePoint *point);
void BKE_mask_point_handle(struct MaskSplinePoint *point, float handle[2]);
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index 52225a1fab0..f2c1d9f8b65 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -377,6 +377,84 @@ float (*BKE_mask_spline_feather_points(MaskSpline * spline, int *tot_feather_poi
return feather;
}
+void BKE_mask_point_direction_switch(MaskSplinePoint *point)
+{
+ const int tot_uw = point->tot_uw;
+ const int tot_uw_half = tot_uw / 2;
+ int i;
+
+ if (tot_uw < 2) {
+ return;
+ }
+
+ /* count */
+ for (i = 0; i < tot_uw_half; i++) {
+ MaskSplinePointUW *uw_a = &point->uw[i];
+ MaskSplinePointUW *uw_b = &point->uw[tot_uw - (i + 1)];
+ SWAP(MaskSplinePointUW, *uw_a, *uw_b);
+ }
+ for (i = 0; i < tot_uw; i++) {
+ MaskSplinePointUW *uw = &point->uw[i];
+ uw->u = 1.0f - uw->u;
+ }
+}
+
+//typedef (float)[MASK_OBJECT_SHAPE_ELEM_SIZE] MaskLayerShapeElem;
+
+typedef struct MaskLayerShapeElem {
+ float value[MASK_OBJECT_SHAPE_ELEM_SIZE];
+} MaskLayerShapeElem;
+
+void BKE_mask_spline_direction_switch(MaskLayer *masklay, MaskSpline *spline)
+{
+ const int tot_point = spline->tot_point;
+ const int tot_point_half = tot_point / 2;
+ int i, i_prev;
+
+ if (tot_point < 2) {
+ return;
+ }
+
+ /* count */
+ for (i = 0; i < tot_point_half; i++) {
+ MaskSplinePoint *point_a = &spline->points[i];
+ MaskSplinePoint *point_b = &spline->points[tot_point - (i + 1)];
+ SWAP(MaskSplinePoint, *point_a, *point_b);
+ }
+
+ /* correct UW's */
+ i_prev = tot_point - 1;
+ for (i = 0; i < tot_point; i++) {
+
+ BKE_mask_point_direction_switch(&spline->points[i]);
+
+ SWAP(MaskSplinePointUW *, spline->points[i].uw, spline->points[i_prev].uw);
+ SWAP(int, spline->points[i].tot_uw, spline->points[i_prev].tot_uw);
+
+ i_prev = i;
+ }
+
+ /* correct animation */
+ if (masklay->splines_shapes.first) {
+ MaskLayerShape *masklay_shape;
+
+ const int spline_index = BKE_mask_layer_shape_spline_to_index(masklay, spline);
+
+ for (masklay_shape = masklay->splines_shapes.first;
+ masklay_shape;
+ masklay_shape = masklay_shape->next)
+ {
+ MaskLayerShapeElem *fp_arr = (MaskLayerShapeElem *)masklay_shape->data;
+
+ for (i = 0; i < tot_point_half; i++) {
+ MaskLayerShapeElem *fp_a = &fp_arr[spline_index + (i) ];
+ MaskLayerShapeElem *fp_b = &fp_arr[spline_index + (tot_point - (i + 1))];
+ SWAP(MaskLayerShapeElem, *fp_a, *fp_b);
+ }
+ }
+ }
+}
+
/* point */
int BKE_mask_point_has_handle(MaskSplinePoint *point)