diff options
Diffstat (limited to 'source')
95 files changed, 2010 insertions, 1436 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 24386730ddb..6fccf819d05 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -42,7 +42,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 263 -#define BLENDER_SUBVERSION 8 +#define BLENDER_SUBVERSION 9 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index ac3daef77f7..279ec272fe8 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -157,6 +157,7 @@ void BKE_image_assign_ibuf(struct Image *ima, struct ImBuf *ibuf); void BKE_image_user_frame_calc(struct ImageUser *iuser, int cfra, int fieldnr); void BKE_image_user_check_frame_calc(struct ImageUser *iuser, int cfra, int fieldnr); int BKE_image_user_frame_get(const struct ImageUser *iuser, int cfra, int fieldnr); +void BKE_image_user_file_path(struct ImageUser *iuser, struct Image *ima, int cfra, char *path); /* sets index offset for multilayer files */ struct RenderPass *BKE_image_multilayer_index(struct RenderResult *rr, struct ImageUser *iuser); diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h index 3f837f995ce..19feb4d8f2e 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -69,7 +69,14 @@ float (*BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feath void BKE_mask_point_direction_switch(struct MaskSplinePoint *point); void BKE_mask_spline_direction_switch(struct MaskLayer *masklay, struct MaskSpline *spline); -float BKE_mask_spline_project_co(struct MaskSpline *spline, struct MaskSplinePoint *point, float start_u, const float co[2]); + +typedef enum { + MASK_PROJ_NEG = -1, + MASK_PROJ_ANY = 0, + MASK_PROJ_POS = 1 +} eMaskSign; +float BKE_mask_spline_project_co(struct MaskSpline *spline, struct MaskSplinePoint *point, + float start_u, const float co[2], const eMaskSign sign); /* point */ int BKE_mask_point_has_handle(struct MaskSplinePoint *point); @@ -91,6 +98,7 @@ float *BKE_mask_point_segment_feather_diff_with_resolution(struct MaskSpline *sp void BKE_mask_point_segment_co(struct MaskSpline *spline, struct MaskSplinePoint *point, float u, float co[2]); void BKE_mask_point_normal(struct MaskSpline *spline, struct MaskSplinePoint *point, float u, float n[2]); +float BKE_mask_point_weight_scalar(struct MaskSpline *spline, struct MaskSplinePoint *point, const float u); float BKE_mask_point_weight(struct MaskSpline *spline, struct MaskSplinePoint *point, float u); struct MaskSplinePointUW *BKE_mask_point_sort_uw(struct MaskSplinePoint *point, struct MaskSplinePointUW *uw); void BKE_mask_point_add_uw(struct MaskSplinePoint *point, float u, float w); @@ -133,11 +141,13 @@ void BKE_mask_layer_shape_to_mask_interp(struct MaskLayer *masklay, struct MaskLayerShape *masklay_shape_a, struct MaskLayerShape *masklay_shape_b, const float fac); -struct MaskLayerShape *BKE_mask_layer_shape_find_frame(struct MaskLayer *masklay, int frame); -int BKE_mask_layer_shape_find_frame_range(struct MaskLayer *masklay, int frame, +struct MaskLayerShape *BKE_mask_layer_shape_find_frame(struct MaskLayer *masklay, const int frame); +int BKE_mask_layer_shape_find_frame_range(struct MaskLayer *masklay, const int frame, struct MaskLayerShape **r_masklay_shape_a, struct MaskLayerShape **r_masklay_shape_b); -struct MaskLayerShape *BKE_mask_layer_shape_varify_frame(struct MaskLayer *masklay, int frame); +struct MaskLayerShape *BKE_mask_layer_shape_alloc(struct MaskLayer *masklay, const int frame); +void BKE_mask_layer_shape_free(struct MaskLayerShape *masklay_shape); +struct MaskLayerShape *BKE_mask_layer_shape_varify_frame(struct MaskLayer *masklay, const int frame); void BKE_mask_layer_shape_unlink(struct MaskLayer *masklay, struct MaskLayerShape *masklay_shape); void BKE_mask_layer_shape_sort(struct MaskLayer *masklay); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 3748a474ddd..9dc5463edab 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -2084,8 +2084,7 @@ static void image_initialize_after_load(Image *ima, ImBuf *ibuf) static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) { struct ImBuf *ibuf; - unsigned short numlen; - char name[FILE_MAX], head[FILE_MAX], tail[FILE_MAX]; + char name[FILE_MAX]; int flag; /* XXX temp stuff? */ @@ -2093,11 +2092,7 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) ima->tpageflag |= IMA_TPAGE_REFRESH; ima->lastframe = frame; - BLI_strncpy(name, ima->name, sizeof(name)); - BLI_stringdec(name, head, tail, &numlen); - BLI_stringenc(name, head, tail, numlen, frame); - - BLI_path_abs(name, ID_BLEND_PATH(G.main, &ima->id)); + BKE_image_user_file_path(iuser, ima, frame, name); flag = IB_rect | IB_multilayer; if (ima->flag & IMA_DO_PREMUL) @@ -2209,8 +2204,7 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) if (ima->anim == NULL) { char str[FILE_MAX]; - BLI_strncpy(str, ima->name, FILE_MAX); - BLI_path_abs(str, ID_BLEND_PATH(G.main, &ima->id)); + BKE_image_user_file_path(iuser, ima, frame, str); /* FIXME: make several stream accessible in image editor, too*/ ima->anim = openanim(str, IB_rect, 0); @@ -2273,8 +2267,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) flag |= IB_premul; /* get the right string */ - BLI_strncpy(str, ima->name, sizeof(str)); - BLI_path_abs(str, ID_BLEND_PATH(G.main, &ima->id)); + BKE_image_user_file_path(iuser, ima, cfra, str); /* read ibuf */ ibuf = IMB_loadiffname(str, flag); @@ -2748,6 +2741,29 @@ void BKE_image_user_check_frame_calc(ImageUser *iuser, int cfra, int fieldnr) } } +void BKE_image_user_file_path(ImageUser *iuser, Image *ima, int cfra, char *filepath) +{ + BLI_strncpy(filepath, ima->name, FILE_MAX); + + if (ima->source == IMA_SRC_SEQUENCE) { + char head[FILE_MAX], tail[FILE_MAX]; + unsigned short numlen; + int frame; + + if(iuser) { + BKE_image_user_frame_calc(iuser, cfra, 0); + frame = iuser->framenr; + } + else { + } + + BLI_stringdec(filepath, head, tail, &numlen); + BLI_stringenc(filepath, head, tail, numlen, frame); + } + + BLI_path_abs(filepath, ID_BLEND_PATH(G.main, &ima->id)); +} + int BKE_image_has_alpha(struct Image *image) { ImBuf *ibuf; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 0abeb483745..c81e607ce93 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1142,7 +1142,7 @@ static ID *is_dupid(ListBase *lb, ID *id, const char *name) * Normally the ID that's being check is already in the ListBase, so ID *id * points at the new entry. The Python Library module needs to know what * the name of a datablock will be before it is appended; in this case ID *id - * id is NULL; + * id is NULL */ static int check_for_dupid(ListBase *lb, ID *id, char *name) diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index 870a84df66a..aaefa558c9b 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -58,6 +58,68 @@ #include "raskter.h" +static MaskSplinePoint *mask_spline_point_next(MaskSpline *spline, MaskSplinePoint *points_array, MaskSplinePoint *point) +{ + if (point == &points_array[spline->tot_point - 1]) { + if (spline->flag & MASK_SPLINE_CYCLIC) { + return &points_array[0]; + } + else { + return NULL; + } + } + else { + return point + 1; + } +} + +static MaskSplinePoint *mask_spline_point_prev(MaskSpline *spline, MaskSplinePoint *points_array, MaskSplinePoint *point) +{ + if (point == points_array) { + if (spline->flag & MASK_SPLINE_CYCLIC) { + return &points_array[spline->tot_point - 1]; + } + else { + return NULL; + } + } + else { + return point - 1; + } +} + +static BezTriple *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) { + return &(points_array[0].bezt); + } + else { + return NULL; + } + } + else { + return &((point + 1))->bezt; + } +} + +#if 0 +static BezTriple *mask_spline_point_prev_bezt(MaskSpline *spline, MaskSplinePoint *points_array, MaskSplinePoint *point) +{ + if (point == points_array) { + if (spline->flag & MASK_SPLINE_CYCLIC) { + return &(points_array[0].bezt); + } + else { + return NULL; + } + } + else { + return &((point - 1))->bezt; + } +} +#endif + MaskSplinePoint *BKE_mask_spline_point_array(MaskSpline *spline) { return spline->points_deform ? spline->points_deform : spline->points; @@ -163,26 +225,20 @@ static int BKE_mask_spline_resolution(MaskSpline *spline, int width, int height) for (i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; - MaskSplinePoint *next_point; - BezTriple *bezt, *next_bezt; + BezTriple *bezt, *bezt_next; float a, b, c, len; int cur_resol; - if (i == spline->tot_point - 1) { - if (spline->flag & MASK_SPLINE_CYCLIC) - next_point = &spline->points[0]; - else - break; - } - else - next_point = &spline->points[i + 1]; - bezt = &point->bezt; - next_bezt = &next_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], next_bezt->vec[0]); - c = len_v3v3(next_bezt->vec[0], next_bezt->vec[1]); + 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; @@ -383,28 +439,33 @@ void BKE_mask_point_direction_switch(MaskSplinePoint *point) const int tot_uw_half = tot_uw / 2; int i; - if (tot_uw < 2) { - return; - } + float co_tmp[2]; - /* 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); + /* swap handles */ + copy_v2_v2(co_tmp, point->bezt.vec[0]); + copy_v2_v2(point->bezt.vec[0], point->bezt.vec[2]); + copy_v2_v2(point->bezt.vec[2], co_tmp); + /* in this case the flags are unlikely to be different but swap anyway */ + SWAP(char, point->bezt.f1, point->bezt.f3); + SWAP(char, point->bezt.h1, point->bezt.h2); + + + /* swap UW's */ + if (tot_uw > 1) { + /* 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; @@ -456,7 +517,8 @@ void BKE_mask_spline_direction_switch(MaskLayer *masklay, MaskSpline *spline) } -float BKE_mask_spline_project_co(MaskSpline *spline, MaskSplinePoint *point, float start_u, const float co[2]) +float BKE_mask_spline_project_co(MaskSpline *spline, MaskSplinePoint *point, + float start_u, const float co[2], const eMaskSign sign) { const float proj_eps = 1e-3; const float proj_eps_squared = proj_eps * proj_eps; @@ -464,6 +526,8 @@ float BKE_mask_spline_project_co(MaskSpline *spline, MaskSplinePoint *point, flo float u = -1.0f, du = 1.0f / N, u1 = start_u, u2 = start_u; float ang = -1.0f; + BLI_assert(ABS(sign) <= 1); /* (-1, 0, 1) */ + while (u1 > 0.0f || u2 < 1.0f) { float n1[2], n2[2], co1[2], co2[2]; float v1[2], v2[2]; @@ -474,20 +538,26 @@ float BKE_mask_spline_project_co(MaskSpline *spline, MaskSplinePoint *point, flo BKE_mask_point_normal(spline, point, u1, n1); sub_v2_v2v2(v1, co, co1); - if (len_squared_v2(v1) > proj_eps_squared) { - ang1 = angle_v2v2(v1, n1); - if (ang1 > M_PI / 2.0f) - ang1 = M_PI - ang1; + if ((sign == MASK_PROJ_ANY) || + ((sign == MASK_PROJ_NEG) && (dot_v2v2(v1, n1) <= 0.0f)) || + ((sign == MASK_PROJ_POS) && (dot_v2v2(v1, n1) >= 0.0f))) + { + + if (len_squared_v2(v1) > proj_eps_squared) { + ang1 = angle_v2v2(v1, n1); + if (ang1 > M_PI / 2.0f) + ang1 = M_PI - ang1; - if (ang < 0.0f || ang1 < ang) { - ang = ang1; + if (ang < 0.0f || ang1 < ang) { + ang = ang1; + u = u1; + } + } + else { u = u1; + break; } } - else { - u = u1; - break; - } } if (u2 <= 1.0f) { @@ -495,20 +565,26 @@ float BKE_mask_spline_project_co(MaskSpline *spline, MaskSplinePoint *point, flo BKE_mask_point_normal(spline, point, u2, n2); sub_v2_v2v2(v2, co, co2); - if (len_squared_v2(v2) > proj_eps_squared) { - ang2 = angle_v2v2(v2, n2); - if (ang2 > M_PI / 2.0f) - ang2 = M_PI - ang2; + if ((sign == MASK_PROJ_ANY) || + ((sign == MASK_PROJ_NEG) && (dot_v2v2(v2, n2) <= 0.0f)) || + ((sign == MASK_PROJ_POS) && (dot_v2v2(v2, n2) >= 0.0f))) + { + + if (len_squared_v2(v2) > proj_eps_squared) { + ang2 = angle_v2v2(v2, n2); + if (ang2 > M_PI / 2.0f) + ang2 = M_PI - ang2; - if (ang2 < ang) { - ang = ang2; + if (ang2 < ang) { + ang = ang2; + u = u2; + } + } + else { u = u2; + break; } } - else { - u = u2; - break; - } } u1 -= du; @@ -611,21 +687,14 @@ float *BKE_mask_point_segment_diff_with_resolution(MaskSpline *spline, MaskSplin { MaskSplinePoint *points_array = BKE_mask_spline_point_array_from_point(spline, point); - BezTriple *bezt, *next; + BezTriple *bezt, *bezt_next; float *diff_points, *fp; int j, resol = BKE_mask_spline_resolution(spline, width, height); bezt = &point->bezt; + bezt_next = mask_spline_point_next_bezt(spline, points_array, point); - if (point == &points_array[spline->tot_point - 1]) { - if (spline->flag & MASK_SPLINE_CYCLIC) - next = &(points_array[0].bezt); - else - next = NULL; - } - else next = &((point + 1))->bezt; - - if (!next) + if (!bezt_next) return NULL; /* resol+1 because of 'forward_diff_bezier' function */ @@ -634,11 +703,11 @@ float *BKE_mask_point_segment_diff_with_resolution(MaskSpline *spline, MaskSplin for (j = 0; j < 2; j++) { BKE_curve_forward_diff_bezier(bezt->vec[1][j], bezt->vec[2][j], - next->vec[0][j], next->vec[1][j], + bezt_next->vec[0][j], bezt_next->vec[1][j], fp + j, resol, 2 * sizeof(float)); } - copy_v2_v2(fp + 2 * resol, next->vec[1]); + copy_v2_v2(fp + 2 * resol, bezt_next->vec[1]); return diff_points; } @@ -652,25 +721,19 @@ void BKE_mask_point_segment_co(MaskSpline *spline, MaskSplinePoint *point, float { MaskSplinePoint *points_array = BKE_mask_spline_point_array_from_point(spline, point); - BezTriple *bezt = &point->bezt, *next; + BezTriple *bezt = &point->bezt, *bezt_next; float q0[2], q1[2], q2[2], r0[2], r1[2]; - if (point == &points_array[spline->tot_point - 1]) { - if (spline->flag & MASK_SPLINE_CYCLIC) - next = &(points_array[0].bezt); - else - next = NULL; - } - else next = &((point + 1))->bezt; + bezt_next = mask_spline_point_next_bezt(spline, points_array, point); - if (!next) { + if (!bezt_next) { copy_v2_v2(co, bezt->vec[1]); return; } interp_v2_v2v2(q0, bezt->vec[1], bezt->vec[2], u); - interp_v2_v2v2(q1, bezt->vec[2], next->vec[0], u); - interp_v2_v2v2(q2, next->vec[0], next->vec[1], u); + interp_v2_v2v2(q1, bezt->vec[2], bezt_next->vec[0], u); + interp_v2_v2v2(q2, bezt_next->vec[0], bezt_next->vec[1], u); interp_v2_v2v2(r0, q0, q1, u); interp_v2_v2v2(r1, q1, q2, u); @@ -682,20 +745,12 @@ void BKE_mask_point_normal(MaskSpline *spline, MaskSplinePoint *point, float u, { MaskSplinePoint *points_array = BKE_mask_spline_point_array_from_point(spline, point); - BezTriple *bezt = &point->bezt, *next; + BezTriple *bezt = &point->bezt, *bezt_next; float q0[2], q1[2], q2[2], r0[2], r1[2], vec[2]; - if (point == &points_array[spline->tot_point - 1]) { - if (spline->flag & MASK_SPLINE_CYCLIC) - next = &(points_array[0].bezt); - else - next = NULL; - } - else { - next = &((point + 1))->bezt; - } + bezt_next = mask_spline_point_next_bezt(spline, points_array, point); - if (!next) { + if (!bezt_next) { BKE_mask_point_handle(point, vec); sub_v2_v2v2(n, vec, bezt->vec[1]); @@ -704,8 +759,8 @@ void BKE_mask_point_normal(MaskSpline *spline, MaskSplinePoint *point, float u, } interp_v2_v2v2(q0, bezt->vec[1], bezt->vec[2], u); - interp_v2_v2v2(q1, bezt->vec[2], next->vec[0], u); - interp_v2_v2v2(q2, next->vec[0], next->vec[1], u); + interp_v2_v2v2(q1, bezt->vec[2], bezt_next->vec[0], u); + interp_v2_v2v2(q2, bezt_next->vec[0], bezt_next->vec[1], u); interp_v2_v2v2(r0, q0, q1, u); interp_v2_v2v2(r1, q1, q2, u); @@ -718,60 +773,89 @@ void BKE_mask_point_normal(MaskSpline *spline, MaskSplinePoint *point, float u, normalize_v2(n); } -float BKE_mask_point_weight(MaskSpline *spline, MaskSplinePoint *point, float u) +static float mask_point_interp_weight(BezTriple *bezt, BezTriple *bezt_next, const float u) { - MaskSplinePoint *points_array = BKE_mask_spline_point_array_from_point(spline, point); + return (bezt->weight * (1.0f - u)) + (bezt_next->weight * u); +} +float BKE_mask_point_weight_scalar(MaskSpline *spline, MaskSplinePoint *point, const float u) +{ + MaskSplinePoint *points_array = BKE_mask_spline_point_array_from_point(spline, point); BezTriple *bezt = &point->bezt, *bezt_next; - float cur_u, cur_w, next_u, next_w, fac; - int i; - if (point == &points_array[spline->tot_point - 1]) { - if (spline->flag & MASK_SPLINE_CYCLIC) { - bezt_next = &(points_array[0].bezt); - } - else { - bezt_next = NULL; - } + bezt_next = mask_spline_point_next_bezt(spline, points_array, point); + + if (!bezt_next) { + return bezt->weight; + } + else if (u <= 0.0) { + return bezt->weight; + } + else if (u >= 1.0f) { + return bezt_next->weight; } else { - bezt_next = &((point + 1))->bezt; + return mask_point_interp_weight(bezt, bezt_next, u); } +} - if (!bezt_next) +float BKE_mask_point_weight(MaskSpline *spline, MaskSplinePoint *point, const float u) +{ + MaskSplinePoint *points_array = BKE_mask_spline_point_array_from_point(spline, point); + BezTriple *bezt = &point->bezt, *bezt_next; + + bezt_next = mask_spline_point_next_bezt(spline, points_array, point); + + if (!bezt_next) { return bezt->weight; + } + else if (u <= 0.0) { + return bezt->weight; + } + else if (u >= 1.0f) { + return bezt_next->weight; + } + else { + float cur_u, cur_w, next_u, next_w, fac; + int i; - for (i = 0; i < point->tot_uw + 1; i++) { + for (i = 0; i < point->tot_uw + 1; i++) { - if (i == 0) { - cur_u = 0.0f; - cur_w = bezt->weight; - } - else { - cur_u = point->uw[i - 1].u; - cur_w = point->uw[i - 1].w; + if (i == 0) { + cur_u = 0.0f; + cur_w = 1.0f; /* mask_point_interp_weight will scale it */ + } + else { + cur_u = point->uw[i - 1].u; + cur_w = point->uw[i - 1].w; + } + + if (i == point->tot_uw) { + next_u = 1.0f; + next_w = 1.0f; /* mask_point_interp_weight will scale it */ + } + else { + next_u = point->uw[i].u; + next_w = point->uw[i].w; + } + + if (u >= cur_u && u <= next_u) { + break; + } } - if (i == point->tot_uw) { - next_u = 1.0f; - next_w = bezt_next->weight; + fac = (u - cur_u) / (next_u - cur_u); + + cur_w *= mask_point_interp_weight(bezt, bezt_next, cur_u); + next_w *= mask_point_interp_weight(bezt, bezt_next, next_u); + + if (spline->weight_interp == MASK_SPLINE_INTERP_EASE) { + return cur_w + (next_w - cur_w) * (3.0f * fac * fac - 2.0f * fac * fac * fac); } else { - next_u = point->uw[i].u; - next_w = point->uw[i].w; - } - - if (u >= cur_u && u <= next_u) { - break; + return (1.0f - fac) * cur_w + fac * next_w; } } - - fac = (u - cur_u) / (next_u - cur_u); - - if (spline->weight_interp == MASK_SPLINE_INTERP_EASE) - return cur_w + (next_w - cur_w) * (3.0f * fac * fac - 2.0f * fac * fac * fac); - else - return (1.0f - fac) * cur_w + fac * next_w; } MaskSplinePointUW *BKE_mask_point_sort_uw(MaskSplinePoint *point, MaskSplinePointUW *uw) @@ -920,6 +1004,20 @@ MaskSpline *BKE_mask_spline_copy(MaskSpline *spline) return nspline; } +/* note: does NOT add to the list */ +MaskLayerShape *BKE_mask_layer_shape_alloc(MaskLayer *masklay, const int frame) +{ + MaskLayerShape *masklay_shape; + int tot_vert = BKE_mask_layer_shape_totvert(masklay); + + masklay_shape = MEM_mallocN(sizeof(MaskLayerShape), __func__); + masklay_shape->frame = frame; + masklay_shape->tot_vert = tot_vert; + masklay_shape->data = MEM_mallocN(tot_vert * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE, __func__); + + return masklay_shape; +} + void BKE_mask_layer_shape_free(MaskLayerShape *masklay_shape) { MEM_freeN(masklay_shape->data); @@ -1084,28 +1182,28 @@ int BKE_mask_evaluate_parent_delta(MaskParent *parent, float ctime, float r_delt } } -static void mask_calc_point_handle(MaskSplinePoint *point, MaskSplinePoint *prev_point, MaskSplinePoint *next_point) +static void mask_calc_point_handle(MaskSplinePoint *point, MaskSplinePoint *point_prev, MaskSplinePoint *point_next) { BezTriple *bezt = &point->bezt; - BezTriple *prev_bezt = NULL, *next_bezt = NULL; + BezTriple *bezt_prev = NULL, *bezt_next = NULL; //int handle_type = bezt->h1; - if (prev_point) - prev_bezt = &prev_point->bezt; + if (point_prev) + bezt_prev = &point_prev->bezt; - if (next_point) - next_bezt = &next_point->bezt; + if (point_next) + bezt_next = &point_next->bezt; #if 1 - if (prev_bezt || next_bezt) { - BKE_nurb_handle_calc(bezt, prev_bezt, next_bezt, 0); + if (bezt_prev || bezt_next) { + BKE_nurb_handle_calc(bezt, bezt_prev, bezt_next, 0); } #else if (handle_type == HD_VECT) { - BKE_nurb_handle_calc(bezt, prev_bezt, next_bezt, 0); + BKE_nurb_handle_calc(bezt, bezt_prev, bezt_next, 0); } else if (handle_type == HD_AUTO) { - BKE_nurb_handle_calc(bezt, prev_bezt, next_bezt, 0); + BKE_nurb_handle_calc(bezt, bezt_prev, bezt_next, 0); } else if (handle_type == HD_ALIGN) { float v1[3], v2[3]; @@ -1133,37 +1231,12 @@ static void mask_calc_point_handle(MaskSplinePoint *point, MaskSplinePoint *prev void BKE_mask_get_handle_point_adjacent(Mask *UNUSED(mask), MaskSpline *spline, MaskSplinePoint *point, MaskSplinePoint **r_point_prev, MaskSplinePoint **r_point_next) { - MaskSplinePoint *prev_point, *next_point; int i = (int)(point - spline->points); - BLI_assert(i >= i && i < spline->tot_point); + (void)i; /* quiet release builds */ - if (i == 0) { - if (spline->flag & MASK_SPLINE_CYCLIC) { - prev_point = &spline->points[spline->tot_point - 1]; - } - else { - prev_point = NULL; - } - } - else { - prev_point = point - 1; - } - - if (i == spline->tot_point - 1) { - if (spline->flag & MASK_SPLINE_CYCLIC) { - next_point = &spline->points[0]; - } - else { - next_point = NULL; - } - } - else { - next_point = point + 1; - } - - *r_point_prev = prev_point; - *r_point_next = next_point; + *r_point_prev = mask_spline_point_prev(spline, spline->points, point); + *r_point_next = mask_spline_point_next(spline, spline->points, point); } /* calculates the tanget of a point by its previous and next @@ -1172,21 +1245,21 @@ void BKE_mask_calc_tangent_polyline(Mask *mask, MaskSpline *spline, MaskSplinePo { float tvec_a[2], tvec_b[2]; - MaskSplinePoint *prev_point, *next_point; + MaskSplinePoint *point_prev, *point_next; BKE_mask_get_handle_point_adjacent(mask, spline, point, - &prev_point, &next_point); + &point_prev, &point_next); - if (prev_point) { - sub_v2_v2v2(tvec_a, point->bezt.vec[1], prev_point->bezt.vec[1]); + if (point_prev) { + sub_v2_v2v2(tvec_a, point->bezt.vec[1], point_prev->bezt.vec[1]); normalize_v2(tvec_a); } else { zero_v2(tvec_a); } - if (next_point) { - sub_v2_v2v2(tvec_b, next_point->bezt.vec[1], point->bezt.vec[1]); + if (point_next) { + sub_v2_v2v2(tvec_b, point_next->bezt.vec[1], point->bezt.vec[1]); normalize_v2(tvec_b); } else { @@ -1199,12 +1272,12 @@ void BKE_mask_calc_tangent_polyline(Mask *mask, MaskSpline *spline, MaskSplinePo void BKE_mask_calc_handle_point(Mask *mask, MaskSpline *spline, MaskSplinePoint *point) { - MaskSplinePoint *prev_point, *next_point; + MaskSplinePoint *point_prev, *point_next; BKE_mask_get_handle_point_adjacent(mask, spline, point, - &prev_point, &next_point); + &point_prev, &point_next); - mask_calc_point_handle(point, prev_point, next_point); + mask_calc_point_handle(point, point_prev, point_next); } static void enforce_dist_v2_v2fl(float v1[2], const float v2[2], const float dist) @@ -1226,31 +1299,31 @@ void BKE_mask_calc_handle_adjacent_interp(Mask *mask, MaskSpline *spline, MaskSp float weight_average = 0.0f; - MaskSplinePoint *prev_point, *next_point; + MaskSplinePoint *point_prev, *point_next; BLI_assert(u >= 0.0f && u <= 1.0f); BKE_mask_get_handle_point_adjacent(mask, spline, point, - &prev_point, &next_point); + &point_prev, &point_next); - if (prev_point && next_point) { - length_average = ((len_v2v2(prev_point->bezt.vec[0], prev_point->bezt.vec[1]) * (1.0f - u)) + - (len_v2v2(next_point->bezt.vec[2], next_point->bezt.vec[1]) * u)); + if (point_prev && point_next) { + length_average = ((len_v2v2(point_prev->bezt.vec[0], point_prev->bezt.vec[1]) * (1.0f - u)) + + (len_v2v2(point_next->bezt.vec[2], point_next->bezt.vec[1]) * u)); - weight_average = (prev_point->bezt.weight * (1.0f - u) + - next_point->bezt.weight * u); + weight_average = (point_prev->bezt.weight * (1.0f - u) + + point_next->bezt.weight * u); length_tot = 1; } else { - if (prev_point) { - length_average += len_v2v2(prev_point->bezt.vec[0], prev_point->bezt.vec[1]); - weight_average += prev_point->bezt.weight; + if (point_prev) { + length_average += len_v2v2(point_prev->bezt.vec[0], point_prev->bezt.vec[1]); + weight_average += point_prev->bezt.weight; length_tot++; } - if (next_point) { - length_average += len_v2v2(next_point->bezt.vec[2], next_point->bezt.vec[1]); - weight_average += next_point->bezt.weight; + if (point_next) { + length_average += len_v2v2(point_next->bezt.vec[2], point_next->bezt.vec[1]); + weight_average += point_next->bezt.weight; length_tot++; } } @@ -1274,18 +1347,18 @@ void BKE_mask_calc_handle_adjacent_interp(Mask *mask, MaskSpline *spline, MaskSp void BKE_mask_calc_handle_point_auto(Mask *mask, MaskSpline *spline, MaskSplinePoint *point, const short do_recalc_length) { - MaskSplinePoint *prev_point, *next_point; + MaskSplinePoint *point_prev, *point_next; const char h_back[2] = {point->bezt.h1, point->bezt.h2}; const float length_average = (do_recalc_length) ? 0.0f /* dummy value */ : (len_v3v3(point->bezt.vec[0], point->bezt.vec[1]) + len_v3v3(point->bezt.vec[1], point->bezt.vec[2])) / 2.0f; BKE_mask_get_handle_point_adjacent(mask, spline, point, - &prev_point, &next_point); + &point_prev, &point_next); point->bezt.h1 = HD_AUTO; point->bezt.h2 = HD_AUTO; - mask_calc_point_handle(point, prev_point, next_point); + mask_calc_point_handle(point, point_prev, point_next); point->bezt.h1 = h_back[0]; point->bezt.h2 = h_back[1]; @@ -1633,7 +1706,7 @@ void BKE_mask_layer_shape_to_mask_interp(MaskLayer *masklay, } } -MaskLayerShape *BKE_mask_layer_shape_find_frame(MaskLayer *masklay, int frame) +MaskLayerShape *BKE_mask_layer_shape_find_frame(MaskLayer *masklay, const int frame) { MaskLayerShape *masklay_shape; @@ -1653,7 +1726,7 @@ MaskLayerShape *BKE_mask_layer_shape_find_frame(MaskLayer *masklay, int frame) } /* when returning 2 - the frame isnt found but before/after frames are */ -int BKE_mask_layer_shape_find_frame_range(MaskLayer *masklay, int frame, +int BKE_mask_layer_shape_find_frame_range(MaskLayer *masklay, const int frame, MaskLayerShape **r_masklay_shape_a, MaskLayerShape **r_masklay_shape_b) { @@ -1688,22 +1761,15 @@ int BKE_mask_layer_shape_find_frame_range(MaskLayer *masklay, int frame, return 0; } -MaskLayerShape *BKE_mask_layer_shape_varify_frame(MaskLayer *masklay, int frame) +MaskLayerShape *BKE_mask_layer_shape_varify_frame(MaskLayer *masklay, const int frame) { MaskLayerShape *masklay_shape; masklay_shape = BKE_mask_layer_shape_find_frame(masklay, frame); if (masklay_shape == NULL) { - int tot_vert = BKE_mask_layer_shape_totvert(masklay); - - masklay_shape = MEM_mallocN(sizeof(MaskLayerShape), __func__); - masklay_shape->frame = frame; - masklay_shape->tot_vert = tot_vert; - masklay_shape->data = MEM_mallocN(tot_vert * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE, __func__); - + masklay_shape = BKE_mask_layer_shape_alloc(masklay, frame); BLI_addtail(&masklay->splines_shapes, masklay_shape); - BKE_mask_layer_shape_sort(masklay); } @@ -1972,15 +2038,6 @@ void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer) /* 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 (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { MaskSpline *spline; @@ -1999,51 +2056,56 @@ void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer) float (*diff_feather_points)[2]; int tot_diff_feather_points; - diff_points = BKE_mask_spline_differentiate_with_resolution(spline, width, height, &tot_diff_point); + diff_points = BKE_mask_spline_differentiate_with_resolution(spline, width, height, + &tot_diff_point); + if (tot_diff_point) { diff_feather_points = BKE_mask_spline_feather_differentiated_points_with_resolution(spline, width, height, &tot_diff_feather_points); - } - /* TODO, make this optional! */ - if (width != height) { - float *fp; - float *ffp; - int i; - float asp; - - if (width < height) { - fp = &diff_points[0][0]; - ffp = &diff_feather_points[0][0]; - asp = (float)width / (float)height; - } - else { - fp = &diff_points[0][1]; - ffp = &diff_feather_points[0][1]; - asp = (float)height / (float)width; - } + /* TODO, make this optional! */ + if (width != height) { + float *fp; + float *ffp; + int i; + float asp; + + if (width < height) { + fp = &diff_points[0][0]; + ffp = tot_diff_feather_points ? &diff_feather_points[0][0] : NULL; + asp = (float)width / (float)height; + } + else { + fp = &diff_points[0][1]; + ffp = tot_diff_feather_points ? &diff_feather_points[0][1] : NULL; + asp = (float)height / (float)width; + } - for (i = 0; i < tot_diff_point; i++, fp += 2) { - (*fp) = (((*fp) - 0.5f) / asp) + 0.5f; - } - for (i = 0; i < tot_diff_feather_points; i++, ffp += 2) { - (*ffp) = (((*ffp) - 0.5f) / asp) + 0.5f; - } - } + for (i = 0; i < tot_diff_point; i++, fp += 2) { + (*fp) = (((*fp) - 0.5f) / asp) + 0.5f; + } - if (tot_diff_point) { - PLX_raskterize((float (*)[2])diff_points, tot_diff_point, - buffer_tmp, width, height); - - if (tot_diff_feather_points) { - PLX_raskterize_feather((float (*)[2])diff_points, tot_diff_point, - (float (*)[2])diff_feather_points, tot_diff_feather_points, - buffer_tmp, width, height); - MEM_freeN(diff_feather_points); + if (tot_diff_feather_points) { + for (i = 0; i < tot_diff_feather_points; i++, ffp += 2) { + (*ffp) = (((*ffp) - 0.5f) / asp) + 0.5f; + } + } } - MEM_freeN(diff_points); + if (tot_diff_point) { + PLX_raskterize(diff_points, tot_diff_point, + buffer_tmp, width, height); + + if (tot_diff_feather_points) { + PLX_raskterize_feather(diff_points, tot_diff_point, + diff_feather_points, tot_diff_feather_points, + buffer_tmp, width, height); + MEM_freeN(diff_feather_points); + } + + MEM_freeN(diff_points); + } } } diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index e0239cde86d..22eae912967 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -153,9 +153,15 @@ static void get_sequence_fname(MovieClip *clip, int framenr, char *name) BLI_strncpy(name, clip->name, sizeof(clip->name)); BLI_stringdec(name, head, tail, &numlen); - /* movieclips always points to first image from sequence, - * autoguess offset for now. could be something smarter in the future */ - offset = sequence_guess_offset(clip->name, strlen(head), numlen); + if (clip->flag & MCLIP_CUSTOM_START_FRAME) { + offset = clip->start_frame; + } + else { + /* movieclips always points to first image from sequence, + * autoguess offset for now. could be something smarter in the future + */ + offset = sequence_guess_offset(clip->name, strlen(head), numlen); + } if (numlen) BLI_stringenc(name, head, tail, numlen, offset + framenr - 1); @@ -250,6 +256,10 @@ static ImBuf *movieclip_load_movie_file(MovieClip *clip, MovieClipUser *user, in dur = IMB_anim_get_duration(clip->anim, tc); fra = framenr - 1; + if (clip->flag & MCLIP_CUSTOM_START_FRAME) { + fra += clip->start_frame - 1; + } + if (fra < 0) fra = 0; @@ -443,6 +453,8 @@ static MovieClip *movieclip_alloc(const char *name) IMB_TC_RECORD_RUN_NO_GAPS; clip->proxy.quality = 90; + clip->start_frame = 1; + return clip; } diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index d818ca09f20..4cbfb4f0f3e 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -1058,7 +1058,8 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm /* if needed, reallocate multires paint mask */ if (gpm && gpm->level < key.level) { gpm->level = key.level; - MEM_freeN(gpm->data); + if (gpm->data) + MEM_freeN(gpm->data); gpm->data = MEM_callocN(sizeof(float) * key.grid_area, "gpm.data"); } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index cdedd818b43..f19dfe74a36 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2674,7 +2674,7 @@ static void basic_force_cb(void *efdata_v, ParticleKey *state, float *force, flo force[2] += (BLI_frand()-0.5f) * part->brownfac; } - if(part->flag & PART_ROT_DYN && epoint.ave) + if (part->flag & PART_ROT_DYN && epoint.ave) copy_v3_v3(pa->state.ave, epoint.ave); } /* gathers all forces that effect particles and calculates a new state for the particle */ diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 7a5465edf02..ebc31517524 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -150,6 +150,7 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs) struct WTURBULENCE *smoke_turbulence_init(int *UNUSED(res), int UNUSED(amplify), int UNUSED(noisetype)) { return NULL; } struct FLUID_3D *smoke_init(int *UNUSED(res), float *UNUSED(p0)) { return NULL; } void smoke_free(struct FLUID_3D *UNUSED(fluid)) {} +float *smoke_get_density(struct FLUID_3D *UNUSED(fluid)) { return NULL; } void smoke_turbulence_free(struct WTURBULENCE *UNUSED(wt)) {} void smoke_initWaveletBlenderRNA(struct WTURBULENCE *UNUSED(wt), float *UNUSED(strength)) {} void smoke_initBlenderRNA(struct FLUID_3D *UNUSED(fluid), float *UNUSED(alpha), float *UNUSED(beta), float *UNUSED(dt_factor), float *UNUSED(vorticity), int *UNUSED(border_colli)) {} diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 91e93bbd05d..40471514b48 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -1003,9 +1003,11 @@ void BKE_ffmpeg_end(void) fprintf(stderr, "Closing ffmpeg...\n"); -/* if (audio_stream) { SEE UPPER - write_audio_frames(); - }*/ +#if 0 + if (audio_stream) { /* SEE UPPER */ + write_audio_frames(); + } +#endif #ifdef WITH_AUDASPACE if (audio_mixdown_device) { diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index 9433cfd31df..5b034bd2872 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -285,8 +285,8 @@ void rgb_to_hsl(float r, float g, float b, float *lh, float *ls, float *ll) else { h = (r - g) / d + 4.0f; } - } - h /= 6.0f; + } + h /= 6.0f; *lh = h; *ls = s; @@ -634,23 +634,23 @@ void BLI_init_srgb_conversion(void) } static float inverse_srgb_companding(float v) { - if (v > 0.04045f) { - return powf((v + 0.055f) / 1.055f, 2.4); - } - else { - return v / 12.92f; - } + if (v > 0.04045f) { + return powf((v + 0.055f) / 1.055f, 2.4); + } + else { + return v / 12.92f; + } } void rgb_to_xyz(float r, float g, float b, float *x, float *y, float *z) { - r = inverse_srgb_companding(r) * 100.0f; - g = inverse_srgb_companding(g) * 100.0f; - b = inverse_srgb_companding(b) * 100.0f; + r = inverse_srgb_companding(r) * 100.0f; + g = inverse_srgb_companding(g) * 100.0f; + b = inverse_srgb_companding(b) * 100.0f; - *x = r * 0.4124 + g * 0.3576 + b * 0.1805; - *y = r * 0.2126 + g * 0.7152 + b * 0.0722; - *z = r * 0.0193 + g * 0.1192 + b * 0.9505; + *x = r * 0.4124 + g * 0.3576 + b * 0.1805; + *y = r * 0.2126 + g * 0.7152 + b * 0.0722; + *z = r * 0.0193 + g * 0.1192 + b * 0.9505; } static float xyz_to_lab_component(float v) diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c index e9bccd4244b..9795d4dea2d 100644 --- a/source/blender/blenlib/intern/string_utf8.c +++ b/source/blender/blenlib/intern/string_utf8.c @@ -335,9 +335,9 @@ size_t BLI_strncpy_wchar_from_utf8(wchar_t *dst_w, const char *src_c, const size int BLI_str_utf8_size(const char *p) { int mask = 0, len; - unsigned char c = (unsigned char) *p; + unsigned char c = (unsigned char) *p; - UTF8_COMPUTE (c, mask, len); + UTF8_COMPUTE (c, mask, len); (void)mask; /* quiet warning */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 4c82e10d717..532488ba2d2 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6228,7 +6228,7 @@ static void lib_link_mask(FileData *fd, Main *main) mask = main->mask.first; while (mask) { - if(mask->id.flag & LIB_NEEDLINK) { + if (mask->id.flag & LIB_NEEDLINK) { MaskLayer *masklay; if (mask->adt) @@ -6725,6 +6725,11 @@ static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNo char basepath[FILE_MAXDIR]; char filename[FILE_MAXFILE]; + /* ugly, need to remove the old inputs list to avoid bad pointer checks when adding new sockets. + * sock->storage is expected to contain path info in ntreeCompositOutputFileAddSocket. + */ + node->inputs.first = node->inputs.last = NULL; + node->storage = nimf; /* split off filename from the old path, to be used as socket sub-path */ @@ -6898,6 +6903,22 @@ static void do_versions_nodetree_frame_2_64_6(bNodeTree *ntree) } } +static void do_version_ntree_image_user_264(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree) +{ + bNode *node; + + for (node = ntree->nodes.first; node; node = node->next) { + if (ELEM(node->type, SH_NODE_TEX_IMAGE, SH_NODE_TEX_ENVIRONMENT)) { + NodeTexImage *tex = node->storage; + + tex->iuser.frames= 1; + tex->iuser.sfra= 1; + tex->iuser.fie_ima= 2; + tex->iuser.ok= 1; + } + } +} + static void do_versions(FileData *fd, Library *lib, Main *main) { /* WATCH IT!!!: pointers from libdata have not been converted */ @@ -7606,6 +7627,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 9)) { + bNodeTreeType *ntreetype = ntreeGetType(NTREE_SHADER); + + if (ntreetype && ntreetype->foreach_nodetree) + ntreetype->foreach_nodetree(main, NULL, do_version_ntree_image_user_264); + } + /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */ { diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 195057817dd..45d7d4a7684 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -804,7 +804,7 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node, bool is_joint = node->getType() == COLLADAFW::Node::JOINT; COLLADAFW::Node *root = root_map.find(node->getUniqueId()) == root_map.end() ? node : root_map[node->getUniqueId()]; - Object *ob = is_joint ? armature_importer->get_armature_for_joint(root) : object_map.find(node->getUniqueId())->second; + Object *ob = is_joint ? armature_importer->get_armature_for_joint(root) : object_map.find(node->getUniqueId())->second; if (!ob) { fprintf(stderr, "cannot find Object for Node with id=\"%s\"\n", node->getOriginalId().c_str()); return; diff --git a/source/blender/compositor/nodes/COM_ViewerNode.cpp b/source/blender/compositor/nodes/COM_ViewerNode.cpp index db4fd115d73..679589a7ce1 100644 --- a/source/blender/compositor/nodes/COM_ViewerNode.cpp +++ b/source/blender/compositor/nodes/COM_ViewerNode.cpp @@ -37,7 +37,7 @@ void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext * Image *image = (Image*)this->getbNode()->id; ImageUser * imageUser = (ImageUser*) this->getbNode()->storage; bNode *editorNode = this->getbNode(); - if (imageSocket->isConnected() && (editorNode->flag & NODE_DO_OUTPUT)) { + if (imageSocket->isConnected()) { ViewerOperation *viewerOperation = new ViewerOperation(); viewerOperation->setColorManagement(context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT); viewerOperation->setColorPredivide(context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE); diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp index babea459d6a..2280ee3a435 100644 --- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp @@ -101,7 +101,10 @@ void BlurBaseOperation::deinitExecution() void BlurBaseOperation::updateSize(MemoryBuffer **memoryBuffers) { - float result[4]; - this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, memoryBuffers); - this->size = result[0]; + if (!this->sizeavailable) { + float result[4]; + this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, memoryBuffers); + this->size = result[0]; + this->sizeavailable = true; + } } diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp index ad8f3b12387..ad58631f2c1 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp @@ -26,13 +26,12 @@ FastGaussianBlurOperation::FastGaussianBlurOperation(): BlurBaseOperation() { - this->iirgaus = false; + this->iirgaus = NULL; } void FastGaussianBlurOperation::executePixel(float *color,int x, int y, MemoryBuffer *inputBuffers[], void *data) { MemoryBuffer *newData = (MemoryBuffer*)data; - newData->read(color, x, y); } @@ -51,10 +50,7 @@ bool FastGaussianBlurOperation::determineDependingAreaOfInterest(rcti *input, Re } else { if (this->iirgaus) { - newInput.xmax = input->xmax + (sx); - newInput.xmin = input->xmin - (sx); - newInput.ymax = input->ymax + (sy); - newInput.ymin = input->ymin - (sy); + return false; } else { newInput.xmin = 0; @@ -66,38 +62,51 @@ bool FastGaussianBlurOperation::determineDependingAreaOfInterest(rcti *input, Re } } -void *FastGaussianBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +void FastGaussianBlurOperation::initExecution() { - MemoryBuffer *newBuf = (MemoryBuffer*)this->inputProgram->initializeTileData(rect, memoryBuffers); - MemoryBuffer *copy = newBuf->duplicate(); - updateSize(memoryBuffers); - - int c; - sx = data->sizex * this->size/2.0f; - sy = data->sizey * this->size/2.0f; - this->iirgaus = true; - - if ((sx == sy) && (sx > 0.f)) { - for (c=0; c<COM_NUMBER_OF_CHANNELS; ++c) - IIR_gauss(copy, sx, c, 3); + BlurBaseOperation::initExecution(); + BlurBaseOperation::initMutex(); +} + +void FastGaussianBlurOperation::deinitExecution() +{ + if (this->iirgaus) { + delete this->iirgaus; + this->iirgaus = NULL; } - else { - if (sx > 0.f) { + BlurBaseOperation::deinitMutex(); +} + +void *FastGaussianBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +{ + BLI_mutex_lock(this->getMutex()); + if (!iirgaus) { + MemoryBuffer *newBuf = (MemoryBuffer*)this->inputProgram->initializeTileData(rect, memoryBuffers); + MemoryBuffer *copy = newBuf->duplicate(); + updateSize(memoryBuffers); + + int c; + sx = data->sizex * this->size/2.0f; + sy = data->sizey * this->size/2.0f; + + if ((sx == sy) && (sx > 0.f)) { for (c=0; c<COM_NUMBER_OF_CHANNELS; ++c) - IIR_gauss(copy, sx, c, 1); + IIR_gauss(copy, sx, c, 3); } - if (sy > 0.f) { - for (c=0; c<COM_NUMBER_OF_CHANNELS; ++c) - IIR_gauss(copy, sy, c, 2); + else { + if (sx > 0.f) { + for (c=0; c<COM_NUMBER_OF_CHANNELS; ++c) + IIR_gauss(copy, sx, c, 1); + } + if (sy > 0.f) { + for (c=0; c<COM_NUMBER_OF_CHANNELS; ++c) + IIR_gauss(copy, sy, c, 2); + } } + this->iirgaus = copy; } - return copy; -} - -void FastGaussianBlurOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data) -{ - MemoryBuffer *newData = (MemoryBuffer*)data; - delete newData; + BLI_mutex_unlock(this->getMutex()); + return iirgaus; } void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, int chan, int xy) diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h index 6c3e373472b..1f71fe7f9ed 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h @@ -30,7 +30,7 @@ class FastGaussianBlurOperation: public BlurBaseOperation { private: float sx; float sy; - bool iirgaus; + MemoryBuffer* iirgaus; public: FastGaussianBlurOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); @@ -38,7 +38,8 @@ public: static void IIR_gauss(MemoryBuffer *src, float sigma, int channel, int xy); void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); - void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data); + void deinitExecution(); + void initExecution(); }; #endif diff --git a/source/blender/compositor/operations/COM_ImageOperation.cpp b/source/blender/compositor/operations/COM_ImageOperation.cpp index 020dfdbdc14..04cd91d3c3a 100644 --- a/source/blender/compositor/operations/COM_ImageOperation.cpp +++ b/source/blender/compositor/operations/COM_ImageOperation.cpp @@ -99,8 +99,8 @@ void BaseImageOperation::determineResolution(unsigned int resolution[], unsigned { ImBuf *stackbuf = getImBuf(); - resolution[0] = 0; - resolution[1] = 0; + resolution[0] = 0; + resolution[1] = 0; if (stackbuf) { resolution[0] = stackbuf->x; diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp index 44b4c26fb64..71fc53e8f8e 100644 --- a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp @@ -50,8 +50,9 @@ ViewerBaseOperation::ViewerBaseOperation() : NodeOperation() void ViewerBaseOperation::initExecution() { - // When initializing the tree during initial load the width and height can be zero. - initImage(); + if (isActiveViewerOutput()) { + initImage(); + } } void ViewerBaseOperation::initImage() @@ -79,7 +80,6 @@ void ViewerBaseOperation::initImage() } void ViewerBaseOperation:: updateImage(rcti *rect) { - /// @todo: introduce new event to update smaller area WM_main_add_notifier(NC_WINDOW|ND_DRAW, NULL); } diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.h b/source/blender/compositor/operations/COM_ViewerBaseOperation.h index 58101911550..f5f30809f65 100644 --- a/source/blender/compositor/operations/COM_ViewerBaseOperation.h +++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.h @@ -42,7 +42,7 @@ protected: bool doColorPredivide; public: - bool isOutputOperation(bool rendering) const {return true;} + bool isOutputOperation(bool rendering) const {return isActiveViewerOutput();} void initExecution(); void deinitExecution(); void setImage(Image *image) {this->image = image;} diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 48743c68ff5..ea3c8685525 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -756,7 +756,7 @@ static int pose_visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) * * TODO, loop over children before parents if multiple bones * at once are to be predictable*/ - CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) + CTX_DATA_BEGIN(C, bPoseChannel *, pchan, selected_pose_bones) { float delta_mat[4][4]; @@ -923,7 +923,7 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op)) pose = ob->pose; ob->mode &= ~OB_MODE_POSE; - CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) + CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases) { if ((base->object->type == OB_ARMATURE) && (base->object != ob)) { bArmature *curarm = base->object->data; @@ -1195,7 +1195,7 @@ static int separate_armature_exec(bContext *C, wmOperator *UNUSED(op)) /* 1) only edit-base selected */ // TODO: use context iterators for this? - CTX_DATA_BEGIN (C, Base *, base, visible_bases) + CTX_DATA_BEGIN(C, Base *, base, visible_bases) { if (base->object == obedit) base->flag |= 1; else base->flag &= ~1; @@ -2848,7 +2848,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* loop over all bones, and only consider if visible */ - CTX_DATA_BEGIN (C, EditBone *, ebone, visible_bones) + CTX_DATA_BEGIN(C, EditBone *, ebone, visible_bones) { if (!(ebone->flag & BONE_CONNECTED) && (ebone->flag & BONE_ROOTSEL)) fill_add_joint(ebone, 0, &points); @@ -3562,7 +3562,7 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op) /* loop over all editable bones */ // XXX the old code did this in reverse order though! - CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) + CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) { for (i = numcuts + 1; i > 1; i--) { /* compute cut ratio first */ @@ -3851,7 +3851,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op) */ /* parent selected bones to the active one */ - CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) + CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) { if (ELEM(ebone, actbone, actmirb) == 0) { if (ebone->flag & BONE_SELECTED) @@ -3877,7 +3877,7 @@ static int armature_parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEve uiLayout *layout = uiPupMenuLayout(pup); int allchildbones = 0; - CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) + CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) { if (ebone != actbone) { if (ebone->parent != actbone) allchildbones = 1; @@ -3937,7 +3937,7 @@ static int armature_parent_clear_exec(bContext *C, wmOperator *op) bArmature *arm = (bArmature *)ob->data; int val = RNA_enum_get(op->ptr, "type"); - CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) + CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) { editbone_clear_parent(ebone, val); } @@ -3974,7 +3974,7 @@ void ARMATURE_OT_parent_clear(wmOperatorType *ot) static int armature_select_inverse_exec(bContext *C, wmOperator *UNUSED(op)) { /* Set the flags */ - CTX_DATA_BEGIN (C, EditBone *, ebone, visible_bones) + CTX_DATA_BEGIN(C, EditBone *, ebone, visible_bones) { /* ignore bone if selection can't change */ if ((ebone->flag & BONE_UNSELECTABLE) == 0) { @@ -4017,7 +4017,7 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op) } /* Set the flags */ - CTX_DATA_BEGIN (C, EditBone *, ebone, visible_bones) + CTX_DATA_BEGIN(C, EditBone *, ebone, visible_bones) { /* ignore bone if selection can't change */ if ((ebone->flag & BONE_UNSELECTABLE) == 0) { @@ -4437,7 +4437,7 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op) */ /* align selected bones to the active one */ - CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) + CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) { if (ELEM(ebone, actbone, actmirb) == 0) { if (ebone->flag & BONE_SELECTED) @@ -4523,7 +4523,9 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor * note, special exception for armature mode so we can do multi-select * we could check for multi-select explicitly but think its fine to * always give predictable behavior in weight paint mode - campbell */ - if ((!extend && !deselect && !toggle)|| ((ob_act && (ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT) == 0))) { + if ((!extend && !deselect && !toggle) || + ((ob_act && (ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT) == 0))) + { ED_pose_deselectall(ob, 0); nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); arm->act_bone = nearBone; @@ -5134,7 +5136,7 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op, } /* only clear relevant transforms for selected bones */ - CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) + CTX_DATA_BEGIN(C, bPoseChannel *, pchan, selected_pose_bones) { /* run provided clearing function */ clear_func(pchan); @@ -5278,7 +5280,7 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op) } /* Set the flags */ - CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) + CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones) { /* select pchan only if selectable, but deselect works always */ switch (action) { @@ -5674,7 +5676,7 @@ static int armature_flip_names_exec(bContext *C, wmOperator *UNUSED(op)) arm = ob->data; /* loop through selected bones, auto-naming them */ - CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) + CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) { flip_side_name(newname, ebone->name, TRUE); // 1 = do strip off number extensions ED_armature_bone_rename(arm, ebone->name, newname); @@ -5719,7 +5721,7 @@ static int armature_autoside_names_exec(bContext *C, wmOperator *op) arm = ob->data; /* loop through selected bones, auto-naming them */ - CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) + CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) { BLI_strncpy(newname, ebone->name, sizeof(newname)); if (bone_autoside_name(newname, 1, axis, ebone->head[axis], ebone->tail[axis])) @@ -5742,7 +5744,8 @@ void ARMATURE_OT_autoside_names(wmOperatorType *ot) {0, "XAXIS", 0, "X-Axis", "Left/Right"}, {1, "YAXIS", 0, "Y-Axis", "Front/Back"}, {2, "ZAXIS", 0, "Z-Axis", "Top/Bottom"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; /* identifiers */ ot->name = "AutoName by Axis"; diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index d642ee57c57..27c40095348 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -141,14 +141,14 @@ void ED_operatormacros_curve(void) wmOperatorTypeMacro *otmacro; ot = WM_operatortype_append_macro("CURVE_OT_duplicate_move", "Add Duplicate", "Duplicate curve and move", - OPTYPE_UNDO|OPTYPE_REGISTER); + OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "CURVE_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); RNA_boolean_set(otmacro->ptr, "mirror", FALSE); ot = WM_operatortype_append_macro("CURVE_OT_extrude_move", "Extrude Curve and Move", - "Extrude curve and move result", OPTYPE_UNDO|OPTYPE_REGISTER); + "Extrude curve and move result", OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "CURVE_OT_extrude"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); @@ -189,8 +189,8 @@ void ED_keymap_curve(wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", ENDKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", LINE_END); RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", LEFTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", PREV_CHAR); RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", RIGHTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", NEXT_CHAR); - RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", LEFTARROWKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0)->ptr, "type", PREV_WORD); - RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", RIGHTARROWKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0)->ptr, "type", NEXT_WORD); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", LEFTARROWKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0)->ptr, "type", PREV_WORD); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", RIGHTARROWKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0)->ptr, "type", NEXT_WORD); RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", UPARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", PREV_LINE); RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", DOWNARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", NEXT_LINE); RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", PAGEUPKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", PREV_PAGE); @@ -224,9 +224,9 @@ void ED_keymap_curve(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "CURVE_OT_vertex_add", LEFTMOUSE, KM_CLICK, KM_CTRL, 0); kmi = WM_keymap_add_item(keymap, "CURVE_OT_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); kmi = WM_keymap_add_item(keymap, "CURVE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); - RNA_enum_set(kmi->ptr, "action", SEL_INVERT); + RNA_enum_set(kmi->ptr, "action", SEL_INVERT); WM_keymap_add_item(keymap, "CURVE_OT_select_row", RKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "CURVE_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index b94d3653f60..2fa7b4b2126 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -3530,7 +3530,8 @@ void CURVE_OT_spline_type_set(wmOperatorType *ot) // {CU_CARDINAL, "CARDINAL", 0, "Cardinal", ""}, // {CU_BSPLINE, "B_SPLINE", 0, "B-Spline", ""}, {CU_NURBS, "NURBS", 0, "NURBS", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; /* identifiers */ ot->name = "Set Spline Type"; @@ -3573,7 +3574,8 @@ void CURVE_OT_handle_type_set(wmOperatorType *ot) {5, "ALIGNED", 0, "Aligned", ""}, {6, "FREE_ALIGN", 0, "Free", ""}, {3, "TOGGLE_FREE_ALIGN", 0, "Toggle Free/Align", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; /* identifiers */ ot->name = "Set Handle Type"; @@ -4886,7 +4888,8 @@ void CURVE_OT_cyclic_toggle(wmOperatorType *ot) static EnumPropertyItem direction_items[] = { {0, "CYCLIC_U", 0, "Cyclic U", ""}, {1, "CYCLIC_V", 0, "Cyclic V", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; /* identifiers */ ot->name = "Toggle Cyclic"; @@ -6007,7 +6010,8 @@ void CURVE_OT_delete(wmOperatorType *ot) {0, "SELECTED", 0, "Select", ""}, {1, "SEGMENT", 0, "Segment", ""}, {2, "ALL", 0, "All", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; /* identifiers */ ot->name = "Delete"; @@ -6101,7 +6105,7 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op)) /* trasnform all selected curves inverse in obact */ invert_m4_m4(imat, ob->obmat); - CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) + CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases) { if (base->object->type == ob->type) { if (base->object != ob) { diff --git a/source/blender/editors/curve/lorem.c b/source/blender/editors/curve/lorem.c index 66b358e04e5..7823be3df6d 100644 --- a/source/blender/editors/curve/lorem.c +++ b/source/blender/editors/curve/lorem.c @@ -25,7 +25,7 @@ #include "curve_intern.h" -const char ED_lorem[]= { +const char ED_lorem[] = { 76, 111, 114, 101, 109, 32, 105, 112, 115, 117, 109, 32, 100, 111, 108, 111, 114, 32, 115, 105, 116, 32, 97, 109, 101, 116, 44, 32, 99, 111, 110, 115, 101, 99, 116, 101, 116, 117, 101, 114, 32, 97, 100, 105, 112, 105, 115, 99, 105, 110, 103, 32, 101, 108, 105, 116, 46, 32, 65, 108, 105, 113, 117, 97, 109, 32, 116, 114, 105, 115, 116, 105, 113, 117, 101, 32, 105, 110, 116, 101, 114, 100, 117, 109, 32, 115, 101, 109, 46, 32, 78, 117, 108, diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h index 7e1505b652f..f7fb1709ce7 100644 --- a/source/blender/editors/include/ED_clip.h +++ b/source/blender/editors/include/ED_clip.h @@ -49,8 +49,8 @@ int ED_space_clip_view_clip_poll(struct bContext *C); int ED_space_clip_tracking_poll(struct bContext *C); int ED_space_clip_tracking_size_poll(struct bContext *C); int ED_space_clip_tracking_frame_poll(struct bContext *C); -int ED_space_clip_maskediting_poll(struct bContext *C); -int ED_space_clip_maskediting_mask_poll(bContext *C); +int ED_space_clip_maskedit_poll(struct bContext *C); +int ED_space_clip_maskedit_mask_poll(bContext *C); void ED_space_clip_set(struct bContext *C, struct bScreen *screen, struct SpaceClip *sc, struct MovieClip *clip); struct MovieClip *ED_space_clip(struct SpaceClip *sc); diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index d867532b273..c4d7197bfa1 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -71,6 +71,7 @@ enum { TFM_BONESIZE, TFM_BONE_ENVELOPE, TFM_CURVE_SHRINKFATTEN, + TFM_MASK_SHRINKFATTEN, TFM_BONE_ROLL, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE, diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 21f87029cb0..7f9a998e6d0 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -166,13 +166,14 @@ static int panels_re_align(ScrArea *sa, ARegion *ar, Panel **r_pa) static void panels_collapse_all(ScrArea *sa, ARegion *ar) { - Panel *pa; - int flag = ((panel_aligned(sa, ar)==BUT_HORIZONTAL)? PNL_CLOSEDX: PNL_CLOSEDY); + Panel *pa; + int flag = ((panel_aligned(sa, ar) == BUT_HORIZONTAL) ? PNL_CLOSEDX : PNL_CLOSEDY); - for (pa= ar->panels.first; pa; pa= pa->next) { - if (pa->type && !(pa->type->flag & PNL_NO_HEADER)) - pa->flag = flag; - } + for (pa = ar->panels.first; pa; pa = pa->next) { + if (pa->type && !(pa->type->flag & PNL_NO_HEADER)) { + pa->flag = flag; + } + } } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index daba096696c..2d9c6ee7657 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2242,7 +2242,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe } } else if (itemptr->type == &RNA_MaskLayer) { - split = uiLayoutSplit(sub, 0.66f, 0); + split = uiLayoutSplit(sub, 0.5f, 0); uiItemL(split, name, icon); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 1a7fc98ef74..004c5306d65 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -162,9 +162,10 @@ static unsigned int scroll_circle_face[14][3] = { }; -static float menu_tria_vert[6][2]= { -{-0.33, 0.16}, {0.33, 0.16}, {0, 0.82}, -{0, -0.82}, {-0.33, -0.16}, {0.33, -0.16}}; +static float menu_tria_vert[6][2] = { + {-0.33, 0.16}, {0.33, 0.16}, {0, 0.82}, + {0, -0.82}, {-0.33, -0.16}, {0.33, -0.16} +}; @@ -1168,7 +1169,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b #if 0 ui_rasterpos_safe(x, y, but->aspect); - if (but->type == IDPOIN) transopts = 0; // no translation, of course! + if (but->type == IDPOIN) transopts = 0; // no translation, of course! else transopts = ui_translate_buttons(); #endif @@ -3133,7 +3134,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct if (but->drawflag & UI_BUT_DRAW_ENUM_ARROWS) wt = widget_type(UI_WTYPE_MENU_RADIO); /* with arrows */ else - wt = widget_type(UI_WTYPE_MENU_ICON_RADIO); /* no arrows */ + wt = widget_type(UI_WTYPE_MENU_ICON_RADIO); /* no arrows */ } /* with menu arrows */ else diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index f2ea81abcbf..2e70a941a54 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -783,8 +783,8 @@ void ui_theme_init_default(void) /* space nla */ btheme->tnla = btheme->tact; - rgba_char_args_set(btheme->tnla.anim_active, 204, 112, 26, 102); /* same as for dopesheet; duplicate here for easier reference */ - rgba_char_args_set(btheme->tnla.anim_non_active,153, 135, 97, 77); + rgba_char_args_set(btheme->tnla.anim_active, 204, 112, 26, 102); /* same as for dopesheet; duplicate here for easier reference */ + rgba_char_args_set(btheme->tnla.anim_non_active, 153, 135, 97, 77); rgba_char_args_set(btheme->tnla.nla_tweaking, 77, 243, 26, 77); rgba_char_args_set(btheme->tnla.nla_tweakdupli, 217, 0, 0, 255); diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index c2c2ebbfe42..f8c36e866d7 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -31,12 +31,9 @@ #include "MEM_guardedalloc.h" -#include "BLI_utildefines.h" -#include "BLI_listbase.h" #include "BLI_math.h" #include "BKE_context.h" -#include "BKE_curve.h" #include "BKE_depsgraph.h" #include "BKE_mask.h" @@ -47,10 +44,7 @@ #include "WM_api.h" #include "WM_types.h" -#include "ED_screen.h" -#include "ED_mask.h" -#include "ED_clip.h" -#include "ED_keyframing.h" +#include "ED_mask.h" /* own include */ #include "RNA_access.h" #include "RNA_define.h" @@ -156,7 +150,7 @@ static int find_nearest_diff_point(bContext *C, Mask *mask, const float normal_c *point_r = point; if (u_r) { - u = BKE_mask_spline_project_co(point_spline, point, u, normal_co); + u = BKE_mask_spline_project_co(point_spline, point, u, normal_co, MASK_PROJ_ANY); *u_r = u; } @@ -630,7 +624,7 @@ void MASK_OT_add_vertex(wmOperatorType *ot) /* api callbacks */ ot->exec = add_vertex_exec; ot->invoke = add_vertex_invoke; - ot->poll = ED_maskediting_mask_poll; + ot->poll = ED_maskedit_mask_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -660,6 +654,11 @@ static int add_feather_vertex_exec(bContext *C, wmOperator *op) if (find_nearest_diff_point(C, mask, co, threshold, TRUE, &masklay, &spline, &point, &u, NULL)) { Scene *scene = CTX_data_scene(C); float w = BKE_mask_point_weight(spline, point, u); + float weight_scalar = BKE_mask_point_weight_scalar(spline, point, u); + + if (weight_scalar != 0.0f) { + w = w / weight_scalar; + } BKE_mask_point_add_uw(point, u, w); @@ -696,7 +695,7 @@ void MASK_OT_add_feather_vertex(wmOperatorType *ot) /* api callbacks */ ot->exec = add_feather_vertex_exec; ot->invoke = add_feather_vertex_invoke; - ot->poll = ED_maskediting_mask_poll; + ot->poll = ED_maskedit_mask_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index e580088e25b..a26ae5ea3c0 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -32,7 +32,6 @@ #include "MEM_guardedalloc.h" #include "BLI_utildefines.h" -#include "BLI_math.h" #include "BKE_context.h" #include "BKE_mask.h" @@ -40,10 +39,8 @@ #include "DNA_mask_types.h" #include "DNA_object_types.h" /* SELECT */ -#include "ED_mask.h" - +#include "ED_mask.h" /* own include */ #include "BIF_gl.h" -#include "BIF_glutil.h" #include "UI_resources.h" diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c index 0b8551ddd4c..9bfcd2a9886 100644 --- a/source/blender/editors/mask/mask_edit.c +++ b/source/blender/editors/mask/mask_edit.c @@ -29,9 +29,7 @@ * \ingroup edmask */ -#include "MEM_guardedalloc.h" -#include "BLI_utildefines.h" #include "BLI_math.h" #include "BKE_context.h" @@ -41,7 +39,7 @@ #include "WM_types.h" #include "ED_screen.h" -#include "ED_mask.h" +#include "ED_mask.h" /* own include */ #include "ED_object.h" /* ED_keymap_proportional_maskmode only */ #include "ED_clip.h" #include "ED_transform.h" @@ -52,23 +50,23 @@ /********************** generic poll functions *********************/ -int ED_maskediting_poll(bContext *C) +int ED_maskedit_poll(bContext *C) { SpaceClip *sc = CTX_wm_space_clip(C); if (sc) { - return ED_space_clip_maskediting_poll(C); + return ED_space_clip_maskedit_poll(C); } return FALSE; } -int ED_maskediting_mask_poll(bContext *C) +int ED_maskedit_mask_poll(bContext *C) { SpaceClip *sc = CTX_wm_space_clip(C); if (sc) { - return ED_space_clip_maskediting_mask_poll(C); + return ED_space_clip_maskedit_mask_poll(C); } return FALSE; @@ -214,6 +212,9 @@ void ED_operatortypes_mask(void) WM_operatortype_append(MASK_OT_hide_view_clear); WM_operatortype_append(MASK_OT_hide_view_set); + /* feather */ + WM_operatortype_append(MASK_OT_feather_weight_clear); + /* shape */ WM_operatortype_append(MASK_OT_slide_point); WM_operatortype_append(MASK_OT_cyclic_toggle); @@ -226,6 +227,7 @@ void ED_operatortypes_mask(void) /* shapekeys */ WM_operatortype_append(MASK_OT_shape_key_insert); WM_operatortype_append(MASK_OT_shape_key_clear); + WM_operatortype_append(MASK_OT_shape_key_feather_reset); } void ED_keymap_mask(wmKeyConfig *keyconf) @@ -233,8 +235,8 @@ void ED_keymap_mask(wmKeyConfig *keyconf) wmKeyMap *keymap; wmKeyMapItem *kmi; - keymap = WM_keymap_find(keyconf, "Mask Editor", 0, 0); - keymap->poll = ED_maskediting_poll; + keymap = WM_keymap_find(keyconf, "Mask Editing", 0, 0); + keymap->poll = ED_maskedit_poll; WM_keymap_add_item(keymap, "MASK_OT_new", NKEY, KM_PRESS, KM_ALT, 0); @@ -295,6 +297,9 @@ void ED_keymap_mask(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MASK_OT_cyclic_toggle", CKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "MASK_OT_slide_point", LEFTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MASK_OT_handle_type_set", VKEY, KM_PRESS, 0, 0); + // WM_keymap_add_item(keymap, "MASK_OT_feather_weight_clear", SKEY, KM_PRESS, KM_ALT, 0); + /* ... matches curve editmode */ + RNA_enum_set(WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_ALT, 0)->ptr, "mode", TFM_MASK_SHRINKFATTEN); /* relationships */ WM_keymap_add_item(keymap, "MASK_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/mask/mask_intern.h b/source/blender/editors/mask/mask_intern.h index 70f13abd44f..fc6089238a1 100644 --- a/source/blender/editors/mask/mask_intern.h +++ b/source/blender/editors/mask/mask_intern.h @@ -54,6 +54,7 @@ void MASK_OT_delete(struct wmOperatorType *ot); void MASK_OT_hide_view_clear(struct wmOperatorType *ot); void MASK_OT_hide_view_set(struct wmOperatorType *ot); +void MASK_OT_feather_weight_clear(struct wmOperatorType *ot); void MASK_OT_switch_direction(struct wmOperatorType *ot); void MASK_OT_handle_type_set(struct wmOperatorType *ot); @@ -92,8 +93,8 @@ void ED_mask_select_toggle_all(struct Mask *mask, int action); void ED_mask_select_flush_all(struct Mask *mask); /* mask_editor.c */ -int ED_maskediting_poll(struct bContext *C); -int ED_maskediting_mask_poll(struct bContext *C); +int ED_maskedit_poll(struct bContext *C); +int ED_maskedit_mask_poll(struct bContext *C); void ED_mask_size(struct bContext *C, int *width, int *height); void ED_mask_aspect(struct bContext *C, float *aspx, float *aspy); @@ -107,5 +108,6 @@ void ED_mask_point_pos__reverse(struct bContext *C, float x, float y, float *xr, /* mask_shapekey.c */ void MASK_OT_shape_key_insert(struct wmOperatorType *ot); void MASK_OT_shape_key_clear(struct wmOperatorType *ot); +void MASK_OT_shape_key_feather_reset(struct wmOperatorType *ot); #endif /* __MASK_INTERN_H__ */ diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index cf3a72bdc78..c9f2450afc3 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -31,12 +31,10 @@ #include "MEM_guardedalloc.h" -#include "BLI_utildefines.h" #include "BLI_listbase.h" #include "BLI_math.h" #include "BKE_context.h" -#include "BKE_curve.h" #include "BKE_depsgraph.h" #include "BKE_mask.h" @@ -315,7 +313,7 @@ void MASK_OT_layer_new(wmOperatorType *ot) /* api callbacks */ ot->exec = masklay_new_exec; - ot->poll = ED_maskediting_poll; + ot->poll = ED_maskedit_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -349,7 +347,7 @@ void MASK_OT_layer_remove(wmOperatorType *ot) /* api callbacks */ ot->exec = masklay_remove_exec; - ot->poll = ED_maskediting_poll; + ot->poll = ED_maskedit_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -357,10 +355,12 @@ void MASK_OT_layer_remove(wmOperatorType *ot) /******************** slide *********************/ -#define SLIDE_ACTION_NONE 0 -#define SLIDE_ACTION_POINT 1 -#define SLIDE_ACTION_HANDLE 2 -#define SLIDE_ACTION_FEATHER 3 +enum { + SLIDE_ACTION_NONE = 0, + SLIDE_ACTION_POINT = 1, + SLIDE_ACTION_HANDLE = 2, + SLIDE_ACTION_FEATHER = 3 +}; typedef struct SlidePointData { int action; @@ -387,15 +387,18 @@ static int slide_point_check_initial_feather(MaskSpline *spline) for (i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; - int j; if (point->bezt.weight != 0.0f) return FALSE; + /* comment for now. if all bezt weights are zero - this is as good-as initial */ +#if 0 + int j; for (j = 0; j < point->tot_uw; j++) { if (point->uw[j].w != 0.0f) return FALSE; } +#endif } return TRUE; @@ -454,25 +457,21 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, wmEvent *event) if (uw) { float co[2]; - - customdata->weight = point->bezt.weight; + float weight_scalar = BKE_mask_point_weight_scalar(spline, point, uw->u); customdata->weight = uw->w; BKE_mask_point_segment_co(spline, point, uw->u, co); BKE_mask_point_normal(spline, point, uw->u, customdata->no); - customdata->feather[0] = co[0] + customdata->no[0] * uw->w; - customdata->feather[1] = co[1] + customdata->no[1] * uw->w; + madd_v2_v2v2fl(customdata->feather, co, customdata->no, uw->w * weight_scalar); } else { BezTriple *bezt = &point->bezt; + customdata->weight = bezt->weight; BKE_mask_point_normal(spline, point, 0.0f, customdata->no); - customdata->feather[0] = bezt->vec[1][0] + customdata->no[0] * bezt->weight; - customdata->feather[1] = bezt->vec[1][1] + customdata->no[1] * bezt->weight; - - customdata->weight = bezt->weight; + madd_v2_v2v2fl(customdata->feather, bezt->vec[1], customdata->no, bezt->weight); } if (customdata->action == SLIDE_ACTION_FEATHER) @@ -533,17 +532,20 @@ static void slide_point_delta_all_feather(SlidePointData *data, float delta) for (i = 0; i < data->spline->tot_point; i++) { MaskSplinePoint *point = &data->spline->points[i]; MaskSplinePoint *orig_point = &data->orig_spline->points[i]; - int j; point->bezt.weight = orig_point->bezt.weight + delta; if (point->bezt.weight < 0.0f) point->bezt.weight = 0.0f; + /* not needed anymore */ +#if 0 + int j; for (j = 0; j < point->tot_uw; j++) { point->uw[j].w = orig_point->uw[j].w + delta; if (point->uw[j].w < 0.0f) point->uw[j].w = 0.0f; } +#endif } } @@ -645,24 +647,53 @@ static int slide_point_modal(bContext *C, wmOperator *op, wmEvent *event) else if (data->action == SLIDE_ACTION_FEATHER) { float vec[2], no[2], p[2], c[2], w, offco[2]; float *weight = NULL; + float weight_scalar = 1.0f; int overall_feather = data->overall_feather || data->initial_feather; add_v2_v2v2(offco, data->feather, dco); if (data->uw) { - float u = BKE_mask_spline_project_co(data->spline, data->point, data->uw->u, offco); + /* project on both sides and find the closest one, + * prevents flickering when projecting onto both sides can happen */ + const float u_pos = BKE_mask_spline_project_co(data->spline, data->point, + data->uw->u, offco, MASK_PROJ_NEG); + const float u_neg = BKE_mask_spline_project_co(data->spline, data->point, + data->uw->u, offco, MASK_PROJ_POS); + float dist_pos = FLT_MAX; + float dist_neg = FLT_MAX; + float co_pos[2]; + float co_neg[2]; + float u; + + if (u_pos > 0.0f && u_pos < 1.0f) { + BKE_mask_point_segment_co(data->spline, data->point, u_pos, co_pos); + dist_pos = len_squared_v2v2(offco, co_pos); + } + + if (u_neg > 0.0f && u_neg < 1.0f) { + BKE_mask_point_segment_co(data->spline, data->point, u_neg, co_neg); + dist_neg = len_squared_v2v2(offco, co_neg); + } + + u = dist_pos < dist_neg ? u_pos : u_neg; if (u > 0.0f && u < 1.0f) { data->uw->u = u; data->uw = BKE_mask_point_sort_uw(data->point, data->uw); weight = &data->uw->w; + weight_scalar = BKE_mask_point_weight_scalar(data->spline, data->point, u); + if (weight_scalar != 0.0f) { + weight_scalar = 1.0f / weight_scalar; + } + BKE_mask_point_normal(data->spline, data->point, data->uw->u, no); BKE_mask_point_segment_co(data->spline, data->point, data->uw->u, p); } } else { weight = &bezt->weight; + /* weight_scalar = 1.0f; keep as is */ copy_v2_v2(no, data->no); copy_v2_v2(p, bezt->vec[1]); } @@ -685,7 +716,7 @@ static int slide_point_modal(bContext *C, wmOperator *op, wmEvent *event) /* restore weight for currently sliding point, so orig_spline would be created * with original weights used */ - *weight = data->weight; + *weight = data->weight * weight_scalar; data->orig_spline = BKE_mask_spline_copy(data->spline); } @@ -704,7 +735,9 @@ static int slide_point_modal(bContext *C, wmOperator *op, wmEvent *event) data->orig_spline = NULL; } - *weight = w; + if (weight_scalar != 0.0f) { + *weight = w * weight_scalar; + } } } } @@ -756,12 +789,12 @@ void MASK_OT_slide_point(wmOperatorType *ot) /* api callbacks */ ot->invoke = slide_point_invoke; ot->modal = slide_point_modal; - ot->poll = ED_maskediting_mask_poll; + ot->poll = ED_maskedit_mask_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - RNA_def_boolean(ot->srna, "slide_feather", 0, "Slide Feather", "First try to slide slide feather instead of vertex"); + RNA_def_boolean(ot->srna, "slide_feather", 0, "Slide Feather", "First try to slide feather instead of vertex"); } /******************** toggle cyclic *********************/ @@ -799,7 +832,7 @@ void MASK_OT_cyclic_toggle(wmOperatorType *ot) /* api callbacks */ ot->exec = cyclic_toggle_exec; - ot->poll = ED_maskediting_mask_poll; + ot->poll = ED_maskedit_mask_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -943,7 +976,7 @@ void MASK_OT_delete(wmOperatorType *ot) /* api callbacks */ ot->invoke = WM_operator_confirm; ot->exec = delete_exec; - ot->poll = ED_maskediting_mask_poll; + ot->poll = ED_maskedit_mask_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -994,7 +1027,7 @@ void MASK_OT_switch_direction(wmOperatorType *ot) /* api callbacks */ ot->exec = mask_switch_direction_exec; - ot->poll = ED_maskediting_mask_poll; + ot->poll = ED_maskedit_mask_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1053,7 +1086,7 @@ void MASK_OT_handle_type_set(wmOperatorType *ot) /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = set_handle_type_exec; - ot->poll = ED_maskediting_mask_poll; + ot->poll = ED_maskedit_mask_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1100,7 +1133,7 @@ void MASK_OT_hide_view_clear(wmOperatorType *ot) /* api callbacks */ ot->exec = mask_hide_view_clear_exec; - ot->poll = ED_maskediting_mask_poll; + ot->poll = ED_maskedit_mask_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1161,11 +1194,67 @@ void MASK_OT_hide_view_set(wmOperatorType *ot) /* api callbacks */ ot->exec = mask_hide_view_set_exec; - ot->poll = ED_maskediting_mask_poll; + ot->poll = ED_maskedit_mask_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected layers"); +} + + +static int mask_feather_weight_clear_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Mask *mask = CTX_data_edit_mask(C); + MaskLayer *masklay; + int changed = FALSE; + int i; + + for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { + MaskSpline *spline; + + if (masklay->restrictflag & (MASK_RESTRICT_SELECT | MASK_RESTRICT_VIEW)) { + continue; + } + + for (spline = masklay->splines.first; spline; spline = spline->next) { + for (i = 0; i < spline->tot_point; i++) { + MaskSplinePoint *point = &spline->points[i]; + + if (MASKPOINT_ISSEL_ANY(point)) { + BezTriple *bezt = &point->bezt; + bezt->weight = 0.0f; + changed = TRUE; + } + } + } + } + + if (changed) { + /* TODO: only update edited splines */ + BKE_mask_update_display(mask, CTX_data_scene(C)->r.cfra); + + WM_event_add_notifier(C, NC_MASK | ND_DRAW, mask); + DAG_id_tag_update(&mask->id, 0); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } +} +void MASK_OT_feather_weight_clear(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Clear Feather Weight"; + ot->description = "Reset the feather weight to zero"; + ot->idname = "MASK_OT_feather_weight_clear"; + + /* api callbacks */ + ot->exec = mask_feather_weight_clear_exec; + ot->poll = ED_maskedit_mask_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/mask/mask_relationships.c b/source/blender/editors/mask/mask_relationships.c index 8a8427c024b..0e893ee2f9f 100644 --- a/source/blender/editors/mask/mask_relationships.c +++ b/source/blender/editors/mask/mask_relationships.c @@ -29,31 +29,22 @@ * \ingroup edmask */ -#include "MEM_guardedalloc.h" -#include "BLI_utildefines.h" -#include "BLI_listbase.h" #include "BLI_math.h" #include "BKE_context.h" -#include "BKE_curve.h" #include "BKE_depsgraph.h" #include "BKE_mask.h" #include "BKE_tracking.h" #include "DNA_mask_types.h" -#include "DNA_scene_types.h" #include "DNA_object_types.h" /* SELECT */ #include "WM_api.h" #include "WM_types.h" #include "ED_screen.h" -#include "ED_mask.h" -#include "ED_clip.h" - -#include "RNA_access.h" -#include "RNA_define.h" +#include "ED_mask.h" /* own include */ #include "mask_intern.h" /* own include */ @@ -91,13 +82,13 @@ void MASK_OT_parent_clear(wmOperatorType *ot) { /* identifiers */ ot->name = "Clear Parent"; - ot->description = "Clear the masks parenting"; + ot->description = "Clear the mask's parenting"; ot->idname = "MASK_OT_parent_clear"; /* api callbacks */ ot->exec = mask_parent_clear_exec; - ot->poll = ED_maskediting_mask_poll; + ot->poll = ED_maskedit_mask_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -169,14 +160,14 @@ void MASK_OT_parent_set(wmOperatorType *ot) { /* identifiers */ ot->name = "Make Parent"; - ot->description = "Set the masks parenting"; + ot->description = "Set the mask's parenting"; ot->idname = "MASK_OT_parent_set"; /* api callbacks */ //ot->invoke = mask_parent_set_invoke; ot->exec = mask_parent_set_exec; - ot->poll = ED_maskediting_mask_poll; + ot->poll = ED_maskedit_mask_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index 18d745dcf7b..55e09529320 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -32,14 +32,10 @@ #include "MEM_guardedalloc.h" #include "BLI_utildefines.h" -#include "BLI_listbase.h" #include "BLI_rect.h" #include "BLI_lasso.h" -#include "BLI_math.h" #include "BKE_context.h" -#include "BKE_curve.h" -#include "BKE_depsgraph.h" #include "BKE_mask.h" #include "DNA_mask_types.h" @@ -49,8 +45,8 @@ #include "WM_types.h" #include "ED_screen.h" -#include "ED_mask.h" #include "ED_clip.h" +#include "ED_mask.h" /* own include */ #include "RNA_access.h" #include "RNA_define.h" @@ -212,13 +208,13 @@ static int select_all_exec(bContext *C, wmOperator *op) void MASK_OT_select_all(wmOperatorType *ot) { /* identifiers */ - ot->name = "Select or Deselect All"; + ot->name = "(De)select All"; ot->description = "Change selection of all curve points"; ot->idname = "MASK_OT_select_all"; /* api callbacks */ ot->exec = select_all_exec; - ot->poll = ED_maskediting_mask_poll; + ot->poll = ED_maskedit_mask_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -366,7 +362,7 @@ void MASK_OT_select(wmOperatorType *ot) /* api callbacks */ ot->exec = select_exec; ot->invoke = select_invoke; - ot->poll = ED_maskediting_mask_poll; + ot->poll = ED_maskedit_mask_poll; /* flags */ ot->flag = OPTYPE_UNDO; @@ -458,7 +454,7 @@ void MASK_OT_select_border(wmOperatorType *ot) ot->invoke = WM_border_select_invoke; ot->exec = border_select_exec; ot->modal = WM_border_select_modal; - ot->poll = ED_maskediting_mask_poll; + ot->poll = ED_maskedit_mask_poll; /* flags */ ot->flag = OPTYPE_UNDO; @@ -554,7 +550,7 @@ void MASK_OT_select_lasso(wmOperatorType *ot) ot->invoke = WM_gesture_lasso_invoke; ot->modal = WM_gesture_lasso_modal; ot->exec = clip_lasso_select_exec; - ot->poll = ED_maskediting_mask_poll; + ot->poll = ED_maskedit_mask_poll; ot->cancel = WM_gesture_lasso_cancel; /* flags */ @@ -655,7 +651,7 @@ void MASK_OT_select_circle(wmOperatorType *ot) ot->invoke = WM_gesture_circle_invoke; ot->modal = WM_gesture_circle_modal; ot->exec = circle_select_exec; - ot->poll = ED_maskediting_mask_poll; + ot->poll = ED_maskedit_mask_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -712,7 +708,7 @@ void MASK_OT_select_linked_pick(wmOperatorType *ot) /* api callbacks */ ot->invoke = mask_select_linked_pick_invoke; - ot->poll = ED_maskediting_mask_poll; + ot->poll = ED_maskedit_mask_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -763,7 +759,7 @@ void MASK_OT_select_linked(wmOperatorType *ot) /* api callbacks */ ot->exec = mask_select_linked_exec; - ot->poll = ED_maskediting_mask_poll; + ot->poll = ED_maskedit_mask_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/mask/mask_shapekey.c b/source/blender/editors/mask/mask_shapekey.c index 94aebb9f3a1..38e8ed627f2 100644 --- a/source/blender/editors/mask/mask_shapekey.c +++ b/source/blender/editors/mask/mask_shapekey.c @@ -29,30 +29,20 @@ * \ingroup edmask */ -#include "MEM_guardedalloc.h" - #include "BLI_utildefines.h" -#include "BLI_listbase.h" -#include "BLI_math.h" #include "BKE_context.h" -#include "BKE_curve.h" #include "BKE_depsgraph.h" #include "BKE_mask.h" +#include "DNA_object_types.h" #include "DNA_mask_types.h" #include "DNA_scene_types.h" -#include "DNA_object_types.h" /* SELECT */ #include "WM_api.h" #include "WM_types.h" -#include "ED_screen.h" -#include "ED_mask.h" -#include "ED_clip.h" - -#include "RNA_access.h" -#include "RNA_define.h" +#include "ED_mask.h" /* own include */ #include "mask_intern.h" /* own include */ @@ -96,7 +86,7 @@ void MASK_OT_shape_key_insert(wmOperatorType *ot) /* api callbacks */ ot->exec = mask_shape_key_insert_exec; - ot->poll = ED_maskediting_mask_poll; + ot->poll = ED_maskedit_mask_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -145,7 +135,7 @@ void MASK_OT_shape_key_clear(wmOperatorType *ot) /* api callbacks */ ot->exec = mask_shape_key_clear_exec; - ot->poll = ED_maskediting_mask_poll; + ot->poll = ED_maskedit_mask_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -166,3 +156,96 @@ int ED_mask_layer_shape_auto_key_all(Mask *mask, const int frame) return change; } + + +static int mask_shape_key_feather_reset_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene = CTX_data_scene(C); + const int frame = CFRA; + Mask *mask = CTX_data_edit_mask(C); + MaskLayer *masklay; + int change = FALSE; + + for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { + + if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { + continue; + } + + if (masklay->splines_shapes.first) { + MaskLayerShape *masklay_shape_reset; + MaskLayerShape *masklay_shape; + + /* get the shapekey of the current state */ + masklay_shape_reset = BKE_mask_layer_shape_alloc(masklay, frame); + /* initialize from mask - as if inseting a keyframe */ + BKE_mask_layer_shape_from_mask(masklay, masklay_shape_reset); + + for (masklay_shape = masklay->splines_shapes.first; + masklay_shape; + masklay_shape = masklay_shape->next) + { + + if (masklay_shape_reset->tot_vert == masklay_shape->tot_vert) { + int i_abs = 0; + int i; + MaskSpline *spline; + MaskLayerShapeElem *shape_ele_src; + MaskLayerShapeElem *shape_ele_dst; + + shape_ele_src = (MaskLayerShapeElem *)masklay_shape_reset->data; + shape_ele_dst = (MaskLayerShapeElem *)masklay_shape->data; + + for (spline = masklay->splines.first; spline; spline = spline->next) { + for (i = 0; i < spline->tot_point; i++) { + MaskSplinePoint *point = &spline->points[i]; + + if (MASKPOINT_ISSEL_ANY(point)) { + /* TODO - nicer access here */ + shape_ele_dst->value[6] = shape_ele_src->value[6]; + } + + shape_ele_src++; + shape_ele_dst++; + + i_abs++; + } + } + + } + else { + // printf("%s: skipping\n", __func__); + } + + change = TRUE; + } + + BKE_mask_layer_shape_free(masklay_shape_reset); + } + } + + if (change) { + WM_event_add_notifier(C, NC_MASK | ND_DATA, mask); + DAG_id_tag_update(&mask->id, 0); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } +} + +void MASK_OT_shape_key_feather_reset(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Feather Reset Animation"; + ot->description = "Resets fearther weights on all selected points animation values"; + ot->idname = "MASK_OT_shape_key_feather_reset"; + + /* api callbacks */ + ot->exec = mask_shape_key_feather_reset_exec; + ot->poll = ED_maskedit_mask_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index cad6c23eb74..93ed7d37235 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -4830,13 +4830,11 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, wmEvent *event) mdiff[1] = opdata->mcenter[1] - event->mval[1]; if (opdata->modify_depth) { - amount = opdata->old_depth + (len_v2(mdiff) - - opdata->initial_length) / opdata->initial_length; + amount = opdata->old_depth + (len_v2(mdiff) - opdata->initial_length) / opdata->initial_length; RNA_float_set(op->ptr, "depth", amount); } else { - amount = opdata->old_thickness - (len_v2(mdiff) - - opdata->initial_length) / opdata->initial_length; + amount = opdata->old_thickness - (len_v2(mdiff) - opdata->initial_length) / opdata->initial_length; amount = MAX2(amount, 0.0f); RNA_float_set(op->ptr, "thickness", amount); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 24dd56a4834..3d7dd01bf30 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -180,7 +180,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op) short changed = 0; const int unselected = RNA_boolean_get(op->ptr, "unselected"); - CTX_DATA_BEGIN (C, Base *, base, visible_bases) + CTX_DATA_BEGIN(C, Base *, base, visible_bases) { if (!unselected) { if (base->flag & SELECT) { @@ -240,7 +240,7 @@ static int object_hide_render_clear_exec(bContext *C, wmOperator *UNUSED(op)) short changed = 0; /* XXX need a context loop to handle such cases */ - CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) + CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects) { if (ob->restrictflag & OB_RESTRICT_RENDER) { ob->restrictflag &= ~OB_RESTRICT_RENDER; @@ -275,7 +275,7 @@ static int object_hide_render_set_exec(bContext *C, wmOperator *op) { const int unselected = RNA_boolean_get(op->ptr, "unselected"); - CTX_DATA_BEGIN (C, Base *, base, visible_bases) + CTX_DATA_BEGIN(C, Base *, base, visible_bases) { if (!unselected) { if (base->flag & SELECT) { @@ -1114,7 +1114,7 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene) ListBase targets = {NULL, NULL}; /* loop over objects in scene */ - CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) + CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects) { /* set flag to force recalc, then grab path(s) from object */ ob->avs.recalc |= ANIMVIZ_RECALC_PATHS; @@ -1157,7 +1157,7 @@ static int object_calculate_paths_exec(bContext *C, wmOperator *op) int end = RNA_int_get(op->ptr, "end_frame"); /* set up path data for bones being calculated */ - CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) + CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects) { bAnimVizSettings *avs = &ob->avs; @@ -1196,9 +1196,9 @@ void OBJECT_OT_paths_calculate(wmOperatorType *ot) /* properties */ RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start", - "First frame to calculate object paths on", MINFRAME, MAXFRAME/2.0); + "First frame to calculate object paths on", MINFRAME, MAXFRAME / 2.0); RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End", - "Last frame to calculate object paths on", MINFRAME, MAXFRAME/2.0); + "Last frame to calculate object paths on", MINFRAME, MAXFRAME / 2.0); } /* --------- */ @@ -1231,7 +1231,7 @@ void OBJECT_OT_paths_update(wmOperatorType *ot) ot->poll = ED_operator_object_active_editable; /* TODO: this should probably check for existing paths */ /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* --------- */ @@ -1240,7 +1240,7 @@ void OBJECT_OT_paths_update(wmOperatorType *ot) void ED_objects_clear_paths(bContext *C) { /* loop over objects in scene */ - CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) + CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects) { if (ob->mpath) { animviz_free_motionpath(ob->mpath); @@ -1288,7 +1288,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op) int clear = (strcmp(op->idname, "OBJECT_OT_shade_flat") == 0); int done = FALSE; - CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) + CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects) { if (ob->type == OB_MESH) { @@ -1666,10 +1666,12 @@ static EnumPropertyItem game_properties_copy_operations[] = { {COPY_PROPERTIES_REPLACE, "REPLACE", 0, "Replace Properties", ""}, {COPY_PROPERTIES_MERGE, "MERGE", 0, "Merge Properties", ""}, {COPY_PROPERTIES_COPY, "COPY", 0, "Copy a Property", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; -static EnumPropertyItem gameprops_items[]= { - {0, NULL, 0, NULL, NULL}}; +static EnumPropertyItem gameprops_items[] = { + {0, NULL, 0, NULL, NULL} +}; static EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { @@ -1706,7 +1708,7 @@ static int game_property_copy_exec(bContext *C, wmOperator *op) prop = BLI_findlink(&ob->prop, propid - 1); if (prop) { - CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) + CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects) { if (ob != ob_iter) set_ob_property(ob_iter, prop); @@ -1715,7 +1717,7 @@ static int game_property_copy_exec(bContext *C, wmOperator *op) } else { - CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) + CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects) { if (ob != ob_iter) { if (type == COPY_PROPERTIES_REPLACE) @@ -1756,7 +1758,7 @@ void OBJECT_OT_game_property_copy(wmOperatorType *ot) static int game_property_clear_exec(bContext *C, wmOperator *UNUSED(op)) { - CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) + CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects) { free_properties(&ob_iter->prop); } @@ -1786,7 +1788,7 @@ static int logicbricks_copy_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = ED_object_active_context(C); - CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) + CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects) { if (ob != ob_iter) { /* first: free all logic */ @@ -1843,7 +1845,7 @@ static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = ED_object_active_context(C); - CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) + CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects) { if (ob != ob_iter) { ob_iter->gameflag = ob->gameflag; diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index f6e8ccf4ec9..0a9944debe1 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -344,18 +344,17 @@ int mouse_lattice(bContext *C, const int mval[2], int extend, int deselect, int bp = findnearestLattvert(&vc, mval, 1); if (bp) { - if (extend) { - bp->f1 |= SELECT; - } - else if (deselect) { - bp->f1 &= ~SELECT; - } + if (extend) { + bp->f1 |= SELECT; + } + else if (deselect) { + bp->f1 &= ~SELECT; + } else if (toggle) { bp->f1 ^= SELECT; /* swap */ } - else - { - ED_setflagsLatt(vc.obedit, 0); + else { + ED_setflagsLatt(vc.obedit, 0); bp->f1 |= SELECT; } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 89c7896d53c..4e98d2ae967 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1951,7 +1951,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); if (sc) { - if ((sc->mode == SC_MODE_MASKEDITING) && sc->mask) { + if ((sc->mode == SC_MODE_MASKEDIT) && sc->mask) { MaskLayer *masklay = BKE_mask_layer_active(sc->mask); mask_to_keylist(&ads, masklay, &keys); } diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c index 5b2c3530aa4..ca2ae6e8461 100644 --- a/source/blender/editors/space_clip/clip_buttons.c +++ b/source/blender/editors/space_clip/clip_buttons.c @@ -168,7 +168,7 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname) scopes->track_preview_height = (scopes->track_preview_height <= UI_UNIT_Y)?UI_UNIT_Y : scopes->track_preview_height; uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, rect.xmax - rect.xmin, - scopes->track_preview_height, scopes, 0, 0, 0, 0, ""); + scopes->track_preview_height, scopes, 0, 0, 0, 0, ""); } /********************* Marker Template ************************/ diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 003fa5c5cef..47825462565 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -198,7 +198,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc clip_draw_curfra_label(sc, x, 8.0f); /* movie clip animation */ - if ((sc->mode == SC_MODE_MASKEDITING) && sc->mask) { + if ((sc->mode == SC_MODE_MASKEDIT) && sc->mask) { MaskLayer *masklay = BKE_mask_layer_active(sc->mask); if (masklay) { MaskLayerShape *masklay_shape; diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index f16ef21b707..3349a61cd86 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -129,7 +129,7 @@ int ED_space_clip_tracking_frame_poll(bContext *C) return FALSE; } -int ED_space_clip_maskediting_poll(bContext *C) +int ED_space_clip_maskedit_poll(bContext *C) { SpaceClip *sc = CTX_wm_space_clip(C); @@ -140,9 +140,9 @@ int ED_space_clip_maskediting_poll(bContext *C) return FALSE; } -int ED_space_clip_maskediting_mask_poll(bContext *C) +int ED_space_clip_maskedit_mask_poll(bContext *C) { - if (ED_space_clip_maskediting_poll(C)) { + if (ED_space_clip_maskedit_poll(C)) { MovieClip *clip = CTX_data_edit_movieclip(C); if (clip) { @@ -282,7 +282,7 @@ void ED_space_clip_mask_aspect(SpaceClip *sc, float *aspx, float *aspy) *aspy *= (float)h; #endif - if(*aspx < *aspy) { + if (*aspx < *aspy) { *aspy= *aspy / *aspx; *aspx= 1.0f; } @@ -329,7 +329,7 @@ void ED_space_clip_aspect_dimension_aware(SpaceClip *sc, float *aspx, float *asp *aspx *= (float)w; *aspy *= (float)h; - if(*aspx < *aspy) { + if (*aspx < *aspy) { *aspy= *aspy / *aspx; *aspx= 1.0f; } @@ -544,7 +544,10 @@ typedef struct SpaceClipDrawContext { struct ImBuf *texture_ibuf; /* image buffer for which texture was created */ int image_width, image_height; /* image width and height for which texture was created */ unsigned last_texture; /* ID of previously used texture, so it'll be restored after clip drawing */ - int framenr; + + /* fields to check if cache is still valid */ + int framenr, start_frame; + short custom_start_frame; } SpaceClipDrawContext; int ED_space_clip_texture_buffer_supported(SpaceClip *sc) @@ -583,6 +586,14 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf) need_rebind |= context->texture_ibuf != ibuf; need_rebind |= context->framenr != sc->user.framenr; + if (clip->flag & MCLIP_CUSTOM_START_FRAME) { + need_rebind |= context->custom_start_frame != TRUE; + need_rebind |= context->start_frame != clip->start_frame; + } + else { + need_rebind |= context->custom_start_frame != FALSE; + } + if (need_rebind) { int width = ibuf->x, height = ibuf->y; int need_recreate = 0; @@ -636,6 +647,8 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf) context->image_width = ibuf->x; context->image_height = ibuf->y; context->framenr = sc->user.framenr; + context->start_frame = clip->start_frame; + context->custom_start_frame = (clip->flag & MCLIP_CUSTOM_START_FRAME) ? TRUE : FALSE; } else { /* displaying exactly the same image which was loaded t oa texture, @@ -681,7 +694,7 @@ int ED_space_clip_show_trackedit(SpaceClip *sc) int ED_space_clip_show_maskedit(SpaceClip *sc) { if (sc) { - return sc->mode == SC_MODE_MASKEDITING; + return sc->mode == SC_MODE_MASKEDIT; } return FALSE; @@ -691,9 +704,11 @@ void ED_space_clip_set_mask(bContext *C, SpaceClip *sc, Mask *mask) { sc->mask = mask; - if(sc->mask && sc->mask->id.us==0) + if (sc->mask && sc->mask->id.us==0) { sc->clip->id.us = 1; + } - if(C) + if (C) { WM_event_add_notifier(C, NC_MASK|NA_SELECTED, mask); + } } diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index b24db67cfc2..51157bc2ed4 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -367,14 +367,14 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_MASK: - switch(wmn->data) { + switch (wmn->data) { case ND_SELECT: case ND_DATA: case ND_DRAW: ED_area_tag_redraw(sa); break; } - switch(wmn->action) { + switch (wmn->action) { case NA_SELECTED: clip_scopes_tag_refresh(sa); ED_area_tag_redraw(sa); @@ -1050,7 +1050,7 @@ static void clip_main_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy); /* own keymap */ - keymap= WM_keymap_find(wm->defaultconf, "Mask Editor", 0, 0); + keymap = WM_keymap_find(wm->defaultconf, "Mask Editing", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); keymap = WM_keymap_find(wm->defaultconf, "Clip", SPACE_CLIP, 0); @@ -1100,7 +1100,7 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar) /* Grease Pencil */ clip_draw_grease_pencil((bContext *)C, 1); - if(sc->mode == SC_MODE_MASKEDITING) { + if (sc->mode == SC_MODE_MASKEDIT) { int x, y; int width, height; float zoomx, zoomy, aspx, aspy; @@ -1326,7 +1326,7 @@ static void clip_header_area_listener(ARegion *ar, wmNotifier *wmn) /* for proportional editmode only */ case ND_TOOLSETTINGS: /* TODO - should do this when in mask mode only but no datas available */ - // if(sc->mode == SC_MODE_MASKEDITING) + // if (sc->mode == SC_MODE_MASKEDIT) { ED_region_tag_redraw(ar); } diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 801b6c9001c..b75b3e6aeb3 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1114,7 +1114,7 @@ static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED( glDisable(GL_BLEND); /* outline active and selected emphasis */ - if( node->flag & (NODE_ACTIVE|SELECT) ) { + if (node->flag & (NODE_ACTIVE | SELECT)) { glEnable(GL_BLEND); glEnable( GL_LINE_SMOOTH ); /* using different shades of TH_TEXT_HI for the empasis, like triangle */ @@ -1132,7 +1132,7 @@ static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED( /* only draw input socket. as they all are placed on the same position. * highlight also if node itself is selected, since we don't display the node body separately! */ - for(sock= node->inputs.first; sock; sock= sock->next) { + for (sock= node->inputs.first; sock; sock= sock->next) { node_socket_circle_draw(ntree, sock, socket_size, (sock->flag & SELECT) || (node->flag & SELECT)); } @@ -1188,6 +1188,47 @@ static void node_common_set_butfunc(bNodeType *ntype) } /* ****************** BUTTON CALLBACKS FOR SHADER NODES ***************** */ + +static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *imaptr, PointerRNA *iuserptr) +{ + uiLayout *col; + int source; + + if(!imaptr->data) + return; + + col = uiLayoutColumn(layout, 0); + + uiItemR(col, imaptr, "source", 0, "", ICON_NONE); + + source = RNA_enum_get(imaptr, "source"); + + if (source == IMA_SRC_SEQUENCE) { + /* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */ + Scene *scene = CTX_data_scene(C); + ImageUser *iuser = iuserptr->data; + char numstr[32]; + const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0); + BLI_snprintf(numstr, sizeof(numstr), IFACE_("Frame: %d"), framenr); + uiItemL(layout, numstr, ICON_NONE); + } + + if (ELEM(source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) { + col = uiLayoutColumn(layout, 1); + uiItemR(col, iuserptr, "frame_duration", 0, NULL, ICON_NONE); + uiItemR(col, iuserptr, "frame_start", 0, NULL, ICON_NONE); + uiItemR(col, iuserptr, "frame_offset", 0, NULL, ICON_NONE); + uiItemR(col, iuserptr, "use_cyclic", 0, NULL, ICON_NONE); + uiItemR(col, iuserptr, "use_auto_refresh", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE); + } + + col = uiLayoutColumn(layout, 0); + + if (RNA_enum_get(imaptr, "type") == IMA_TYPE_MULTILAYER) + uiItemR(col, iuserptr, "layer", 0, NULL, ICON_NONE); + +} + static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA *ptr) { bNode *node = ptr->data; @@ -1259,16 +1300,25 @@ static void node_shader_buts_attribute(uiLayout *layout, bContext *UNUSED(C), Po static void node_shader_buts_tex_image(uiLayout *layout, bContext *C, PointerRNA *ptr) { + PointerRNA imaptr = RNA_pointer_get(ptr, "image"); + PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user"); + uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL); uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE); -} + node_buts_image_user(layout, C, &imaptr, &iuserptr); +} static void node_shader_buts_tex_environment(uiLayout *layout, bContext *C, PointerRNA *ptr) { + PointerRNA imaptr = RNA_pointer_get(ptr, "image"); + PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user"); + uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL); uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE); uiItemR(layout, ptr, "projection", 0, "", ICON_NONE); + + node_buts_image_user(layout, C, &imaptr, &iuserptr); } static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) @@ -1391,11 +1441,9 @@ static void node_shader_set_butfunc(bNodeType *ntype) static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA *ptr) { - uiLayout *col; bNode *node = ptr->data; PointerRNA imaptr; PropertyRNA *prop; - int source; uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL); @@ -1405,35 +1453,7 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA * if (!prop || RNA_property_type(prop) != PROP_POINTER) return; imaptr = RNA_property_pointer_get(ptr, prop); - col = uiLayoutColumn(layout, 0); - - uiItemR(col, &imaptr, "source", 0, NULL, ICON_NONE); - - source = RNA_enum_get(&imaptr, "source"); - - if (source == IMA_SRC_SEQUENCE) { - /* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */ - Scene *scene = CTX_data_scene(C); - ImageUser *iuser = node->storage; - char numstr[32]; - const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0); - BLI_snprintf(numstr, sizeof(numstr), IFACE_("Frame: %d"), framenr); - uiItemL(layout, numstr, ICON_NONE); - } - - if (ELEM(source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) { - col = uiLayoutColumn(layout, 1); - uiItemR(col, ptr, "frame_duration", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "frame_start", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "frame_offset", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "use_cyclic", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "use_auto_refresh", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE); - } - - col = uiLayoutColumn(layout, 0); - - if (RNA_enum_get(&imaptr, "type") == IMA_TYPE_MULTILAYER) - uiItemR(col, ptr, "layer", 0, NULL, ICON_NONE); + node_buts_image_user(layout, C, &imaptr, ptr); } static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, PointerRNA *ptr) diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 1b229c78e0f..b4e07546fa9 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -2756,11 +2756,11 @@ static int add_reroute_intersect_check(bNodeLink *link, float mcoords[][2], int float coord_array[LINK_RESOL+1][2]; int i, b; - if(node_link_bezier_points(NULL, NULL, link, coord_array, LINK_RESOL)) { + if (node_link_bezier_points(NULL, NULL, link, coord_array, LINK_RESOL)) { - for(i=0; i<tot-1; i++) - for(b=0; b<LINK_RESOL; b++) - if(isect_line_line_v2(mcoords[i], mcoords[i+1], coord_array[b], coord_array[b+1]) > 0) { + for (i=0; i<tot-1; i++) + for (b=0; b<LINK_RESOL; b++) + if (isect_line_line_v2(mcoords[i], mcoords[i+1], coord_array[b], coord_array[b+1]) > 0) { result[0] = (mcoords[i][0]+mcoords[i+1][0])/2.0f; result[1] = (mcoords[i][1]+mcoords[i+1][1])/2.0f; return 1; @@ -2783,18 +2783,18 @@ static int add_reroute_exec(bContext *C, wmOperator *op) UI_view2d_region_to_view(&ar->v2d, (short)loc[0], (short)loc[1], &mcoords[i][0], &mcoords[i][1]); i++; - if(i>= 256) break; + if (i>= 256) break; } RNA_END; - if(i>1) { + if (i>1) { bNodeLink *link; float insertPoint[2]; ED_preview_kill_jobs(C); - for(link= snode->edittree->links.first; link; link=link->next) { - if(add_reroute_intersect_check(link, mcoords, i, insertPoint)) { + for (link= snode->edittree->links.first; link; link=link->next) { + if (add_reroute_intersect_check(link, mcoords, i, insertPoint)) { bNodeTemplate ntemp; bNode *rerouteNode; diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 0a3678ca901..e7be750928d 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -76,7 +76,7 @@ static bNode *node_under_mouse_tweak(bNodeTree *ntree, int mx, int my) { bNode *node; - for(node=ntree->nodes.last; node; node=node->prev) { + for (node=ntree->nodes.last; node; node=node->prev) { if (node->typeinfo->tweak_area_func) { if (node->typeinfo->tweak_area_func(node, mx, my)) return node; diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index a752a7d71ae..e5f7b8fd76d 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -1503,7 +1503,12 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) scene = (Scene *)outliner_search_back(soops, te_found, ID_SCE); if (scene == NULL) { - return OPERATOR_CANCELLED; + /* currently outlier organized in a way, that if there's no parent scene + * element for object it means that all displayed objects belong to + * active scene and parenting them is allowed (sergey) + */ + + scene = CTX_data_scene(C); } if ((par->type != OB_ARMATURE) && (par->type != OB_CURVE) && (par->type != OB_LATTICE)) { diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 4d45be561c6..c78be8bd223 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -98,7 +98,16 @@ static int outliner_parent_drop_poll(bContext *C, wmDrag *drag, wmEvent *event) if (te_valid) { /* check that parent/child are both in the same scene */ Scene *scene = (Scene *)outliner_search_back(soops, te_valid, ID_SCE); - if (BKE_scene_base_find(scene, (Object *)id)) { + + if (!scene) { + /* currently outlier organized in a way, that if there's no parent scene + * element for object it means that all displayed objects belong to + * active scene and parenting them is allowed (sergey) + */ + return 1; + } + + if (scene && BKE_scene_base_find(scene, (Object *)id)) { return 1; } } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 006704e26bf..7a8c2cde074 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1728,6 +1728,9 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int case TFM_CURVE_SHRINKFATTEN: initCurveShrinkFatten(t); break; + case TFM_MASK_SHRINKFATTEN: + initMaskShrinkFatten(t); + break; case TFM_TRACKBALL: initTrackball(t); break; @@ -3927,8 +3930,77 @@ int CurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) continue; if (td->val) { - // *td->val= ratio; *td->val= td->ival*ratio; + /* apply PET */ + *td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival); + if (*td->val <= 0.0f) *td->val = 0.001f; + } + } + + recalcData(t); + + ED_area_headerprint(t->sa, str); + + return 1; +} + + +void initMaskShrinkFatten(TransInfo *t) +{ + t->mode = TFM_MASK_SHRINKFATTEN; + t->transform = MaskShrinkFatten; + + initMouseInputMode(t, &t->mouse, INPUT_SPRING); + + t->idx_max = 0; + t->num.idx_max = 0; + t->snap[0] = 0.0f; + t->snap[1] = 0.1f; + t->snap[2] = t->snap[1] * 0.1f; + + t->num.increment = t->snap[1]; + + t->flag |= T_NO_ZERO; + t->num.flag |= NUM_NO_ZERO; + + t->flag |= T_NO_CONSTRAINT; +} + +int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) +{ + TransData *td = t->data; + float ratio; + int i; + char str[50]; + + ratio = t->values[0]; + + snapGrid(t, &ratio); + + applyNumInput(&t->num, &ratio); + + /* header print for NumInput */ + if (hasNumInput(&t->num)) { + char c[20]; + + outputNumInput(&(t->num), c); + sprintf(str, "Shrink/Fatten: %s", c); + } + else { + sprintf(str, "Shrink/Fatten: %3f", ratio); + } + + for (i = 0 ; i < t->total; i++, td++) { + if (td->flag & TD_NOACTION) + break; + + if (td->flag & TD_SKIP) + continue; + + if (td->val) { + *td->val = td->ival * ratio; + /* apply PET */ + *td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival); if (*td->val <= 0.0f) *td->val = 0.001f; } } diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 59688f1436e..32a4d4ab1a3 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -494,6 +494,9 @@ int Tilt(TransInfo *t, const int mval[2]); void initCurveShrinkFatten(TransInfo *t); int CurveShrinkFatten(TransInfo *t, const int mval[2]); +void initMaskShrinkFatten(TransInfo *t); +int MaskShrinkFatten(TransInfo *t, const int mval[2]); + void initTrackball(TransInfo *t); int Trackball(TransInfo *t, const int mval[2]); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 8a7caeb3060..c1d2cf2c2a8 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -5918,8 +5918,16 @@ static void MaskPointToTransData(SpaceClip *sc, MaskSplinePoint *point, memset(td->axismtx, 0, sizeof(td->axismtx)); td->axismtx[2][2] = 1.0f; - td->ext= NULL; - td->val= NULL; + td->ext = NULL; + + if (i == 1) { + /* scaling weights */ + td->val = &bezt->weight; + td->ival = *td->val; + } + else { + td->val = NULL; + } if (is_sel_any) { td->flag |= TD_SELECTED; @@ -5981,6 +5989,11 @@ static void createTransMaskingData(bContext *C, TransInfo *t) int count = 0, countsel = 0; int propmode = t->flag & T_PROP_EDIT; + t->total = 0; + + if (!mask) + return; + /* count */ for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { MaskSpline *spline = masklay->splines.first; @@ -6066,7 +6079,7 @@ void flushTransMasking(TransInfo *t) invy = 1.0f/aspy; /* flush to 2d vector from internally used 3d vector */ - for(a=0, td = t->data2d, tdm = t->customData; a<t->total; a++, td++, tdm++) { + for (a=0, td = t->data2d, tdm = t->customData; a<t->total; a++, td++, tdm++) { td->loc2d[0]= td->loc[0]*invx; td->loc2d[1]= td->loc[1]*invy; diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 870f8c742e1..4ea89de9070 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -135,6 +135,7 @@ EnumPropertyItem transform_mode_types[] = {TFM_BONESIZE, "BONE_SIZE", 0, "Bonesize", ""}, {TFM_BONE_ENVELOPE, "BONE_ENVELOPE", 0, "Bone_Envelope", ""}, {TFM_CURVE_SHRINKFATTEN, "CURVE_SHRINKFATTEN", 0, "Curve_Shrinkfatten", ""}, + {TFM_MASK_SHRINKFATTEN, "MASK_SHRINKFATTEN", 0, "Mask_Shrinkfatten", ""}, {TFM_BONE_ROLL, "BONE_ROLL", 0, "Bone_Roll", ""}, {TFM_TIME_TRANSLATE, "TIME_TRANSLATE", 0, "Time_Translate", ""}, {TFM_TIME_SLIDE, "TIME_SLIDE", 0, "Time_Slide", ""}, diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 4c6ead3d3f4..75ed7d7eb19 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -1151,7 +1151,7 @@ void GPU_buffer_unbind(void) glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); } } - GLStates &= !(GPU_BUFFER_VERTEX_STATE | GPU_BUFFER_NORMAL_STATE | + GLStates &= ~(GPU_BUFFER_VERTEX_STATE | GPU_BUFFER_NORMAL_STATE | GPU_BUFFER_TEXCOORD_STATE | GPU_BUFFER_COLOR_STATE | GPU_BUFFER_ELEMENT_STATE); @@ -1191,7 +1191,7 @@ void GPU_color_switch(int mode) else { if (GLStates & GPU_BUFFER_COLOR_STATE) glDisableClientState(GL_COLOR_ARRAY); - GLStates &= (!GPU_BUFFER_COLOR_STATE); + GLStates &= ~GPU_BUFFER_COLOR_STATE; } } diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 31008ff8685..78b5219206d 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -772,7 +772,7 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la GPU_link(mat, "mtex_value_invert", shadfac, &shadfac); GPU_link(mat, "mix_mult", shadfac, rgb, GPU_uniform(lamp->shadow_color), &rgb); GPU_link(mat, "mtex_value_invert", shadfac, &shadfac); - add_to_diffuse(mat, ma, shi, is, rgb, &shr->diff); + add_to_diffuse(mat, ma, shi, is, rgb, &shr->diff); } } diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 65c0bcb3c63..b9bd7e961f8 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -1105,7 +1105,7 @@ void mtex_normal(vec3 texco, sampler2D ima, out vec3 normal) // It needs to be done because in Blender // the normal used points inward. // Should this ever change this negate must be removed. - vec4 color = texture2D(ima, texco.xy); + vec4 color = texture2D(ima, texco.xy); normal = 2.0*(vec3(-color.r, color.g, color.b) - vec3(-0.5, 0.5, 0.5)); } @@ -1190,7 +1190,7 @@ void mtex_bump_init_viewspace( vec3 surf_pos, vec3 surf_norm, } void mtex_bump_tap3( vec3 texco, sampler2D ima, float hScale, - out float dBs, out float dBt ) + out float dBs, out float dBt ) { vec2 STll = texco.xy; vec2 STlr = texco.xy + dFdx(texco.xy) ; @@ -1945,22 +1945,23 @@ void shade_alpha_obcolor(vec4 col, vec4 obcol, out vec4 outcol) float fresnel_dielectric(vec3 Incoming, vec3 Normal, float eta) { - /* compute fresnel reflectance without explicitly computing - the refracted direction */ - float c = abs(dot(Incoming, Normal)); - float g = eta * eta - 1.0 + c * c; - float result; - - if(g > 0.0) { - g = sqrt(g); - float A =(g - c)/(g + c); - float B =(c *(g + c)- 1.0)/(c *(g - c)+ 1.0); - result = 0.5 * A * A *(1.0 + B * B); - } - else - result = 1.0; /* TIR (no refracted component) */ + /* compute fresnel reflectance without explicitly computing + * the refracted direction */ + float c = abs(dot(Incoming, Normal)); + float g = eta * eta - 1.0 + c * c; + float result; + + if(g > 0.0) { + g = sqrt(g); + float A =(g - c)/(g + c); + float B =(c *(g + c)- 1.0)/(c *(g - c)+ 1.0); + result = 0.5 * A * A *(1.0 + B * B); + } + else { + result = 1.0; /* TIR (no refracted component) */ + } - return result; + return result; } float hypot(float x, float y) @@ -2135,13 +2136,13 @@ void node_tex_environment_empty(vec3 co, out vec4 color) void node_tex_image(vec3 co, sampler2D ima, out vec4 color, out float alpha) { color = texture2D(ima, co.xy); - alpha = color.a; + alpha = color.a; } void node_tex_image_empty(vec3 co, out vec4 color, out float alpha) { color = vec4(0.0); - alpha = 0.0; + alpha = 0.0; } void node_tex_magic(vec3 p, float scale, float distortion, out vec4 color, out float fac) diff --git a/source/blender/imbuf/intern/dds/ColorBlock.cpp b/source/blender/imbuf/intern/dds/ColorBlock.cpp index 42bec5874ca..0b9f5c163fb 100644 --- a/source/blender/imbuf/intern/dds/ColorBlock.cpp +++ b/source/blender/imbuf/intern/dds/ColorBlock.cpp @@ -176,7 +176,7 @@ bool ColorBlock::isSingleColorNoAlpha() const int i; for (i = 0; i < 16; i++) { - if (m_color[i].a != 0) c = m_color[i]; + if (m_color[i].a != 0) c = m_color[i]; } Color32 mask(0xFF, 0xFF, 0xFF, 0x00); diff --git a/source/blender/makesdna/DNA_mask_types.h b/source/blender/makesdna/DNA_mask_types.h index 28fc9466613..c036369c692 100644 --- a/source/blender/makesdna/DNA_mask_types.h +++ b/source/blender/makesdna/DNA_mask_types.h @@ -97,6 +97,15 @@ typedef struct MaskLayerShape { char pad[7]; } MaskLayerShape; +/* cast to this for convenience, not saved */ +#define MASK_OBJECT_SHAPE_ELEM_SIZE 8 /* 3x 2D points + weight + radius == 8 */ + +# +# +typedef struct MaskLayerShapeElem { + float value[MASK_OBJECT_SHAPE_ELEM_SIZE]; +} MaskLayerShapeElem; + typedef struct MaskLayer { struct MaskLayer *next, *prev; @@ -129,8 +138,6 @@ typedef struct MaskLayer { #define MASK_SPLINE_INTERP_LINEAR 1 #define MASK_SPLINE_INTERP_EASE 2 -#define MASK_OBJECT_SHAPE_ELEM_SIZE 8 /* 3x 2D points + weight + radius == 8 */ - /* ob->restrictflag */ #define MASK_RESTRICT_VIEW 1 #define MASK_RESTRICT_SELECT 2 diff --git a/source/blender/makesdna/DNA_movieclip_types.h b/source/blender/makesdna/DNA_movieclip_types.h index f073a1957dc..81d532fd247 100644 --- a/source/blender/makesdna/DNA_movieclip_types.h +++ b/source/blender/makesdna/DNA_movieclip_types.h @@ -85,6 +85,8 @@ typedef struct MovieClip { int flag; int len; /* length of movie */ + + int start_frame, pad; } MovieClip; typedef struct MovieClipScopes { @@ -121,6 +123,7 @@ typedef struct MovieClipScopes { /* MovieClip->flag */ #define MCLIP_USE_PROXY (1<<0) #define MCLIP_USE_PROXY_CUSTOM_DIR (1<<1) +#define MCLIP_CUSTOM_START_FRAME (1<<2) #define MCLIP_TIMECODE_FLAGS (MCLIP_USE_PROXY|MCLIP_USE_PROXY_CUSTOM_DIR) diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 39f3fda1157..38622569590 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -563,6 +563,7 @@ typedef struct NodeTexSky { typedef struct NodeTexImage { NodeTexBase base; + ImageUser iuser; int color_space, pad; } NodeTexImage; @@ -572,6 +573,7 @@ typedef struct NodeTexChecker { typedef struct NodeTexEnvironment { NodeTexBase base; + ImageUser iuser; int color_space, projection; } NodeTexEnvironment; diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index b1e64641985..8935268cb91 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -1048,7 +1048,7 @@ typedef enum eSpaceClip_Mode { SC_MODE_TRACKING = 0, SC_MODE_RECONSTRUCTION, SC_MODE_DISTORTION, - SC_MODE_MASKEDITING, + SC_MODE_MASKEDIT, } eSpaceClip_Mode; /* SpaceClip->view */ diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index e7f9977d040..82c0757456d 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -209,6 +209,10 @@ if(WITH_FFTW3) add_definitions(-DWITH_FFTW3) endif() +if(WITH_MOD_SMOKE) + add_definitions(-DWITH_SMOKE) +endif() + if(WITH_MOD_OCEANSIM) add_definitions(-DWITH_OCEANSIM) endif() @@ -253,6 +257,7 @@ blender_include_dirs( ../../../../intern/cycles/blender ../../../../intern/guardedalloc ../../../../intern/memutil + ../../../../intern/smoke/extern ) blender_include_dirs_sys( diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript index 99fab18b4bf..d26de50fae0 100644 --- a/source/blender/makesrna/intern/SConscript +++ b/source/blender/makesrna/intern/SConscript @@ -35,7 +35,11 @@ incs += ' ../../windowmanager ../../editors/include ../../blenfont' incs += ' ../../render/extern/include ../../bmesh' incs += ' #/intern/audaspace/intern #/intern/cycles/blender' incs += ' #/extern/glew/include ' +incs += ' #/intern/smoke/extern' +if env['WITH_BF_SMOKE']: + defs.append('WITH_SMOKE') + if env['WITH_BF_OPENEXR']: defs.append('WITH_OPENEXR') diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c index c356cae81af..51d370d5a88 100644 --- a/source/blender/makesrna/intern/rna_mask.c +++ b/source/blender/makesrna/intern/rna_mask.c @@ -324,7 +324,7 @@ static void rna_def_maskParent(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; srna = RNA_def_struct(brna, "MaskParent", NULL); - RNA_def_struct_ui_text(srna, "Mask Parent", "Parenting settings for maskign element"); + RNA_def_struct_ui_text(srna, "Mask Parent", "Parenting settings for masking element"); /* use_parent */ prop = RNA_def_property(srna, "use_parent", PROP_BOOLEAN, PROP_NONE); @@ -497,7 +497,7 @@ static void rna_def_maskSpline(BlenderRNA *brna) rna_def_maskSplinePoint(brna); srna = RNA_def_struct(brna, "MaskSpline", NULL); - RNA_def_struct_ui_text(srna, "Mask spline", "Single spline used for defining mash shape"); + RNA_def_struct_ui_text(srna, "Mask spline", "Single spline used for defining mask shape"); /* weight interpolation */ prop = RNA_def_property(srna, "weight_interpolation", PROP_ENUM, PROP_NONE); @@ -583,7 +583,7 @@ static void rna_def_mask_layer(BlenderRNA *brna) prop = RNA_def_property(srna, "invert", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "blend_flag", MASK_BLENDFLAG_INVERT); - RNA_def_property_ui_text(prop, "Restrict View", "Restrict visibility in the viewport"); + RNA_def_property_ui_text(prop, "Restrict View", "Invert the mask black/white"); RNA_def_property_update(prop, NC_MASK | NA_EDITED, NULL); } diff --git a/source/blender/makesrna/intern/rna_movieclip.c b/source/blender/makesrna/intern/rna_movieclip.c index 13c11f6402f..26d967dfb42 100644 --- a/source/blender/makesrna/intern/rna_movieclip.c +++ b/source/blender/makesrna/intern/rna_movieclip.c @@ -285,6 +285,19 @@ static void rna_def_movieclip(BlenderRNA *brna) RNA_def_property_struct_type(prop, "GreasePencil"); RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this movie clip"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL); + + /* use custom offset */ + prop = RNA_def_property(srna, "use_custom_start_frame", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MCLIP_CUSTOM_START_FRAME); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Custom Start Frame", "Use custom first frame offset instead of automatic frame number"); + RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update"); + + /* frame offset */ + prop = RNA_def_property(srna, "start_frame", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "start_frame"); + RNA_def_property_ui_text(prop, "Start Frame", "Number of frame from sequence or movie displaying at scene frame #1"); + RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update"); } void RNA_def_movieclip(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 1f574ba2473..ae489790825 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -1429,6 +1429,12 @@ static void def_sh_tex_environment(StructRNA *srna) RNA_def_property_ui_text(prop, "Projection", "Projection of the input image"); RNA_def_property_update(prop, 0, "rna_Node_update"); + prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "iuser"); + RNA_def_property_ui_text(prop, "Image User", + "Parameters defining which layer, pass and frame of the image is displayed"); + RNA_def_property_update(prop, 0, "rna_Node_update"); } static void def_sh_tex_image(StructRNA *srna) @@ -1458,6 +1464,13 @@ static void def_sh_tex_image(StructRNA *srna) RNA_def_property_enum_items(prop, prop_color_space_items); RNA_def_property_ui_text(prop, "Color Space", "Image file color space"); RNA_def_property_update(prop, 0, "rna_Node_update"); + + prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "iuser"); + RNA_def_property_ui_text(prop, "Image User", + "Parameters defining which layer, pass and frame of the image is displayed"); + RNA_def_property_update(prop, 0, "rna_Node_update"); } static void def_sh_tex_gradient(StructRNA *srna) @@ -1830,29 +1843,10 @@ static void def_cmp_levels(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } -static void def_cmp_image(StructRNA *srna) +static void def_node_image_user(StructRNA *srna) { PropertyRNA *prop; - -#if 0 - static EnumPropertyItem type_items[] = { - {IMA_SRC_FILE, "IMAGE", 0, "Image", ""}, - {IMA_SRC_MOVIE, "MOVIE", "Movie", ""}, - {IMA_SRC_SEQUENCE, "SEQUENCE", "Sequence", ""}, - {IMA_SRC_GENERATED, "GENERATED", "Generated", ""}, - {0, NULL, 0, NULL, NULL} - }; -#endif - - prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "id"); - RNA_def_property_struct_type(prop, "Image"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Image", ""); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - - RNA_def_struct_sdna_from(srna, "ImageUser", "storage"); - + prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "frames"); RNA_def_property_range(prop, 0, MAXFRAMEF); @@ -1893,6 +1887,31 @@ static void def_cmp_image(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_image_layer_update"); } +static void def_cmp_image(StructRNA *srna) +{ + PropertyRNA *prop; + +#if 0 + static EnumPropertyItem type_items[] = { + {IMA_SRC_FILE, "IMAGE", 0, "Image", ""}, + {IMA_SRC_MOVIE, "MOVIE", "Movie", ""}, + {IMA_SRC_SEQUENCE, "SEQUENCE", "Sequence", ""}, + {IMA_SRC_GENERATED, "GENERATED", "Generated", ""}, + {0, NULL, 0, NULL, NULL} + }; +#endif + + prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "id"); + RNA_def_property_struct_type(prop, "Image"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Image", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + RNA_def_struct_sdna_from(srna, "ImageUser", "storage"); + def_node_image_user(srna); +} + static void def_cmp_render_layers(StructRNA *srna) { PropertyRNA *prop; @@ -3515,7 +3534,7 @@ static void def_tex_image(StructRNA *srna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Image", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - + /* is this supposed to be exposed? not sure.. */ #if 0 prop = RNA_def_property(srna, "settings", PROP_POINTER, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c index bdbd153b1e2..2fb882d96a1 100644 --- a/source/blender/makesrna/intern/rna_sequencer_api.c +++ b/source/blender/makesrna/intern/rna_sequencer_api.c @@ -327,7 +327,12 @@ static void rna_SequenceElements_pop(ID *id, Sequence *seq, ReportList *reports, return; } - if (seq->len <= index) { + /* python style negative indexing */ + if (index < 0) { + index += seq->len; + } + + if (seq->len <= index || index < 0) { BKE_report(reports, RPT_ERROR, "SequenceElements.pop: index out of range"); return; } @@ -335,6 +340,7 @@ static void rna_SequenceElements_pop(ID *id, Sequence *seq, ReportList *reports, new_seq = MEM_callocN(sizeof(StripElem) * (seq->len - 1), "SequenceElements_pop"); seq->len--; + /* TODO - simply use 2 memcpy calls */ for (i = 0, se = seq->strip->stripdata; i < seq->len; i++, se++) { if (i == index) se++; @@ -394,7 +400,7 @@ void RNA_api_sequence_elements(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "pop", "rna_SequenceElements_pop"); RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); RNA_def_function_ui_description(func, "Pop an image off the collection"); - parm = RNA_def_int(func, "index", 0, 0, INT_MAX, "", "Index of image to remove", 0, INT_MAX); + parm = RNA_def_int(func, "index", -1, INT_MIN, INT_MAX, "", "Index of image to remove", INT_MIN, INT_MAX); RNA_def_property_flag(parm, PROP_REQUIRED); } diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index 19925546de3..c0efff2d179 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -51,6 +51,8 @@ #include "BKE_depsgraph.h" #include "BKE_particle.h" +#include "smoke_API.h" + static void rna_Smoke_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { @@ -111,6 +113,35 @@ static char *rna_SmokeCollSettings_path(PointerRNA *ptr) return BLI_sprintfN("modifiers[\"%s\"].coll_settings", md->name); } +static int rna_SmokeModifier_density_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION]) +{ + SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data; + + if (settings->fluid) + { + float *density = smoke_get_density(settings->fluid); + unsigned int size = settings->res[0] * settings->res[1] * settings->res[2]; + + if(density) + length[0] = size; + else + length[0] = 0; + } + else + length[0] = 0; // No smoke domain created yet + + return length[0]; +} + +static void rna_SmokeModifier_density_get(PointerRNA *ptr, float *values) +{ + SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data; + float *density = smoke_get_density(settings->fluid); + unsigned int size = settings->res[0] * settings->res[1] * settings->res[2]; + + memcpy(values, density, size * sizeof(float)); +} + #else static void rna_def_smoke_domain_settings(BlenderRNA *brna) @@ -282,6 +313,33 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Vorticity", "Amount of turbulence/rotation in fluid"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + prop = RNA_def_property(srna, "density", PROP_FLOAT, PROP_NONE); + RNA_def_property_array(prop, 32); + RNA_def_property_flag(prop, PROP_DYNAMIC); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_dynamic_array_funcs(prop, "rna_SmokeModifier_density_get_length"); + RNA_def_property_float_funcs(prop, "rna_SmokeModifier_density_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Density", "Smoke density"); + + prop = RNA_def_property(srna, "cell_size", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "dx"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "dx", "Cell Size"); + + prop = RNA_def_property(srna, "start_point", PROP_FLOAT, PROP_XYZ); + RNA_def_property_float_sdna(prop, NULL, "p0"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "p0", "Start point"); + + prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "scale"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "scale", "Domain scale factor"); + + prop = RNA_def_property(srna, "domain_resolution", PROP_INT, PROP_XYZ); + RNA_def_property_int_sdna(prop, NULL, "res"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "res", "Smoke Grid Resolution"); } static void rna_def_smoke_flow_settings(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 5e1a17b8e1d..a57c39967fc 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2983,7 +2983,7 @@ static void rna_def_space_clip(BlenderRNA *brna) {SC_MODE_RECONSTRUCTION, "RECONSTRUCTION", ICON_SNAP_FACE, "Reconstruction", "Show tracking/reconstruction tools"}, {SC_MODE_DISTORTION, "DISTORTION", ICON_GRID, "Distortion", "Show distortion tools"}, - {SC_MODE_MASKEDITING, "MASKEDITING", ICON_MOD_MASK, "Mask editing", "Show mask editing tools"}, + {SC_MODE_MASKEDIT, "MASKEDIT", ICON_MOD_MASK, "Mask editing", "Show mask editing tools"}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index ec215120f0c..84723e95e80 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1992,27 +1992,27 @@ static void rna_def_userdef_theme_space_nla(BlenderRNA *brna) prop = RNA_def_property(srna, "meta_strips", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "nla_meta"); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Meta Strips", "Meta Strip - Unselected. For grouping related strips"); + RNA_def_property_ui_text(prop, "Meta Strips", "Meta Strip - Unselected (for grouping related strips)"); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "meta_strips_selected", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "nla_meta_sel"); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Meta Strips Selected", "Meta Strip - Selected. For grouping related strips"); + RNA_def_property_ui_text(prop, "Meta Strips Selected", "Meta Strip - Selected (for grouping related strips)"); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "sound_strips", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "nla_sound"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Sound Strips", - "Sound Strip - Unselected. For timing speaker sounds"); + "Sound Strip - Unselected (for timing speaker sounds)"); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "sound_strips_selected", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "nla_sound_sel"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Sound Strips Selected", - "Sound Strip - Selected. For timing speaker sounds"); + "Sound Strip - Selected (for timing speaker sounds)"); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "tweak", PROP_FLOAT, PROP_COLOR_GAMMA); @@ -2984,7 +2984,7 @@ static void rna_def_userdef_system(BlenderRNA *brna) {10, "CATALAN", 0, "Catalan (Català )", "ca_AD"}, {16, "CROATIAN", 0, "Croatian (Hrvatski)", "hr_HR"}, {11, "CZECH", 0, "Czech (Český)", "cs_CZ"}, -/* { 3, "DUTCH", 0, "Dutch (Nederlandse taal)", "nl_NL"}, */ /* XXX No po's yet. */ + { 3, "DUTCH", 0, "Dutch (Nederlandse taal)", "nl_NL"}, { 6, "FINNISH", 0, "Finnish (Suomi)", "fi_FI"}, { 5, "GERMAN", 0, "German (Deutsch)", "de_DE"}, {23, "GREEK", 0, "Greek (Ελληνικά)", "el_GR"}, diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c index eb3334d31ce..1b3e3c16486 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.c @@ -79,7 +79,11 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj if ((l1 = e->l) && (l2 = e->l->radial_next) != l1) { - if (dot_v3v3(l1->f->no, l2->f->no) < threshold) { + if (/* 3+ faces on thsi edge, always split */ + UNLIKELY(l1 != l2->radial_next) || + /* 2 face edge - check angle*/ + (dot_v3v3(l1->f->no, l2->f->no) < threshold)) + { BMO_elem_flag_enable(bm, e, EDGE_MARK); } } diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index b69f167f876..b9593353288 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -205,12 +205,12 @@ static MFace *get_dface(DerivedMesh *dm, DerivedMesh *split, int cur, int i, MFa return df; } -#define SET_VERTS(a, b, c, d) \ - v[0] = mf->v##a; uv[0] = a - 1; \ - v[1] = mf->v##b; uv[1] = b - 1; \ - v[2] = mf->v##c; uv[2] = c - 1; \ - v[3] = mf->v##d; uv[3] = d - 1; \ - (void)0 +#define SET_VERTS(a, b, c, d) { \ + v[0] = mf->v##a; uv[0] = a - 1; \ + v[1] = mf->v##b; uv[1] = b - 1; \ + v[2] = mf->v##c; uv[2] = c - 1; \ + v[3] = mf->v##d; uv[3] = d - 1; \ + } (void)0 #define GET_ES(v1, v2) edgecut_get(eh, v1, v2) #define INT_UV(uvf, c0, c1) interp_v2_v2v2(uvf, mf->uv[c0], mf->uv[c1], 0.5f) diff --git a/source/blender/modifiers/intern/MOD_remesh.c b/source/blender/modifiers/intern/MOD_remesh.c index 57966b5824b..2b55471be3d 100644 --- a/source/blender/modifiers/intern/MOD_remesh.c +++ b/source/blender/modifiers/intern/MOD_remesh.c @@ -87,6 +87,7 @@ static void init_dualcon_mesh(DualConInput *mesh, DerivedMesh *dm) mesh->face_stride = sizeof(MFace); mesh->totface = dm->getNumTessFaces(dm); + INIT_MINMAX(mesh->min, mesh->max); dm->getMinMax(dm, mesh->min, mesh->max); } diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c index 99a5dcb5ef5..1313f5aa3ef 100644 --- a/source/blender/modifiers/intern/MOD_smooth.c +++ b/source/blender/modifiers/intern/MOD_smooth.c @@ -244,6 +244,7 @@ ModifierTypeInfo modifierType_Smooth = { /* structSize */ sizeof(SmoothModifierData), /* type */ eModifierTypeType_OnlyDeform, /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_AcceptsCVs | eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c index 745cf1304bd..6f8e65a6e8e 100644 --- a/source/blender/modifiers/intern/MOD_solidify.c +++ b/source/blender/modifiers/intern/MOD_solidify.c @@ -435,7 +435,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, if (ofs_orig != 0.0f) { scalar_short = scalar_short_vgroup = ofs_orig / 32767.0f; - mv = mvert + (((ofs_new >= ofs_orig) == do_flip) ? 0 : numVerts); /* as above but swapped, intentional use 'ofs_new' */ + mv = mvert + (((ofs_new >= ofs_orig) == do_flip) ? 0 : numVerts); /* as above but swapped */ dv = dvert; for (i = 0; i < numVerts; i++, mv++) { if (dv) { diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c index 9f458678ae0..3d1b656fc4e 100644 --- a/source/blender/nodes/intern/node_common.c +++ b/source/blender/nodes/intern/node_common.c @@ -857,7 +857,7 @@ ListBase node_reroute_internal_connect(bNodeTree *ntree, bNode *node) ret.first = ret.last = NULL; /* Security check! */ - if(!ntree) + if (!ntree) return ret; link = MEM_callocN(sizeof(bNodeLink), "internal node link"); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c index e5dc64aca05..e3300c89a01 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c @@ -46,6 +46,10 @@ static void node_shader_init_tex_environment(bNodeTree *UNUSED(ntree), bNode* no default_color_mapping(&tex->base.color_mapping); tex->color_space = SHD_COLORSPACE_COLOR; tex->projection = SHD_PROJ_EQUIRECTANGULAR; + tex->iuser.frames= 1; + tex->iuser.sfra= 1; + tex->iuser.fie_ima= 2; + tex->iuser.ok= 1; node->storage = tex; } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c index db1c9081471..d4d43c1430c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c @@ -46,6 +46,10 @@ static void node_shader_init_tex_image(bNodeTree *UNUSED(ntree), bNode* node, bN default_tex_mapping(&tex->base.tex_mapping); default_color_mapping(&tex->base.color_mapping); tex->color_space = SHD_COLORSPACE_COLOR; + tex->iuser.frames= 1; + tex->iuser.sfra= 1; + tex->iuser.fie_ima= 2; + tex->iuser.ok= 1; node->storage = tex; } diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c index 6ca4ad15859..053dac71fe6 100644 --- a/source/blender/python/bmesh/bmesh_py_types.c +++ b/source/blender/python/bmesh/bmesh_py_types.c @@ -2099,7 +2099,7 @@ static struct PyMethodDef bpy_bmesh_methods[] = { {"select_flush_mode", (PyCFunction)bpy_bmesh_select_flush_mode, METH_NOARGS, bpy_bmesh_select_flush_mode_doc}, {"select_flush", (PyCFunction)bpy_bmesh_select_flush, METH_O, bpy_bmesh_select_flush_doc}, {"normal_update", (PyCFunction)bpy_bmesh_normal_update, METH_VARARGS, bpy_bmesh_normal_update_doc}, - {"transform", (PyCFunction)bpy_bmesh_transform, METH_VARARGS|METH_KEYWORDS, bpy_bmesh_transform_doc}, + {"transform", (PyCFunction)bpy_bmesh_transform, METH_VARARGS | METH_KEYWORDS, bpy_bmesh_transform_doc}, {NULL, NULL, 0, NULL} }; @@ -2141,7 +2141,7 @@ static struct PyMethodDef bpy_bmface_methods[] = { {"copy_from", (PyCFunction)bpy_bm_elem_copy_from, METH_O, bpy_bm_elem_copy_from_doc}, {"copy_from_face_interp", (PyCFunction)bpy_bmface_copy_from_face_interp, METH_O, bpy_bmface_copy_from_face_interp_doc}, - {"copy", (PyCFunction)bpy_bmface_copy, METH_VARARGS|METH_KEYWORDS, bpy_bmface_copy_doc}, + {"copy", (PyCFunction)bpy_bmface_copy, METH_VARARGS | METH_KEYWORDS, bpy_bmface_copy_doc}, {"calc_area", (PyCFunction)bpy_bmface_calc_area, METH_NOARGS, bpy_bmface_calc_area_doc}, {"calc_perimeter", (PyCFunction)bpy_bmface_calc_perimeter, METH_NOARGS, bpy_bmface_calc_perimeter_doc}, diff --git a/source/blender/python/intern/bpy_library.c b/source/blender/python/intern/bpy_library.c index 1d02acbe983..d34bdfe9448 100644 --- a/source/blender/python/intern/bpy_library.c +++ b/source/blender/python/intern/bpy_library.c @@ -170,18 +170,18 @@ static PyTypeObject bpy_lib_Type = { }; PyDoc_STRVAR(bpy_lib_load_doc, - ".. method:: load(filepath, link=False, relative=False)\n" - "\n" - " Returns a context manager which exposes 2 library objects on entering.\n" - " Each object has attributes matching bpy.data which are lists of strings to be linked.\n" - "\n" - " :arg filepath: The path to a blend file.\n" - " :type filepath: string\n" - " :arg link: When False reference to the original file is lost.\n" - " :type link: bool\n" - " :arg relative: When True the path is stored relative to the open blend file.\n" - " :type relative: bool\n" - ); +".. method:: load(filepath, link=False, relative=False)\n" +"\n" +" Returns a context manager which exposes 2 library objects on entering.\n" +" Each object has attributes matching bpy.data which are lists of strings to be linked.\n" +"\n" +" :arg filepath: The path to a blend file.\n" +" :type filepath: string\n" +" :arg link: When False reference to the original file is lost.\n" +" :type link: bool\n" +" :arg relative: When True the path is stored relative to the open blend file.\n" +" :type relative: bool\n" +); static PyObject *bpy_lib_load(PyObject *UNUSED(self), PyObject *args, PyObject *kwds) { static const char *kwlist[] = {"filepath", "link", "relative", NULL}; diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index c6bfeff1651..4d05b837952 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -807,6 +807,7 @@ PyDoc_STRVAR(M_Geometry_intersect_point_quad_2d_doc, "\n" " Takes 5 vectors (using only the x and y coordinates): one is the point and the next 4 define the quad, \n" " only the x and y are used from the vectors. Returns 1 if the point is within the quad, otherwise 0.\n" +" Works only with convex quads without singular edges." "\n" " :arg pt: Point\n" " :type pt: :class:`mathutils.Vector`\n" diff --git a/source/blender/render/intern/raytrace/rayobject_octree.cpp b/source/blender/render/intern/raytrace/rayobject_octree.cpp index dc7b6dd6e8d..538c5493282 100644 --- a/source/blender/render/intern/raytrace/rayobject_octree.cpp +++ b/source/blender/render/intern/raytrace/rayobject_octree.cpp @@ -51,18 +51,15 @@ #define BRANCH_ARRAY 1024 #define NODE_ARRAY 4096 -typedef struct Branch -{ +typedef struct Branch { struct Branch *b[8]; } Branch; -typedef struct OcVal -{ +typedef struct OcVal { short ocx, ocy, ocz; } OcVal; -typedef struct Node -{ +typedef struct Node { struct RayFace *v[8]; struct OcVal ov[8]; struct Node *next; @@ -73,7 +70,7 @@ typedef struct Octree { struct Branch **adrbranch; struct Node **adrnode; - float ocsize; /* ocsize: mult factor, max size octree */ + float ocsize; /* ocsize: mult factor, max size octree */ float ocfacx, ocfacy, ocfacz; float min[3], max[3]; int ocres; @@ -121,8 +118,8 @@ static RayObjectAPI octree_api = /* **************** ocval method ******************* */ /* within one octree node, a set of 3x15 bits defines a 'boundbox' to OR with */ -#define OCVALRES 15 -#define BROW16(min, max) (((max)>=OCVALRES? 0xFFFF: (1<<(max+1))-1) - ((min>0)? ((1<<(min))-1):0) ) +#define OCVALRES 15 +#define BROW16(min, max) (((max) >= OCVALRES ? 0xFFFF : (1 << (max + 1)) - 1) - ((min > 0) ? ((1 << (min)) - 1) : 0)) static void calc_ocval_face(float *v1, float *v2, float *v3, float *v4, short x, short y, short z, OcVal *ov) { @@ -137,17 +134,17 @@ static void calc_ocval_face(float *v1, float *v2, float *v3, float *v4, short x, DO_MINMAX(v4, min, max); } - ocmin= OCVALRES*(min[0]-x); - ocmax= OCVALRES*(max[0]-x); - ov->ocx= BROW16(ocmin, ocmax); - - ocmin= OCVALRES*(min[1]-y); - ocmax= OCVALRES*(max[1]-y); - ov->ocy= BROW16(ocmin, ocmax); - - ocmin= OCVALRES*(min[2]-z); - ocmax= OCVALRES*(max[2]-z); - ov->ocz= BROW16(ocmin, ocmax); + ocmin = OCVALRES * (min[0] - x); + ocmax = OCVALRES * (max[0] - x); + ov->ocx = BROW16(ocmin, ocmax); + + ocmin = OCVALRES * (min[1] - y); + ocmax = OCVALRES * (max[1] - y); + ov->ocy = BROW16(ocmin, ocmax); + + ocmin = OCVALRES * (min[2] - z); + ocmax = OCVALRES * (max[2] - z); + ov->ocz = BROW16(ocmin, ocmax); } @@ -155,35 +152,35 @@ static void calc_ocval_ray(OcVal *ov, float xo, float yo, float zo, float *vec1, { int ocmin, ocmax; - if (vec1[0]<vec2[0]) { - ocmin= OCVALRES*(vec1[0] - xo); - ocmax= OCVALRES*(vec2[0] - xo); + if (vec1[0] < vec2[0]) { + ocmin = OCVALRES * (vec1[0] - xo); + ocmax = OCVALRES * (vec2[0] - xo); } else { - ocmin= OCVALRES*(vec2[0] - xo); - ocmax= OCVALRES*(vec1[0] - xo); + ocmin = OCVALRES * (vec2[0] - xo); + ocmax = OCVALRES * (vec1[0] - xo); } - ov->ocx= BROW16(ocmin, ocmax); + ov->ocx = BROW16(ocmin, ocmax); - if (vec1[1]<vec2[1]) { - ocmin= OCVALRES*(vec1[1] - yo); - ocmax= OCVALRES*(vec2[1] - yo); + if (vec1[1] < vec2[1]) { + ocmin = OCVALRES * (vec1[1] - yo); + ocmax = OCVALRES * (vec2[1] - yo); } else { - ocmin= OCVALRES*(vec2[1] - yo); - ocmax= OCVALRES*(vec1[1] - yo); + ocmin = OCVALRES * (vec2[1] - yo); + ocmax = OCVALRES * (vec1[1] - yo); } - ov->ocy= BROW16(ocmin, ocmax); + ov->ocy = BROW16(ocmin, ocmax); - if (vec1[2]<vec2[2]) { - ocmin= OCVALRES*(vec1[2] - zo); - ocmax= OCVALRES*(vec2[2] - zo); + if (vec1[2] < vec2[2]) { + ocmin = OCVALRES * (vec1[2] - zo); + ocmax = OCVALRES * (vec2[2] - zo); } else { - ocmin= OCVALRES*(vec2[2] - zo); - ocmax= OCVALRES*(vec1[2] - zo); + ocmin = OCVALRES * (vec2[2] - zo); + ocmax = OCVALRES * (vec1[2] - zo); } - ov->ocz= BROW16(ocmin, ocmax); + ov->ocz = BROW16(ocmin, ocmax); } /* ************* octree ************** */ @@ -195,17 +192,17 @@ static Branch *addbranch(Octree *oc, Branch *br, short ocb) if (br->b[ocb]) return br->b[ocb]; oc->branchcount++; - index= oc->branchcount>>12; + index = oc->branchcount >> 12; - if (oc->adrbranch[index]==NULL) - oc->adrbranch[index]= (Branch*)MEM_callocN(4096*sizeof(Branch), "new oc branch"); + if (oc->adrbranch[index] == NULL) + oc->adrbranch[index] = (Branch *)MEM_callocN(4096 * sizeof(Branch), "new oc branch"); - if (oc->branchcount>= BRANCH_ARRAY*4096) { + if (oc->branchcount >= BRANCH_ARRAY * 4096) { printf("error; octree branches full\n"); - oc->branchcount=0; + oc->branchcount = 0; } - return br->b[ocb]= oc->adrbranch[index]+(oc->branchcount & 4095); + return br->b[ocb] = oc->adrbranch[index] + (oc->branchcount & 4095); } static Node *addnode(Octree *oc) @@ -213,17 +210,17 @@ static Node *addnode(Octree *oc) int index; oc->nodecount++; - index= oc->nodecount>>12; + index = oc->nodecount >> 12; - if (oc->adrnode[index]==NULL) - oc->adrnode[index]= (Node*)MEM_callocN(4096*sizeof(Node), "addnode"); + if (oc->adrnode[index] == NULL) + oc->adrnode[index] = (Node *)MEM_callocN(4096 * sizeof(Node), "addnode"); - if (oc->nodecount> NODE_ARRAY*NODE_ARRAY) { + if (oc->nodecount > NODE_ARRAY * NODE_ARRAY) { printf("error; octree nodes full\n"); - oc->nodecount=0; + oc->nodecount = 0; } - return oc->adrnode[index]+(oc->nodecount & 4095); + return oc->adrnode[index] + (oc->nodecount & 4095); } static int face_in_node(RayFace *face, short x, short y, short z, float rtf[][3]) @@ -234,33 +231,33 @@ static int face_in_node(RayFace *face, short x, short y, short z, float rtf[][3] // init static vars if (face) { normal_tri_v3(nor, rtf[0], rtf[1], rtf[2]); - d= -nor[0]*rtf[0][0] - nor[1]*rtf[0][1] - nor[2]*rtf[0][2]; + d = -nor[0] * rtf[0][0] - nor[1] * rtf[0][1] - nor[2] * rtf[0][2]; return 0; } - fx= x; - fy= y; - fz= z; - - if ((fx)*nor[0] + (fy)*nor[1] + (fz)*nor[2] + d > 0.0f) { - if ((fx+1)*nor[0] + (fy )*nor[1] + (fz )*nor[2] + d < 0.0f) return 1; - if ((fx )*nor[0] + (fy+1)*nor[1] + (fz )*nor[2] + d < 0.0f) return 1; - if ((fx+1)*nor[0] + (fy+1)*nor[1] + (fz )*nor[2] + d < 0.0f) return 1; - - if ((fx )*nor[0] + (fy )*nor[1] + (fz+1)*nor[2] + d < 0.0f) return 1; - if ((fx+1)*nor[0] + (fy )*nor[1] + (fz+1)*nor[2] + d < 0.0f) return 1; - if ((fx )*nor[0] + (fy+1)*nor[1] + (fz+1)*nor[2] + d < 0.0f) return 1; - if ((fx+1)*nor[0] + (fy+1)*nor[1] + (fz+1)*nor[2] + d < 0.0f) return 1; + fx = x; + fy = y; + fz = z; + + if ((fx) * nor[0] + (fy) * nor[1] + (fz) * nor[2] + d > 0.0f) { + if ((fx + 1) * nor[0] + (fy ) * nor[1] + (fz ) * nor[2] + d < 0.0f) return 1; + if ((fx ) * nor[0] + (fy + 1) * nor[1] + (fz ) * nor[2] + d < 0.0f) return 1; + if ((fx + 1) * nor[0] + (fy + 1) * nor[1] + (fz ) * nor[2] + d < 0.0f) return 1; + + if ((fx ) * nor[0] + (fy ) * nor[1] + (fz + 1) * nor[2] + d < 0.0f) return 1; + if ((fx + 1) * nor[0] + (fy ) * nor[1] + (fz + 1) * nor[2] + d < 0.0f) return 1; + if ((fx ) * nor[0] + (fy + 1) * nor[1] + (fz + 1) * nor[2] + d < 0.0f) return 1; + if ((fx + 1) * nor[0] + (fy + 1) * nor[1] + (fz + 1) * nor[2] + d < 0.0f) return 1; } else { - if ((fx+1)*nor[0] + (fy )*nor[1] + (fz )*nor[2] + d > 0.0f) return 1; - if ((fx )*nor[0] + (fy+1)*nor[1] + (fz )*nor[2] + d > 0.0f) return 1; - if ((fx+1)*nor[0] + (fy+1)*nor[1] + (fz )*nor[2] + d > 0.0f) return 1; - - if ((fx )*nor[0] + (fy )*nor[1] + (fz+1)*nor[2] + d > 0.0f) return 1; - if ((fx+1)*nor[0] + (fy )*nor[1] + (fz+1)*nor[2] + d > 0.0f) return 1; - if ((fx )*nor[0] + (fy+1)*nor[1] + (fz+1)*nor[2] + d > 0.0f) return 1; - if ((fx+1)*nor[0] + (fy+1)*nor[1] + (fz+1)*nor[2] + d > 0.0f) return 1; + if ((fx + 1) * nor[0] + (fy ) * nor[1] + (fz ) * nor[2] + d > 0.0f) return 1; + if ((fx ) * nor[0] + (fy + 1) * nor[1] + (fz ) * nor[2] + d > 0.0f) return 1; + if ((fx + 1) * nor[0] + (fy + 1) * nor[1] + (fz ) * nor[2] + d > 0.0f) return 1; + + if ((fx ) * nor[0] + (fy ) * nor[1] + (fz + 1) * nor[2] + d > 0.0f) return 1; + if ((fx + 1) * nor[0] + (fy ) * nor[1] + (fz + 1) * nor[2] + d > 0.0f) return 1; + if ((fx ) * nor[0] + (fy + 1) * nor[1] + (fz + 1) * nor[2] + d > 0.0f) return 1; + if ((fx + 1) * nor[0] + (fy + 1) * nor[1] + (fz + 1) * nor[2] + d > 0.0f) return 1; } return 0; @@ -272,163 +269,163 @@ static void ocwrite(Octree *oc, RayFace *face, int quad, short x, short y, short Node *no; short a, oc0, oc1, oc2, oc3, oc4, oc5; - x<<=2; - y<<=1; + x <<= 2; + y <<= 1; - br= oc->adrbranch[0]; + br = oc->adrbranch[0]; - if (oc->ocres==512) { - oc0= ((x & 1024)+(y & 512)+(z & 256))>>8; - br= addbranch(oc, br, oc0); + if (oc->ocres == 512) { + oc0 = ((x & 1024) + (y & 512) + (z & 256)) >> 8; + br = addbranch(oc, br, oc0); } - if (oc->ocres>=256) { - oc0= ((x & 512)+(y & 256)+(z & 128))>>7; - br= addbranch(oc, br, oc0); + if (oc->ocres >= 256) { + oc0 = ((x & 512) + (y & 256) + (z & 128)) >> 7; + br = addbranch(oc, br, oc0); } - if (oc->ocres>=128) { - oc0= ((x & 256)+(y & 128)+(z & 64))>>6; - br= addbranch(oc, br, oc0); + if (oc->ocres >= 128) { + oc0 = ((x & 256) + (y & 128) + (z & 64)) >> 6; + br = addbranch(oc, br, oc0); } - oc0= ((x & 128)+(y & 64)+(z & 32))>>5; - oc1= ((x & 64)+(y & 32)+(z & 16))>>4; - oc2= ((x & 32)+(y & 16)+(z & 8))>>3; - oc3= ((x & 16)+(y & 8)+(z & 4))>>2; - oc4= ((x & 8)+(y & 4)+(z & 2))>>1; - oc5= ((x & 4)+(y & 2)+(z & 1)); - - br= addbranch(oc, br, oc0); - br= addbranch(oc, br, oc1); - br= addbranch(oc, br, oc2); - br= addbranch(oc, br, oc3); - br= addbranch(oc, br, oc4); - no= (Node *)br->b[oc5]; - if (no==NULL) br->b[oc5]= (Branch *)(no= addnode(oc)); + oc0 = ((x & 128) + (y & 64) + (z & 32)) >> 5; + oc1 = ((x & 64) + (y & 32) + (z & 16)) >> 4; + oc2 = ((x & 32) + (y & 16) + (z & 8)) >> 3; + oc3 = ((x & 16) + (y & 8) + (z & 4)) >> 2; + oc4 = ((x & 8) + (y & 4) + (z & 2)) >> 1; + oc5 = ((x & 4) + (y & 2) + (z & 1)); + + br = addbranch(oc, br, oc0); + br = addbranch(oc, br, oc1); + br = addbranch(oc, br, oc2); + br = addbranch(oc, br, oc3); + br = addbranch(oc, br, oc4); + no = (Node *)br->b[oc5]; + if (no == NULL) br->b[oc5] = (Branch *)(no = addnode(oc)); while (no->next) no = no->next; - a= 0; - if (no->v[7]) { /* node full */ - no->next= addnode(oc); - no= no->next; + a = 0; + if (no->v[7]) { /* node full */ + no->next = addnode(oc); + no = no->next; } else { while (no->v[a] != NULL) a++; } - no->v[a]= (RayFace*) RE_rayobject_align(face); + no->v[a] = (RayFace *) RE_rayobject_align(face); if (quad) - calc_ocval_face(rtf[0], rtf[1], rtf[2], rtf[3], x>>2, y>>1, z, &no->ov[a]); + calc_ocval_face(rtf[0], rtf[1], rtf[2], rtf[3], x >> 2, y >> 1, z, &no->ov[a]); else - calc_ocval_face(rtf[0], rtf[1], rtf[2], NULL, x>>2, y>>1, z, &no->ov[a]); + calc_ocval_face(rtf[0], rtf[1], rtf[2], NULL, x >> 2, y >> 1, z, &no->ov[a]); } static void d2dda(Octree *oc, short b1, short b2, short c1, short c2, char *ocface, short rts[][3], float rtf[][3]) { int ocx1, ocx2, ocy1, ocy2; - int x, y, dx=0, dy=0; + int x, y, dx = 0, dy = 0; float ox1, ox2, oy1, oy2; float labda, labdao, labdax, labday, ldx, ldy; - ocx1= rts[b1][c1]; - ocy1= rts[b1][c2]; - ocx2= rts[b2][c1]; - ocy2= rts[b2][c2]; + ocx1 = rts[b1][c1]; + ocy1 = rts[b1][c2]; + ocx2 = rts[b2][c1]; + ocy2 = rts[b2][c2]; - if (ocx1==ocx2 && ocy1==ocy2) { - ocface[oc->ocres*ocx1+ocy1]= 1; + if (ocx1 == ocx2 && ocy1 == ocy2) { + ocface[oc->ocres * ocx1 + ocy1] = 1; return; } - ox1= rtf[b1][c1]; - oy1= rtf[b1][c2]; - ox2= rtf[b2][c1]; - oy2= rtf[b2][c2]; + ox1 = rtf[b1][c1]; + oy1 = rtf[b1][c2]; + ox2 = rtf[b2][c1]; + oy2 = rtf[b2][c2]; - if (ox1!=ox2) { - if (ox2-ox1>0.0f) { - labdax= (ox1-ocx1-1.0f)/(ox1-ox2); - ldx= -1.0f/(ox1-ox2); - dx= 1; + if (ox1 != ox2) { + if (ox2 - ox1 > 0.0f) { + labdax = (ox1 - ocx1 - 1.0f) / (ox1 - ox2); + ldx = -1.0f / (ox1 - ox2); + dx = 1; } else { - labdax= (ox1-ocx1)/(ox1-ox2); - ldx= 1.0f/(ox1-ox2); - dx= -1; + labdax = (ox1 - ocx1) / (ox1 - ox2); + ldx = 1.0f / (ox1 - ox2); + dx = -1; } } else { - labdax=1.0f; - ldx=0; + labdax = 1.0f; + ldx = 0; } - if (oy1!=oy2) { - if (oy2-oy1>0.0f) { - labday= (oy1-ocy1-1.0f)/(oy1-oy2); - ldy= -1.0f/(oy1-oy2); - dy= 1; + if (oy1 != oy2) { + if (oy2 - oy1 > 0.0f) { + labday = (oy1 - ocy1 - 1.0f) / (oy1 - oy2); + ldy = -1.0f / (oy1 - oy2); + dy = 1; } else { - labday= (oy1-ocy1)/(oy1-oy2); - ldy= 1.0f/(oy1-oy2); - dy= -1; + labday = (oy1 - ocy1) / (oy1 - oy2); + ldy = 1.0f / (oy1 - oy2); + dy = -1; } } else { - labday=1.0f; - ldy=0; + labday = 1.0f; + ldy = 0; } - x=ocx1; y=ocy1; - labda= MIN2(labdax, labday); + x = ocx1; y = ocy1; + labda = MIN2(labdax, labday); while (TRUE) { - if (x<0 || y<0 || x>=oc->ocres || y>=oc->ocres); - else ocface[oc->ocres*x+y]= 1; + if (x < 0 || y < 0 || x >= oc->ocres || y >= oc->ocres) ; + else ocface[oc->ocres * x + y] = 1; - labdao=labda; - if (labdax==labday) { - labdax+=ldx; - x+=dx; - labday+=ldy; - y+=dy; + labdao = labda; + if (labdax == labday) { + labdax += ldx; + x += dx; + labday += ldy; + y += dy; } else { - if (labdax<labday) { - labdax+=ldx; - x+=dx; + if (labdax < labday) { + labdax += ldx; + x += dx; } else { - labday+=ldy; - y+=dy; + labday += ldy; + y += dy; } } - labda=MIN2(labdax, labday); - if (labda==labdao) break; - if (labda>=1.0f) break; + labda = MIN2(labdax, labday); + if (labda == labdao) break; + if (labda >= 1.0f) break; } - ocface[oc->ocres*ocx2+ocy2]=1; + ocface[oc->ocres * ocx2 + ocy2] = 1; } static void filltriangle(Octree *oc, short c1, short c2, char *ocface, short *ocmin, short *ocmax) { int a, x, y, y1, y2; - for (x=ocmin[c1];x<=ocmax[c1];x++) { - a= oc->ocres*x; - for (y=ocmin[c2];y<=ocmax[c2];y++) { - if (ocface[a+y]) { + for (x = ocmin[c1]; x <= ocmax[c1]; x++) { + a = oc->ocres * x; + for (y = ocmin[c2]; y <= ocmax[c2]; y++) { + if (ocface[a + y]) { y++; - while (ocface[a+y] && y!=ocmax[c2]) y++; - for (y1=ocmax[c2];y1>y;y1--) { - if (ocface[a+y1]) { - for (y2=y;y2<=y1;y2++) ocface[a+y2]=1; - y1=0; + while (ocface[a + y] && y != ocmax[c2]) y++; + for (y1 = ocmax[c2]; y1 > y; y1--) { + if (ocface[a + y1]) { + for (y2 = y; y2 <= y1; y2++) ocface[a + y2] = 1; + y1 = 0; } } - y=ocmax[c2]; + y = ocmax[c2]; } } } @@ -436,7 +433,7 @@ static void filltriangle(Octree *oc, short c1, short c2, char *ocface, short *oc static void RE_rayobject_octree_free(RayObject *tree) { - Octree *oc= (Octree*)tree; + Octree *oc = (Octree *)tree; #if 0 printf("branches %d nodes %d\n", oc->branchcount, oc->nodecount); @@ -448,28 +445,28 @@ static void RE_rayobject_octree_free(RayObject *tree) MEM_freeN(oc->ocface); if (oc->adrbranch) { - int a= 0; + int a = 0; while (oc->adrbranch[a]) { MEM_freeN(oc->adrbranch[a]); - oc->adrbranch[a]= NULL; + oc->adrbranch[a] = NULL; a++; } MEM_freeN(oc->adrbranch); - oc->adrbranch= NULL; + oc->adrbranch = NULL; } - oc->branchcount= 0; + oc->branchcount = 0; if (oc->adrnode) { - int a= 0; + int a = 0; while (oc->adrnode[a]) { MEM_freeN(oc->adrnode[a]); - oc->adrnode[a]= NULL; + oc->adrnode[a] = NULL; a++; } MEM_freeN(oc->adrnode); - oc->adrnode= NULL; + oc->adrnode = NULL; } - oc->nodecount= 0; + oc->nodecount = 0; MEM_freeN(oc); } @@ -477,29 +474,29 @@ static void RE_rayobject_octree_free(RayObject *tree) RayObject *RE_rayobject_octree_create(int ocres, int size) { - Octree *oc= (Octree*)MEM_callocN(sizeof(Octree), "Octree"); - assert( RE_rayobject_isAligned(oc) ); /* RayObject API assumes real data to be 4-byte aligned */ + Octree *oc = (Octree *)MEM_callocN(sizeof(Octree), "Octree"); + assert(RE_rayobject_isAligned(oc) ); /* RayObject API assumes real data to be 4-byte aligned */ oc->rayobj.api = &octree_api; oc->ocres = ocres; - oc->ro_nodes = (RayFace**)MEM_callocN(sizeof(RayFace*)*size, "octree rayobject nodes"); + oc->ro_nodes = (RayFace **)MEM_callocN(sizeof(RayFace *) * size, "octree rayobject nodes"); oc->ro_nodes_size = size; oc->ro_nodes_used = 0; - return RE_rayobject_unalignRayAPI((RayObject*) oc); + return RE_rayobject_unalignRayAPI((RayObject *) oc); } static void RE_rayobject_octree_add(RayObject *tree, RayObject *node) { - Octree *oc = (Octree*)tree; + Octree *oc = (Octree *)tree; - assert( RE_rayobject_isRayFace(node) ); - assert( oc->ro_nodes_used < oc->ro_nodes_size ); - oc->ro_nodes[ oc->ro_nodes_used++ ] = (RayFace*)RE_rayobject_align(node); + assert(RE_rayobject_isRayFace(node) ); + assert(oc->ro_nodes_used < oc->ro_nodes_size); + oc->ro_nodes[oc->ro_nodes_used++] = (RayFace *)RE_rayobject_align(node); } static void octree_fill_rayface(Octree *oc, RayFace *face) @@ -508,14 +505,14 @@ static void octree_fill_rayface(Octree *oc, RayFace *face) float co1[3], co2[3], co3[3], co4[3]; short rts[4][3]; short ocmin[3], ocmax[3]; - char *ocface= oc->ocface; // front, top, size view of face, to fill in + char *ocface = oc->ocface; // front, top, size view of face, to fill in int a, b, c, oc1, oc2, oc3, oc4, x, y, z, ocres2; - ocfac[0]= oc->ocfacx; - ocfac[1]= oc->ocfacy; - ocfac[2]= oc->ocfacz; + ocfac[0] = oc->ocfacx; + ocfac[1] = oc->ocfacy; + ocfac[2] = oc->ocfacz; - ocres2= oc->ocres*oc->ocres; + ocres2 = oc->ocres * oc->ocres; copy_v3_v3(co1, face->v1); copy_v3_v3(co2, face->v2); @@ -523,7 +520,7 @@ static void octree_fill_rayface(Octree *oc, RayFace *face) if (face->v4) copy_v3_v3(co4, face->v4); - for (c=0;c<3;c++) { + for (c = 0; c < 3; c++) { rtf[0][c] = (co1[c] - oc->min[c]) * ocfac[c]; rts[0][c] = (short)rtf[0][c]; rtf[1][c] = (co2[c] - oc->min[c]) * ocfac[c]; @@ -536,62 +533,62 @@ static void octree_fill_rayface(Octree *oc, RayFace *face) } } - for (c=0;c<3;c++) { - oc1= rts[0][c]; - oc2= rts[1][c]; - oc3= rts[2][c]; + for (c = 0; c < 3; c++) { + oc1 = rts[0][c]; + oc2 = rts[1][c]; + oc3 = rts[2][c]; if (!RE_rayface_isQuad(face)) { - ocmin[c]= MIN3(oc1, oc2, oc3); - ocmax[c]= MAX3(oc1, oc2, oc3); + ocmin[c] = MIN3(oc1, oc2, oc3); + ocmax[c] = MAX3(oc1, oc2, oc3); } else { - oc4= rts[3][c]; - ocmin[c]= MIN4(oc1, oc2, oc3, oc4); - ocmax[c]= MAX4(oc1, oc2, oc3, oc4); + oc4 = rts[3][c]; + ocmin[c] = MIN4(oc1, oc2, oc3, oc4); + ocmax[c] = MAX4(oc1, oc2, oc3, oc4); } - if (ocmax[c]>oc->ocres-1) ocmax[c]=oc->ocres-1; - if (ocmin[c]<0) ocmin[c]=0; + if (ocmax[c] > oc->ocres - 1) ocmax[c] = oc->ocres - 1; + if (ocmin[c] < 0) ocmin[c] = 0; } - if (ocmin[0]==ocmax[0] && ocmin[1]==ocmax[1] && ocmin[2]==ocmax[2]) { + if (ocmin[0] == ocmax[0] && ocmin[1] == ocmax[1] && ocmin[2] == ocmax[2]) { ocwrite(oc, face, RE_rayface_isQuad(face), ocmin[0], ocmin[1], ocmin[2], rtf); } else { - d2dda(oc, 0, 1, 0, 1, ocface+ocres2, rts, rtf); + d2dda(oc, 0, 1, 0, 1, ocface + ocres2, rts, rtf); d2dda(oc, 0, 1, 0, 2, ocface, rts, rtf); - d2dda(oc, 0, 1, 1, 2, ocface+2*ocres2, rts, rtf); - d2dda(oc, 1, 2, 0, 1, ocface+ocres2, rts, rtf); + d2dda(oc, 0, 1, 1, 2, ocface + 2 * ocres2, rts, rtf); + d2dda(oc, 1, 2, 0, 1, ocface + ocres2, rts, rtf); d2dda(oc, 1, 2, 0, 2, ocface, rts, rtf); - d2dda(oc, 1, 2, 1, 2, ocface+2*ocres2, rts, rtf); + d2dda(oc, 1, 2, 1, 2, ocface + 2 * ocres2, rts, rtf); if (!RE_rayface_isQuad(face)) { - d2dda(oc, 2, 0, 0, 1, ocface+ocres2, rts, rtf); + d2dda(oc, 2, 0, 0, 1, ocface + ocres2, rts, rtf); d2dda(oc, 2, 0, 0, 2, ocface, rts, rtf); - d2dda(oc, 2, 0, 1, 2, ocface+2*ocres2, rts, rtf); + d2dda(oc, 2, 0, 1, 2, ocface + 2 * ocres2, rts, rtf); } else { - d2dda(oc, 2, 3, 0, 1, ocface+ocres2, rts, rtf); + d2dda(oc, 2, 3, 0, 1, ocface + ocres2, rts, rtf); d2dda(oc, 2, 3, 0, 2, ocface, rts, rtf); - d2dda(oc, 2, 3, 1, 2, ocface+2*ocres2, rts, rtf); - d2dda(oc, 3, 0, 0, 1, ocface+ocres2, rts, rtf); + d2dda(oc, 2, 3, 1, 2, ocface + 2 * ocres2, rts, rtf); + d2dda(oc, 3, 0, 0, 1, ocface + ocres2, rts, rtf); d2dda(oc, 3, 0, 0, 2, ocface, rts, rtf); - d2dda(oc, 3, 0, 1, 2, ocface+2*ocres2, rts, rtf); + d2dda(oc, 3, 0, 1, 2, ocface + 2 * ocres2, rts, rtf); } /* nothing todo with triangle..., just fills :) */ - filltriangle(oc, 0, 1, ocface+ocres2, ocmin, ocmax); + filltriangle(oc, 0, 1, ocface + ocres2, ocmin, ocmax); filltriangle(oc, 0, 2, ocface, ocmin, ocmax); - filltriangle(oc, 1, 2, ocface+2*ocres2, ocmin, ocmax); + filltriangle(oc, 1, 2, ocface + 2 * ocres2, ocmin, ocmax); /* init static vars here */ face_in_node(face, 0, 0, 0, rtf); - for (x=ocmin[0];x<=ocmax[0];x++) { - a= oc->ocres*x; - for (y=ocmin[1];y<=ocmax[1];y++) { - if (ocface[a+y+ocres2]) { - b= oc->ocres*y+2*ocres2; - for (z=ocmin[2];z<=ocmax[2];z++) { - if (ocface[b+z] && ocface[a+z]) { + for (x = ocmin[0]; x <= ocmax[0]; x++) { + a = oc->ocres * x; + for (y = ocmin[1]; y <= ocmax[1]; y++) { + if (ocface[a + y + ocres2]) { + b = oc->ocres * y + 2 * ocres2; + for (z = ocmin[2]; z <= ocmax[2]; z++) { + if (ocface[b + z] && ocface[a + z]) { if (face_in_node(NULL, x, y, z, rtf)) ocwrite(oc, face, RE_rayface_isQuad(face), x, y, z, rtf); } @@ -601,18 +598,18 @@ static void octree_fill_rayface(Octree *oc, RayFace *face) } /* same loops to clear octree, doubt it can be done smarter */ - for (x=ocmin[0];x<=ocmax[0];x++) { - a= oc->ocres*x; - for (y=ocmin[1];y<=ocmax[1];y++) { + for (x = ocmin[0]; x <= ocmax[0]; x++) { + a = oc->ocres * x; + for (y = ocmin[1]; y <= ocmax[1]; y++) { /* x-y */ - ocface[a+y+ocres2]= 0; + ocface[a + y + ocres2] = 0; - b= oc->ocres*y + 2*ocres2; - for (z=ocmin[2];z<=ocmax[2];z++) { + b = oc->ocres * y + 2 * ocres2; + for (z = ocmin[2]; z <= ocmax[2]; z++) { /* y-z */ - ocface[b+z]= 0; + ocface[b + z] = 0; /* x-z */ - ocface[a+z]= 0; + ocface[a + z] = 0; } } } @@ -621,44 +618,44 @@ static void octree_fill_rayface(Octree *oc, RayFace *face) static void RE_rayobject_octree_done(RayObject *tree) { - Octree *oc = (Octree*)tree; + Octree *oc = (Octree *)tree; int c; float t00, t01, t02; - int ocres2 = oc->ocres*oc->ocres; + int ocres2 = oc->ocres * oc->ocres; INIT_MINMAX(oc->min, oc->max); /* Calculate Bounding Box */ - for (c=0; c<oc->ro_nodes_used; c++) - RE_rayobject_merge_bb( RE_rayobject_unalignRayFace(oc->ro_nodes[c]), oc->min, oc->max); + for (c = 0; c < oc->ro_nodes_used; c++) + RE_rayobject_merge_bb(RE_rayobject_unalignRayFace(oc->ro_nodes[c]), oc->min, oc->max); /* Alloc memory */ - oc->adrbranch= (Branch**)MEM_callocN(sizeof(void *)*BRANCH_ARRAY, "octree branches"); - oc->adrnode= (Node**)MEM_callocN(sizeof(void *)*NODE_ARRAY, "octree nodes"); + oc->adrbranch = (Branch **)MEM_callocN(sizeof(void *) * BRANCH_ARRAY, "octree branches"); + oc->adrnode = (Node **)MEM_callocN(sizeof(void *) * NODE_ARRAY, "octree nodes"); - oc->adrbranch[0]=(Branch *)MEM_callocN(4096*sizeof(Branch), "makeoctree"); + oc->adrbranch[0] = (Branch *)MEM_callocN(4096 * sizeof(Branch), "makeoctree"); /* the lookup table, per face, for which nodes to fill in */ - oc->ocface= (char*)MEM_callocN( 3*ocres2 + 8, "ocface"); - memset(oc->ocface, 0, 3*ocres2); + oc->ocface = (char *)MEM_callocN(3 * ocres2 + 8, "ocface"); + memset(oc->ocface, 0, 3 * ocres2); - for (c=0;c<3;c++) { /* octree enlarge, still needed? */ - oc->min[c]-= 0.01f; - oc->max[c]+= 0.01f; + for (c = 0; c < 3; c++) { /* octree enlarge, still needed? */ + oc->min[c] -= 0.01f; + oc->max[c] += 0.01f; } - t00= oc->max[0]-oc->min[0]; - t01= oc->max[1]-oc->min[1]; - t02= oc->max[2]-oc->min[2]; + t00 = oc->max[0] - oc->min[0]; + t01 = oc->max[1] - oc->min[1]; + t02 = oc->max[2] - oc->min[2]; /* this minus 0.1 is old safety... seems to be needed? */ - oc->ocfacx= (oc->ocres-0.1)/t00; - oc->ocfacy= (oc->ocres-0.1)/t01; - oc->ocfacz= (oc->ocres-0.1)/t02; + oc->ocfacx = (oc->ocres - 0.1) / t00; + oc->ocfacy = (oc->ocres - 0.1) / t01; + oc->ocfacz = (oc->ocres - 0.1) / t02; - oc->ocsize= sqrt(t00*t00+t01*t01+t02*t02); /* global, max size octree */ + oc->ocsize = sqrt(t00 * t00 + t01 * t01 + t02 * t02); /* global, max size octree */ - for (c=0; c<oc->ro_nodes_used; c++) { + for (c = 0; c < oc->ro_nodes_used; c++) { octree_fill_rayface(oc, oc->ro_nodes[c]); } @@ -667,14 +664,14 @@ static void RE_rayobject_octree_done(RayObject *tree) MEM_freeN(oc->ro_nodes); oc->ro_nodes = NULL; - printf("%f %f - %f\n", oc->min[0], oc->max[0], oc->ocfacx ); - printf("%f %f - %f\n", oc->min[1], oc->max[1], oc->ocfacy ); - printf("%f %f - %f\n", oc->min[2], oc->max[2], oc->ocfacz ); + printf("%f %f - %f\n", oc->min[0], oc->max[0], oc->ocfacx); + printf("%f %f - %f\n", oc->min[1], oc->max[1], oc->ocfacy); + printf("%f %f - %f\n", oc->min[2], oc->max[2], oc->ocfacz); } static void RE_rayobject_octree_bb(RayObject *tree, float *min, float *max) { - Octree *oc = (Octree*)tree; + Octree *oc = (Octree *)tree; DO_MINMAX(oc->min, min, max); DO_MINMAX(oc->max, min, max); } @@ -687,7 +684,7 @@ static int testnode(Octree *UNUSED(oc), Isect *is, Node *no, OcVal ocval) /* return on any first hit */ if (is->mode == RE_RAY_SHADOW) { - for ( ; no; no = no->next) { + for (; no; no = no->next) { for (nr = 0; nr < 8; nr++) { RayFace *face = no->v[nr]; OcVal *ov = no->ov + nr; @@ -695,7 +692,7 @@ static int testnode(Octree *UNUSED(oc), Isect *is, Node *no, OcVal ocval) if (!face) break; if ( (ov->ocx & ocval.ocx) && (ov->ocy & ocval.ocy) && (ov->ocz & ocval.ocz) ) { - if ( RE_rayobject_intersect( RE_rayobject_unalignRayFace(face), is) ) + if (RE_rayobject_intersect(RE_rayobject_unalignRayFace(face), is) ) return 1; } } @@ -703,9 +700,9 @@ static int testnode(Octree *UNUSED(oc), Isect *is, Node *no, OcVal ocval) } else { /* else mirror or glass or shadowtra, return closest face */ - int found= 0; + int found = 0; - for ( ; no; no = no->next) { + for (; no; no = no->next) { for (nr = 0; nr < 8; nr++) { RayFace *face = no->v[nr]; OcVal *ov = no->ov + nr; @@ -713,7 +710,7 @@ static int testnode(Octree *UNUSED(oc), Isect *is, Node *no, OcVal ocval) if (!face) break; if ( (ov->ocx & ocval.ocx) && (ov->ocy & ocval.ocy) && (ov->ocz & ocval.ocz) ) { - if ( RE_rayobject_intersect( RE_rayobject_unalignRayFace(face), is) ) { + if (RE_rayobject_intersect(RE_rayobject_unalignRayFace(face), is) ) { found = 1; } } @@ -732,49 +729,49 @@ static Node *ocread(Octree *oc, int x, int y, int z) Branch *br; int oc1; - x<<=2; - y<<=1; + x <<= 2; + y <<= 1; - br= oc->adrbranch[0]; + br = oc->adrbranch[0]; - if (oc->ocres==512) { - oc1= ((x & 1024)+(y & 512)+(z & 256))>>8; - br= br->b[oc1]; - if (br==NULL) { + if (oc->ocres == 512) { + oc1 = ((x & 1024) + (y & 512) + (z & 256)) >> 8; + br = br->b[oc1]; + if (br == NULL) { return NULL; } } - if (oc->ocres>=256) { - oc1= ((x & 512)+(y & 256)+(z & 128))>>7; - br= br->b[oc1]; - if (br==NULL) { + if (oc->ocres >= 256) { + oc1 = ((x & 512) + (y & 256) + (z & 128)) >> 7; + br = br->b[oc1]; + if (br == NULL) { return NULL; } } - if (oc->ocres>=128) { - oc1= ((x & 256)+(y & 128)+(z & 64))>>6; - br= br->b[oc1]; - if (br==NULL) { + if (oc->ocres >= 128) { + oc1 = ((x & 256) + (y & 128) + (z & 64)) >> 6; + br = br->b[oc1]; + if (br == NULL) { return NULL; } } - oc1= ((x & 128)+(y & 64)+(z & 32))>>5; - br= br->b[oc1]; + oc1 = ((x & 128) + (y & 64) + (z & 32)) >> 5; + br = br->b[oc1]; if (br) { - oc1= ((x & 64)+(y & 32)+(z & 16))>>4; - br= br->b[oc1]; + oc1 = ((x & 64) + (y & 32) + (z & 16)) >> 4; + br = br->b[oc1]; if (br) { - oc1= ((x & 32)+(y & 16)+(z & 8))>>3; - br= br->b[oc1]; + oc1 = ((x & 32) + (y & 16) + (z & 8)) >> 3; + br = br->b[oc1]; if (br) { - oc1= ((x & 16)+(y & 8)+(z & 4))>>2; - br= br->b[oc1]; + oc1 = ((x & 16) + (y & 8) + (z & 4)) >> 2; + br = br->b[oc1]; if (br) { - oc1= ((x & 8)+(y & 4)+(z & 2))>>1; - br= br->b[oc1]; + oc1 = ((x & 8) + (y & 4) + (z & 2)) >> 1; + br = br->b[oc1]; if (br) { - oc1= ((x & 4)+(y & 2)+(z & 1)); + oc1 = ((x & 4) + (y & 2) + (z & 1)); return (Node *)br->b[oc1]; } } @@ -789,24 +786,24 @@ static int cliptest(float p, float q, float *u1, float *u2) { float r; - if (p<0.0f) { - if (q<p) return 0; - else if (q<0.0f) { - r= q/p; - if (r>*u2) return 0; - else if (r>*u1) *u1=r; + if (p < 0.0f) { + if (q < p) return 0; + else if (q < 0.0f) { + r = q / p; + if (r > *u2) return 0; + else if (r > *u1) *u1 = r; } } else { - if (p>0.0f) { - if (q<0.0f) return 0; - else if (q<p) { - r= q/p; - if (r<*u1) return 0; - else if (r<*u2) *u2=r; + if (p > 0.0f) { + if (q < 0.0f) return 0; + else if (q < p) { + r = q / p; + if (r < *u1) return 0; + else if (r < *u2) *u2 = r; } } - else if (q<0.0f) return 0; + else if (q < 0.0f) return 0; } return 1; } @@ -816,16 +813,16 @@ static int cliptest(float p, float q, float *u1, float *u2) #if 0 -in top: static int coh_nodes[16*16*16][6]; -in makeoctree: memset(coh_nodes, 0, sizeof(coh_nodes)); +in top : static int coh_nodes[16 * 16 * 16][6]; +in makeoctree : memset(coh_nodes, 0, sizeof(coh_nodes)); static void add_coherence_test(int ocx1, int ocx2, int ocy1, int ocy2, int ocz1, int ocz2) { short *sp; - sp= coh_nodes[ (ocx2 & 15) + 16*(ocy2 & 15) + 256*(ocz2 & 15) ]; - sp[0]= ocx1; sp[1]= ocy1; sp[2]= ocz1; - sp[3]= ocx2; sp[4]= ocy2; sp[5]= ocz2; + sp = coh_nodes[(ocx2 & 15) + 16 * (ocy2 & 15) + 256 * (ocz2 & 15)]; + sp[0] = ocx1; sp[1] = ocy1; sp[2] = ocz1; + sp[3] = ocx2; sp[4] = ocy2; sp[5] = ocz2; } @@ -833,9 +830,9 @@ static int do_coherence_test(int ocx1, int ocx2, int ocy1, int ocy2, int ocz1, i { short *sp; - sp= coh_nodes[ (ocx2 & 15) + 16*(ocy2 & 15) + 256*(ocz2 & 15) ]; - if (sp[0]==ocx1 && sp[1]==ocy1 && sp[2]==ocz1 && - sp[3]==ocx2 && sp[4]==ocy2 && sp[5]==ocz2) return 1; + sp = coh_nodes[(ocx2 & 15) + 16 * (ocy2 & 15) + 256 * (ocz2 & 15)]; + if (sp[0] == ocx1 && sp[1] == ocy1 && sp[2] == ocz1 && + sp[3] == ocx2 && sp[4] == ocy2 && sp[5] == ocz2) return 1; return 0; } @@ -845,7 +842,7 @@ static int do_coherence_test(int ocx1, int ocx2, int ocy1, int ocy2, int ocz1, i /* starts with is->orig.face */ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is) { - Octree *oc= (Octree*)tree; + Octree *oc = (Octree *)tree; Node *no; OcVal ocval; float vec1[3], vec2[3], start[3], end[3]; @@ -853,47 +850,47 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is) float labdao, labdax, ldx, labday, ldy, labdaz, ldz, ddalabda; float olabda = 0; int dx, dy, dz; - int xo, yo, zo, c1=0; + int xo, yo, zo, c1 = 0; int ocx1, ocx2, ocy1, ocy2, ocz1, ocz2; /* clip with octree */ - if (oc->branchcount==0) return 0; + if (oc->branchcount == 0) return 0; /* do this before intersect calls */ #if 0 - is->facecontr= NULL; /* to check shared edge */ - is->obcontr= 0; - is->faceisect= is->isect= 0; /* shared edge, quad half flag */ - is->userdata= oc->userdata; + is->facecontr = NULL; /* to check shared edge */ + is->obcontr = 0; + is->faceisect = is->isect = 0; /* shared edge, quad half flag */ + is->userdata = oc->userdata; #endif - copy_v3_v3( start, is->start ); - madd_v3_v3v3fl( end, is->start, is->dir, is->dist ); - ldx= is->dir[0]*is->dist; + copy_v3_v3(start, is->start); + madd_v3_v3v3fl(end, is->start, is->dir, is->dist); + ldx = is->dir[0] * is->dist; olabda = is->dist; - u1= 0.0f; - u2= 1.0f; + u1 = 0.0f; + u2 = 1.0f; /* clip with octree cube */ - if (cliptest(-ldx, start[0]-oc->min[0], &u1, &u2)) { - if (cliptest(ldx, oc->max[0]-start[0], &u1, &u2)) { - ldy= is->dir[1]*is->dist; - if (cliptest(-ldy, start[1]-oc->min[1], &u1, &u2)) { - if (cliptest(ldy, oc->max[1]-start[1], &u1, &u2)) { - ldz = is->dir[2]*is->dist; - if (cliptest(-ldz, start[2]-oc->min[2], &u1, &u2)) { - if (cliptest(ldz, oc->max[2]-start[2], &u1, &u2)) { - c1=1; - if (u2<1.0f) { - end[0] = start[0]+u2*ldx; - end[1] = start[1]+u2*ldy; - end[2] = start[2]+u2*ldz; + if (cliptest(-ldx, start[0] - oc->min[0], &u1, &u2)) { + if (cliptest(ldx, oc->max[0] - start[0], &u1, &u2)) { + ldy = is->dir[1] * is->dist; + if (cliptest(-ldy, start[1] - oc->min[1], &u1, &u2)) { + if (cliptest(ldy, oc->max[1] - start[1], &u1, &u2)) { + ldz = is->dir[2] * is->dist; + if (cliptest(-ldz, start[2] - oc->min[2], &u1, &u2)) { + if (cliptest(ldz, oc->max[2] - start[2], &u1, &u2)) { + c1 = 1; + if (u2 < 1.0f) { + end[0] = start[0] + u2 * ldx; + end[1] = start[1] + u2 * ldy; + end[2] = start[2] + u2 * ldz; } - if (u1>0.0f) { - start[0] += u1*ldx; - start[1] += u1*ldy; - start[2] += u1*ldz; + if (u1 > 0.0f) { + start[0] += u1 * ldx; + start[1] += u1 * ldy; + start[2] += u1 * ldz; } } } @@ -902,34 +899,34 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is) } } - if (c1==0) return 0; + if (c1 == 0) return 0; /* reset static variables in ocread */ //ocread(oc, oc->ocres, 0, 0); /* setup 3dda to traverse octree */ - ox1= (start[0]-oc->min[0])*oc->ocfacx; - oy1= (start[1]-oc->min[1])*oc->ocfacy; - oz1= (start[2]-oc->min[2])*oc->ocfacz; - ox2= (end[0]-oc->min[0])*oc->ocfacx; - oy2= (end[1]-oc->min[1])*oc->ocfacy; - oz2= (end[2]-oc->min[2])*oc->ocfacz; - - ocx1= (int)ox1; - ocy1= (int)oy1; - ocz1= (int)oz1; - ocx2= (int)ox2; - ocy2= (int)oy2; - ocz2= (int)oz2; + ox1 = (start[0] - oc->min[0]) * oc->ocfacx; + oy1 = (start[1] - oc->min[1]) * oc->ocfacy; + oz1 = (start[2] - oc->min[2]) * oc->ocfacz; + ox2 = (end[0] - oc->min[0]) * oc->ocfacx; + oy2 = (end[1] - oc->min[1]) * oc->ocfacy; + oz2 = (end[2] - oc->min[2]) * oc->ocfacz; + + ocx1 = (int)ox1; + ocy1 = (int)oy1; + ocz1 = (int)oz1; + ocx2 = (int)ox2; + ocy2 = (int)oy2; + ocz2 = (int)oz2; - if (ocx1==ocx2 && ocy1==ocy2 && ocz1==ocz2) { - no= ocread(oc, ocx1, ocy1, ocz1); + if (ocx1 == ocx2 && ocy1 == ocy2 && ocz1 == ocz2) { + no = ocread(oc, ocx1, ocy1, ocz1); if (no) { /* exact intersection with node */ - vec1[0]= ox1; vec1[1]= oy1; vec1[2]= oz1; - vec2[0]= ox2; vec2[1]= oy2; vec2[2]= oz2; + vec1[0] = ox1; vec1[1] = oy1; vec1[2] = oz1; + vec2[0] = ox2; vec2[1] = oy2; vec2[2] = oz2; calc_ocval_ray(&ocval, (float)ocx1, (float)ocy1, (float)ocz1, vec1, vec2); - if ( testnode(oc, is, no, ocval) ) return 1; + if (testnode(oc, is, no, ocval) ) return 1; } } else { @@ -939,153 +936,153 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is) int eqval; /* calc labda en ld */ - dox= ox1-ox2; - doy= oy1-oy2; - doz= oz1-oz2; - - if (dox<-FLT_EPSILON) { - ldx= -1.0f/dox; - labdax= (ocx1-ox1+1.0f)*ldx; - dx= 1; + dox = ox1 - ox2; + doy = oy1 - oy2; + doz = oz1 - oz2; + + if (dox < -FLT_EPSILON) { + ldx = -1.0f / dox; + labdax = (ocx1 - ox1 + 1.0f) * ldx; + dx = 1; } - else if (dox>FLT_EPSILON) { - ldx= 1.0f/dox; - labdax= (ox1-ocx1)*ldx; - dx= -1; + else if (dox > FLT_EPSILON) { + ldx = 1.0f / dox; + labdax = (ox1 - ocx1) * ldx; + dx = -1; } else { - labdax=1.0f; - ldx=0; - dx= 0; + labdax = 1.0f; + ldx = 0; + dx = 0; } - if (doy<-FLT_EPSILON) { - ldy= -1.0f/doy; - labday= (ocy1-oy1+1.0f)*ldy; - dy= 1; + if (doy < -FLT_EPSILON) { + ldy = -1.0f / doy; + labday = (ocy1 - oy1 + 1.0f) * ldy; + dy = 1; } - else if (doy>FLT_EPSILON) { - ldy= 1.0f/doy; - labday= (oy1-ocy1)*ldy; - dy= -1; + else if (doy > FLT_EPSILON) { + ldy = 1.0f / doy; + labday = (oy1 - ocy1) * ldy; + dy = -1; } else { - labday=1.0f; - ldy=0; - dy= 0; + labday = 1.0f; + ldy = 0; + dy = 0; } - if (doz<-FLT_EPSILON) { - ldz= -1.0f/doz; - labdaz= (ocz1-oz1+1.0f)*ldz; - dz= 1; + if (doz < -FLT_EPSILON) { + ldz = -1.0f / doz; + labdaz = (ocz1 - oz1 + 1.0f) * ldz; + dz = 1; } - else if (doz>FLT_EPSILON) { - ldz= 1.0f/doz; - labdaz= (oz1-ocz1)*ldz; - dz= -1; + else if (doz > FLT_EPSILON) { + ldz = 1.0f / doz; + labdaz = (oz1 - ocz1) * ldz; + dz = -1; } else { - labdaz=1.0f; - ldz=0; - dz= 0; + labdaz = 1.0f; + ldz = 0; + dz = 0; } - xo=ocx1; yo=ocy1; zo=ocz1; - ddalabda= MIN3(labdax, labday, labdaz); + xo = ocx1; yo = ocy1; zo = ocz1; + ddalabda = MIN3(labdax, labday, labdaz); - vec2[0]= ox1; - vec2[1]= oy1; - vec2[2]= oz1; + vec2[0] = ox1; + vec2[1] = oy1; + vec2[2] = oz1; /* this loop has been constructed to make sure the first and last node of ray * are always included, even when ddalabda==1.0f or larger */ while (TRUE) { - no= ocread(oc, xo, yo, zo); + no = ocread(oc, xo, yo, zo); if (no) { /* calculate ray intersection with octree node */ copy_v3_v3(vec1, vec2); // dox, y, z is negative - vec2[0]= ox1-ddalabda*dox; - vec2[1]= oy1-ddalabda*doy; - vec2[2]= oz1-ddalabda*doz; + vec2[0] = ox1 - ddalabda * dox; + vec2[1] = oy1 - ddalabda * doy; + vec2[2] = oz1 - ddalabda * doz; calc_ocval_ray(&ocval, (float)xo, (float)yo, (float)zo, vec1, vec2); //is->dist = (u1+ddalabda*(u2-u1))*olabda; - if ( testnode(oc, is, no, ocval) ) + if (testnode(oc, is, no, ocval) ) found = 1; - if (is->dist < (u1+ddalabda*(u2-u1))*olabda) + if (is->dist < (u1 + ddalabda * (u2 - u1)) * olabda) return found; } - labdao= ddalabda; + labdao = ddalabda; /* traversing ocree nodes need careful detection of smallest values, with proper * exceptions for equal labdas */ - eqval= (labdax==labday); - if (labday==labdaz) eqval += 2; - if (labdax==labdaz) eqval += 4; - - if (eqval) { // only 4 cases exist! - if (eqval==7) { // x=y=z - xo+=dx; labdax+=ldx; - yo+=dy; labday+=ldy; - zo+=dz; labdaz+=ldz; + eqval = (labdax == labday); + if (labday == labdaz) eqval += 2; + if (labdax == labdaz) eqval += 4; + + if (eqval) { // only 4 cases exist! + if (eqval == 7) { // x=y=z + xo += dx; labdax += ldx; + yo += dy; labday += ldy; + zo += dz; labdaz += ldz; } - else if (eqval==1) { // x=y + else if (eqval == 1) { // x=y if (labday < labdaz) { - xo+=dx; labdax+=ldx; - yo+=dy; labday+=ldy; + xo += dx; labdax += ldx; + yo += dy; labday += ldy; } else { - zo+=dz; labdaz+=ldz; + zo += dz; labdaz += ldz; } } - else if (eqval==2) { // y=z + else if (eqval == 2) { // y=z if (labdax < labday) { - xo+=dx; labdax+=ldx; + xo += dx; labdax += ldx; } else { - yo+=dy; labday+=ldy; - zo+=dz; labdaz+=ldz; + yo += dy; labday += ldy; + zo += dz; labdaz += ldz; } } else { // x=z if (labday < labdax) { - yo+=dy; labday+=ldy; + yo += dy; labday += ldy; } else { - xo+=dx; labdax+=ldx; - zo+=dz; labdaz+=ldz; + xo += dx; labdax += ldx; + zo += dz; labdaz += ldz; } } } - else { // all three different, just three cases exist - eqval= (labdax<labday); - if (labday<labdaz) eqval += 2; - if (labdax<labdaz) eqval += 4; + else { // all three different, just three cases exist + eqval = (labdax < labday); + if (labday < labdaz) eqval += 2; + if (labdax < labdaz) eqval += 4; - if (eqval==7 || eqval==5) { // x smallest - xo+=dx; labdax+=ldx; + if (eqval == 7 || eqval == 5) { // x smallest + xo += dx; labdax += ldx; } - else if (eqval==2 || eqval==6) { // y smallest - yo+=dy; labday+=ldy; + else if (eqval == 2 || eqval == 6) { // y smallest + yo += dy; labday += ldy; } else { // z smallest - zo+=dz; labdaz+=ldz; + zo += dz; labdaz += ldz; } } - ddalabda=MIN3(labdax, labday, labdaz); - if (ddalabda==labdao) break; + ddalabda = MIN3(labdax, labday, labdaz); + if (ddalabda == labdao) break; /* to make sure the last node is always checked */ - if (labdao>=1.0f) break; + if (labdao >= 1.0f) break; } } diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index 0f3a3111a13..61de4d39585 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -74,49 +74,49 @@ static void envmap_split_ima(EnvMap *env, ImBuf *ibuf) /* after lock we test cube[1], if set the other thread has done it fine */ BLI_lock_thread(LOCK_IMAGE); - if (env->cube[1]==NULL) { + if (env->cube[1] == NULL) { BKE_free_envmapdata(env); - dx= ibuf->y; - dx/= 2; - if (3*dx == ibuf->x) { + dx = ibuf->y; + dx /= 2; + if (3 * dx == ibuf->x) { env->type = ENV_CUBE; - env->ok= ENV_OSA; + env->ok = ENV_OSA; } else if (ibuf->x == ibuf->y) { env->type = ENV_PLANE; - env->ok= ENV_OSA; + env->ok = ENV_OSA; } else { printf("Incorrect envmap size\n"); - env->ok= 0; - env->ima->ok= 0; + env->ok = 0; + env->ima->ok = 0; } if (env->ok) { if (env->type == ENV_CUBE) { - for (part=0; part<6; part++) { - env->cube[part]= IMB_allocImBuf(dx, dx, 24, IB_rect|IB_rectfloat); + for (part = 0; part < 6; part++) { + env->cube[part] = IMB_allocImBuf(dx, dx, 24, IB_rect | IB_rectfloat); } IMB_float_from_rect(ibuf); IMB_rectcpy(env->cube[0], ibuf, - 0, 0, 0, 0, dx, dx); + 0, 0, 0, 0, dx, dx); IMB_rectcpy(env->cube[1], ibuf, - 0, 0, dx, 0, dx, dx); + 0, 0, dx, 0, dx, dx); IMB_rectcpy(env->cube[2], ibuf, - 0, 0, 2*dx, 0, dx, dx); + 0, 0, 2 * dx, 0, dx, dx); IMB_rectcpy(env->cube[3], ibuf, - 0, 0, 0, dx, dx, dx); + 0, 0, 0, dx, dx, dx); IMB_rectcpy(env->cube[4], ibuf, - 0, 0, dx, dx, dx, dx); + 0, 0, dx, dx, dx, dx); IMB_rectcpy(env->cube[5], ibuf, - 0, 0, 2*dx, dx, dx, dx); + 0, 0, 2 * dx, dx, dx, dx); } else { /* ENV_PLANE */ - env->cube[1]= IMB_dupImBuf(ibuf); + env->cube[1] = IMB_dupImBuf(ibuf); IMB_float_from_rect(env->cube[1]); } } @@ -134,53 +134,53 @@ static Render *envmap_render_copy(Render *re, EnvMap *env) float viewscale; int cuberes; - envre= RE_NewRender("Envmap"); + envre = RE_NewRender("Envmap"); - env->lastsize= re->r.size; + env->lastsize = re->r.size; cuberes = (env->cuberes * re->r.size) / 100; cuberes &= 0xFFFC; /* this flag has R_ZTRA in it for example */ - envre->flag= re->flag; + envre->flag = re->flag; /* set up renderdata */ - envre->r= re->r; + envre->r = re->r; envre->r.mode &= ~(R_BORDER | R_PANORAMA | R_ORTHO | R_MBLUR); - envre->r.layers.first= envre->r.layers.last= NULL; - envre->r.filtertype= 0; - envre->r.xparts= envre->r.yparts= 2; - envre->r.size= 100; - envre->r.yasp= envre->r.xasp= 1; + envre->r.layers.first = envre->r.layers.last = NULL; + envre->r.filtertype = 0; + envre->r.xparts = envre->r.yparts = 2; + envre->r.size = 100; + envre->r.yasp = envre->r.xasp = 1; RE_InitState(envre, NULL, &envre->r, NULL, cuberes, cuberes, NULL); - envre->scene= re->scene; /* unsure about this... */ - envre->lay= re->lay; + envre->scene = re->scene; /* unsure about this... */ + envre->lay = re->lay; /* view stuff in env render */ - viewscale= (env->type == ENV_PLANE)? env->viewscale: 1.0f; + viewscale = (env->type == ENV_PLANE) ? env->viewscale : 1.0f; RE_SetEnvmapCamera(envre, env->object, viewscale, env->clipsta, env->clipend); /* callbacks */ - envre->display_draw= re->display_draw; - envre->ddh= re->ddh; - envre->test_break= re->test_break; - envre->tbh= re->tbh; + envre->display_draw = re->display_draw; + envre->ddh = re->ddh; + envre->test_break = re->test_break; + envre->tbh = re->tbh; /* and for the evil stuff; copy the database... */ - envre->totvlak= re->totvlak; - envre->totvert= re->totvert; - envre->tothalo= re->tothalo; - envre->totstrand= re->totstrand; - envre->totlamp= re->totlamp; - envre->sortedhalos= re->sortedhalos; - envre->lights= re->lights; - envre->objecttable= re->objecttable; - envre->customdata_names= re->customdata_names; - envre->raytree= re->raytree; - envre->totinstance= re->totinstance; - envre->instancetable= re->instancetable; - envre->objectinstance= re->objectinstance; - envre->qmcsamplers= re->qmcsamplers; + envre->totvlak = re->totvlak; + envre->totvert = re->totvert; + envre->tothalo = re->tothalo; + envre->totstrand = re->totstrand; + envre->totlamp = re->totlamp; + envre->sortedhalos = re->sortedhalos; + envre->lights = re->lights; + envre->objecttable = re->objecttable; + envre->customdata_names = re->customdata_names; + envre->raytree = re->raytree; + envre->totinstance = re->totinstance; + envre->instancetable = re->instancetable; + envre->objectinstance = re->objectinstance; + envre->qmcsamplers = re->qmcsamplers; return envre; } @@ -188,20 +188,20 @@ static Render *envmap_render_copy(Render *re, EnvMap *env) static void envmap_free_render_copy(Render *envre) { - envre->totvlak= 0; - envre->totvert= 0; - envre->tothalo= 0; - envre->totstrand= 0; - envre->totlamp= 0; - envre->totinstance= 0; - envre->sortedhalos= NULL; - envre->lights.first= envre->lights.last= NULL; - envre->objecttable.first= envre->objecttable.last= NULL; - envre->customdata_names.first= envre->customdata_names.last= NULL; - envre->raytree= NULL; - envre->instancetable.first= envre->instancetable.last= NULL; - envre->objectinstance= NULL; - envre->qmcsamplers= NULL; + envre->totvlak = 0; + envre->totvert = 0; + envre->tothalo = 0; + envre->totstrand = 0; + envre->totlamp = 0; + envre->totinstance = 0; + envre->sortedhalos = NULL; + envre->lights.first = envre->lights.last = NULL; + envre->objecttable.first = envre->objecttable.last = NULL; + envre->customdata_names.first = envre->customdata_names.last = NULL; + envre->raytree = NULL; + envre->instancetable.first = envre->instancetable.last = NULL; + envre->objectinstance = NULL; + envre->qmcsamplers = NULL; RE_FreeRender(envre); } @@ -212,28 +212,28 @@ static void envmap_transmatrix(float mat[][4], int part) { float tmat[4][4], eul[3], rotmat[4][4]; - eul[0]= eul[1]= eul[2]= 0.0; + eul[0] = eul[1] = eul[2] = 0.0; - if (part==0) { /* neg z */ + if (part == 0) { /* neg z */ ; } - else if (part==1) { /* pos z */ - eul[0]= M_PI; + else if (part == 1) { /* pos z */ + eul[0] = M_PI; } - else if (part==2) { /* pos y */ - eul[0]= M_PI/2.0; + else if (part == 2) { /* pos y */ + eul[0] = M_PI / 2.0; } - else if (part==3) { /* neg x */ - eul[0]= M_PI/2.0; - eul[2]= M_PI/2.0; + else if (part == 3) { /* neg x */ + eul[0] = M_PI / 2.0; + eul[2] = M_PI / 2.0; } - else if (part==4) { /* neg y */ - eul[0]= M_PI/2.0; - eul[2]= M_PI; + else if (part == 4) { /* neg y */ + eul[0] = M_PI / 2.0; + eul[2] = M_PI; } - else { /* pos x */ - eul[0]= M_PI/2.0; - eul[2]= -M_PI/2.0; + else { /* pos x */ + eul[0] = M_PI / 2.0; + eul[2] = -M_PI / 2.0; } copy_m4_m4(tmat, mat); @@ -255,7 +255,7 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode) float imat[3][3], pmat[4][4], smat[4][4], tmat[4][4], cmat[3][3], tmpmat[4][4]; int a; - if (mode==0) { + if (mode == 0) { invert_m4_m4(tmat, mat); copy_m3_m4(imat, tmat); } @@ -264,13 +264,13 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode) copy_m3_m4(imat, mat); } - for (obi=re->instancetable.first; obi; obi=obi->next) { + for (obi = re->instancetable.first; obi; obi = obi->next) { /* append or set matrix depending on dupli */ if (obi->flag & R_DUPLI_TRANSFORMED) { copy_m4_m4(tmpmat, obi->mat); mult_m4_m4m4(obi->mat, tmat, tmpmat); } - else if (mode==1) + else if (mode == 1) copy_m4_m4(obi->mat, tmat); else unit_m4(obi->mat); @@ -280,24 +280,24 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode) transpose_m3(obi->nmat); /* indicate the renderer has to use transform matrices */ - if (mode==0) + if (mode == 0) obi->flag &= ~R_ENV_TRANSFORMED; else obi->flag |= R_ENV_TRANSFORMED; } - for (obr=re->objecttable.first; obr; obr=obr->next) { - for (a=0; a<obr->tothalo; a++) { - if ((a & 255)==0) har= obr->bloha[a>>8]; + for (obr = re->objecttable.first; obr; obr = obr->next) { + for (a = 0; a < obr->tothalo; a++) { + if ((a & 255) == 0) har = obr->bloha[a >> 8]; else har++; mul_m4_v3(tmat, har->co); } } - for (go=re->lights.first; go; go= go->next) { - lar= go->lampren; + for (go = re->lights.first; go; go = go->next) { + lar = go->lampren; /* removed here some horrible code of someone in NaN who tried to fix * prototypes... just solved by introducing a correct cmat[3][3] instead @@ -308,14 +308,14 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode) mul_m3_v3(imat, lar->vec); mul_m4_v3(tmat, lar->co); - lar->sh_invcampos[0]= -lar->co[0]; - lar->sh_invcampos[1]= -lar->co[1]; - lar->sh_invcampos[2]= -lar->co[2]; + lar->sh_invcampos[0] = -lar->co[0]; + lar->sh_invcampos[1] = -lar->co[1]; + lar->sh_invcampos[2] = -lar->co[2]; mul_m3_v3(lar->imat, lar->sh_invcampos); - lar->sh_invcampos[2]*= lar->sh_zfac; + lar->sh_invcampos[2] *= lar->sh_zfac; if (lar->shb) { - if (mode==1) { + if (mode == 1) { invert_m4_m4(pmat, mat); mult_m4_m4m4(smat, lar->shb->viewmat, pmat); mult_m4_m4m4(lar->shb->persmat, lar->shb->winmat, smat); @@ -342,12 +342,12 @@ static void env_layerflags(Render *re, unsigned int notlay) * now (face & ~not) is true */ - notlay= ~notlay; + notlay = ~notlay; - for (obr=re->objecttable.first; obr; obr=obr->next) { - if ((obr->lay & notlay)==0) { - for (a=0; a<obr->totvlak; a++) { - if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; + for (obr = re->objecttable.first; obr; obr = obr->next) { + if ((obr->lay & notlay) == 0) { + for (a = 0; a < obr->totvlak; a++) { + if ((a & 255) == 0) vlr = obr->vlaknodes[a >> 8].vlak; else vlr++; vlr->flag |= R_HIDDEN; @@ -362,9 +362,9 @@ static void env_hideobject(Render *re, Object *ob) VlakRen *vlr = NULL; int a; - for (obr=re->objecttable.first; obr; obr=obr->next) { - for (a=0; a<obr->totvlak; a++) { - if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; + for (obr = re->objecttable.first; obr; obr = obr->next) { + for (a = 0; a < obr->totvlak; a++) { + if ((a & 255) == 0) vlr = obr->vlaknodes[a >> 8].vlak; else vlr++; if (obr->ob == ob) @@ -379,9 +379,9 @@ static void env_showobjects(Render *re) VlakRen *vlr = NULL; int a; - for (obr=re->objecttable.first; obr; obr=obr->next) { - for (a=0; a<obr->totvlak; a++) { - if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; + for (obr = re->objecttable.first; obr; obr = obr->next) { + for (a = 0; a < obr->totvlak; a++) { + if ((a & 255) == 0) vlr = obr->vlaknodes[a >> 8].vlak; else vlr++; vlr->flag &= ~R_HIDDEN; @@ -396,12 +396,12 @@ static void env_set_imats(Render *re) Base *base; float mat[4][4]; - base= re->scene->base.first; + base = re->scene->base.first; while (base) { mult_m4_m4m4(mat, re->viewmat, base->object->obmat); invert_m4_m4(base->object->imat, mat); - base= base->next; + base = base->next; } } @@ -420,7 +420,7 @@ static void render_envmap(Render *re, EnvMap *env) /* need a recalc: ortho-render has no correct viewinv */ invert_m4_m4(oldviewinv, re->viewmat); - envre= envmap_render_copy(re, env); + envre = envmap_render_copy(re, env); /* precalc orthmat for object */ copy_m4_m4(orthmat, env->object->obmat); @@ -431,8 +431,8 @@ static void render_envmap(Render *re, EnvMap *env) invert_m4_m4(tmat, mat); copy_m3_m4(env->obimat, tmat); - for (part=0; part<6; part++) { - if (env->type==ENV_PLANE && part!=1) + for (part = 0; part < 6; part++) { + if (env->type == ENV_PLANE && part != 1) continue; re->display_clear(re->dch, envre->result); @@ -456,7 +456,7 @@ static void render_envmap(Render *re, EnvMap *env) env_hideobject(envre, env->object); env_set_imats(envre); - if (re->test_break(re->tbh)==0) { + if (re->test_break(re->tbh) == 0) { RE_TileProcessor(envre); } @@ -464,23 +464,23 @@ static void render_envmap(Render *re, EnvMap *env) env_showobjects(envre); env_rotate_scene(envre, tmat, 0); - if (re->test_break(re->tbh)==0) { - RenderLayer *rl= envre->result->layers.first; + if (re->test_break(re->tbh) == 0) { + RenderLayer *rl = envre->result->layers.first; int y; float *alpha; - ibuf= IMB_allocImBuf(envre->rectx, envre->recty, 24, IB_rect|IB_rectfloat); + ibuf = IMB_allocImBuf(envre->rectx, envre->recty, 24, IB_rect | IB_rectfloat); memcpy(ibuf->rect_float, rl->rectf, ibuf->channels * ibuf->x * ibuf->y * sizeof(float)); if (re->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) ibuf->profile = IB_PROFILE_LINEAR_RGB; /* envmap renders without alpha */ - alpha= ((float *)ibuf->rect_float)+3; - for (y= ibuf->x*ibuf->y - 1; y>=0; y--, alpha+=4) - *alpha= 1.0; + alpha = ((float *)ibuf->rect_float) + 3; + for (y = ibuf->x * ibuf->y - 1; y >= 0; y--, alpha += 4) + *alpha = 1.0; - env->cube[part]= ibuf; + env->cube[part] = ibuf; } if (re->test_break(re->tbh)) break; @@ -489,9 +489,9 @@ static void render_envmap(Render *re, EnvMap *env) if (re->test_break(re->tbh)) BKE_free_envmapdata(env); else { - if (envre->r.mode & R_OSA) env->ok= ENV_OSA; - else env->ok= ENV_NORMAL; - env->lastframe= re->scene->r.cfra; + if (envre->r.mode & R_OSA) env->ok = ENV_OSA; + else env->ok = ENV_NORMAL; + env->lastframe = re->scene->r.cfra; } /* restore */ @@ -505,27 +505,27 @@ static void render_envmap(Render *re, EnvMap *env) void make_envmaps(Render *re) { Tex *tex; - int do_init = FALSE, depth= 0, trace; + int do_init = FALSE, depth = 0, trace; if (!(re->r.mode & R_ENVMAP)) return; /* we don't raytrace, disabling the flag will cause ray_transp render solid */ - trace= (re->r.mode & R_RAYTRACE); + trace = (re->r.mode & R_RAYTRACE); re->r.mode &= ~R_RAYTRACE; - re->i.infostr= "Creating Environment maps"; + re->i.infostr = "Creating Environment maps"; re->stats_draw(re->sdh, &re->i); /* 5 = hardcoded max recursion level */ - while (depth<5) { - tex= re->main->tex.first; + while (depth < 5) { + tex = re->main->tex.first; while (tex) { - if (tex->id.us && tex->type==TEX_ENVMAP) { + if (tex->id.us && tex->type == TEX_ENVMAP) { if (tex->env && tex->env->object) { - EnvMap *env= tex->env; + EnvMap *env = tex->env; if (env->object->lay & re->lay) { - if (env->stype==ENV_LOAD) { + if (env->stype == ENV_LOAD) { float orthmat[4][4], mat[4][4], tmat[4][4]; /* precalc orthmat for object */ @@ -545,31 +545,31 @@ void make_envmaps(Render *re) /* set 'recalc' to make sure it does an entire loop of recalcs */ if (env->ok) { - /* free when OSA, and old one isn't OSA */ - if ((re->r.mode & R_OSA) && env->ok==ENV_NORMAL) + /* free when OSA, and old one isn't OSA */ + if ((re->r.mode & R_OSA) && env->ok == ENV_NORMAL) BKE_free_envmapdata(env); - /* free when size larger */ + /* free when size larger */ else if (env->lastsize < re->r.size) BKE_free_envmapdata(env); - /* free when env is in recalcmode */ + /* free when env is in recalcmode */ else if (env->recalc) BKE_free_envmapdata(env); } - if (env->ok==0 && depth==0) env->recalc= 1; + if (env->ok == 0 && depth == 0) env->recalc = 1; - if (env->ok==0) { + if (env->ok == 0) { do_init = TRUE; render_envmap(re, env); - if (depth==env->depth) env->recalc= 0; + if (depth == env->depth) env->recalc = 0; } } } } } } - tex= tex->id.next; + tex = tex->id.next; } depth++; } @@ -591,55 +591,55 @@ static int envcube_isect(EnvMap *env, const float vec[3], float answ[2]) float labda; int face; - if (env->type==ENV_PLANE) { - face= 1; + if (env->type == ENV_PLANE) { + face = 1; - labda= 1.0f/vec[2]; - answ[0]= env->viewscale*labda*vec[0]; - answ[1]= -env->viewscale*labda*vec[1]; + labda = 1.0f / vec[2]; + answ[0] = env->viewscale * labda * vec[0]; + answ[1] = -env->viewscale * labda * vec[1]; } else { /* which face */ - if ( vec[2] <= -fabsf(vec[0]) && vec[2] <= -fabsf(vec[1]) ) { - face= 0; - labda= -1.0f/vec[2]; - answ[0]= labda*vec[0]; - answ[1]= labda*vec[1]; + if (vec[2] <= -fabsf(vec[0]) && vec[2] <= -fabsf(vec[1]) ) { + face = 0; + labda = -1.0f / vec[2]; + answ[0] = labda * vec[0]; + answ[1] = labda * vec[1]; } else if (vec[2] >= fabsf(vec[0]) && vec[2] >= fabsf(vec[1])) { - face= 1; - labda= 1.0f/vec[2]; - answ[0]= labda*vec[0]; - answ[1]= -labda*vec[1]; + face = 1; + labda = 1.0f / vec[2]; + answ[0] = labda * vec[0]; + answ[1] = -labda * vec[1]; } else if (vec[1] >= fabsf(vec[0])) { - face= 2; - labda= 1.0f/vec[1]; - answ[0]= labda*vec[0]; - answ[1]= labda*vec[2]; + face = 2; + labda = 1.0f / vec[1]; + answ[0] = labda * vec[0]; + answ[1] = labda * vec[2]; } else if (vec[0] <= -fabsf(vec[1])) { - face= 3; - labda= -1.0f/vec[0]; - answ[0]= labda*vec[1]; - answ[1]= labda*vec[2]; + face = 3; + labda = -1.0f / vec[0]; + answ[0] = labda * vec[1]; + answ[1] = labda * vec[2]; } else if (vec[1] <= -fabsf(vec[0])) { - face= 4; - labda= -1.0f/vec[1]; - answ[0]= -labda*vec[0]; - answ[1]= labda*vec[2]; + face = 4; + labda = -1.0f / vec[1]; + answ[0] = -labda * vec[0]; + answ[1] = labda * vec[2]; } else { - face= 5; - labda= 1.0f/vec[0]; - answ[0]= -labda*vec[1]; - answ[1]= labda*vec[2]; + face = 5; + labda = 1.0f / vec[0]; + answ[0] = -labda * vec[1]; + answ[1] = labda * vec[2]; } } - answ[0]= 0.5f+0.5f*answ[0]; - answ[1]= 0.5f+0.5f*answ[1]; + answ[0] = 0.5f + 0.5f * answ[0]; + answ[1] = 0.5f + 0.5f * answ[1]; return face; } @@ -647,23 +647,23 @@ static int envcube_isect(EnvMap *env, const float vec[3], float answ[2]) static void set_dxtdyt(float *dxts, float *dyts, float *dxt, float *dyt, int face) { - if (face==2 || face==4) { - dxts[0]= dxt[0]; - dyts[0]= dyt[0]; - dxts[1]= dxt[2]; - dyts[1]= dyt[2]; + if (face == 2 || face == 4) { + dxts[0] = dxt[0]; + dyts[0] = dyt[0]; + dxts[1] = dxt[2]; + dyts[1] = dyt[2]; } - else if (face==3 || face==5) { - dxts[0]= dxt[1]; - dxts[1]= dxt[2]; - dyts[0]= dyt[1]; - dyts[1]= dyt[2]; + else if (face == 3 || face == 5) { + dxts[0] = dxt[1]; + dxts[1] = dxt[2]; + dyts[0] = dyt[1]; + dyts[1] = dyt[2]; } else { - dxts[0]= dxt[0]; - dyts[0]= dyt[0]; - dxts[1]= dxt[1]; - dyts[1]= dyt[1]; + dxts[0] = dxt[0]; + dyts[0] = dyt[0]; + dxts[1] = dxt[1]; + dyts[1] = dyt[1]; } } @@ -671,34 +671,34 @@ static void set_dxtdyt(float *dxts, float *dyts, float *dxt, float *dyt, int fac int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexResult *texres) { - extern Render R; /* only in this call */ + extern Render R; /* only in this call */ /* texvec should be the already reflected normal */ EnvMap *env; ImBuf *ibuf; float fac, vec[3], sco[3], dxts[3], dyts[3]; int face, face1; - env= tex->env; - if (env==NULL || (env->stype!=ENV_LOAD && env->object==NULL)) { - texres->tin= 0.0; + env = tex->env; + if (env == NULL || (env->stype != ENV_LOAD && env->object == NULL)) { + texres->tin = 0.0; return 0; } - if (env->stype==ENV_LOAD) { - env->ima= tex->ima; + if (env->stype == ENV_LOAD) { + env->ima = tex->ima; if (env->ima && env->ima->ok) { - if (env->cube[1]==NULL) { - ImBuf *ibuf_ima= BKE_image_get_ibuf(env->ima, NULL); + if (env->cube[1] == NULL) { + ImBuf *ibuf_ima = BKE_image_get_ibuf(env->ima, NULL); if (ibuf_ima) envmap_split_ima(env, ibuf_ima); else - env->ok= 0; + env->ok = 0; } } } - if (env->ok==0) { - texres->tin= 0.0; + if (env->ok == 0) { + texres->tin = 0.0; return 0; } @@ -707,8 +707,8 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe if (env->object) mul_m3_v3(env->obimat, vec); else mul_mat3_m4_v3(R.viewinv, vec); - face= envcube_isect(env, vec, sco); - ibuf= env->cube[face]; + face = envcube_isect(env, vec, sco); + ibuf = env->cube[face]; if (osatex) { if (env->object) { @@ -724,45 +724,45 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe /* edges? */ - if (texres->ta<1.0f) { + if (texres->ta < 1.0f) { TexResult texr1, texr2; - texr1.nor= texr2.nor= NULL; - texr1.talpha= texr2.talpha= texres->talpha; /* boxclip expects this initialized */ + texr1.nor = texr2.nor = NULL; + texr1.talpha = texr2.talpha = texres->talpha; /* boxclip expects this initialized */ add_v3_v3(vec, dxt); - face1= envcube_isect(env, vec, sco); + face1 = envcube_isect(env, vec, sco); sub_v3_v3(vec, dxt); - if (face!=face1) { - ibuf= env->cube[face1]; + if (face != face1) { + ibuf = env->cube[face1]; set_dxtdyt(dxts, dyts, dxt, dyt, face1); imagewraposa(tex, NULL, ibuf, sco, dxts, dyts, &texr1); } - else texr1.tr= texr1.tg= texr1.tb= texr1.ta= 0.0; + else texr1.tr = texr1.tg = texr1.tb = texr1.ta = 0.0; /* here was the nasty bug! results were not zero-ed. FPE! */ add_v3_v3(vec, dyt); - face1= envcube_isect(env, vec, sco); + face1 = envcube_isect(env, vec, sco); sub_v3_v3(vec, dyt); - if (face!=face1) { - ibuf= env->cube[face1]; + if (face != face1) { + ibuf = env->cube[face1]; set_dxtdyt(dxts, dyts, dxt, dyt, face1); imagewraposa(tex, NULL, ibuf, sco, dxts, dyts, &texr2); } - else texr2.tr= texr2.tg= texr2.tb= texr2.ta= 0.0; + else texr2.tr = texr2.tg = texr2.tb = texr2.ta = 0.0; - fac= (texres->ta+texr1.ta+texr2.ta); - if (fac!=0.0f) { - fac= 1.0f/fac; + fac = (texres->ta + texr1.ta + texr2.ta); + if (fac != 0.0f) { + fac = 1.0f / fac; - texres->tr= fac*(texres->ta*texres->tr + texr1.ta*texr1.tr + texr2.ta*texr2.tr ); - texres->tg= fac*(texres->ta*texres->tg + texr1.ta*texr1.tg + texr2.ta*texr2.tg ); - texres->tb= fac*(texres->ta*texres->tb + texr1.ta*texr1.tb + texr2.ta*texr2.tb ); + texres->tr = fac * (texres->ta * texres->tr + texr1.ta * texr1.tr + texr2.ta * texr2.tr); + texres->tg = fac * (texres->ta * texres->tg + texr1.ta * texr1.tg + texr2.ta * texr2.tg); + texres->tb = fac * (texres->ta * texres->tb + texr1.ta * texr1.tb + texr2.ta * texr2.tb); } - texres->ta= 1.0; + texres->ta = 1.0; } } else { @@ -771,7 +771,3 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe return 1; } - -/* ------------------------------------------------------------------------- */ - -/* eof */ diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c index b599da48803..75748696a72 100644 --- a/source/blender/render/intern/source/volumetric.c +++ b/source/blender/render/intern/source/volumetric.c @@ -71,7 +71,7 @@ extern struct Render R; /* luminance rec. 709 */ BLI_INLINE float luminance(const float col[3]) { - return (0.212671f*col[0] + 0.71516f*col[1] + 0.072169f*col[2]); + return (0.212671f * col[0] + 0.71516f * col[1] + 0.072169f * col[2]); } /* tracing */ @@ -80,7 +80,7 @@ static float vol_get_shadow(ShadeInput *shi, LampRen *lar, const float co[3]) float visibility = 1.f; if (lar->shb) { - float dxco[3]={0.f, 0.f, 0.f}, dyco[3]={0.f, 0.f, 0.f}; + float dxco[3] = {0.f, 0.f, 0.f}, dyco[3] = {0.f, 0.f, 0.f}; visibility = testshadowbuf(&R, lar->shb, co, dxco, dyco, 1.0, 0.0); } @@ -89,7 +89,7 @@ static float vol_get_shadow(ShadeInput *shi, LampRen *lar, const float co[3]) Isect is; copy_v3_v3(is.start, co); - if (lar->type==LA_SUN || lar->type==LA_HEMI) { + if (lar->type == LA_SUN || lar->type == LA_HEMI) { is.dir[0] = -lar->vec[0]; is.dir[1] = -lar->vec[1]; is.dir[2] = -lar->vec[2]; @@ -97,17 +97,17 @@ static float vol_get_shadow(ShadeInput *shi, LampRen *lar, const float co[3]) } else { sub_v3_v3v3(is.dir, lar->co, is.start); - is.dist = normalize_v3(is.dir ); + is.dist = normalize_v3(is.dir); } is.mode = RE_RAY_MIRROR; is.check = RE_CHECK_VLR_NON_SOLID_MATERIAL; is.skip = 0; - if (lar->mode & (LA_LAYER|LA_LAYER_SHADOW)) - is.lay= lar->lay; + if (lar->mode & (LA_LAYER | LA_LAYER_SHADOW)) + is.lay = lar->lay; else - is.lay= -1; + is.lay = -1; is.orig.ob = NULL; is.orig.face = NULL; @@ -117,7 +117,7 @@ static float vol_get_shadow(ShadeInput *shi, LampRen *lar, const float co[3]) visibility = 0.f; } - lar->last_hit[shi->thread]= is.last_hit; + lar->last_hit[shi->thread] = is.last_hit; } return visibility; } @@ -128,26 +128,26 @@ static int vol_get_bounds(ShadeInput *shi, const float co[3], const float vec[3] copy_v3_v3(isect->start, co); copy_v3_v3(isect->dir, vec); isect->dist = FLT_MAX; - isect->mode= RE_RAY_MIRROR; + isect->mode = RE_RAY_MIRROR; isect->last_hit = NULL; - isect->lay= -1; - isect->check= RE_CHECK_VLR_NONE; + isect->lay = -1; + isect->check = RE_CHECK_VLR_NONE; if (intersect_type == VOL_BOUNDS_DEPTH) { isect->skip = RE_SKIP_VLR_NEIGHBOUR; - isect->orig.face = (void*)shi->vlr; - isect->orig.ob = (void*)shi->obi; + isect->orig.face = (void *)shi->vlr; + isect->orig.ob = (void *)shi->obi; } else { // if (intersect_type == VOL_BOUNDS_SS) { - isect->skip= 0; - isect->orig.face= NULL; + isect->skip = 0; + isect->orig.face = NULL; isect->orig.ob = NULL; } if (RE_rayobject_raycast(R.raytree, isect)) { - hitco[0] = isect->start[0] + isect->dist*isect->dir[0]; - hitco[1] = isect->start[1] + isect->dist*isect->dir[1]; - hitco[2] = isect->start[2] + isect->dist*isect->dir[2]; + hitco[0] = isect->start[0] + isect->dist * isect->dir[0]; + hitco[1] = isect->start[1] + isect->dist * isect->dir[1]; + hitco[2] = isect->start[2] + isect->dist * isect->dir[2]; return 1; } else { @@ -162,18 +162,18 @@ static void shade_intersection(ShadeInput *shi, float col_r[4], Isect *is) memset(&shi_new, 0, sizeof(ShadeInput)); - shi_new.mask= shi->mask; - shi_new.osatex= shi->osatex; - shi_new.thread= shi->thread; + shi_new.mask = shi->mask; + shi_new.osatex = shi->osatex; + shi_new.thread = shi->thread; shi_new.depth = shi->depth + 1; - shi_new.volume_depth= shi->volume_depth + 1; - shi_new.xs= shi->xs; - shi_new.ys= shi->ys; - shi_new.lay= shi->lay; - shi_new.passflag= SCE_PASS_COMBINED; /* result of tracing needs no pass info */ - shi_new.combinedflag= 0xFFFFFF; /* ray trace does all options */ - shi_new.light_override= shi->light_override; - shi_new.mat_override= shi->mat_override; + shi_new.volume_depth = shi->volume_depth + 1; + shi_new.xs = shi->xs; + shi_new.ys = shi->ys; + shi_new.lay = shi->lay; + shi_new.passflag = SCE_PASS_COMBINED; /* result of tracing needs no pass info */ + shi_new.combinedflag = 0xFFFFFF; /* ray trace does all options */ + shi_new.light_override = shi->light_override; + shi_new.mat_override = shi->mat_override; copy_v3_v3(shi_new.camera_co, is->start); @@ -196,13 +196,13 @@ static void vol_trace_behind(ShadeInput *shi, VlakRen *vlr, const float co[3], f copy_v3_v3(isect.dir, shi->view); isect.dist = FLT_MAX; - isect.mode= RE_RAY_MIRROR; + isect.mode = RE_RAY_MIRROR; isect.check = RE_CHECK_VLR_NONE; isect.skip = RE_SKIP_VLR_NEIGHBOUR; - isect.orig.ob = (void*) shi->obi; - isect.orig.face = (void*)vlr; + isect.orig.ob = (void *) shi->obi; + isect.orig.face = (void *)vlr; isect.last_hit = NULL; - isect.lay= -1; + isect.lay = -1; /* check to see if there's anything behind the volume, otherwise shade the sky */ if (RE_rayobject_raycast(R.raytree, &isect)) { @@ -241,11 +241,11 @@ static void vol_get_precached_scattering(Render *re, ShadeInput *shi, float scat /* Meta object density, brute force for now * (might be good enough anyway, don't need huge number of metaobs to model volumetric objects */ -static float metadensity(Object* ob, const float co[3]) +static float metadensity(Object *ob, const float co[3]) { float mat[4][4], imat[4][4], dens = 0.f; - MetaBall* mb = (MetaBall*)ob->data; - MetaElem* ml; + MetaBall *mb = (MetaBall *)ob->data; + MetaElem *ml; /* transform co to meta-element */ float tco[3] = {co[0], co[1], co[2]}; @@ -253,13 +253,13 @@ static float metadensity(Object* ob, const float co[3]) invert_m4_m4(imat, mat); mul_m4_v3(imat, tco); - for (ml = mb->elems.first; ml; ml=ml->next) { + for (ml = mb->elems.first; ml; ml = ml->next) { float bmat[3][3], dist2; /* element rotation transform */ float tp[3] = {ml->x - tco[0], ml->y - tco[1], ml->z - tco[2]}; quat_to_mat3(bmat, ml->quat); - transpose_m3(bmat); // rot.only, so inverse == transpose + transpose_m3(bmat); // rot.only, so inverse == transpose mul_m3_v3(bmat, tp); /* MB_BALL default */ @@ -269,10 +269,10 @@ static float metadensity(Object* ob, const float co[3]) break; case MB_CUBE: tp[2] = (tp[2] > ml->expz) ? (tp[2] - ml->expz) : ((tp[2] < -ml->expz) ? (tp[2] + ml->expz) : 0.f); - // no break, xy as plane + // no break, xy as plane case MB_PLANE: tp[1] = (tp[1] > ml->expy) ? (tp[1] - ml->expy) : ((tp[1] < -ml->expy) ? (tp[1] + ml->expy) : 0.f); - // no break, x as tube + // no break, x as tube case MB_TUBE: tp[0] = (tp[0] > ml->expx) ? (tp[0] - ml->expx) : ((tp[0] < -ml->expx) ? (tp[0] + ml->expx) : 0.f); } @@ -280,7 +280,7 @@ static float metadensity(Object* ob, const float co[3]) /* ml->rad2 is not set */ dist2 = 1.0f - (dot_v3v3(tp, tp) / (ml->rad * ml->rad)); if (dist2 > 0.f) - dens += (ml->flag & MB_NEGATIVE) ? -ml->s*dist2*dist2*dist2 : ml->s*dist2*dist2*dist2; + dens += (ml->flag & MB_NEGATIVE) ? -ml->s * dist2 * dist2 * dist2 : ml->s * dist2 * dist2 * dist2; } dens -= mb->thresh; @@ -299,7 +299,7 @@ float vol_get_density(struct ShadeInput *shi, const float co[3]) if (shi->obi->obr->ob->type == OB_MBALL) { const float md = metadensity(shi->obi->obr->ob, co); if (md < 1.f) density *= md; - } + } return density * density_scale; } @@ -311,11 +311,11 @@ float vol_get_density(struct ShadeInput *shi, const float co[3]) static void vol_get_reflection_color(ShadeInput *shi, float ref_col[3], const float co[3]) { float scatter = shi->mat->vol.scattering; - float reflection= shi->mat->vol.reflection; + float reflection = shi->mat->vol.reflection; copy_v3_v3(ref_col, shi->mat->vol.reflection_col); - if (shi->mat->mapto_textured & (MAP_SCATTERING+MAP_REFLECTION_COL)) - do_volume_tex(shi, co, MAP_SCATTERING+MAP_REFLECTION_COL, ref_col, &scatter, &R); + if (shi->mat->mapto_textured & (MAP_SCATTERING + MAP_REFLECTION_COL)) + do_volume_tex(shi, co, MAP_SCATTERING + MAP_REFLECTION_COL, ref_col, &scatter, &R); /* only one single float parameter at a time... :s */ if (shi->mat->mapto_textured & (MAP_REFLECTION)) @@ -333,8 +333,8 @@ static void vol_get_emission(ShadeInput *shi, float emission_col[3], const float float emission = shi->mat->vol.emission; copy_v3_v3(emission_col, shi->mat->vol.emission_col); - if (shi->mat->mapto_textured & (MAP_EMISSION+MAP_EMISSION_COL)) - do_volume_tex(shi, co, MAP_EMISSION+MAP_EMISSION_COL, emission_col, &emission, &R); + if (shi->mat->mapto_textured & (MAP_EMISSION + MAP_EMISSION_COL)) + do_volume_tex(shi, co, MAP_EMISSION + MAP_EMISSION_COL, emission_col, &emission, &R); emission_col[0] = emission_col[0] * emission; emission_col[1] = emission_col[1] * emission; @@ -353,8 +353,8 @@ static void vol_get_sigma_t(ShadeInput *shi, float sigma_t[3], const float co[3] float transmission_col[3] = {shi->mat->vol.transmission_col[0], shi->mat->vol.transmission_col[1], shi->mat->vol.transmission_col[2]}; float scattering = shi->mat->vol.scattering; - if (shi->mat->mapto_textured & (MAP_SCATTERING+MAP_TRANSMISSION_COL)) - do_volume_tex(shi, co, MAP_SCATTERING+MAP_TRANSMISSION_COL, transmission_col, &scattering, &R); + if (shi->mat->mapto_textured & (MAP_SCATTERING + MAP_TRANSMISSION_COL)) + do_volume_tex(shi, co, MAP_SCATTERING + MAP_TRANSMISSION_COL, transmission_col, &scattering, &R); sigma_t[0] = (1.0f - transmission_col[0]) + scattering; sigma_t[1] = (1.0f - transmission_col[1]) + scattering; @@ -378,13 +378,13 @@ static float vol_get_phasefunc(ShadeInput *UNUSED(shi), float g, const float w[3 * until Blender's shading system supports this better. --matt */ - if (g == 0.f) { /* isotropic */ + if (g == 0.f) { /* isotropic */ return normalize * 1.f; } - else { /* schlick */ + else { /* schlick */ const float k = 1.55f * g - .55f * g * g * g; const float kcostheta = k * dot_v3v3(w, wp); - return normalize * (1.f - k*k) / ((1.f - kcostheta) * (1.f - kcostheta)); + return normalize * (1.f - k * k) / ((1.f - kcostheta) * (1.f - kcostheta)); } /* not used, but here for reference: */ @@ -395,14 +395,14 @@ static float vol_get_phasefunc(ShadeInput *UNUSED(shi), float g, const float w[3 case MA_VOL_PH_MIEMURKY: return normalize * (0.5f + 16.5f * powf(0.5 * (1.f + costheta), 32.f)); case MA_VOL_PH_RAYLEIGH: - return normalize * 3.f/4.f * (1 + costheta * costheta); + return normalize * 3.f / 4.f * (1 + costheta * costheta); case MA_VOL_PH_HG: return normalize * (1.f - g * g) / powf(1.f + g * g - 2.f * g * costheta, 1.5f); case MA_VOL_PH_SCHLICK: { const float k = 1.55f * g - .55f * g * g * g; const float kcostheta = k * costheta; - return normalize * (1.f - k*k) / ((1.f - kcostheta) * (1.f - kcostheta)); + return normalize * (1.f - k * k) / ((1.f - kcostheta) * (1.f - kcostheta)); } case MA_VOL_PH_ISOTROPIC: default: @@ -471,20 +471,20 @@ static void vol_get_transmittance(ShadeInput *shi, float tr[3], const float co[3 static void vol_shade_one_lamp(struct ShadeInput *shi, const float co[3], const float view[3], LampRen *lar, float lacol[3]) { float visifac, lv[3], lampdist; - float tr[3]={1.0, 1.0, 1.0}; + float tr[3] = {1.0, 1.0, 1.0}; float hitco[3], *atten_co; float p, ref_col[3]; - if (lar->mode & LA_LAYER) if ((lar->lay & shi->obi->lay)==0) return; - if ((lar->lay & shi->lay)==0) return; + if (lar->mode & LA_LAYER) if ((lar->lay & shi->obi->lay) == 0) return; + if ((lar->lay & shi->lay) == 0) return; if (lar->energy == 0.0f) return; - if ((visifac= lamp_get_visibility(lar, co, lv, &lampdist)) == 0.f) return; + if ((visifac = lamp_get_visibility(lar, co, lv, &lampdist)) == 0.f) return; copy_v3_v3(lacol, &lar->r); if (lar->mode & LA_TEXTURE) { - shi->osatex= 0; + shi->osatex = 0; do_lamp_tex(lar, lv, shi, lacol, LA_TEXTURE); } @@ -519,7 +519,7 @@ static void vol_shade_one_lamp(struct ShadeInput *shi, const float co[3], const if (ELEM(lar->type, LA_SUN, LA_HEMI)) /* infinite lights, can never be inside volume */ atten_co = hitco; - else if ( lampdist < dist ) { + else if (lampdist < dist) { atten_co = lar->co; } else @@ -558,10 +558,10 @@ void vol_get_scattering(ShadeInput *shi, float scatter_col[3], const float co[3] zero_v3(scatter_col); - lights= get_lights(shi); - for (go=lights->first; go; go= go->next) { + lights = get_lights(shi); + for (go = lights->first; go; go = go->next) { float lacol[3] = {0.f, 0.f, 0.f}; - lar= go->lampren; + lar = go->lampren; if (lar) { vol_shade_one_lamp(shi, co, view, lar, lacol); @@ -598,7 +598,7 @@ static void volumeintegrate(struct ShadeInput *shi, float col[4], const float co float t0 = 0.f; float pt0 = t0; - float t1 = normalize_v3(step_vec); /* returns vector length */ + float t1 = normalize_v3(step_vec); /* returns vector length */ t0 += stepsize * ((shi->mat->vol.stepsize_type == MA_VOL_STEP_CONSTANT) ? 0.5f : BLI_thread_frand(shi->thread)); p[0] += t0 * step_vec[0]; @@ -656,7 +656,7 @@ static void volume_trace(struct ShadeInput *shi, struct ShadeResult *shr, int in float hitco[3], col[4] = {0.f, 0.f, 0.f, 0.f}; float *startco, *endco; int trace_behind = 1; - const int ztransp= ((shi->depth==0) && (shi->mat->mode & MA_TRANSP) && (shi->mat->mode & MA_ZTRANSP)); + const int ztransp = ((shi->depth == 0) && (shi->mat->mode & MA_TRANSP) && (shi->mat->mode & MA_ZTRANSP)); Isect is; /* check for shading an internal face a volume object directly */ @@ -669,7 +669,7 @@ static void volume_trace(struct ShadeInput *shi, struct ShadeResult *shr, int in if (ztransp && inside_volume == VOL_SHADE_INSIDE) { MatInside *mi; - int render_this=0; + int render_this = 0; /* don't render the backfaces of ztransp volume materials. * @@ -683,9 +683,9 @@ static void volume_trace(struct ShadeInput *shi, struct ShadeResult *shr, int in * which would otherwise render the volume in between the camera and the backface * --matt */ - for (mi=R.render_volumes_inside.first; mi; mi=mi->next) { + for (mi = R.render_volumes_inside.first; mi; mi = mi->next) { /* weak... */ - if (mi->ma == shi->mat) render_this=1; + if (mi->ma == shi->mat) render_this = 1; } if (!render_this) return; } @@ -733,7 +733,7 @@ static void volume_trace(struct ShadeInput *shi, struct ShadeResult *shr, int in } if (ztransp) - col[3] = col[3]>1.f?1.f:col[3]; + col[3] = col[3] > 1.f ? 1.f : col[3]; else col[3] = 1.f; @@ -749,7 +749,7 @@ void shade_volume_shadow(struct ShadeInput *shi, struct ShadeResult *shr, struct { float hitco[3]; float tr[3] = {1.0, 1.0, 1.0}; - Isect is= {{0}}; + Isect is = {{0}}; float *startco, *endco; memset(shr, 0, sizeof(ShadeResult)); @@ -825,5 +825,3 @@ void shade_volume_inside(ShadeInput *shi, ShadeResult *shr) shi->obi = obi_backup; shi->obr = obi_backup->obr; } - - diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c index 90e6594d888..7d54f77fc90 100644 --- a/source/blender/render/intern/source/voxeldata.c +++ b/source/blender/render/intern/source/voxeldata.c @@ -66,10 +66,10 @@ static int is_vd_res_ok(VoxelData *vd) { /* arbitrary large value so corrupt headers don't break */ - const int min= 1, max= 100000; - return (vd->resol[0] >= min && vd->resol[0] <= max) && - (vd->resol[1] >= min && vd->resol[1] <= max) && - (vd->resol[2] >= min && vd->resol[2] <= max); + const int min = 1, max = 100000; + return (vd->resol[0] >= min && vd->resol[0] <= max) && + (vd->resol[1] >= min && vd->resol[1] <= max) && + (vd->resol[2] >= min && vd->resol[2] <= max); } /* use size_t because the result may exceed INT_MAX */ @@ -86,10 +86,10 @@ static int load_frame_blendervoxel(VoxelData *vd, FILE *fp, int frame) if (is_vd_res_ok(vd) == FALSE) return 0; - vd->dataset = MEM_mapallocN(sizeof(float)*size, "voxel dataset"); + vd->dataset = MEM_mapallocN(sizeof(float) * size, "voxel dataset"); if (vd->dataset == NULL) return 0; - if (fseek(fp, frame*size*sizeof(float)+offset, 0) == -1) + if (fseek(fp, frame * size * sizeof(float) + offset, 0) == -1) return 0; if (fread(vd->dataset, sizeof(float), size, fp) != size) return 0; @@ -108,29 +108,29 @@ static int load_frame_raw8(VoxelData *vd, FILE *fp, int frame) if (is_vd_res_ok(vd) == FALSE) return 0; - vd->dataset = MEM_mapallocN(sizeof(float)*size, "voxel dataset"); + vd->dataset = MEM_mapallocN(sizeof(float) * size, "voxel dataset"); if (vd->dataset == NULL) return 0; - data_c = (char *)MEM_mallocN(sizeof(char)*size, "temporary voxel file reading storage"); + data_c = (char *)MEM_mallocN(sizeof(char) * size, "temporary voxel file reading storage"); if (data_c == NULL) { MEM_freeN(vd->dataset); - vd->dataset= NULL; + vd->dataset = NULL; return 0; } - if (fseek(fp, (frame-1)*size*sizeof(char), 0) == -1) { + if (fseek(fp, (frame - 1) * size * sizeof(char), 0) == -1) { MEM_freeN(data_c); MEM_freeN(vd->dataset); - vd->dataset= NULL; + vd->dataset = NULL; return 0; } if (fread(data_c, sizeof(char), size, fp) != size) { MEM_freeN(data_c); MEM_freeN(vd->dataset); - vd->dataset= NULL; + vd->dataset = NULL; return 0; } - for (i=0; i<size; i++) { + for (i = 0; i < size; i++) { vd->dataset[i] = (float)data_c[i] / 255.f; } MEM_freeN(data_c); @@ -146,7 +146,7 @@ static void load_frame_image_sequence(VoxelData *vd, Tex *tex) Image *ima = tex->ima; ImageUser *tiuser = &tex->iuser; ImageUser iuser = *(tiuser); - int x=0, y=0, z=0; + int x = 0, y = 0, z = 0; float *rf; if (!ima || !tiuser) return; @@ -157,10 +157,10 @@ static void load_frame_image_sequence(VoxelData *vd, Tex *tex) /* find the first valid ibuf and use it to initialize the resolution of the data set */ /* need to do this in advance so we know how much memory to allocate */ - ibuf= BKE_image_get_ibuf(ima, &iuser); + ibuf = BKE_image_get_ibuf(ima, &iuser); while (!ibuf && (iuser.framenr < iuser.frames)) { iuser.framenr++; - ibuf= BKE_image_get_ibuf(ima, &iuser); + ibuf = BKE_image_get_ibuf(ima, &iuser); } if (!ibuf) return; if (!ibuf->rect_float) IMB_float_from_rect(ibuf); @@ -169,23 +169,23 @@ static void load_frame_image_sequence(VoxelData *vd, Tex *tex) vd->resol[0] = ibuf->x; vd->resol[1] = ibuf->y; vd->resol[2] = iuser.frames; - vd->dataset = MEM_mapallocN(sizeof(float)*vd_resol_size(vd), "voxel dataset"); + vd->dataset = MEM_mapallocN(sizeof(float) * vd_resol_size(vd), "voxel dataset"); - for (z=0; z < iuser.frames; z++) { + for (z = 0; z < iuser.frames; z++) { /* get a new ibuf for each frame */ if (z > 0) { iuser.framenr++; - ibuf= BKE_image_get_ibuf(ima, &iuser); + ibuf = BKE_image_get_ibuf(ima, &iuser); if (!ibuf) break; if (!ibuf->rect_float) IMB_float_from_rect(ibuf); } rf = ibuf->rect_float; - for (y=0; y < ibuf->y; y++) { - for (x=0; x < ibuf->x; x++) { + for (y = 0; y < ibuf->y; y++) { + for (x = 0; x < ibuf->x; x++) { /* currently averaged to monchrome */ - vd->dataset[ BLI_VOXEL_INDEX(x, y, z, vd->resol) ] = (rf[0] + rf[1] + rf[2]) * 0.333f; - rf +=4; + vd->dataset[BLI_VOXEL_INDEX(x, y, z, vd->resol)] = (rf[0] + rf[1] + rf[2]) * 0.333f; + rf += 4; } } @@ -198,7 +198,7 @@ static void load_frame_image_sequence(VoxelData *vd, Tex *tex) static int read_voxeldata_header(FILE *fp, struct VoxelData *vd) { - VoxelDataHeader *h=(VoxelDataHeader *)MEM_mallocN(sizeof(VoxelDataHeader), "voxel data header"); + VoxelDataHeader *h = (VoxelDataHeader *)MEM_mallocN(sizeof(VoxelDataHeader), "voxel data header"); rewind(fp); if (fread(h, sizeof(VoxelDataHeader), 1, fp) != 1) { @@ -206,9 +206,9 @@ static int read_voxeldata_header(FILE *fp, struct VoxelData *vd) return 0; } - vd->resol[0]=h->resolX; - vd->resol[1]=h->resolY; - vd->resol[2]=h->resolZ; + vd->resol[0] = h->resolX; + vd->resol[1] = h->resolY; + vd->resol[2] = h->resolZ; MEM_freeN(h); return 1; @@ -221,8 +221,8 @@ static void init_frame_smoke(VoxelData *vd, float cfra) ModifierData *md; vd->dataset = NULL; - if (vd->object == NULL) return; - ob= vd->object; + if (vd->object == NULL) return; + ob = vd->object; /* draw code for smoke */ if ((md = (ModifierData *)modifiers_findByType(ob, eModifierType_Smoke))) { @@ -231,23 +231,23 @@ static void init_frame_smoke(VoxelData *vd, float cfra) if (smd->domain && smd->domain->fluid) { if (cfra < smd->domain->point_cache[0]->startframe) - ; /* don't show smoke before simulation starts, this could be made an option in the future */ + ; /* don't show smoke before simulation starts, this could be made an option in the future */ else if (vd->smoked_type == TEX_VD_SMOKEHEAT) { size_t totRes; size_t i; float *heat; copy_v3_v3_int(vd->resol, smd->domain->res); - totRes= vd_resol_size(vd); + totRes = vd_resol_size(vd); // scaling heat values from -2.0-2.0 to 0.0-1.0 - vd->dataset = MEM_mapallocN(sizeof(float)*(totRes), "smoke data"); + vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data"); heat = smoke_get_heat(smd->domain->fluid); - for (i=0; i<totRes; i++) { - vd->dataset[i] = (heat[i]+2.0f)/4.0f; + for (i = 0; i < totRes; i++) { + vd->dataset[i] = (heat[i] + 2.0f) / 4.0f; } //vd->dataset = smoke_get_heat(smd->domain->fluid); @@ -258,17 +258,17 @@ static void init_frame_smoke(VoxelData *vd, float cfra) float *xvel, *yvel, *zvel; copy_v3_v3_int(vd->resol, smd->domain->res); - totRes= vd_resol_size(vd); + totRes = vd_resol_size(vd); // scaling heat values from -2.0-2.0 to 0.0-1.0 - vd->dataset = MEM_mapallocN(sizeof(float)*(totRes), "smoke data"); + vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data"); xvel = smoke_get_velocity_x(smd->domain->fluid); yvel = smoke_get_velocity_y(smd->domain->fluid); zvel = smoke_get_velocity_z(smd->domain->fluid); - for (i=0; i<totRes; i++) { - vd->dataset[i] = sqrt(xvel[i]*xvel[i] + yvel[i]*yvel[i] + zvel[i]*zvel[i])*3.0f; + for (i = 0; i < totRes; i++) { + vd->dataset[i] = sqrt(xvel[i] * xvel[i] + yvel[i] * yvel[i] + zvel[i] * zvel[i]) * 3.0f; } } @@ -286,10 +286,10 @@ static void init_frame_smoke(VoxelData *vd, float cfra) } /* TODO: is_vd_res_ok(rvd) doesnt check this resolution */ - totRes= vd_resol_size(vd); + totRes = vd_resol_size(vd); /* always store copy, as smoke internal data can change */ - vd->dataset = MEM_mapallocN(sizeof(float)*(totRes), "smoke data"); - memcpy(vd->dataset, density, sizeof(float)*totRes); + vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data"); + memcpy(vd->dataset, density, sizeof(float) * totRes); } // end of fluid condition } } @@ -300,7 +300,7 @@ static void init_frame_smoke(VoxelData *vd, float cfra) (void)vd; (void)cfra; - vd->dataset= NULL; + vd->dataset = NULL; #endif } @@ -342,7 +342,7 @@ void cache_voxeldata(Tex *tex, int scene_frame) if (!fp) return; if (read_voxeldata_header(fp, vd)) - load_frame_blendervoxel(vd, fp, curframe-1); + load_frame_blendervoxel(vd, fp, curframe - 1); fclose(fp); return; @@ -362,17 +362,17 @@ void make_voxeldata(struct Render *re) { Tex *tex; - re->i.infostr= "Loading voxel datasets"; + re->i.infostr = "Loading voxel datasets"; re->stats_draw(re->sdh, &re->i); /* XXX: should be doing only textures used in this render */ - for (tex= re->main->tex.first; tex; tex= tex->id.next) { - if (tex->id.us && tex->type==TEX_VOXELDATA) { + for (tex = re->main->tex.first; tex; tex = tex->id.next) { + if (tex->id.us && tex->type == TEX_VOXELDATA) { cache_voxeldata(tex, re->r.cfra); } } - re->i.infostr= NULL; + re->i.infostr = NULL; re->stats_draw(re->sdh, &re->i); } @@ -383,7 +383,7 @@ int voxeldatatex(struct Tex *tex, const float texvec[3], struct TexResult *texre VoxelData *vd = tex->vd; float co[3], offset[3] = {0.5, 0.5, 0.5}; - if (vd->dataset==NULL) { + if (vd->dataset == NULL) { texres->tin = 0.0f; return 0; } @@ -448,5 +448,3 @@ int voxeldatatex(struct Tex *tex, const float texvec[3], struct TexResult *texre return retval; } - - diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index d7d55885f37..1cf58b4345b 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2174,8 +2174,8 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) /* Options panel */ selected = RNA_boolean_get(op->ptr, "selected"); apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers"); - include_bone_children = RNA_boolean_get(op->ptr, "include_bone_children"); - use_object_instantiation = RNA_boolean_get(op->ptr, "use_object_instantiation"); + include_bone_children = RNA_boolean_get(op->ptr, "include_bone_children"); + use_object_instantiation = RNA_boolean_get(op->ptr, "use_object_instantiation"); second_life = RNA_boolean_get(op->ptr, "second_life"); /* get editmode results */ diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp index d0d940a2e42..ce183b37498 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp +++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp @@ -91,10 +91,10 @@ void SCA_PropertySensor::PrecalculateRangeExpression() //The context is needed to retrieve the property at runtime but it creates //loop of references pars.SetContext(this->AddRef()); - STR_String checkstr = "(" + m_checkpropval + " <= " - + m_checkpropname + ") && ( " - + m_checkpropname + " <= " - + m_checkpropmaxval + ")"; + STR_String checkstr = ("(" + m_checkpropval + " <= " + + m_checkpropname + ") && ( " + + m_checkpropname + " <= " + + m_checkpropmaxval + ")"); m_range_expr = pars.ProcessText(checkstr); } diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp index 40dba3bf03a..b0fc1431482 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp +++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp @@ -141,8 +141,7 @@ bool SCA_RandomActuator::Update() int res; /* The [0, 1] interval is projected onto the [min, max+1] domain, */ /* and then rounded. */ - res = (int) floor( ((m_parameter2 - m_parameter1 + 1) * m_base->DrawFloat()) - + m_parameter1); + res = (int)floor( ((m_parameter2 - m_parameter1 + 1) * m_base->DrawFloat()) + m_parameter1); tmpval = new CIntValue(res); } break; @@ -172,8 +171,7 @@ bool SCA_RandomActuator::Update() } break; case KX_RANDOMACT_FLOAT_UNIFORM: { - float res = ((m_parameter2 - m_parameter1) * m_base->DrawFloat()) - + m_parameter1; + float res = ((m_parameter2 - m_parameter1) * m_base->DrawFloat()) + m_parameter1; tmpval = new CFloatValue(res); } break; @@ -239,8 +237,7 @@ bool SCA_RandomActuator::Update() /* controlling parameter. Using the 'normal' exponent is not very */ /* intuitive... */ /* tmpval = new CFloatValue( (1.0 / m_parameter1) */ - tmpval = new CFloatValue( (m_parameter1) - * (-log(1.0 - m_base->DrawFloat())) ); + tmpval = new CFloatValue((m_parameter1) * (-log(1.0 - m_base->DrawFloat()))); } break; diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 4f0ae4261c9..695ad1f945c 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -2267,10 +2267,10 @@ KX_PYMETHODDEF_DOC(KX_Scene, addObject, !ConvertPythonToGameObject(pyother, &other, false, "scene.addObject(object, other, time): KX_Scene (second argument)") ) return NULL; - if (!m_inactivelist->SearchValue(ob)) { - PyErr_Format(PyExc_ValueError, "scene.addObject(object, other, time): KX_Scene (second argument): object does not belong to scene"); - return NULL; - } + if (!m_inactivelist->SearchValue(ob)) { + PyErr_Format(PyExc_ValueError, "scene.addObject(object, other, time): KX_Scene (second argument): object does not belong to scene"); + return NULL; + } SCA_IObject* replica = AddReplicaObject((SCA_IObject*)ob, other, time); // release here because AddReplicaObject AddRef's diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 767d99583b8..343cb549337 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -719,8 +719,8 @@ void CcdPhysicsEnvironment::processFhSprings(double curTime,float interval) { if (ctrl->getConstructionInfo().m_do_fh) { - btVector3 lspot = cl_object->getCenterOfMassPosition() - + rayDirLocal * resultCallback.m_closestHitFraction; + btVector3 lspot = cl_object->getCenterOfMassPosition() + + rayDirLocal * resultCallback.m_closestHitFraction; diff --git a/source/gameengine/VideoTexture/FilterColor.h b/source/gameengine/VideoTexture/FilterColor.h index 9b1976cf40f..cd61900bbda 100644 --- a/source/gameengine/VideoTexture/FilterColor.h +++ b/source/gameengine/VideoTexture/FilterColor.h @@ -91,9 +91,9 @@ protected: /// calculate one color component unsigned char calcColor (unsigned int val, short idx) { - return (((m_matrix[idx][0] * (VT_R(val)) + m_matrix[idx][1] * (VT_G(val)) - + m_matrix[idx][2] * (VT_B(val)) + m_matrix[idx][3] * (VT_A(val)) - + m_matrix[idx][4]) >> 8) & 0xFF); + return (((m_matrix[idx][0] * (VT_R(val)) + m_matrix[idx][1] * (VT_G(val)) + + m_matrix[idx][2] * (VT_B(val)) + m_matrix[idx][3] * (VT_A(val)) + + m_matrix[idx][4]) >> 8) & 0xFF); } /// filter pixel template, source int buffer |