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:
Diffstat (limited to 'source/blender/blenkernel/intern/mask.c')
-rw-r--r--source/blender/blenkernel/intern/mask.c48
1 files changed, 32 insertions, 16 deletions
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index e307ad6cac8..c925ebe26cf 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -142,10 +142,12 @@ MaskLayer *BKE_mask_layer_new(Mask *mask, const char *name)
{
MaskLayer *masklay = MEM_callocN(sizeof(MaskLayer), __func__);
- if (name && name[0])
+ if (name && name[0]) {
BLI_strncpy(masklay->name, name, sizeof(masklay->name));
- else
+ }
+ else {
strcpy(masklay->name, "MaskLayer");
+ }
BLI_addtail(&mask->masklayers, masklay);
@@ -178,8 +180,9 @@ void BKE_mask_layer_remove(Mask *mask, MaskLayer *masklay)
mask->masklay_tot--;
- if (mask->masklay_act >= mask->masklay_tot)
+ if (mask->masklay_act >= mask->masklay_tot) {
mask->masklay_act = mask->masklay_tot - 1;
+ }
}
void BKE_mask_layer_unique_name(Mask *mask, MaskLayer *masklay)
@@ -399,8 +402,9 @@ float BKE_mask_spline_project_co(MaskSpline *spline,
if (len_squared_v2(v1) > proj_eps_sq) {
ang1 = angle_v2v2(v1, n1);
- if (ang1 > (float)M_PI / 2.0f)
+ if (ang1 > (float)M_PI / 2.0f) {
ang1 = (float)M_PI - ang1;
+ }
if (ang < 0.0f || ang1 < ang) {
ang = ang1;
@@ -424,8 +428,9 @@ float BKE_mask_spline_project_co(MaskSpline *spline,
if (len_squared_v2(v2) > proj_eps_sq) {
ang2 = angle_v2v2(v2, n2);
- if (ang2 > (float)M_PI / 2.0f)
+ if (ang2 > (float)M_PI / 2.0f) {
ang2 = (float)M_PI - ang2;
+ }
if (ang2 < ang) {
ang = ang2;
@@ -728,10 +733,12 @@ MaskSplinePointUW *BKE_mask_point_sort_uw(MaskSplinePoint *point, MaskSplinePoin
void BKE_mask_point_add_uw(MaskSplinePoint *point, float u, float w)
{
- if (!point->uw)
+ if (!point->uw) {
point->uw = MEM_mallocN(sizeof(*point->uw), "mask point uw");
- else
+ }
+ else {
point->uw = MEM_reallocN(point->uw, (point->tot_uw + 1) * sizeof(*point->uw));
+ }
point->uw[point->tot_uw].u = u;
point->uw[point->tot_uw].w = w;
@@ -816,10 +823,12 @@ Mask *BKE_mask_new(Main *bmain, const char *name)
Mask *mask;
char mask_name[MAX_ID_NAME - 2];
- if (name && name[0])
+ if (name && name[0]) {
BLI_strncpy(mask_name, name, sizeof(mask_name));
- else
+ }
+ else {
strcpy(mask_name, "Mask");
+ }
mask = mask_alloc(bmain, mask_name);
@@ -889,8 +898,9 @@ void BKE_mask_make_local(Main *bmain, Mask *mask, const bool lib_local)
void BKE_mask_point_free(MaskSplinePoint *point)
{
- if (point->uw)
+ if (point->uw) {
MEM_freeN(point->uw);
+ }
}
void BKE_mask_spline_free(MaskSpline *spline)
@@ -940,8 +950,9 @@ static MaskSplinePoint *mask_spline_points_copy(const MaskSplinePoint *points, i
for (i = 0; i < tot_point; i++) {
MaskSplinePoint *point = &npoints[i];
- if (point->uw)
+ if (point->uw) {
point->uw = MEM_dupallocN(point->uw);
+ }
}
return npoints;
@@ -1214,11 +1225,13 @@ static void mask_calc_point_handle(MaskSplinePoint *point,
BezTriple *bezt_prev = NULL, *bezt_next = NULL;
//int handle_type = bezt->h1;
- if (point_prev)
+ if (point_prev) {
bezt_prev = &point_prev->bezt;
+ }
- if (point_next)
+ if (point_next) {
bezt_next = &point_next->bezt;
+ }
#if 1
if (bezt_prev || bezt_next) {
@@ -1699,12 +1712,15 @@ static int mask_layer_shape_sort_cb(const void *masklay_shape_a_ptr,
const MaskLayerShape *masklay_shape_a = masklay_shape_a_ptr;
const MaskLayerShape *masklay_shape_b = masklay_shape_b_ptr;
- if (masklay_shape_a->frame < masklay_shape_b->frame)
+ if (masklay_shape_a->frame < masklay_shape_b->frame) {
return -1;
- else if (masklay_shape_a->frame > masklay_shape_b->frame)
+ }
+ else if (masklay_shape_a->frame > masklay_shape_b->frame) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
void BKE_mask_layer_shape_sort(MaskLayer *masklay)