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:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-08-21 14:17:55 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-08-21 14:17:55 +0400
commite7ecd7b68c46b084cc5448c4574b29512891b666 (patch)
treed89d0e26634332b7db94ab9dc024e1377984d019 /source/blender/editors/mask
parent1c2a657eee8ab8a10f74e348435ff054dea64eb9 (diff)
Clear cyclic flag if we didn't copy the whole mask spline
Diffstat (limited to 'source/blender/editors/mask')
-rw-r--r--source/blender/editors/mask/mask_ops.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c
index 04a0bbc6b54..3ae7fd67d8a 100644
--- a/source/blender/editors/mask/mask_ops.c
+++ b/source/blender/editors/mask/mask_ops.c
@@ -1489,6 +1489,7 @@ static int mask_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
int i = 0;
while (i < spline->tot_point) {
int start = i, end = -1;
+ /* Find next selected segment. */
while (MASKPOINT_ISSEL_ANY(point)) {
BKE_mask_point_select_set(point, false);
end = i;
@@ -1502,21 +1503,27 @@ static int mask_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
MaskSpline *new_spline = BKE_mask_spline_add(mask_layer);
MaskSplinePoint *new_point;
int b;
+
+ /* BKE_mask_spline_add might allocate the points, need to free them in this case. */
if (new_spline->points) {
MEM_freeN(new_spline->points);
}
+ /* Copy options from old spline. */
new_spline->flag = spline->flag;
new_spline->offset_mode = spline->offset_mode;
new_spline->weight_interp = spline->weight_interp;
new_spline->parent = spline->parent;
+ /* Allocate new points and copy them from old spline. */
new_spline->tot_point = end - start + 1;
new_spline->points = MEM_mallocN(sizeof(MaskSplinePoint) * new_spline->tot_point,
"duplicated mask points");
memcpy(new_spline->points, spline->points + start,
new_spline->tot_point * sizeof(MaskSplinePoint));
+
+ /* Select points and duplicate their UWs (if needed). */
for (b = 0, new_point = new_spline->points;
b < new_spline->tot_point;
b++, new_point++)
@@ -1527,6 +1534,14 @@ static int mask_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
BKE_mask_point_select_set(new_point, true);
}
+ /* Clear cyclic flag if we didn't copy the whole spline. */
+ if (new_spline->flag & MASK_SPLINE_CYCLIC) {
+ if (start != 0 || end != spline->tot_point - 1) {
+ new_spline->flag &= ~MASK_SPLINE_CYCLIC;
+ }
+ }
+
+ /* Flush selection to splines. */
new_spline->flag |= SELECT;
spline->flag &= ~SELECT;