Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/animation/anim_markers.c2
-rw-r--r--source/blender/editors/datafiles/CMakeLists.txt2
-rw-r--r--source/blender/editors/gpencil/gpencil_intern.h3
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c282
-rw-r--r--source/blender/editors/include/ED_mask.h30
-rw-r--r--source/blender/editors/include/ED_transform_snap_object_context.h2
-rw-r--r--source/blender/editors/include/UI_icons.h16
-rw-r--r--source/blender/editors/include/UI_interface.h6
-rw-r--r--source/blender/editors/interface/CMakeLists.txt1
-rw-r--r--source/blender/editors/interface/interface_eyedropper.c1
-rw-r--r--source/blender/editors/interface/interface_eyedropper_gpencil_color.c324
-rw-r--r--source/blender/editors/interface/interface_intern.h3
-rw-r--r--source/blender/editors/interface/interface_layout.c30
-rw-r--r--source/blender/editors/interface/interface_ops.c1
-rw-r--r--source/blender/editors/interface/interface_templates.c36
-rw-r--r--source/blender/editors/interface/interface_widgets.c33
-rw-r--r--source/blender/editors/mask/mask_add.c227
-rw-r--r--source/blender/editors/mask/mask_draw.c119
-rw-r--r--source/blender/editors/mask/mask_edit.c10
-rw-r--r--source/blender/editors/mask/mask_editaction.c183
-rw-r--r--source/blender/editors/mask/mask_intern.h10
-rw-r--r--source/blender/editors/mask/mask_ops.c229
-rw-r--r--source/blender/editors/mask/mask_relationships.c24
-rw-r--r--source/blender/editors/mask/mask_select.c144
-rw-r--r--source/blender/editors/mask/mask_shapekey.c179
-rw-r--r--source/blender/editors/render/render_view.c2
-rw-r--r--source/blender/editors/screen/area.c2
-rw-r--r--source/blender/editors/screen/screen_ops.c2
-rw-r--r--source/blender/editors/space_file/file_ops.c64
-rw-r--r--source/blender/editors/space_file/filelist.c2
-rw-r--r--source/blender/editors/space_file/filesel.c6
-rw-r--r--source/blender/editors/space_graph/space_graph.c6
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c4
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c67
-rw-r--r--source/blender/editors/space_sequencer/sequencer_intern.h4
-rw-r--r--source/blender/editors/space_sequencer/sequencer_ops.c4
-rw-r--r--source/blender/editors/space_sequencer/sequencer_select.c86
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c8
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c6
-rw-r--r--source/blender/editors/transform/transform_snap.c4
-rw-r--r--source/blender/editors/transform/transform_snap_object.c186
41 files changed, 1584 insertions, 766 deletions
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 29d06d5b297..36583ecf060 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -1181,7 +1181,7 @@ static int select_timeline_marker_frame(ListBase *markers,
LISTBASE_CIRCULAR_FORWARD_BEGIN (markers, marker, marker_selected) {
/* this way a not-extend select will always give 1 selected marker */
- if ((marker->frame == frame)) {
+ if (marker->frame == frame) {
marker->flag ^= SELECT;
break;
}
diff --git a/source/blender/editors/datafiles/CMakeLists.txt b/source/blender/editors/datafiles/CMakeLists.txt
index 1c7edb6c46a..680fe3a00e5 100644
--- a/source/blender/editors/datafiles/CMakeLists.txt
+++ b/source/blender/editors/datafiles/CMakeLists.txt
@@ -693,6 +693,7 @@ set_property(GLOBAL PROPERTY ICON_GEOM_NAMES
ops.gpencil.primitive_circle
ops.gpencil.primitive_curve
ops.gpencil.primitive_line
+ ops.gpencil.primitive_polyline
ops.gpencil.radius
ops.gpencil.sculpt_clone
ops.gpencil.sculpt_grab
@@ -728,6 +729,7 @@ set_property(GLOBAL PROPERTY ICON_GEOM_NAMES
ops.mesh.spin.duplicate
ops.mesh.vertices_smooth
ops.node.links_cut
+ ops.paint.eyedropper_add
ops.paint.vertex_color_fill
ops.paint.weight_fill
ops.paint.weight_gradient
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index a8f8ec0e8c5..1af641e5c84 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -214,6 +214,8 @@ typedef struct tGPDprimitive {
int sel_cp;
/** flag to determine operations in progress */
int flag;
+ /** flag to determine operations previous mode */
+ int prev_flag;
/** recorded mouse-position */
float mval[2];
/** previous recorded mouse-position */
@@ -465,6 +467,7 @@ enum {
GP_STROKE_CIRCLE = 2,
GP_STROKE_ARC = 3,
GP_STROKE_CURVE = 4,
+ GP_STROKE_POLYLINE = 5,
};
enum {
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index 9072f5f6bef..f0ff38e60b1 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -90,6 +90,7 @@
#define IN_MOVE 3
#define IN_BRUSH_SIZE 4
#define IN_BRUSH_STRENGTH 5
+#define IN_POLYLINE 6
#define SELECT_NONE 0
#define SELECT_START 1
@@ -184,6 +185,29 @@ static void gpencil_primitive_to_square(tGPDprimitive *tgpi, const float x, cons
}
}
+/* Helper to constrain a primitive */
+static void gpencil_primitive_constrain(tGPDprimitive *tgpi, bool line_mode)
+{
+ float x = tgpi->end[0] - tgpi->origin[0];
+ float y = tgpi->end[1] - tgpi->origin[1];
+
+ if (line_mode) {
+ float angle = fabsf(atan2f(y, x));
+ if (angle < 0.4f || angle > (M_PI - 0.4f)) {
+ tgpi->end[1] = tgpi->origin[1];
+ }
+ else if (angle > (M_PI_2 - 0.4f) && angle < (M_PI_2 + 0.4f)) {
+ tgpi->end[0] = tgpi->origin[0];
+ }
+ else {
+ gpencil_primitive_to_square(tgpi, x, y);
+ }
+ }
+ else {
+ gpencil_primitive_to_square(tgpi, x, y);
+ }
+}
+
/* Helper to rotate point around origin */
static void gp_rotate_v2_v2v2fl(float v[2],
const float p[2],
@@ -404,6 +428,11 @@ static void gpencil_primitive_status_indicators(bContext *C, tGPDprimitive *tgpi
"adjust subdivision number, Shift to align, Alt to center, E: extrude"),
UI_MAX_DRAW_STR);
}
+ else if (tgpi->type == GP_STROKE_POLYLINE) {
+ BLI_strncpy(msg_str,
+ TIP_("Line: ESC to cancel, LMB to set, Enter/MMB to confirm, Shift to align"),
+ UI_MAX_DRAW_STR);
+ }
else if (tgpi->type == GP_STROKE_BOX) {
BLI_strncpy(msg_str,
TIP_("Rectangle: ESC to cancel, LMB set origin, Enter/MMB to confirm, WHEEL/+- "
@@ -429,7 +458,12 @@ static void gpencil_primitive_status_indicators(bContext *C, tGPDprimitive *tgpi
UI_MAX_DRAW_STR);
}
- if (ELEM(tgpi->type, GP_STROKE_CIRCLE, GP_STROKE_ARC, GP_STROKE_LINE, GP_STROKE_BOX)) {
+ if (ELEM(tgpi->type,
+ GP_STROKE_CIRCLE,
+ GP_STROKE_ARC,
+ GP_STROKE_LINE,
+ GP_STROKE_BOX,
+ GP_STROKE_POLYLINE)) {
if (hasNumInput(&tgpi->num)) {
char str_offs[NUM_STR_REP_LEN];
@@ -528,7 +562,7 @@ static void gp_primitive_rectangle(tGPDprimitive *tgpi, tGPspoint *points2D)
}
/* create a line */
-static void gp_primitive_line(tGPDprimitive *tgpi, tGPspoint *points2D)
+static void gp_primitive_line(tGPDprimitive *tgpi, tGPspoint *points2D, bool editable)
{
const int totpoints = (tgpi->tot_edges + tgpi->tot_stored_edges);
const float step = 1.0f / (float)(tgpi->tot_edges - 1);
@@ -540,15 +574,22 @@ static void gp_primitive_line(tGPDprimitive *tgpi, tGPspoint *points2D)
a += step;
}
- float color[4];
- UI_GetThemeColor4fv(TH_GIZMO_PRIMARY, color);
- gp_primitive_set_cp(tgpi, tgpi->end, color, BIG_SIZE_CTL);
- if (tgpi->tot_stored_edges) {
- UI_GetThemeColor4fv(TH_REDALERT, color);
- gp_primitive_set_cp(tgpi, tgpi->start, color, SMALL_SIZE_CTL);
+ if (editable) {
+ float color[4];
+ UI_GetThemeColor4fv(TH_GIZMO_PRIMARY, color);
+ gp_primitive_set_cp(tgpi, tgpi->end, color, BIG_SIZE_CTL);
+ if (tgpi->tot_stored_edges) {
+ UI_GetThemeColor4fv(TH_REDALERT, color);
+ gp_primitive_set_cp(tgpi, tgpi->start, color, SMALL_SIZE_CTL);
+ }
+ else {
+ gp_primitive_set_cp(tgpi, tgpi->start, color, BIG_SIZE_CTL);
+ }
}
else {
- gp_primitive_set_cp(tgpi, tgpi->start, color, BIG_SIZE_CTL);
+ float color[4];
+ UI_GetThemeColor4fv(TH_REDALERT, color);
+ gp_primitive_set_cp(tgpi, tgpi->start, color, SMALL_SIZE_CTL);
}
}
@@ -693,7 +734,10 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
gp_primitive_rectangle(tgpi, points2D);
break;
case GP_STROKE_LINE:
- gp_primitive_line(tgpi, points2D);
+ gp_primitive_line(tgpi, points2D, true);
+ break;
+ case GP_STROKE_POLYLINE:
+ gp_primitive_line(tgpi, points2D, false);
break;
case GP_STROKE_CIRCLE:
gp_primitive_circle(tgpi, points2D);
@@ -1041,6 +1085,7 @@ static void gpencil_primitive_update(bContext *C, wmOperator *op, tGPDprimitive
gp_primitive_update_strokes(C, tgpi);
}
+/* Initialise mouse points */
static void gpencil_primitive_interaction_begin(tGPDprimitive *tgpi, const wmEvent *event)
{
copy_v2fl_v2i(tgpi->mval, event->mval);
@@ -1164,6 +1209,10 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op)
/* set default edge count */
switch (tgpi->type) {
+ case GP_STROKE_POLYLINE: {
+ RNA_int_set(op->ptr, "edges", 8);
+ break;
+ }
case GP_STROKE_LINE: {
RNA_int_set(op->ptr, "edges", 8);
break;
@@ -1334,6 +1383,42 @@ static void gpencil_primitive_edit_event_handling(
}
switch (event->type) {
+ case LEFTMOUSE: {
+ if ((event->val == KM_RELEASE) && (tgpi->flag == IN_PROGRESS)) {
+ /* set control points and enter edit mode */
+ if ((ELEM(tgpi->type, GP_STROKE_POLYLINE))) {
+ gpencil_primitive_add_segment(tgpi);
+ copy_v2_v2(tgpi->start, tgpi->end);
+ copy_v2_v2(tgpi->origin, tgpi->start);
+ gp_primitive_update_cps(tgpi);
+
+ tgpi->flag = IN_POLYLINE;
+ WM_cursor_modal_set(win, WM_CURSOR_CROSS);
+ }
+ else {
+ tgpi->flag = IN_CURVE_EDIT;
+ gp_primitive_update_cps(tgpi);
+ gpencil_primitive_update(C, op, tgpi);
+ }
+ }
+ else if ((event->val == KM_PRESS) && !ELEM(tgpi->type, GP_STROKE_POLYLINE)) {
+ /* find nearest cp based on stroke end points */
+ if (move == MOVE_ENDS) {
+ tgpi->sel_cp = (a < b) ? SELECT_START : SELECT_END;
+ }
+ else if (move == MOVE_CP) {
+ tgpi->sel_cp = (c < d) ? SELECT_CP1 : SELECT_CP2;
+ }
+ else {
+ tgpi->sel_cp = SELECT_NONE;
+ }
+ break;
+ }
+ else {
+ tgpi->sel_cp = SELECT_NONE;
+ }
+ break;
+ }
case MOUSEMOVE: {
if ((event->val == KM_PRESS) && tgpi->sel_cp != SELECT_NONE) {
if (tgpi->sel_cp == SELECT_START && tgpi->tot_stored_edges == 0) {
@@ -1366,31 +1451,6 @@ static void gpencil_primitive_edit_event_handling(
}
break;
}
- case LEFTMOUSE: {
- if ((event->val == KM_PRESS)) {
- /* find nearest cp based on stroke end points */
- if (move == MOVE_ENDS) {
- tgpi->sel_cp = (a < b) ? SELECT_START : SELECT_END;
- }
- else if (move == MOVE_CP) {
- tgpi->sel_cp = (c < d) ? SELECT_CP1 : SELECT_CP2;
- }
- else {
- tgpi->sel_cp = SELECT_NONE;
- }
- break;
- }
- else if ((event->val == KM_RELEASE) && (tgpi->flag == IN_PROGRESS)) {
- /* set control points and enter edit mode */
- tgpi->flag = IN_CURVE_EDIT;
- gp_primitive_update_cps(tgpi);
- gpencil_primitive_update(C, op, tgpi);
- }
- else {
- tgpi->sel_cp = SELECT_NONE;
- }
- break;
- }
case MKEY: {
if ((event->val == KM_PRESS) && (tgpi->curve) && (ELEM(tgpi->orign_type, GP_STROKE_ARC))) {
tgpi->flip ^= 1;
@@ -1524,6 +1584,96 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
copy_v2_v2(tgpi->mvalo, tgpi->mval);
return OPERATOR_RUNNING_MODAL;
}
+ else if (tgpi->flag == IN_POLYLINE) {
+
+ switch (event->type) {
+
+ case ESCKEY: {
+ /* return to normal cursor and header status */
+ ED_workspace_status_text(C, NULL);
+ WM_cursor_modal_restore(win);
+
+ /* clean up temp data */
+ gpencil_primitive_exit(C, op);
+
+ /* canceled! */
+ return OPERATOR_CANCELLED;
+ }
+ case LEFTMOUSE: {
+ if (event->val == KM_PRESS) {
+ WM_cursor_modal_set(win, WM_CURSOR_CROSS);
+ gpencil_primitive_add_segment(tgpi);
+
+ gpencil_primitive_update(C, op, tgpi);
+ copy_v2_v2(tgpi->start, tgpi->end);
+ copy_v2_v2(tgpi->origin, tgpi->end);
+ }
+ break;
+ }
+ case SPACEKEY: /* confirm */
+ case MIDDLEMOUSE:
+ case RETKEY:
+ case RIGHTMOUSE: {
+ if (event->val == KM_PRESS) {
+ tgpi->flag = IDLE;
+ tgpi->tot_edges = tgpi->tot_stored_edges ? 1 : 0;
+ gp_primitive_update_strokes(C, tgpi);
+ gpencil_primitive_interaction_end(C, op, win, tgpi);
+ return OPERATOR_FINISHED;
+ }
+ break;
+ }
+ case MOUSEMOVE: {
+ WM_cursor_modal_set(win, WM_CURSOR_NSEW_SCROLL);
+ copy_v2_v2(tgpi->end, tgpi->mval);
+
+ if (event->shift) {
+ gpencil_primitive_constrain(tgpi, true);
+ }
+
+ gpencil_primitive_update(C, op, tgpi);
+ break;
+ }
+ case PADPLUSKEY:
+ case WHEELUPMOUSE: {
+ if ((event->val != KM_RELEASE)) {
+ tgpi->tot_edges = tgpi->tot_edges + 1;
+ CLAMP(tgpi->tot_edges, MIN_EDGES, MAX_EDGES);
+ RNA_int_set(op->ptr, "edges", tgpi->tot_edges);
+ gpencil_primitive_update(C, op, tgpi);
+ }
+ break;
+ }
+ case PADMINUS:
+ case WHEELDOWNMOUSE: {
+ if ((event->val != KM_RELEASE)) {
+ tgpi->tot_edges = tgpi->tot_edges - 1;
+ CLAMP(tgpi->tot_edges, MIN_EDGES, MAX_EDGES);
+ RNA_int_set(op->ptr, "edges", tgpi->tot_edges);
+ gpencil_primitive_update(C, op, tgpi);
+ }
+ break;
+ }
+ case FKEY: /* brush thickness/ brush strength */
+ {
+ if ((event->val == KM_PRESS)) {
+ if (event->shift) {
+ tgpi->prev_flag = tgpi->flag;
+ tgpi->flag = IN_BRUSH_STRENGTH;
+ }
+ else {
+ tgpi->prev_flag = tgpi->flag;
+ tgpi->flag = IN_BRUSH_SIZE;
+ }
+ WM_cursor_modal_set(win, WM_CURSOR_NS_SCROLL);
+ }
+ break;
+ }
+ }
+
+ copy_v2_v2(tgpi->mvalo, tgpi->mval);
+ return OPERATOR_RUNNING_MODAL;
+ }
else if (tgpi->flag == IN_BRUSH_SIZE) {
switch (event->type) {
case MOUSEMOVE:
@@ -1534,11 +1684,11 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
case MIDDLEMOUSE:
case LEFTMOUSE:
tgpi->brush_size = 0;
- tgpi->flag = IN_CURVE_EDIT;
+ tgpi->flag = tgpi->prev_flag;
break;
case RIGHTMOUSE:
if (event->val == KM_RELEASE) {
- tgpi->flag = IN_CURVE_EDIT;
+ tgpi->flag = tgpi->prev_flag;
gpencil_primitive_size(tgpi, true);
gpencil_primitive_update(C, op, tgpi);
}
@@ -1557,11 +1707,11 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
case MIDDLEMOUSE:
case LEFTMOUSE:
tgpi->brush_strength = 0.0f;
- tgpi->flag = IN_CURVE_EDIT;
+ tgpi->flag = tgpi->prev_flag;
break;
case RIGHTMOUSE:
if (event->val == KM_RELEASE) {
- tgpi->flag = IN_CURVE_EDIT;
+ tgpi->flag = tgpi->prev_flag;
gpencil_primitive_strength(tgpi, true);
gpencil_primitive_update(C, op, tgpi);
}
@@ -1570,7 +1720,7 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
copy_v2_v2(tgpi->mvalo, tgpi->mval);
return OPERATOR_RUNNING_MODAL;
}
- else if (tgpi->flag != IDLE) {
+ else if (!ELEM(tgpi->flag, IDLE) && !ELEM(tgpi->type, GP_STROKE_POLYLINE)) {
gpencil_primitive_edit_event_handling(C, op, win, event, tgpi);
}
@@ -1581,24 +1731,38 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
/* TODO: Ignore if not in main region yet */
tgpi->flag = IN_PROGRESS;
gpencil_primitive_interaction_begin(tgpi, event);
+ if (ELEM(tgpi->type, GP_STROKE_POLYLINE)) {
+ tgpi->flag = IN_POLYLINE;
+ gpencil_primitive_update(C, op, tgpi);
+ return OPERATOR_RUNNING_MODAL;
+ }
}
- else if ((event->val == KM_RELEASE) && (tgpi->flag == IN_MOVE)) {
- tgpi->flag = IN_CURVE_EDIT;
- }
- else if ((event->val == KM_RELEASE) && (tgpi->flag == IN_PROGRESS)) {
+ else if ((event->val == KM_RELEASE) && (tgpi->flag == IN_PROGRESS) &&
+ (!ELEM(tgpi->type, GP_STROKE_POLYLINE))) {
/* set control points and enter edit mode */
tgpi->flag = IN_CURVE_EDIT;
gp_primitive_update_cps(tgpi);
gpencil_primitive_update(C, op, tgpi);
}
else if ((event->val == KM_RELEASE) && (tgpi->flag == IN_PROGRESS) &&
- (tgpi->type != GP_STROKE_CURVE)) {
+ (!ELEM(tgpi->type, GP_STROKE_CURVE, GP_STROKE_POLYLINE))) {
/* stop drawing primitive */
tgpi->flag = IDLE;
gpencil_primitive_interaction_end(C, op, win, tgpi);
/* done! */
return OPERATOR_FINISHED;
}
+ else if ((event->val == KM_RELEASE) && (tgpi->flag == IN_PROGRESS) &&
+ (ELEM(tgpi->type, GP_STROKE_POLYLINE))) {
+ /* set control points and enter edit mode */
+ tgpi->flag = IN_POLYLINE;
+ gpencil_primitive_update(C, op, tgpi);
+ copy_v2_v2(tgpi->mvalo, tgpi->mval);
+ return OPERATOR_RUNNING_MODAL;
+ }
+ else if ((event->val == KM_RELEASE) && (tgpi->flag == IN_MOVE)) {
+ tgpi->flag = IN_CURVE_EDIT;
+ }
else {
if (G.debug & G_DEBUG) {
printf("GP Add Primitive Modal: LEFTMOUSE %d, Status = %d\n", event->val, tgpi->flag);
@@ -1619,7 +1783,7 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
/* exception to cancel current stroke when we have previous strokes in buffer */
if (tgpi->tot_stored_edges > 0) {
tgpi->flag = IDLE;
- tgpi->tot_edges = 0;
+ tgpi->tot_edges = tgpi->tot_stored_edges ? 1 : 0;
gp_primitive_update_strokes(C, tgpi);
gpencil_primitive_interaction_end(C, op, win, tgpi);
/* done! */
@@ -1674,9 +1838,11 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
{
if ((event->val == KM_PRESS)) {
if (event->shift) {
+ tgpi->prev_flag = tgpi->flag;
tgpi->flag = IN_BRUSH_STRENGTH;
}
else {
+ tgpi->prev_flag = tgpi->flag;
tgpi->flag = IN_BRUSH_SIZE;
}
WM_cursor_modal_set(win, WM_CURSOR_NS_SCROLL);
@@ -1713,7 +1879,7 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
}
case MOUSEMOVE: /* calculate new position */
{
- if (tgpi->flag == IN_CURVE_EDIT) {
+ if (ELEM(tgpi->flag, IN_CURVE_EDIT)) {
break;
}
/* only handle mousemove if not doing numinput */
@@ -1726,26 +1892,11 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
}
/* Keep square if shift key */
if (event->shift) {
- float x = tgpi->end[0] - tgpi->origin[0];
- float y = tgpi->end[1] - tgpi->origin[1];
- if (tgpi->type == GP_STROKE_LINE || tgpi->curve) {
- float angle = fabsf(atan2f(y, x));
- if (angle < 0.4f || angle > (M_PI - 0.4f)) {
- tgpi->end[1] = tgpi->origin[1];
- }
- else if (angle > (M_PI_2 - 0.4f) && angle < (M_PI_2 + 0.4f)) {
- tgpi->end[0] = tgpi->origin[0];
- }
- else {
- gpencil_primitive_to_square(tgpi, x, y);
- }
- }
- else {
- gpencil_primitive_to_square(tgpi, x, y);
- }
+ gpencil_primitive_constrain(
+ tgpi, (ELEM(tgpi->type, GP_STROKE_LINE, GP_STROKE_POLYLINE) || tgpi->curve));
}
/* Center primitive if alt key */
- if (event->alt) {
+ if (event->alt && !ELEM(tgpi->type, GP_STROKE_POLYLINE)) {
tgpi->start[0] = tgpi->origin[0] - (tgpi->end[0] - tgpi->origin[0]);
tgpi->start[1] = tgpi->origin[1] - (tgpi->end[1] - tgpi->origin[1]);
}
@@ -1797,6 +1948,7 @@ void GPENCIL_OT_primitive(wmOperatorType *ot)
static EnumPropertyItem primitive_type[] = {
{GP_STROKE_BOX, "BOX", 0, "Box", ""},
{GP_STROKE_LINE, "LINE", 0, "Line", ""},
+ {GP_STROKE_POLYLINE, "POLYLINE", 0, "Polyline", ""},
{GP_STROKE_CIRCLE, "CIRCLE", 0, "Circle", ""},
{GP_STROKE_ARC, "ARC", 0, "Arc", ""},
{GP_STROKE_CURVE, "CURVE", 0, "Curve", ""},
diff --git a/source/blender/editors/include/ED_mask.h b/source/blender/editors/include/ED_mask.h
index df4349a9063..f4725fea039 100644
--- a/source/blender/editors/include/ED_mask.h
+++ b/source/blender/editors/include/ED_mask.h
@@ -77,41 +77,41 @@ void ED_mask_draw_frames(
struct Mask *mask, struct ARegion *ar, const int cfra, const int sfra, const int efra);
/* mask_shapekey.c */
-void ED_mask_layer_shape_auto_key(struct MaskLayer *masklay, const int frame);
+void ED_mask_layer_shape_auto_key(struct MaskLayer *mask_layer, const int frame);
bool ED_mask_layer_shape_auto_key_all(struct Mask *mask, const int frame);
bool ED_mask_layer_shape_auto_key_select(struct Mask *mask, const int frame);
/* ----------- Mask AnimEdit API ------------------ */
-bool ED_masklayer_frames_looper(struct MaskLayer *masklay,
+bool ED_masklayer_frames_looper(struct MaskLayer *mask_layer,
struct Scene *scene,
- short (*masklay_shape_cb)(struct MaskLayerShape *,
- struct Scene *));
-void ED_masklayer_make_cfra_list(struct MaskLayer *masklay, ListBase *elems, bool onlysel);
+ short (*mask_layer_shape_cb)(struct MaskLayerShape *,
+ struct Scene *));
+void ED_masklayer_make_cfra_list(struct MaskLayer *mask_layer, ListBase *elems, bool onlysel);
-bool ED_masklayer_frame_select_check(struct MaskLayer *masklay);
-void ED_masklayer_frame_select_set(struct MaskLayer *masklay, short mode);
-void ED_masklayer_frames_select_box(struct MaskLayer *masklay,
+bool ED_masklayer_frame_select_check(struct MaskLayer *mask_layer);
+void ED_masklayer_frame_select_set(struct MaskLayer *mask_layer, short mode);
+void ED_masklayer_frames_select_box(struct MaskLayer *mask_layer,
float min,
float max,
short select_mode);
void ED_masklayer_frames_select_region(struct KeyframeEditData *ked,
- struct MaskLayer *masklay,
+ struct MaskLayer *mask_layer,
short tool,
short select_mode);
-void ED_mask_select_frames(struct MaskLayer *masklay, short select_mode);
-void ED_mask_select_frame(struct MaskLayer *masklay, int selx, short select_mode);
+void ED_mask_select_frames(struct MaskLayer *mask_layer, short select_mode);
+void ED_mask_select_frame(struct MaskLayer *mask_layer, int selx, short select_mode);
-bool ED_masklayer_frames_delete(struct MaskLayer *masklay);
-void ED_masklayer_frames_duplicate(struct MaskLayer *masklay);
+bool ED_masklayer_frames_delete(struct MaskLayer *mask_layer);
+void ED_masklayer_frames_duplicate(struct MaskLayer *mask_layer);
-void ED_masklayer_snap_frames(struct MaskLayer *masklay, struct Scene *scene, short mode);
+void ED_masklayer_snap_frames(struct MaskLayer *mask_layer, struct Scene *scene, short mode);
#if 0
void free_gpcopybuf(void);
void copy_gpdata(void);
void paste_gpdata(void);
-void mirror_masklayer_frames(struct MaskLayer *masklay, short mode);
+void mirror_masklayer_frames(struct MaskLayer *mask_layer, short mode);
#endif
#endif /* __ED_MASK_H__ */
diff --git a/source/blender/editors/include/ED_transform_snap_object_context.h b/source/blender/editors/include/ED_transform_snap_object_context.h
index 40e0005b487..0e20abe4221 100644
--- a/source/blender/editors/include/ED_transform_snap_object_context.h
+++ b/source/blender/editors/include/ED_transform_snap_object_context.h
@@ -68,6 +68,8 @@ struct SnapObjectParams {
unsigned int use_object_edit_cage : 1;
/* snap to the closest element, use when using more than one snap type */
unsigned int use_occlusion_test : 1;
+ /* exclude back facing geometry from snapping */
+ unsigned int use_backface_culling : 1;
};
typedef struct SnapObjectContext SnapObjectContext;
diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h
index 1c2bc54d821..c15f299bca8 100644
--- a/source/blender/editors/include/UI_icons.h
+++ b/source/blender/editors/include/UI_icons.h
@@ -76,7 +76,7 @@ DEF_ICON(X)
DEF_ICON(DUPLICATE)
DEF_ICON(TRASH)
DEF_ICON(COLLECTION_NEW)
-DEF_ICON_BLANK(77)
+DEF_ICON(OPTIONS)
DEF_ICON(NODE)
DEF_ICON(NODE_SEL)
@@ -104,8 +104,8 @@ DEF_ICON(RIGHTARROW)
DEF_ICON(DOWNARROW_HLT)
DEF_ICON(FCURVE_SNAPSHOT)
DEF_ICON(OBJECT_HIDDEN)
-DEF_ICON_BLANK(105)
-DEF_ICON_BLANK(106)
+DEF_ICON(TOPBAR)
+DEF_ICON(STATUSBAR)
DEF_ICON(PLUGIN)
/* various ui */
@@ -283,7 +283,7 @@ DEF_ICON(MOUSE_MOVE)
DEF_ICON(MOUSE_LMB_DRAG)
DEF_ICON(MOUSE_MMB_DRAG)
DEF_ICON(MOUSE_RMB_DRAG)
-DEF_ICON_BLANK(284)
+DEF_ICON(MEMORY)
DEF_ICON(PRESET_NEW)
DEF_ICON_BLANK(286)
DEF_ICON(DECORATE)
@@ -774,9 +774,9 @@ DEF_ICON_BLANK(277)
DEF_ICON_BLANK(772)
DEF_ICON_BLANK(773)
DEF_ICON_BLANK(774)
-DEF_ICON_BLANK(775)
-DEF_ICON_BLANK(776)
-DEF_ICON_BLANK(777)
+DEF_ICON(HOME)
+DEF_ICON(DOCUMENTS)
+DEF_ICON(TEMP)
/* FILE SELECT */
DEF_ICON(SORTALPHA)
@@ -857,7 +857,7 @@ DEF_ICON(SCRIPTPLUGINS)
DEF_ICON_BLANK(855)
DEF_ICON_BLANK(856)
DEF_ICON_BLANK(857)
-DEF_ICON_BLANK(858)
+DEF_ICON(DISC)
DEF_ICON(DESKTOP)
DEF_ICON(EXTERNAL_DRIVE)
DEF_ICON(NETWORK_DRIVE)
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index f5721c008b2..8f205173011 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -2021,6 +2021,12 @@ void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C);
void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C);
void uiTemplateInputStatus(uiLayout *layout, struct bContext *C);
void uiTemplateKeymapItemProperties(uiLayout *layout, struct PointerRNA *ptr);
+
+bool uiTemplateEventFromKeymapItem(struct uiLayout *layout,
+ const char *text,
+ const struct wmKeyMapItem *kmi,
+ bool text_fallback);
+
void uiTemplateComponentMenu(uiLayout *layout,
struct PointerRNA *ptr,
const char *propname,
diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt
index bc8d25e8d9e..d33023c69a1 100644
--- a/source/blender/editors/interface/CMakeLists.txt
+++ b/source/blender/editors/interface/CMakeLists.txt
@@ -50,6 +50,7 @@ set(SRC
interface_eyedropper_datablock.c
interface_eyedropper_depth.c
interface_eyedropper_driver.c
+ interface_eyedropper_gpencil_color.c
interface_handlers.c
interface_icons.c
interface_icons_event.c
diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c
index 3c26c37b610..988dea270f5 100644
--- a/source/blender/editors/interface/interface_eyedropper.c
+++ b/source/blender/editors/interface/interface_eyedropper.c
@@ -69,6 +69,7 @@ wmKeyMap *eyedropper_modal_keymap(wmKeyConfig *keyconf)
WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_id");
WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_depth");
WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_driver");
+ WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_gpencil_color");
return keymap;
}
diff --git a/source/blender/editors/interface/interface_eyedropper_gpencil_color.c b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c
new file mode 100644
index 00000000000..02d4596e93c
--- /dev/null
+++ b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c
@@ -0,0 +1,324 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup edinterface
+ *
+ * Eyedropper (RGB Color)
+ *
+ * Defines:
+ * - #UI_OT_eyedropper_gpencil_color
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_string.h"
+
+#include "BLT_translation.h"
+
+#include "DNA_gpencil_types.h"
+#include "DNA_space_types.h"
+
+#include "BKE_context.h"
+#include "BKE_gpencil.h"
+#include "BKE_main.h"
+#include "BKE_material.h"
+#include "BKE_report.h"
+
+#include "UI_interface.h"
+
+#include "IMB_colormanagement.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "ED_gpencil.h"
+#include "ED_screen.h"
+#include "ED_undo.h"
+
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
+
+#include "interface_intern.h"
+#include "interface_eyedropper_intern.h"
+
+typedef struct EyedropperGPencil {
+ struct ColorManagedDisplay *display;
+ /** color under cursor RGB */
+ float color[3];
+} EyedropperGPencil;
+
+/* Helper: Draw status message while the user is running the operator */
+static void eyedropper_gpencil_status_indicators(bContext *C)
+{
+ char msg_str[UI_MAX_DRAW_STR];
+ BLI_strncpy(
+ msg_str, TIP_("LMB: Stroke - Shift: Fill - Shift+Ctrl: Stroke + Fill"), UI_MAX_DRAW_STR);
+
+ ED_workspace_status_text(C, msg_str);
+}
+
+/* Initialize. */
+static bool eyedropper_gpencil_init(bContext *C, wmOperator *op)
+{
+ EyedropperGPencil *eye = MEM_callocN(sizeof(EyedropperGPencil), __func__);
+
+ op->customdata = eye;
+ Scene *scene = CTX_data_scene(C);
+
+ const char *display_device;
+ display_device = scene->display_settings.display_device;
+ eye->display = IMB_colormanagement_display_get_named(display_device);
+
+ return true;
+}
+
+/* Exit and free memory. */
+static void eyedropper_gpencil_exit(bContext *C, wmOperator *op)
+{
+ /* Clear status message area. */
+ ED_workspace_status_text(C, NULL);
+
+ MEM_SAFE_FREE(op->customdata);
+}
+
+/* Set the material. */
+static void eyedropper_gpencil_color_set(bContext *C, const wmEvent *event, EyedropperGPencil *eye)
+{
+ Main *bmain = CTX_data_main(C);
+ Object *ob = CTX_data_active_object(C);
+ Material *ma = NULL;
+
+ const bool only_stroke = ((!event->ctrl) && (!event->shift));
+ const bool only_fill = ((!event->ctrl) && (event->shift));
+ const bool both = ((event->ctrl) && (event->shift));
+
+ float col_conv[4];
+ bool found = false;
+
+ /* Convert from linear rgb space to display space because grease pencil colors are in display
+ * space, and this conversion is needed to undo the conversion to linear performed by
+ * eyedropper_color_sample_fl. */
+ if (eye->display) {
+ copy_v3_v3(col_conv, eye->color);
+ IMB_colormanagement_scene_linear_to_display_v3(col_conv, eye->display);
+ }
+ else {
+ copy_v3_v3(col_conv, eye->color);
+ }
+
+ /* Look for a similar material in grease pencil slots. */
+ short *totcol = give_totcolp(ob);
+ for (short i = 0; i < *totcol; i++) {
+ ma = give_current_material(ob, i + 1);
+ if (ma == NULL) {
+ continue;
+ }
+
+ MaterialGPencilStyle *gp_style = ma->gp_style;
+ if (gp_style != NULL) {
+ /* Check stroke color. */
+ bool found_stroke = compare_v3v3(gp_style->stroke_rgba, col_conv, 0.01f) &&
+ (gp_style->flag & GP_STYLE_STROKE_SHOW);
+ /* Check fill color. */
+ bool found_fill = compare_v3v3(gp_style->fill_rgba, col_conv, 0.01f) &&
+ (gp_style->flag & GP_STYLE_FILL_SHOW);
+
+ if ((only_stroke) && (found_stroke) && ((gp_style->flag & GP_STYLE_FILL_SHOW) == 0)) {
+ found = true;
+ }
+ else if ((only_fill) && (found_fill) && ((gp_style->flag & GP_STYLE_STROKE_SHOW) == 0)) {
+ found = true;
+ }
+ else if ((both) && (found_stroke) && (found_fill)) {
+ found = true;
+ }
+
+ /* Found existing material. */
+ if (found) {
+ ob->actcol = i + 1;
+ WM_main_add_notifier(NC_MATERIAL | ND_SHADING_LINKS, NULL);
+ WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ return;
+ }
+ }
+ }
+
+ /* If material was not found add a new material with stroke and/or fill color
+ * depending of the secondary key (LMB: Stroke, Shift: Fill, Shift+Ctrl: Stroke/Fill)
+ */
+ int idx;
+ Material *ma_new = BKE_gpencil_object_material_new(bmain, ob, "Material", &idx);
+ WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, &ob->id);
+ WM_main_add_notifier(NC_MATERIAL | ND_SHADING_LINKS, NULL);
+ DEG_relations_tag_update(bmain);
+
+ BLI_assert(ma_new != NULL);
+
+ MaterialGPencilStyle *gp_style_new = ma_new->gp_style;
+ BLI_assert(gp_style_new != NULL);
+
+ /* Only create Stroke (default option). */
+ if (only_stroke) {
+ /* Stroke color. */
+ gp_style_new->flag |= GP_STYLE_STROKE_SHOW;
+ gp_style_new->flag &= ~GP_STYLE_FILL_SHOW;
+ copy_v3_v3(gp_style_new->stroke_rgba, col_conv);
+ zero_v4(gp_style_new->fill_rgba);
+ }
+ /* Fill Only. */
+ else if (only_fill) {
+ /* Fill color. */
+ gp_style_new->flag &= ~GP_STYLE_STROKE_SHOW;
+ gp_style_new->flag |= GP_STYLE_FILL_SHOW;
+ zero_v4(gp_style_new->stroke_rgba);
+ copy_v3_v3(gp_style_new->fill_rgba, col_conv);
+ }
+ /* Stroke and Fill. */
+ else if (both) {
+ gp_style_new->flag |= GP_STYLE_STROKE_SHOW | GP_STYLE_FILL_SHOW;
+ copy_v3_v3(gp_style_new->stroke_rgba, col_conv);
+ copy_v3_v3(gp_style_new->fill_rgba, col_conv);
+ }
+ /* Push undo for new created material. */
+ ED_undo_push(C, "Add Grease Pencil Material");
+}
+
+/* Sample the color below cursor. */
+static void eyedropper_gpencil_color_sample(bContext *C, EyedropperGPencil *eye, int mx, int my)
+{
+ eyedropper_color_sample_fl(C, mx, my, eye->color);
+}
+
+/* Cancel operator. */
+static void eyedropper_gpencil_cancel(bContext *C, wmOperator *op)
+{
+ eyedropper_gpencil_exit(C, op);
+}
+
+/* Main modal status check. */
+static int eyedropper_gpencil_modal(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ EyedropperGPencil *eye = (EyedropperGPencil *)op->customdata;
+ /* Handle modal keymap */
+ switch (event->type) {
+ case EVT_MODAL_MAP: {
+ switch (event->val) {
+ case EYE_MODAL_SAMPLE_BEGIN: {
+ return OPERATOR_RUNNING_MODAL;
+ }
+ case EYE_MODAL_CANCEL: {
+ eyedropper_gpencil_cancel(C, op);
+ return OPERATOR_CANCELLED;
+ }
+ case EYE_MODAL_SAMPLE_CONFIRM: {
+ eyedropper_gpencil_color_sample(C, eye, event->x, event->y);
+
+ /* Create material. */
+ eyedropper_gpencil_color_set(C, event, eye);
+ WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+
+ eyedropper_gpencil_exit(C, op);
+ return OPERATOR_FINISHED;
+ break;
+ }
+ default: {
+ break;
+ }
+ }
+ break;
+ }
+ case MOUSEMOVE:
+ case INBETWEEN_MOUSEMOVE: {
+ eyedropper_gpencil_color_sample(C, eye, event->x, event->y);
+ break;
+ }
+ default: {
+ break;
+ }
+ }
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+/* Modal Operator init */
+static int eyedropper_gpencil_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ /* Init. */
+ if (eyedropper_gpencil_init(C, op)) {
+ /* Add modal temp handler. */
+ WM_event_add_modal_handler(C, op);
+ /* Status message. */
+ eyedropper_gpencil_status_indicators(C);
+
+ return OPERATOR_RUNNING_MODAL;
+ }
+ else {
+ return OPERATOR_PASS_THROUGH;
+ }
+}
+
+/* Repeat operator */
+static int eyedropper_gpencil_exec(bContext *C, wmOperator *op)
+{
+ /* init */
+ if (eyedropper_gpencil_init(C, op)) {
+
+ /* cleanup */
+ eyedropper_gpencil_exit(C, op);
+
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_PASS_THROUGH;
+ }
+}
+
+static bool eyedropper_gpencil_poll(bContext *C)
+{
+ /* Only valid if the current active object is grease pencil. */
+ Object *obact = CTX_data_active_object(C);
+ if ((obact == NULL) || (obact->type != OB_GPENCIL)) {
+ return false;
+ }
+
+ /* Test we have a window below. */
+ return (CTX_wm_window(C) != NULL);
+}
+
+void UI_OT_eyedropper_gpencil_color(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Grease Pencil Eyedropper";
+ ot->idname = "UI_OT_eyedropper_gpencil_color";
+ ot->description = "Sample a color from the Blender Window and create Grease Pencil material";
+
+ /* api callbacks */
+ ot->invoke = eyedropper_gpencil_invoke;
+ ot->modal = eyedropper_gpencil_modal;
+ ot->cancel = eyedropper_gpencil_cancel;
+ ot->exec = eyedropper_gpencil_exec;
+ ot->poll = eyedropper_gpencil_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING;
+}
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 4351b75eb86..81979b1fc8f 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -971,6 +971,9 @@ void UI_OT_eyedropper_depth(struct wmOperatorType *ot);
/* interface_eyedropper_driver.c */
void UI_OT_eyedropper_driver(struct wmOperatorType *ot);
+/* interface_eyedropper_gpencil_color.c */
+void UI_OT_eyedropper_gpencil_color(struct wmOperatorType *ot);
+
/* interface_util.c */
/**
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index a6f8ba4560d..2a4c2aba4a1 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -3650,8 +3650,13 @@ static void ui_litem_estimate_box(uiLayout *litem)
uiStyle *style = litem->root->style;
ui_litem_estimate_column(litem, true);
- litem->w += 2 * style->boxspace;
- litem->h += 2 * style->boxspace;
+
+ int boxspace = style->boxspace;
+ if (litem->root->type == UI_LAYOUT_HEADER) {
+ boxspace = 0;
+ }
+ litem->w += 2 * boxspace;
+ litem->h += 2 * boxspace;
}
static void ui_litem_layout_box(uiLayout *litem)
@@ -3661,29 +3666,34 @@ static void ui_litem_layout_box(uiLayout *litem)
uiBut *but;
int w, h;
+ int boxspace = style->boxspace;
+ if (litem->root->type == UI_LAYOUT_HEADER) {
+ boxspace = 0;
+ }
+
w = litem->w;
h = litem->h;
- litem->x += style->boxspace;
- litem->y -= style->boxspace;
+ litem->x += boxspace;
+ litem->y -= boxspace;
if (w != 0) {
- litem->w -= 2 * style->boxspace;
+ litem->w -= 2 * boxspace;
}
if (h != 0) {
- litem->h -= 2 * style->boxspace;
+ litem->h -= 2 * boxspace;
}
ui_litem_layout_column(litem, true);
- litem->x -= style->boxspace;
- litem->y -= style->boxspace;
+ litem->x -= boxspace;
+ litem->y -= boxspace;
if (w != 0) {
- litem->w += 2 * style->boxspace;
+ litem->w += 2 * boxspace;
}
if (h != 0) {
- litem->h += 2 * style->boxspace;
+ litem->h += 2 * boxspace;
}
/* roundbox around the sublayout */
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 4e56a02997b..7ce4242c697 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -1751,6 +1751,7 @@ void ED_operatortypes_ui(void)
WM_operatortype_append(UI_OT_eyedropper_id);
WM_operatortype_append(UI_OT_eyedropper_depth);
WM_operatortype_append(UI_OT_eyedropper_driver);
+ WM_operatortype_append(UI_OT_eyedropper_gpencil_color);
}
/**
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index fe484676ddd..021d7733fae 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -6657,6 +6657,42 @@ void uiTemplateKeymapItemProperties(uiLayout *layout, PointerRNA *ptr)
/** \} */
/* -------------------------------------------------------------------- */
+/** \name Event Icon Template
+ *
+ * \{ */
+
+bool uiTemplateEventFromKeymapItem(struct uiLayout *layout,
+ const char *text,
+ const struct wmKeyMapItem *kmi,
+ bool text_fallback)
+{
+ bool ok = false;
+
+ int icon_mod[4];
+#ifdef WITH_HEADLESS
+ int icon = 0;
+#else
+ int icon = UI_icon_from_keymap_item(kmi, icon_mod);
+#endif
+ if (icon != 0) {
+ for (int j = 0; j < ARRAY_SIZE(icon_mod) && icon_mod[j]; j++) {
+ uiItemL(layout, "", icon_mod[j]);
+ }
+ uiItemL(layout, text, icon);
+ ok = true;
+ }
+ else if (text_fallback) {
+ const char *event_text = WM_key_event_string(kmi->type, true);
+ uiItemL(layout, event_text, ICON_NONE);
+ uiItemL(layout, text, ICON_NONE);
+ ok = true;
+ }
+ return ok;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Color Management Template
* \{ */
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index b3e039292e1..4cef9ace66e 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -184,6 +184,18 @@ static void color_ensure_contrast_v3(uchar cp[3], const uchar cp_other[3], int c
}
}
+static void color_mul_hsl_v3(uchar ch[3], float h_factor, float s_factor, float l_factor)
+{
+ float rgb[3], hsl[3];
+ rgb_uchar_to_float(rgb, ch);
+ rgb_to_hsl_v(rgb, hsl);
+ hsl[0] *= h_factor;
+ hsl[1] *= s_factor;
+ hsl[2] *= l_factor;
+ hsl_to_rgb_v(hsl, rgb);
+ rgb_float_to_uchar(ch, rgb);
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -2573,11 +2585,12 @@ static void ui_widget_color_disabled(uiWidgetType *wt)
wt->wcol_theme = &wcol_theme_s;
}
-static void widget_active_color(uchar cp[3])
+static void widget_active_color(uiWidgetColors *wcol)
{
- cp[0] = cp[0] >= 240 ? 255 : cp[0] + 15;
- cp[1] = cp[1] >= 240 ? 255 : cp[1] + 15;
- cp[2] = cp[2] >= 240 ? 255 : cp[2] + 15;
+ bool dark = (rgb_to_grayscale_byte(wcol->text) > rgb_to_grayscale_byte(wcol->inner));
+ color_mul_hsl_v3(wcol->inner, 1.0f, 1.15f, dark ? 1.2f : 1.1f);
+ color_mul_hsl_v3(wcol->outline, 1.0f, 1.15f, 1.15f);
+ color_mul_hsl_v3(wcol->text, 1.0f, 1.15f, dark ? 1.25f : 0.8f);
}
static const uchar *widget_color_blend_from_flags(const uiWidgetStateColors *wcol_state,
@@ -2641,10 +2654,10 @@ static void widget_state(uiWidgetType *wt, int state, int drawflag)
if (color_blend != NULL) {
color_blend_v3_v3(wt->wcol.inner, color_blend, wcol_state->blend);
}
+ }
- if (state & UI_ACTIVE) { /* mouse over? */
- widget_active_color(wt->wcol.inner);
- }
+ if (state & UI_ACTIVE) {
+ widget_active_color(&wt->wcol);
}
if (state & UI_BUT_REDALERT) {
@@ -3403,7 +3416,7 @@ static void widget_numbut_draw(
wcol_zone = *wcol;
copy_v3_v3_uchar(wcol_zone.item, wcol->text);
if (state & UI_STATE_ACTIVE_LEFT) {
- widget_active_color(wcol_zone.inner);
+ widget_active_color(&wcol_zone);
}
rect_zone = *rect;
@@ -3423,7 +3436,7 @@ static void widget_numbut_draw(
wcol_zone = *wcol;
copy_v3_v3_uchar(wcol_zone.item, wcol->text);
if (state & UI_STATE_ACTIVE_RIGHT) {
- widget_active_color(wcol_zone.inner);
+ widget_active_color(&wcol_zone);
}
rect_zone = *rect;
@@ -3442,7 +3455,7 @@ static void widget_numbut_draw(
wcol_zone = *wcol;
copy_v3_v3_uchar(wcol_zone.item, wcol->text);
if (!(state & (UI_STATE_ACTIVE_LEFT | UI_STATE_ACTIVE_RIGHT))) {
- widget_active_color(wcol_zone.inner);
+ widget_active_color(&wcol_zone);
}
rect_zone = *rect;
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c
index 4624611419e..5c730c74df7 100644
--- a/source/blender/editors/mask/mask_add.c
+++ b/source/blender/editors/mask/mask_add.c
@@ -55,7 +55,7 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
float tangent[2],
const bool use_deform,
const bool use_project,
- MaskLayer **masklay_r,
+ MaskLayer **mask_layer_r,
MaskSpline **spline_r,
MaskSplinePoint **point_r,
float *u_r,
@@ -64,7 +64,7 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
- MaskLayer *point_masklay;
+ MaskLayer *point_mask_layer;
MaskSpline *point_spline;
MaskSplinePoint *point = NULL;
float dist_best_sq = FLT_MAX, co[2];
@@ -81,16 +81,16 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
co[0] = normal_co[0] * scalex;
co[1] = normal_co[1] * scaley;
- for (MaskLayer *masklay_orig = mask_orig->masklayers.first,
- *masklay_eval = mask_eval->masklayers.first;
- masklay_orig != NULL;
- masklay_orig = masklay_orig->next, masklay_eval = masklay_eval->next) {
- if (masklay_orig->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
+ for (MaskLayer *mask_layer_orig = mask_orig->masklayers.first,
+ *mask_layer_eval = mask_eval->masklayers.first;
+ mask_layer_orig != NULL;
+ mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next) {
+ if (mask_layer_orig->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline_orig = masklay_orig->splines.first,
- *spline_eval = masklay_eval->splines.first;
+ for (MaskSpline *spline_orig = mask_layer_orig->splines.first,
+ *spline_eval = mask_layer_eval->splines.first;
spline_orig != NULL;
spline_orig = spline_orig->next, spline_eval = spline_eval->next) {
int i;
@@ -136,7 +136,7 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
sub_v2_v2v2(tangent, &diff_points[2 * j + 2], &diff_points[2 * j]);
}
- point_masklay = masklay_orig;
+ point_mask_layer = mask_layer_orig;
point_spline = spline_orig;
point = use_deform ?
&spline_orig->points[(cur_point_eval - spline_eval->points_deform)] :
@@ -156,8 +156,8 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
}
if (point && dist_best_sq < threshold) {
- if (masklay_r) {
- *masklay_r = point_masklay;
+ if (mask_layer_r) {
+ *mask_layer_r = point_mask_layer;
}
if (spline_r) {
@@ -184,8 +184,8 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
return true;
}
- if (masklay_r) {
- *masklay_r = NULL;
+ if (mask_layer_r) {
+ *mask_layer_r = NULL;
}
if (spline_r) {
@@ -331,21 +331,22 @@ static void setup_vertex_point(Mask *mask,
/* **** add extrude vertex **** */
-static void finSelectedSplinePoint(MaskLayer *masklay,
+static void finSelectedSplinePoint(MaskLayer *mask_layer,
MaskSpline **spline,
MaskSplinePoint **point,
bool check_active)
{
- MaskSpline *cur_spline = masklay->splines.first;
+ MaskSpline *cur_spline = mask_layer->splines.first;
*spline = NULL;
*point = NULL;
if (check_active) {
/* TODO, having an active point but no active spline is possible, why? */
- if (masklay->act_spline && masklay->act_point && MASKPOINT_ISSEL_ANY(masklay->act_point)) {
- *spline = masklay->act_spline;
- *point = masklay->act_point;
+ if (mask_layer->act_spline && mask_layer->act_point &&
+ MASKPOINT_ISSEL_ANY(mask_layer->act_point)) {
+ *spline = mask_layer->act_spline;
+ *point = mask_layer->act_point;
return;
}
}
@@ -397,7 +398,7 @@ static void mask_spline_add_point_at_index(MaskSpline *spline, int point_index)
static bool add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2])
{
- MaskLayer *masklay;
+ MaskLayer *mask_layer;
MaskSpline *spline;
MaskSplinePoint *point = NULL;
const float threshold = 9;
@@ -412,7 +413,7 @@ static bool add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2
tangent,
true,
true,
- &masklay,
+ &mask_layer,
&spline,
&point,
&u,
@@ -432,14 +433,14 @@ static bool add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2
setup_vertex_point(mask, spline, new_point, co, u, ctime, NULL, true);
/* TODO - we could pass the spline! */
- BKE_mask_layer_shape_changed_add(masklay,
- BKE_mask_layer_shape_spline_to_index(masklay, spline) +
+ BKE_mask_layer_shape_changed_add(mask_layer,
+ BKE_mask_layer_shape_spline_to_index(mask_layer, spline) +
point_index + 1,
true,
true);
- masklay->act_spline = spline;
- masklay->act_point = new_point;
+ mask_layer->act_spline = spline;
+ mask_layer->act_point = new_point;
WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
@@ -451,7 +452,7 @@ static bool add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2
static bool add_vertex_extrude(const bContext *C,
Mask *mask,
- MaskLayer *masklay,
+ MaskLayer *mask_layer,
const float co[2])
{
Scene *scene = CTX_data_scene(C);
@@ -468,11 +469,11 @@ static bool add_vertex_extrude(const bContext *C,
bool do_cyclic_correct = false;
bool do_prev; /* use prev point rather then next?? */
- if (!masklay) {
+ if (!mask_layer) {
return false;
}
else {
- finSelectedSplinePoint(masklay, &spline, &point, true);
+ finSelectedSplinePoint(mask_layer, &spline, &point, true);
}
ED_mask_select_toggle_all(mask, SEL_DESELECT);
@@ -533,14 +534,17 @@ static bool add_vertex_extrude(const bContext *C,
new_point = &spline->points[point_index + 1];
}
- masklay->act_point = new_point;
+ mask_layer->act_point = new_point;
setup_vertex_point(mask, spline, new_point, co, 0.5f, ctime, ref_point, false);
- if (masklay->splines_shapes.first) {
+ if (mask_layer->splines_shapes.first) {
point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point);
- BKE_mask_layer_shape_changed_add(
- masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index, true, true);
+ BKE_mask_layer_shape_changed_add(mask_layer,
+ BKE_mask_layer_shape_spline_to_index(mask_layer, spline) +
+ point_index,
+ true,
+ true);
}
WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
@@ -548,7 +552,7 @@ static bool add_vertex_extrude(const bContext *C,
return true;
}
-static bool add_vertex_new(const bContext *C, Mask *mask, MaskLayer *masklay, const float co[2])
+static bool add_vertex_new(const bContext *C, Mask *mask, MaskLayer *mask_layer, const float co[2])
{
Scene *scene = CTX_data_scene(C);
const float ctime = CFRA;
@@ -556,27 +560,30 @@ static bool add_vertex_new(const bContext *C, Mask *mask, MaskLayer *masklay, co
MaskSpline *spline;
MaskSplinePoint *new_point = NULL, *ref_point = NULL;
- if (!masklay) {
- /* if there's no masklay currently operationg on, create new one */
- masklay = BKE_mask_layer_new(mask, "");
+ if (!mask_layer) {
+ /* if there's no mask layer currently operationg on, create new one */
+ mask_layer = BKE_mask_layer_new(mask, "");
mask->masklay_act = mask->masklay_tot - 1;
}
ED_mask_select_toggle_all(mask, SEL_DESELECT);
- spline = BKE_mask_spline_add(masklay);
+ spline = BKE_mask_spline_add(mask_layer);
- masklay->act_spline = spline;
+ mask_layer->act_spline = spline;
new_point = spline->points;
- masklay->act_point = new_point;
+ mask_layer->act_point = new_point;
setup_vertex_point(mask, spline, new_point, co, 0.5f, ctime, ref_point, false);
{
int point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point);
- BKE_mask_layer_shape_changed_add(
- masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index, true, true);
+ BKE_mask_layer_shape_changed_add(mask_layer,
+ BKE_mask_layer_shape_spline_to_index(mask_layer, spline) +
+ point_index,
+ true,
+ true);
}
WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
@@ -584,69 +591,112 @@ static bool add_vertex_new(const bContext *C, Mask *mask, MaskLayer *masklay, co
return true;
}
-static int add_vertex_exec(bContext *C, wmOperator *op)
+/* Convert coordinate from normalized space to pixel one.
+ * TODO(sergey): Make the function more generally available. */
+static void mask_point_make_pixel_space(bContext *C,
+ float point_normalized[2],
+ float point_pixel[2])
{
- Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *masklay;
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
- float co[2];
+ float scalex, scaley;
+ ED_mask_pixelspace_factor(sa, ar, &scalex, &scaley);
- if (mask == NULL) {
- /* if there's no active mask, create one */
- mask = ED_mask_new(C, NULL);
+ point_pixel[0] = point_normalized[0] * scalex;
+ point_pixel[1] = point_normalized[1] * scaley;
+}
+
+static int add_vertex_handle_cyclic_at_point(bContext *C,
+ Mask *mask,
+ MaskSpline *spline,
+ MaskSplinePoint *active_point,
+ MaskSplinePoint *other_point,
+ float co[2])
+{
+ const float tolerance_in_pixels_squared = 4 * 4;
+
+ if (spline->flag & MASK_SPLINE_CYCLIC) {
+ /* No cycling toggle needed, we've got nothing meaningful to do in this operator. */
+ return OPERATOR_CANCELLED;
}
- masklay = BKE_mask_layer_active(mask);
+ float co_pixel[2];
+ mask_point_make_pixel_space(C, co, co_pixel);
+
+ float point_pixel[2];
+ mask_point_make_pixel_space(C, other_point->bezt.vec[1], point_pixel);
- if (masklay && masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
- masklay = NULL;
+ const float dist_squared = len_squared_v2v2(co_pixel, point_pixel);
+ if (dist_squared > tolerance_in_pixels_squared) {
+ return OPERATOR_PASS_THROUGH;
}
- RNA_float_get_array(op->ptr, "location", co);
+ spline->flag |= MASK_SPLINE_CYCLIC;
- /* TODO, having an active point but no active spline is possible, why? */
- if (masklay && masklay->act_spline && masklay->act_point &&
- MASKPOINT_ISSEL_ANY(masklay->act_point)) {
+ /* TODO, update keyframes in time. */
+ BKE_mask_calc_handle_point_auto(spline, active_point, false);
+ BKE_mask_calc_handle_point_auto(spline, other_point, false);
- /* cheap trick - double click for cyclic */
- MaskSpline *spline = masklay->act_spline;
- MaskSplinePoint *point = masklay->act_point;
+ DEG_id_tag_update(&mask->id, ID_RECALC_GEOMETRY);
- const bool is_sta = (point == spline->points);
- const bool is_end = (point == &spline->points[spline->tot_point - 1]);
+ WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
- /* then check are we overlapping the mouse */
- if ((is_sta || is_end) && equals_v2v2(co, point->bezt.vec[1])) {
- if (spline->flag & MASK_SPLINE_CYCLIC) {
- /* nothing to do */
- return OPERATOR_CANCELLED;
- }
- else {
- /* recalc the connecting point as well to make a nice even curve */
- MaskSplinePoint *point_other = is_end ? spline->points :
- &spline->points[spline->tot_point - 1];
- spline->flag |= MASK_SPLINE_CYCLIC;
+ return OPERATOR_FINISHED;
+}
- /* TODO, update keyframes in time */
- BKE_mask_calc_handle_point_auto(spline, point, false);
- BKE_mask_calc_handle_point_auto(spline, point_other, false);
+static int add_vertex_handle_cyclic(
+ bContext *C, Mask *mask, MaskSpline *spline, MaskSplinePoint *active_point, float co[2])
+{
+ MaskSplinePoint *first_point = &spline->points[0];
+ MaskSplinePoint *last_point = &spline->points[spline->tot_point - 1];
+ const bool is_first_point_active = (active_point == first_point);
+ const bool is_last_point_active = (active_point == last_point);
+ if (is_last_point_active) {
+ return add_vertex_handle_cyclic_at_point(C, mask, spline, active_point, first_point, co);
+ }
+ else if (is_first_point_active) {
+ return add_vertex_handle_cyclic_at_point(C, mask, spline, active_point, last_point, co);
+ }
+ return OPERATOR_PASS_THROUGH;
+}
- DEG_id_tag_update(&mask->id, ID_RECALC_GEOMETRY);
+static int add_vertex_exec(bContext *C, wmOperator *op)
+{
+ Mask *mask = CTX_data_edit_mask(C);
+ if (mask == NULL) {
+ /* if there's no active mask, create one */
+ mask = ED_mask_new(C, NULL);
+ }
- WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
- return OPERATOR_FINISHED;
- }
+ MaskLayer *mask_layer = BKE_mask_layer_active(mask);
+
+ if (mask_layer && mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
+ mask_layer = NULL;
+ }
+
+ float co[2];
+ RNA_float_get_array(op->ptr, "location", co);
+
+ /* TODO, having an active point but no active spline is possible, why? */
+ if (mask_layer && mask_layer->act_spline && mask_layer->act_point &&
+ MASKPOINT_ISSEL_ANY(mask_layer->act_point)) {
+ MaskSpline *spline = mask_layer->act_spline;
+ MaskSplinePoint *active_point = mask_layer->act_point;
+ const int cyclic_result = add_vertex_handle_cyclic(C, mask, spline, active_point, co);
+ if (cyclic_result != OPERATOR_PASS_THROUGH) {
+ return cyclic_result;
}
if (!add_vertex_subdivide(C, mask, co)) {
- if (!add_vertex_extrude(C, mask, masklay, co)) {
+ if (!add_vertex_extrude(C, mask, mask_layer, co)) {
return OPERATOR_CANCELLED;
}
}
}
else {
if (!add_vertex_subdivide(C, mask, co)) {
- if (!add_vertex_new(C, mask, masklay, co)) {
+ if (!add_vertex_new(C, mask, mask_layer, co)) {
return OPERATOR_CANCELLED;
}
}
@@ -704,7 +754,7 @@ void MASK_OT_add_vertex(wmOperatorType *ot)
static int add_feather_vertex_exec(bContext *C, wmOperator *op)
{
Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *masklay;
+ MaskLayer *mask_layer;
MaskSpline *spline;
MaskSplinePoint *point = NULL;
const float threshold = 9;
@@ -717,8 +767,19 @@ static int add_feather_vertex_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
- if (ED_mask_find_nearest_diff_point(
- C, mask, co, threshold, true, NULL, true, true, &masklay, &spline, &point, &u, NULL)) {
+ if (ED_mask_find_nearest_diff_point(C,
+ mask,
+ co,
+ threshold,
+ true,
+ NULL,
+ true,
+ true,
+ &mask_layer,
+ &spline,
+ &point,
+ &u,
+ NULL)) {
float w = BKE_mask_point_weight(spline, point, u);
float weight_scalar = BKE_mask_point_weight_scalar(spline, point, u);
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index 85fedac05ce..71aa860d703 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -56,13 +56,13 @@
#include "mask_intern.h" /* own include */
-static void mask_spline_color_get(MaskLayer *masklay,
+static void mask_spline_color_get(MaskLayer *mask_layer,
MaskSpline *spline,
const bool is_sel,
unsigned char r_rgb[4])
{
if (is_sel) {
- if (masklay->act_spline == spline) {
+ if (mask_layer->act_spline == spline) {
r_rgb[0] = r_rgb[1] = r_rgb[2] = 255;
}
else {
@@ -78,7 +78,7 @@ static void mask_spline_color_get(MaskLayer *masklay,
r_rgb[3] = 255;
}
-static void mask_spline_feather_color_get(MaskLayer *UNUSED(masklay),
+static void mask_spline_feather_color_get(MaskLayer *UNUSED(mask_layer),
MaskSpline *UNUSED(spline),
const bool is_sel,
unsigned char r_rgb[4])
@@ -187,13 +187,13 @@ static void draw_single_handle(const MaskLayer *mask_layer,
/* return non-zero if spline is selected */
static void draw_spline_points(const bContext *C,
- MaskLayer *masklay,
+ MaskLayer *mask_layer,
MaskSpline *spline,
const char draw_flag,
const char draw_type)
{
const bool is_spline_sel = (spline->flag & SELECT) &&
- (masklay->restrictflag & MASK_RESTRICT_SELECT) == 0;
+ (mask_layer->restrictflag & MASK_RESTRICT_SELECT) == 0;
const bool is_smooth = (draw_flag & MASK_DRAWFLAG_SMOOTH) != 0;
unsigned char rgb_spline[4];
@@ -216,7 +216,7 @@ static void draw_spline_points(const bContext *C,
/* TODO, add this to sequence editor */
float handle_size = 2.0f * UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE) * U.pixelsize;
- mask_spline_color_get(masklay, spline, is_spline_sel, rgb_spline);
+ mask_spline_color_get(mask_layer, spline, is_spline_sel, rgb_spline);
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -249,7 +249,7 @@ static void draw_spline_points(const bContext *C,
}
if (sel) {
- if (point == masklay->act_point) {
+ if (point == mask_layer->act_point) {
immUniformColor3f(1.0f, 1.0f, 1.0f);
}
else {
@@ -300,7 +300,7 @@ static void draw_spline_points(const bContext *C,
mask_point_undistort_pos(sc, handle, handle);
}
draw_single_handle(
- masklay, point, MASK_WHICH_HANDLE_STICK, draw_type, handle_size, vert, handle);
+ mask_layer, point, MASK_WHICH_HANDLE_STICK, draw_type, handle_size, vert, handle);
}
else {
float handle_left[2], handle_right[2];
@@ -311,9 +311,9 @@ static void draw_spline_points(const bContext *C,
mask_point_undistort_pos(sc, handle_left, handle_left);
}
draw_single_handle(
- masklay, point, MASK_WHICH_HANDLE_LEFT, draw_type, handle_size, vert, handle_left);
+ mask_layer, point, MASK_WHICH_HANDLE_LEFT, draw_type, handle_size, vert, handle_left);
draw_single_handle(
- masklay, point, MASK_WHICH_HANDLE_RIGHT, draw_type, handle_size, vert, handle_right);
+ mask_layer, point, MASK_WHICH_HANDLE_RIGHT, draw_type, handle_size, vert, handle_right);
}
/* bind program in loop so it does not interfere with draw_single_handle */
@@ -321,7 +321,7 @@ static void draw_spline_points(const bContext *C,
/* draw CV point */
if (MASKPOINT_ISSEL_KNOT(point)) {
- if (point == masklay->act_point) {
+ if (point == mask_layer->act_point) {
immUniformColor3f(1.0f, 1.0f, 1.0f);
}
else {
@@ -352,7 +352,7 @@ static void draw_spline_points(const bContext *C,
immBindBuiltinProgram(GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA);
immUniform1f("outlineWidth", 1.5f);
- if (masklay->act_spline == spline) {
+ if (mask_layer->act_spline == spline) {
immUniformColor3f(1.0f, 1.0f, 1.0f);
}
else {
@@ -519,7 +519,7 @@ static void mask_draw_curve_type(const bContext *C,
}
static void draw_spline_curve(const bContext *C,
- MaskLayer *masklay,
+ MaskLayer *mask_layer,
MaskSpline *spline,
const char draw_flag,
const char draw_type,
@@ -533,7 +533,7 @@ static void draw_spline_curve(const bContext *C,
unsigned char rgb_tmp[4];
const bool is_spline_sel = (spline->flag & SELECT) &&
- (masklay->restrictflag & MASK_RESTRICT_SELECT) == 0;
+ (mask_layer->restrictflag & MASK_RESTRICT_SELECT) == 0;
const bool is_smooth = (draw_flag & MASK_DRAWFLAG_SMOOTH) != 0;
const bool is_fill = (spline->flag & MASK_SPLINE_NOFILL) == 0;
@@ -557,7 +557,7 @@ static void draw_spline_curve(const bContext *C,
spline, &tot_feather_point, resol, (is_fill != false));
/* draw feather */
- mask_spline_feather_color_get(masklay, spline, is_spline_sel, rgb_tmp);
+ mask_spline_feather_color_get(mask_layer, spline, is_spline_sel, rgb_tmp);
mask_draw_curve_type(
C, spline, feather_points, tot_feather_point, true, is_active, rgb_tmp, draw_type);
@@ -581,7 +581,7 @@ static void draw_spline_curve(const bContext *C,
MEM_freeN(feather_points);
/* draw main curve */
- mask_spline_color_get(masklay, spline, is_spline_sel, rgb_tmp);
+ mask_spline_color_get(mask_layer, spline, is_spline_sel, rgb_tmp);
mask_draw_curve_type(
C, spline, diff_points, tot_diff_point, false, is_active, rgb_tmp, draw_type);
MEM_freeN(diff_points);
@@ -591,37 +591,37 @@ static void draw_spline_curve(const bContext *C,
}
}
-static void draw_masklays(const bContext *C,
- Mask *mask,
- const char draw_flag,
- const char draw_type,
- const int width,
- const int height)
+static void draw_mask_layers(const bContext *C,
+ Mask *mask,
+ const char draw_flag,
+ const char draw_type,
+ const int width,
+ const int height)
{
GPU_blend(true);
GPU_blend_set_func_separate(
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
GPU_program_point_size(true);
- MaskLayer *masklay;
+ MaskLayer *mask_layer;
int i;
- for (masklay = mask->masklayers.first, i = 0; masklay; masklay = masklay->next, i++) {
- MaskSpline *spline;
+ for (mask_layer = mask->masklayers.first, i = 0; mask_layer != NULL;
+ mask_layer = mask_layer->next, i++) {
const bool is_active = (i == mask->masklay_act);
- if (masklay->restrictflag & MASK_RESTRICT_VIEW) {
+ if (mask_layer->restrictflag & MASK_RESTRICT_VIEW) {
continue;
}
- for (spline = masklay->splines.first; spline; spline = spline->next) {
+ for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
/* draw curve itself first... */
- draw_spline_curve(C, masklay, spline, draw_flag, draw_type, is_active, width, height);
+ draw_spline_curve(C, mask_layer, spline, draw_flag, draw_type, is_active, width, height);
- if (!(masklay->restrictflag & MASK_RESTRICT_SELECT)) {
+ if (!(mask_layer->restrictflag & MASK_RESTRICT_SELECT)) {
/* ...and then handles over the curve so they're nicely visible */
- draw_spline_points(C, masklay, spline, draw_flag, draw_type);
+ draw_spline_points(C, mask_layer, spline, draw_flag, draw_type);
}
/* show undeform for testing */
@@ -629,8 +629,8 @@ static void draw_masklays(const bContext *C,
void *back = spline->points_deform;
spline->points_deform = NULL;
- draw_spline_curve(C, masklay, spline, draw_flag, draw_type, is_active, width, height);
- draw_spline_points(C, masklay, spline, draw_flag, draw_type);
+ draw_spline_curve(C, mask_layer, spline, draw_flag, draw_type, is_active, width, height);
+ draw_spline_points(C, mask_layer, spline, draw_flag, draw_type);
spline->points_deform = back;
}
}
@@ -652,7 +652,7 @@ void ED_mask_draw(const bContext *C, const char draw_flag, const char draw_type)
ED_mask_get_size(sa, &width, &height);
- draw_masklays(C, mask, draw_flag, draw_type, width, height);
+ draw_mask_layers(C, mask, draw_flag, draw_type, width, height);
}
static float *mask_rasterize(Mask *mask, const int width, const int height)
@@ -784,7 +784,7 @@ void ED_mask_draw_region(
}
/* draw! */
- draw_masklays(C, mask_eval, draw_flag, draw_type, width, height);
+ draw_mask_layers(C, mask_eval, draw_flag, draw_type, width, height);
if (do_draw_cb) {
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
@@ -797,36 +797,39 @@ void ED_mask_draw_frames(Mask *mask, ARegion *ar, const int cfra, const int sfra
{
const float framelen = ar->winx / (float)(efra - sfra + 1);
- MaskLayer *masklay = BKE_mask_layer_active(mask);
+ MaskLayer *mask_layer = BKE_mask_layer_active(mask);
+ if (mask_layer == NULL) {
+ return;
+ }
- if (masklay) {
- unsigned int num_lines = BLI_listbase_count(&masklay->splines_shapes);
+ unsigned int num_lines = BLI_listbase_count(&mask_layer->splines_shapes);
+ if (num_lines == 0) {
+ return;
+ }
- if (num_lines > 0) {
- /* Local coordinate visible rect inside region, to accommodate overlapping ui. */
- const rcti *rect_visible = ED_region_visible_rect(ar);
- const int region_bottom = rect_visible->ymin;
+ /* Local coordinate visible rect inside region, to accommodate overlapping ui. */
+ const rcti *rect_visible = ED_region_visible_rect(ar);
+ const int region_bottom = rect_visible->ymin;
- uint pos = GPU_vertformat_attr_add(
- immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
+ uint pos = GPU_vertformat_attr_add(
+ immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- immUniformColor4ub(255, 175, 0, 255);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ immUniformColor4ub(255, 175, 0, 255);
- immBegin(GPU_PRIM_LINES, 2 * num_lines);
+ immBegin(GPU_PRIM_LINES, 2 * num_lines);
- for (MaskLayerShape *masklay_shape = masklay->splines_shapes.first; masklay_shape;
- masklay_shape = masklay_shape->next) {
- int frame = masklay_shape->frame;
+ for (MaskLayerShape *mask_layer_shape = mask_layer->splines_shapes.first;
+ mask_layer_shape != NULL;
+ mask_layer_shape = mask_layer_shape->next) {
+ int frame = mask_layer_shape->frame;
- /* draw_keyframe(i, CFRA, sfra, framelen, 1); */
- int height = (frame == cfra) ? 22 : 10;
- int x = (frame - sfra) * framelen;
- immVertex2i(pos, x, region_bottom);
- immVertex2i(pos, x, region_bottom + height * UI_DPI_FAC);
- }
- immEnd();
- immUnbindProgram();
- }
+ /* draw_keyframe(i, CFRA, sfra, framelen, 1); */
+ int height = (frame == cfra) ? 22 : 10;
+ int x = (frame - sfra) * framelen;
+ immVertex2i(pos, x, region_bottom);
+ immVertex2i(pos, x, region_bottom + height * UI_DPI_FAC);
}
+ immEnd();
+ immUnbindProgram();
}
diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c
index 0c5591ed89b..56d8ef56160 100644
--- a/source/blender/editors/mask/mask_edit.c
+++ b/source/blender/editors/mask/mask_edit.c
@@ -371,7 +371,6 @@ void ED_mask_cursor_location_get(ScrArea *sa, float cursor[2])
bool ED_mask_selected_minmax(const bContext *C, float min[2], float max[2])
{
Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *mask_layer;
bool ok = false;
if (mask == NULL) {
@@ -379,15 +378,14 @@ bool ED_mask_selected_minmax(const bContext *C, float min[2], float max[2])
}
INIT_MINMAX2(min, max);
- for (mask_layer = mask->masklayers.first; mask_layer != NULL; mask_layer = mask_layer->next) {
- MaskSpline *spline;
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer != NULL;
+ mask_layer = mask_layer->next) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (spline = mask_layer->splines.first; spline != NULL; spline = spline->next) {
+ for (MaskSpline *spline = mask_layer->splines.first; spline != NULL; spline = spline->next) {
MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
- int i;
- for (i = 0; i < spline->tot_point; i++) {
+ for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
MaskSplinePoint *deform_point = &points_array[i];
BezTriple *bezt = &point->bezt;
diff --git a/source/blender/editors/mask/mask_editaction.c b/source/blender/editors/mask/mask_editaction.c
index 985fa58cace..33f4bab14ec 100644
--- a/source/blender/editors/mask/mask_editaction.c
+++ b/source/blender/editors/mask/mask_editaction.c
@@ -53,22 +53,22 @@
/* Generics - Loopers */
/* Loops over the mask-frames for a mask-layer, and applies the given callback */
-bool ED_masklayer_frames_looper(MaskLayer *masklay,
+bool ED_masklayer_frames_looper(MaskLayer *mask_layer,
Scene *scene,
- short (*masklay_shape_cb)(MaskLayerShape *, Scene *))
+ short (*mask_layer_shape_cb)(MaskLayerShape *, Scene *))
{
- MaskLayerShape *masklay_shape;
+ MaskLayerShape *mask_layer_shape;
/* error checker */
- if (masklay == NULL) {
+ if (mask_layer == NULL) {
return false;
}
/* do loop */
- for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
- masklay_shape = masklay_shape->next) {
+ for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape;
+ mask_layer_shape = mask_layer_shape->next) {
/* execute callback */
- if (masklay_shape_cb(masklay_shape, scene)) {
+ if (mask_layer_shape_cb(mask_layer_shape, scene)) {
return true;
}
}
@@ -81,24 +81,24 @@ bool ED_masklayer_frames_looper(MaskLayer *masklay,
/* Data Conversion Tools */
/* make a listing all the mask-frames in a layer as cfraelems */
-void ED_masklayer_make_cfra_list(MaskLayer *masklay, ListBase *elems, bool onlysel)
+void ED_masklayer_make_cfra_list(MaskLayer *mask_layer, ListBase *elems, bool onlysel)
{
- MaskLayerShape *masklay_shape;
+ MaskLayerShape *mask_layer_shape;
CfraElem *ce;
/* error checking */
- if (ELEM(NULL, masklay, elems)) {
+ if (ELEM(NULL, mask_layer, elems)) {
return;
}
/* loop through mask-frames, adding */
- for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
- masklay_shape = masklay_shape->next) {
- if ((onlysel == false) || (masklay_shape->flag & MASK_SHAPE_SELECT)) {
+ for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape;
+ mask_layer_shape = mask_layer_shape->next) {
+ if ((onlysel == false) || (mask_layer_shape->flag & MASK_SHAPE_SELECT)) {
ce = MEM_callocN(sizeof(CfraElem), "CfraElem");
- ce->cfra = (float)masklay_shape->frame;
- ce->sel = (masklay_shape->flag & MASK_SHAPE_SELECT) ? 1 : 0;
+ ce->cfra = (float)mask_layer_shape->frame;
+ ce->sel = (mask_layer_shape->flag & MASK_SHAPE_SELECT) ? 1 : 0;
BLI_addtail(elems, ce);
}
@@ -109,19 +109,19 @@ void ED_masklayer_make_cfra_list(MaskLayer *masklay, ListBase *elems, bool onlys
/* Selection Tools */
/* check if one of the frames in this layer is selected */
-bool ED_masklayer_frame_select_check(MaskLayer *masklay)
+bool ED_masklayer_frame_select_check(MaskLayer *mask_layer)
{
- MaskLayerShape *masklay_shape;
+ MaskLayerShape *mask_layer_shape;
/* error checking */
- if (masklay == NULL) {
+ if (mask_layer == NULL) {
return 0;
}
/* stop at the first one found */
- for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
- masklay_shape = masklay_shape->next) {
- if (masklay_shape->flag & MASK_SHAPE_SELECT) {
+ for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape;
+ mask_layer_shape = mask_layer_shape->next) {
+ if (mask_layer_shape->flag & MASK_SHAPE_SELECT) {
return 1;
}
}
@@ -131,120 +131,120 @@ bool ED_masklayer_frame_select_check(MaskLayer *masklay)
}
/* helper function - select mask-frame based on SELECT_* mode */
-static void masklayshape_select(MaskLayerShape *masklay_shape, short select_mode)
+static void mask_layer_shape_select(MaskLayerShape *mask_layer_shape, short select_mode)
{
- if (masklay_shape == NULL) {
+ if (mask_layer_shape == NULL) {
return;
}
switch (select_mode) {
case SELECT_ADD:
- masklay_shape->flag |= MASK_SHAPE_SELECT;
+ mask_layer_shape->flag |= MASK_SHAPE_SELECT;
break;
case SELECT_SUBTRACT:
- masklay_shape->flag &= ~MASK_SHAPE_SELECT;
+ mask_layer_shape->flag &= ~MASK_SHAPE_SELECT;
break;
case SELECT_INVERT:
- masklay_shape->flag ^= MASK_SHAPE_SELECT;
+ mask_layer_shape->flag ^= MASK_SHAPE_SELECT;
break;
}
}
/* set all/none/invert select (like above, but with SELECT_* modes) */
-void ED_mask_select_frames(MaskLayer *masklay, short select_mode)
+void ED_mask_select_frames(MaskLayer *mask_layer, short select_mode)
{
- MaskLayerShape *masklay_shape;
+ MaskLayerShape *mask_layer_shape;
/* error checking */
- if (masklay == NULL) {
+ if (mask_layer == NULL) {
return;
}
/* handle according to mode */
- for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
- masklay_shape = masklay_shape->next) {
- masklayshape_select(masklay_shape, select_mode);
+ for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape;
+ mask_layer_shape = mask_layer_shape->next) {
+ mask_layer_shape_select(mask_layer_shape, select_mode);
}
}
/* set all/none/invert select */
-void ED_masklayer_frame_select_set(MaskLayer *masklay, short mode)
+void ED_masklayer_frame_select_set(MaskLayer *mask_layer, short mode)
{
/* error checking */
- if (masklay == NULL) {
+ if (mask_layer == NULL) {
return;
}
/* now call the standard function */
- ED_mask_select_frames(masklay, mode);
+ ED_mask_select_frames(mask_layer, mode);
}
/* select the frame in this layer that occurs on this frame (there should only be one at most) */
-void ED_mask_select_frame(MaskLayer *masklay, int selx, short select_mode)
+void ED_mask_select_frame(MaskLayer *mask_layer, int selx, short select_mode)
{
- MaskLayerShape *masklay_shape;
+ MaskLayerShape *mask_layer_shape;
- if (masklay == NULL) {
+ if (mask_layer == NULL) {
return;
}
- masklay_shape = BKE_mask_layer_shape_find_frame(masklay, selx);
+ mask_layer_shape = BKE_mask_layer_shape_find_frame(mask_layer, selx);
- if (masklay_shape) {
- masklayshape_select(masklay_shape, select_mode);
+ if (mask_layer_shape) {
+ mask_layer_shape_select(mask_layer_shape, select_mode);
}
}
/* select the frames in this layer that occur within the bounds specified */
-void ED_masklayer_frames_select_box(MaskLayer *masklay, float min, float max, short select_mode)
+void ED_masklayer_frames_select_box(MaskLayer *mask_layer, float min, float max, short select_mode)
{
- MaskLayerShape *masklay_shape;
+ MaskLayerShape *mask_layer_shape;
- if (masklay == NULL) {
+ if (mask_layer == NULL) {
return;
}
/* only select those frames which are in bounds */
- for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
- masklay_shape = masklay_shape->next) {
- if (IN_RANGE(masklay_shape->frame, min, max)) {
- masklayshape_select(masklay_shape, select_mode);
+ for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape;
+ mask_layer_shape = mask_layer_shape->next) {
+ if (IN_RANGE(mask_layer_shape->frame, min, max)) {
+ mask_layer_shape_select(mask_layer_shape, select_mode);
}
}
}
/* select the frames in this layer that occur within the lasso/circle region specified */
void ED_masklayer_frames_select_region(KeyframeEditData *ked,
- MaskLayer *masklay,
+ MaskLayer *mask_layer,
short tool,
short select_mode)
{
- MaskLayerShape *masklay_shape;
+ MaskLayerShape *mask_layer_shape;
- if (masklay == NULL) {
+ if (mask_layer == NULL) {
return;
}
/* only select frames which are within the region */
- for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
- masklay_shape = masklay_shape->next) {
+ for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape;
+ mask_layer_shape = mask_layer_shape->next) {
/* construct a dummy point coordinate to do this testing with */
float pt[2] = {0};
- pt[0] = masklay_shape->frame;
+ pt[0] = mask_layer_shape->frame;
pt[1] = ked->channel_y;
/* check the necessary regions */
if (tool == BEZT_OK_CHANNEL_LASSO) {
/* Lasso */
if (keyframe_region_lasso_test(ked->data, pt)) {
- masklayshape_select(masklay_shape, select_mode);
+ mask_layer_shape_select(mask_layer_shape, select_mode);
}
}
else if (tool == BEZT_OK_CHANNEL_CIRCLE) {
/* Circle */
if (keyframe_region_circle_test(ked->data, pt)) {
- masklayshape_select(masklay_shape, select_mode);
+ mask_layer_shape_select(mask_layer_shape, select_mode);
}
}
}
@@ -254,23 +254,23 @@ void ED_masklayer_frames_select_region(KeyframeEditData *ked,
/* Frame Editing Tools */
/* Delete selected frames */
-bool ED_masklayer_frames_delete(MaskLayer *masklay)
+bool ED_masklayer_frames_delete(MaskLayer *mask_layer)
{
- MaskLayerShape *masklay_shape, *masklay_shape_next;
+ MaskLayerShape *mask_layer_shape, *mask_layer_shape_next;
bool changed = false;
/* error checking */
- if (masklay == NULL) {
+ if (mask_layer == NULL) {
return false;
}
/* check for frames to delete */
- for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
- masklay_shape = masklay_shape_next) {
- masklay_shape_next = masklay_shape->next;
+ for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape;
+ mask_layer_shape = mask_layer_shape_next) {
+ mask_layer_shape_next = mask_layer_shape->next;
- if (masklay_shape->flag & MASK_SHAPE_SELECT) {
- BKE_mask_layer_shape_unlink(masklay, masklay_shape);
+ if (mask_layer_shape->flag & MASK_SHAPE_SELECT) {
+ BKE_mask_layer_shape_unlink(mask_layer, mask_layer_shape);
changed = true;
}
}
@@ -279,29 +279,30 @@ bool ED_masklayer_frames_delete(MaskLayer *masklay)
}
/* Duplicate selected frames from given mask-layer */
-void ED_masklayer_frames_duplicate(MaskLayer *masklay)
+void ED_masklayer_frames_duplicate(MaskLayer *mask_layer)
{
- MaskLayerShape *masklay_shape, *gpfn;
+ MaskLayerShape *mask_layer_shape, *gpfn;
/* error checking */
- if (masklay == NULL) {
+ if (mask_layer == NULL) {
return;
}
/* duplicate selected frames */
- for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = gpfn) {
- gpfn = masklay_shape->next;
+ for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape;
+ mask_layer_shape = gpfn) {
+ gpfn = mask_layer_shape->next;
/* duplicate this frame */
- if (masklay_shape->flag & MASK_SHAPE_SELECT) {
+ if (mask_layer_shape->flag & MASK_SHAPE_SELECT) {
MaskLayerShape *mask_shape_dupe;
/* duplicate frame, and deselect self */
- mask_shape_dupe = BKE_mask_layer_shape_duplicate(masklay_shape);
- masklay_shape->flag &= ~MASK_SHAPE_SELECT;
+ mask_shape_dupe = BKE_mask_layer_shape_duplicate(mask_layer_shape);
+ mask_layer_shape->flag &= ~MASK_SHAPE_SELECT;
/* XXX - how to handle duplicate frames? */
- BLI_insertlinkafter(&masklay->splines_shapes, masklay_shape, mask_shape_dupe);
+ BLI_insertlinkafter(&mask_layer->splines_shapes, mask_layer_shape, mask_shape_dupe);
}
}
}
@@ -309,55 +310,55 @@ void ED_masklayer_frames_duplicate(MaskLayer *masklay)
/* -------------------------------------- */
/* Snap Tools */
-static short snap_masklayer_nearest(MaskLayerShape *masklay_shape, Scene *UNUSED(scene))
+static short snap_mask_layer_nearest(MaskLayerShape *mask_layer_shape, Scene *UNUSED(scene))
{
- if (masklay_shape->flag & MASK_SHAPE_SELECT) {
- masklay_shape->frame = (int)(floor(masklay_shape->frame + 0.5));
+ if (mask_layer_shape->flag & MASK_SHAPE_SELECT) {
+ mask_layer_shape->frame = (int)(floor(mask_layer_shape->frame + 0.5));
}
return 0;
}
-static short snap_masklayer_nearestsec(MaskLayerShape *masklay_shape, Scene *scene)
+static short snap_mask_layer_nearestsec(MaskLayerShape *mask_layer_shape, Scene *scene)
{
float secf = (float)FPS;
- if (masklay_shape->flag & MASK_SHAPE_SELECT) {
- masklay_shape->frame = (int)(floorf(masklay_shape->frame / secf + 0.5f) * secf);
+ if (mask_layer_shape->flag & MASK_SHAPE_SELECT) {
+ mask_layer_shape->frame = (int)(floorf(mask_layer_shape->frame / secf + 0.5f) * secf);
}
return 0;
}
-static short snap_masklayer_cframe(MaskLayerShape *masklay_shape, Scene *scene)
+static short snap_mask_layer_cframe(MaskLayerShape *mask_layer_shape, Scene *scene)
{
- if (masklay_shape->flag & MASK_SHAPE_SELECT) {
- masklay_shape->frame = (int)CFRA;
+ if (mask_layer_shape->flag & MASK_SHAPE_SELECT) {
+ mask_layer_shape->frame = (int)CFRA;
}
return 0;
}
-static short snap_masklayer_nearmarker(MaskLayerShape *masklay_shape, Scene *scene)
+static short snap_mask_layer_nearmarker(MaskLayerShape *mask_layer_shape, Scene *scene)
{
- if (masklay_shape->flag & MASK_SHAPE_SELECT) {
- masklay_shape->frame = (int)ED_markers_find_nearest_marker_time(&scene->markers,
- (float)masklay_shape->frame);
+ if (mask_layer_shape->flag & MASK_SHAPE_SELECT) {
+ mask_layer_shape->frame = (int)ED_markers_find_nearest_marker_time(
+ &scene->markers, (float)mask_layer_shape->frame);
}
return 0;
}
/* snap selected frames to ... */
-void ED_masklayer_snap_frames(MaskLayer *masklay, Scene *scene, short mode)
+void ED_masklayer_snap_frames(MaskLayer *mask_layer, Scene *scene, short mode)
{
switch (mode) {
case SNAP_KEYS_NEARFRAME: /* snap to nearest frame */
- ED_masklayer_frames_looper(masklay, scene, snap_masklayer_nearest);
+ ED_masklayer_frames_looper(mask_layer, scene, snap_mask_layer_nearest);
break;
case SNAP_KEYS_CURFRAME: /* snap to current frame */
- ED_masklayer_frames_looper(masklay, scene, snap_masklayer_cframe);
+ ED_masklayer_frames_looper(mask_layer, scene, snap_mask_layer_cframe);
break;
case SNAP_KEYS_NEARMARKER: /* snap to nearest marker */
- ED_masklayer_frames_looper(masklay, scene, snap_masklayer_nearmarker);
+ ED_masklayer_frames_looper(mask_layer, scene, snap_mask_layer_nearmarker);
break;
case SNAP_KEYS_NEARSEC: /* snap to nearest second */
- ED_masklayer_frames_looper(masklay, scene, snap_masklayer_nearestsec);
+ ED_masklayer_frames_looper(mask_layer, scene, snap_mask_layer_nearestsec);
break;
default: /* just in case */
break;
diff --git a/source/blender/editors/mask/mask_intern.h b/source/blender/editors/mask/mask_intern.h
index 67785f1ae46..7cf92a9051a 100644
--- a/source/blender/editors/mask/mask_intern.h
+++ b/source/blender/editors/mask/mask_intern.h
@@ -39,7 +39,7 @@ bool ED_mask_find_nearest_diff_point(const struct bContext *C,
float tangent[2],
const bool use_deform,
const bool use_project,
- struct MaskLayer **masklay_r,
+ struct MaskLayer **mask_layer_r,
struct MaskSpline **spline_r,
struct MaskSplinePoint **point_r,
float *u_r,
@@ -76,7 +76,7 @@ bool ED_mask_feather_find_nearest(const struct bContext *C,
struct Mask *mask,
const float normal_co[2],
const float threshold,
- struct MaskLayer **masklay_r,
+ struct MaskLayer **mask_layer_r,
struct MaskSpline **spline_r,
struct MaskSplinePoint **point_r,
struct MaskSplinePointUW **uw_r,
@@ -86,7 +86,7 @@ struct MaskSplinePoint *ED_mask_point_find_nearest(const struct bContext *C,
struct Mask *mask,
const float normal_co[2],
const float threshold,
- struct MaskLayer **masklay_r,
+ struct MaskLayer **mask_layer_r,
struct MaskSpline **spline_r,
eMaskWhichHandle *which_handle_r,
float *score);
@@ -114,11 +114,11 @@ void MASK_OT_select_more(struct wmOperatorType *ot);
void MASK_OT_select_less(struct wmOperatorType *ot);
bool ED_mask_spline_select_check(struct MaskSpline *spline);
-bool ED_mask_layer_select_check(struct MaskLayer *masklay);
+bool ED_mask_layer_select_check(struct MaskLayer *mask_layer);
bool ED_mask_select_check(struct Mask *mask);
void ED_mask_spline_select_set(struct MaskSpline *spline, const bool do_select);
-void ED_mask_layer_select_set(struct MaskLayer *masklay, const bool do_select);
+void ED_mask_layer_select_set(struct MaskLayer *mask_layer, const bool do_select);
void ED_mask_select_toggle_all(struct Mask *mask, int action);
void ED_mask_select_flush_all(struct Mask *mask);
diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c
index c91f431ad20..3a982b255f0 100644
--- a/source/blender/editors/mask/mask_ops.c
+++ b/source/blender/editors/mask/mask_ops.c
@@ -69,7 +69,7 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C,
Mask *mask_orig,
const float normal_co[2],
const float threshold,
- MaskLayer **masklay_r,
+ MaskLayer **mask_layer_r,
MaskSpline **spline_r,
eMaskWhichHandle *which_handle_r,
float *score)
@@ -77,7 +77,7 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C,
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
- MaskLayer *point_masklay = NULL;
+ MaskLayer *point_mask_layer = NULL;
MaskSpline *point_spline = NULL;
MaskSplinePoint *point = NULL;
float co[2];
@@ -95,17 +95,17 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C,
co[0] = normal_co[0] * scalex;
co[1] = normal_co[1] * scaley;
- for (MaskLayer *masklay_orig = mask_orig->masklayers.first,
- *masklay_eval = mask_eval->masklayers.first;
- masklay_orig != NULL;
- masklay_orig = masklay_orig->next, masklay_eval = masklay_eval->next) {
+ for (MaskLayer *mask_layer_orig = mask_orig->masklayers.first,
+ *mask_layer_eval = mask_eval->masklayers.first;
+ mask_layer_orig != NULL;
+ mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next) {
- if (masklay_orig->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
+ if (mask_layer_orig->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline_orig = masklay_orig->splines.first,
- *spline_eval = masklay_eval->splines.first;
+ for (MaskSpline *spline_orig = mask_layer_orig->splines.first,
+ *spline_eval = mask_layer_eval->splines.first;
spline_orig != NULL;
spline_orig = spline_orig->next, spline_eval = spline_eval->next) {
MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline_eval);
@@ -124,7 +124,7 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C,
if (cur_len_sq < len_sq) {
point_spline = spline_orig;
- point_masklay = masklay_orig;
+ point_mask_layer = mask_layer_orig;
point = cur_point_orig;
len_sq = cur_len_sq;
which_handle = MASK_WHICH_HANDLE_NONE;
@@ -174,7 +174,7 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C,
}
if (cur_len_sq <= len_sq && cur_which_handle != MASK_WHICH_HANDLE_NONE) {
- point_masklay = masklay_orig;
+ point_mask_layer = mask_layer_orig;
point_spline = spline_orig;
point = cur_point_orig;
len_sq = cur_len_sq;
@@ -185,8 +185,8 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C,
}
if (len_sq < threshold_sq) {
- if (masklay_r) {
- *masklay_r = point_masklay;
+ if (mask_layer_r) {
+ *mask_layer_r = point_mask_layer;
}
if (spline_r) {
@@ -204,8 +204,8 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C,
return point;
}
- if (masklay_r) {
- *masklay_r = NULL;
+ if (mask_layer_r) {
+ *mask_layer_r = NULL;
}
if (spline_r) {
@@ -223,7 +223,7 @@ bool ED_mask_feather_find_nearest(const bContext *C,
Mask *mask_orig,
const float normal_co[2],
const float threshold,
- MaskLayer **masklay_r,
+ MaskLayer **mask_layer_r,
MaskSpline **spline_r,
MaskSplinePoint **point_r,
MaskSplinePointUW **uw_r,
@@ -232,7 +232,7 @@ bool ED_mask_feather_find_nearest(const bContext *C,
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
- MaskLayer *point_masklay = NULL;
+ MaskLayer *point_mask_layer = NULL;
MaskSpline *point_spline = NULL;
MaskSplinePoint *point = NULL;
MaskSplinePointUW *uw = NULL;
@@ -250,13 +250,13 @@ bool ED_mask_feather_find_nearest(const bContext *C,
co[0] = normal_co[0] * scalex;
co[1] = normal_co[1] * scaley;
- for (MaskLayer *masklay_orig = mask_orig->masklayers.first,
- *masklay_eval = mask_eval->masklayers.first;
- masklay_orig != NULL;
- masklay_orig = masklay_orig->next, masklay_eval = masklay_eval->next) {
+ for (MaskLayer *mask_layer_orig = mask_orig->masklayers.first,
+ *mask_layer_eval = mask_eval->masklayers.first;
+ mask_layer_orig != NULL;
+ mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next) {
- for (MaskSpline *spline_orig = masklay_orig->splines.first,
- *spline_eval = masklay_eval->splines.first;
+ for (MaskSpline *spline_orig = mask_layer_orig->splines.first,
+ *spline_eval = mask_layer_eval->splines.first;
spline_orig != NULL;
spline_orig = spline_orig->next, spline_eval = spline_eval->next) {
// MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
@@ -264,7 +264,7 @@ bool ED_mask_feather_find_nearest(const bContext *C,
int i, tot_feather_point;
float(*feather_points)[2], (*fp)[2];
- if (masklay_orig->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
+ if (mask_layer_orig->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
@@ -291,7 +291,7 @@ bool ED_mask_feather_find_nearest(const bContext *C,
uw = &cur_point_orig->uw[j - 1];
}
- point_masklay = masklay_orig;
+ point_mask_layer = mask_layer_orig;
point_spline = spline_orig;
point = cur_point_orig;
len = cur_len_sq;
@@ -306,8 +306,8 @@ bool ED_mask_feather_find_nearest(const bContext *C,
}
if (len < threshold_sq) {
- if (masklay_r) {
- *masklay_r = point_masklay;
+ if (mask_layer_r) {
+ *mask_layer_r = point_mask_layer;
}
if (spline_r) {
@@ -329,8 +329,8 @@ bool ED_mask_feather_find_nearest(const bContext *C,
return true;
}
- if (masklay_r) {
- *masklay_r = NULL;
+ if (mask_layer_r) {
+ *mask_layer_r = NULL;
}
if (spline_r) {
@@ -428,9 +428,9 @@ void MASK_OT_new(wmOperatorType *ot)
RNA_def_string(ot->srna, "name", NULL, MAX_ID_NAME - 2, "Name", "Name of new mask");
}
-/******************** create new masklay *********************/
+/******************** create new mask layer *********************/
-static int masklay_new_exec(bContext *C, wmOperator *op)
+static int mask_layer_new_exec(bContext *C, wmOperator *op)
{
Mask *mask = CTX_data_edit_mask(C);
char name[MAX_ID_NAME - 2];
@@ -454,7 +454,7 @@ void MASK_OT_layer_new(wmOperatorType *ot)
ot->idname = "MASK_OT_layer_new";
/* api callbacks */
- ot->exec = masklay_new_exec;
+ ot->exec = mask_layer_new_exec;
ot->poll = ED_maskedit_poll;
/* flags */
@@ -466,13 +466,13 @@ void MASK_OT_layer_new(wmOperatorType *ot)
/******************** remove mask layer *********************/
-static int masklay_remove_exec(bContext *C, wmOperator *UNUSED(op))
+static int mask_layer_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *masklay = BKE_mask_layer_active(mask);
+ MaskLayer *mask_layer = BKE_mask_layer_active(mask);
- if (masklay) {
- BKE_mask_layer_remove(mask, masklay);
+ if (mask_layer) {
+ BKE_mask_layer_remove(mask, mask_layer);
WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
DEG_id_tag_update(&mask->id, ID_RECALC_COPY_ON_WRITE);
@@ -489,7 +489,7 @@ void MASK_OT_layer_remove(wmOperatorType *ot)
ot->idname = "MASK_OT_layer_remove";
/* api callbacks */
- ot->exec = masklay_remove_exec;
+ ot->exec = mask_layer_remove_exec;
ot->poll = ED_maskedit_poll;
/* flags */
@@ -511,7 +511,7 @@ typedef struct SlidePointData {
short event_invoke_type;
int action;
Mask *mask;
- MaskLayer *masklay;
+ MaskLayer *mask_layer;
MaskSpline *spline, *orig_spline;
MaskSplinePoint *point;
MaskSplinePointUW *uw;
@@ -555,7 +555,6 @@ static bool spline_under_mouse_get(const bContext *C,
const float threshold = 19.0f;
ScrArea *sa = CTX_wm_area(C);
SpaceClip *sc = CTX_wm_space_clip(C);
- MaskLayer *mask_layer;
int width, height;
float pixel_co[2];
float closest_dist_squared = 0.0f;
@@ -570,13 +569,13 @@ static bool spline_under_mouse_get(const bContext *C,
if (sc != NULL) {
undistort = (sc->clip != NULL) && (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT) != 0;
}
- for (mask_layer = mask->masklayers.first; mask_layer != NULL; mask_layer = mask_layer->next) {
- MaskSpline *spline;
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer != NULL;
+ mask_layer = mask_layer->next) {
if (mask_layer->restrictflag & MASK_RESTRICT_SELECT) {
continue;
}
- for (spline = mask_layer->splines.first; spline != NULL; spline = spline->next) {
+ for (MaskSpline *spline = mask_layer->splines.first; spline != NULL; spline = spline->next) {
MaskSplinePoint *points_array;
float min[2], max[2], center[2];
float dist_squared;
@@ -719,7 +718,7 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent *
Mask *mask = CTX_data_edit_mask(C);
SlidePointData *customdata = NULL;
- MaskLayer *masklay, *cv_masklay, *feather_masklay;
+ MaskLayer *mask_layer, *cv_mask_layer, *feather_mask_layer;
MaskSpline *spline, *cv_spline, *feather_spline;
MaskSplinePoint *point, *cv_point, *feather_point;
MaskSplinePointUW *uw = NULL;
@@ -733,13 +732,13 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent *
ED_mask_get_size(sa, &width, &height);
cv_point = ED_mask_point_find_nearest(
- C, mask, co, threshold, &cv_masklay, &cv_spline, &which_handle, &cv_score);
+ C, mask, co, threshold, &cv_mask_layer, &cv_spline, &which_handle, &cv_score);
if (ED_mask_feather_find_nearest(C,
mask,
co,
threshold,
- &feather_masklay,
+ &feather_mask_layer,
&feather_spline,
&feather_point,
&uw,
@@ -747,7 +746,7 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent *
if (slide_feather || !cv_point || feather_score < cv_score) {
action = SLIDE_ACTION_FEATHER;
- masklay = feather_masklay;
+ mask_layer = feather_mask_layer;
spline = feather_spline;
point = feather_point;
}
@@ -761,13 +760,13 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent *
action = SLIDE_ACTION_POINT;
}
- masklay = cv_masklay;
+ mask_layer = cv_mask_layer;
spline = cv_spline;
point = cv_point;
}
if (action == SLIDE_ACTION_NONE) {
- if (spline_under_mouse_get(C, mask, co, &masklay, &spline)) {
+ if (spline_under_mouse_get(C, mask, co, &mask_layer, &spline)) {
action = SLIDE_ACTION_SPLINE;
point = NULL;
}
@@ -777,7 +776,7 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent *
customdata = MEM_callocN(sizeof(SlidePointData), "mask slide point data");
customdata->event_invoke_type = event->type;
customdata->mask = mask;
- customdata->masklay = masklay;
+ customdata->mask_layer = mask_layer;
customdata->spline = spline;
customdata->point = point;
customdata->width = width;
@@ -790,7 +789,7 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent *
if (customdata->action != SLIDE_ACTION_SPLINE) {
customdata->old_h1 = point->bezt.h1;
customdata->old_h2 = point->bezt.h2;
- select_sliding_point(mask, masklay, spline, point, which_handle);
+ select_sliding_point(mask, mask_layer, spline, point, which_handle);
check_sliding_handle_type(point, which_handle);
}
@@ -850,8 +849,8 @@ static int slide_point_invoke(bContext *C, wmOperator *op, const wmEvent *event)
WM_event_add_modal_handler(C, op);
- slidedata->masklay->act_spline = slidedata->spline;
- slidedata->masklay->act_point = slidedata->point;
+ slidedata->mask_layer->act_spline = slidedata->spline;
+ slidedata->mask_layer->act_point = slidedata->point;
WM_event_add_notifier(C, NC_MASK | ND_SELECT, mask);
@@ -1140,7 +1139,7 @@ static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* dont key sliding feather uw's */
if ((data->action == SLIDE_ACTION_FEATHER && data->uw) == false) {
if (IS_AUTOKEY_ON(scene)) {
- ED_mask_layer_shape_auto_key(data->masklay, CFRA);
+ ED_mask_layer_shape_auto_key(data->mask_layer, CFRA);
}
}
@@ -1586,16 +1585,13 @@ void MASK_OT_slide_spline_curvature(wmOperatorType *ot)
static int cyclic_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *masklay;
-
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- MaskSpline *spline;
- if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (spline = masklay->splines.first; spline; spline = spline->next) {
+ for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
if (ED_mask_spline_select_check(spline)) {
spline->flag ^= MASK_SPLINE_CYCLIC;
}
@@ -1666,18 +1662,17 @@ static void delete_feather_points(MaskSplinePoint *point)
static int delete_exec(bContext *C, wmOperator *UNUSED(op))
{
Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *masklay;
bool changed = false;
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
MaskSpline *spline;
int mask_layer_shape_ofs = 0;
- if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
+ if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- spline = masklay->splines.first;
+ spline = mask_layer->splines.first;
while (spline) {
const int tot_point_orig = spline->tot_point;
@@ -1695,15 +1690,15 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op))
if (count == 0) {
/* delete the whole spline */
- BLI_remlink(&masklay->splines, spline);
+ BLI_remlink(&mask_layer->splines, spline);
BKE_mask_spline_free(spline);
- if (spline == masklay->act_spline) {
- masklay->act_spline = NULL;
- masklay->act_point = NULL;
+ if (spline == mask_layer->act_spline) {
+ mask_layer->act_spline = NULL;
+ mask_layer->act_point = NULL;
}
- BKE_mask_layer_shape_changed_remove(masklay, mask_layer_shape_ofs, tot_point_orig);
+ BKE_mask_layer_shape_changed_remove(mask_layer, mask_layer_shape_ofs, tot_point_orig);
}
else {
MaskSplinePoint *new_points;
@@ -1715,8 +1710,8 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op))
MaskSplinePoint *point = &spline->points[i];
if (!MASKPOINT_ISSEL_ANY(point)) {
- if (point == masklay->act_point) {
- masklay->act_point = &new_points[j];
+ if (point == mask_layer->act_point) {
+ mask_layer->act_point = &new_points[j];
}
delete_feather_points(point);
@@ -1725,14 +1720,14 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op))
j++;
}
else {
- if (point == masklay->act_point) {
- masklay->act_point = NULL;
+ if (point == mask_layer->act_point) {
+ mask_layer->act_point = NULL;
}
BKE_mask_point_free(point);
spline->tot_point--;
- BKE_mask_layer_shape_changed_remove(masklay, mask_layer_shape_ofs + j, 1);
+ BKE_mask_layer_shape_changed_remove(mask_layer, mask_layer_shape_ofs + j, 1);
}
}
@@ -1750,8 +1745,8 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op))
/* not essential but confuses users when there are keys with no data!
* assume if they delete all data from the layer they also dont care about keys */
- if (BLI_listbase_is_empty(&masklay->splines)) {
- BKE_mask_layer_free_shapes(masklay);
+ if (BLI_listbase_is_empty(&mask_layer->splines)) {
+ BKE_mask_layer_free_shapes(mask_layer);
}
}
@@ -1787,22 +1782,20 @@ static int mask_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *masklay;
bool changed = false;
/* do actual selection */
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- MaskSpline *spline;
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
bool changed_layer = false;
- if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
+ if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (spline = masklay->splines.first; spline; spline = spline->next) {
+ for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
if (ED_mask_spline_select_check(spline)) {
- BKE_mask_spline_direction_switch(masklay, spline);
+ BKE_mask_spline_direction_switch(mask_layer, spline);
changed = true;
changed_layer = true;
}
@@ -1810,7 +1803,7 @@ static int mask_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
if (changed_layer) {
if (IS_AUTOKEY_ON(scene)) {
- ED_mask_layer_shape_auto_key(masklay, CFRA);
+ ED_mask_layer_shape_auto_key(mask_layer, CFRA);
}
}
}
@@ -1847,22 +1840,19 @@ static int mask_normals_make_consistent_exec(bContext *C, wmOperator *UNUSED(op)
{
Scene *scene = CTX_data_scene(C);
Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *masklay;
- int i;
bool changed = false;
/* do actual selection */
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- MaskSpline *spline;
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
bool changed_layer = false;
- if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
+ if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (spline = masklay->splines.first; spline; spline = spline->next) {
- for (i = 0; i < spline->tot_point; i++) {
+ for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
if (MASKPOINT_ISSEL_ANY(point)) {
@@ -1875,7 +1865,7 @@ static int mask_normals_make_consistent_exec(bContext *C, wmOperator *UNUSED(op)
if (changed_layer) {
if (IS_AUTOKEY_ON(scene)) {
- ED_mask_layer_shape_auto_key(masklay, CFRA);
+ ED_mask_layer_shape_auto_key(mask_layer, CFRA);
}
}
}
@@ -1913,21 +1903,17 @@ void MASK_OT_normals_make_consistent(wmOperatorType *ot)
static int set_handle_type_exec(bContext *C, wmOperator *op)
{
Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *masklay;
int handle_type = RNA_enum_get(op->ptr, "type");
bool changed = false;
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- MaskSpline *spline;
- int i;
-
- if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (spline = masklay->splines.first; spline; spline = spline->next) {
- for (i = 0; i < spline->tot_point; i++) {
+ for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
if (MASKPOINT_ISSEL_ANY(point)) {
@@ -1999,15 +1985,14 @@ void MASK_OT_handle_type_set(wmOperatorType *ot)
static int mask_hide_view_clear_exec(bContext *C, wmOperator *op)
{
Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *masklay;
bool changed = false;
const bool select = RNA_boolean_get(op->ptr, "select");
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
- if (masklay->restrictflag & OB_RESTRICT_VIEWPORT) {
- ED_mask_layer_select_set(masklay, select);
- masklay->restrictflag &= ~OB_RESTRICT_VIEWPORT;
+ if (mask_layer->restrictflag & OB_RESTRICT_VIEWPORT) {
+ ED_mask_layer_select_set(mask_layer, select);
+ mask_layer->restrictflag &= ~OB_RESTRICT_VIEWPORT;
changed = true;
}
}
@@ -2044,32 +2029,31 @@ void MASK_OT_hide_view_clear(wmOperatorType *ot)
static int mask_hide_view_set_exec(bContext *C, wmOperator *op)
{
Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *masklay;
const bool unselected = RNA_boolean_get(op->ptr, "unselected");
bool changed = false;
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
- if (masklay->restrictflag & MASK_RESTRICT_SELECT) {
+ if (mask_layer->restrictflag & MASK_RESTRICT_SELECT) {
continue;
}
if (!unselected) {
- if (ED_mask_layer_select_check(masklay)) {
- ED_mask_layer_select_set(masklay, false);
+ if (ED_mask_layer_select_check(mask_layer)) {
+ ED_mask_layer_select_set(mask_layer, false);
- masklay->restrictflag |= OB_RESTRICT_VIEWPORT;
+ mask_layer->restrictflag |= OB_RESTRICT_VIEWPORT;
changed = true;
- if (masklay == BKE_mask_layer_active(mask)) {
+ if (mask_layer == BKE_mask_layer_active(mask)) {
BKE_mask_layer_active_set(mask, NULL);
}
}
}
else {
- if (!ED_mask_layer_select_check(masklay)) {
- masklay->restrictflag |= OB_RESTRICT_VIEWPORT;
+ if (!ED_mask_layer_select_check(mask_layer)) {
+ mask_layer->restrictflag |= OB_RESTRICT_VIEWPORT;
changed = true;
- if (masklay == BKE_mask_layer_active(mask)) {
+ if (mask_layer == BKE_mask_layer_active(mask)) {
BKE_mask_layer_active_set(mask, NULL);
}
}
@@ -2108,19 +2092,15 @@ void MASK_OT_hide_view_set(wmOperatorType *ot)
static int mask_feather_weight_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *masklay;
bool changed = false;
- int i;
-
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- MaskSpline *spline;
- if (masklay->restrictflag & (MASK_RESTRICT_SELECT | MASK_RESTRICT_VIEW)) {
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ if (mask_layer->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++) {
+ for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
if (MASKPOINT_ISSEL_ANY(point)) {
@@ -2247,12 +2227,9 @@ void MASK_OT_layer_move(wmOperatorType *ot)
static int mask_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
{
Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *mask_layer;
-
- for (mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
- MaskSpline *spline;
- for (spline = mask_layer->splines.last; spline; spline = spline->prev) {
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ for (MaskSpline *spline = mask_layer->splines.last; spline; spline = spline->prev) {
MaskSplinePoint *point = spline->points;
int i = 0;
while (i < spline->tot_point) {
diff --git a/source/blender/editors/mask/mask_relationships.c b/source/blender/editors/mask/mask_relationships.c
index 75b2aee3570..130ebb61a90 100644
--- a/source/blender/editors/mask/mask_relationships.c
+++ b/source/blender/editors/mask/mask_relationships.c
@@ -43,18 +43,14 @@
static int mask_parent_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *masklay;
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- MaskSpline *spline;
- int i;
-
- if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (spline = masklay->splines.first; spline; spline = spline->next) {
- for (i = 0; i < spline->tot_point; i++) {
+ for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
if (MASKPOINT_ISSEL_ANY(point)) {
@@ -89,7 +85,6 @@ void MASK_OT_parent_clear(wmOperatorType *ot)
static int mask_parent_set_exec(bContext *C, wmOperator *UNUSED(op))
{
Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *masklay;
/* parent info */
SpaceClip *sc = CTX_wm_space_clip(C);
@@ -141,16 +136,13 @@ static int mask_parent_set_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- MaskSpline *spline;
- int i;
-
- if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (spline = masklay->splines.first; spline; spline = spline->next) {
- for (i = 0; i < spline->tot_point; i++) {
+ for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
if (MASKPOINT_ISSEL_ANY(point)) {
diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c
index 2b3bd1b72c9..656c055a7d9 100644
--- a/source/blender/editors/mask/mask_select.c
+++ b/source/blender/editors/mask/mask_select.c
@@ -68,15 +68,13 @@ bool ED_mask_spline_select_check(MaskSpline *spline)
return false;
}
-bool ED_mask_layer_select_check(MaskLayer *masklay)
+bool ED_mask_layer_select_check(MaskLayer *mask_layer)
{
- MaskSpline *spline;
-
- if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
+ if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
return false;
}
- for (spline = masklay->splines.first; spline; spline = spline->next) {
+ for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
if (ED_mask_spline_select_check(spline)) {
return true;
}
@@ -87,10 +85,8 @@ bool ED_mask_layer_select_check(MaskLayer *masklay)
bool ED_mask_select_check(Mask *mask)
{
- MaskLayer *masklay;
-
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- if (ED_mask_layer_select_check(masklay)) {
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ if (ED_mask_layer_select_check(mask_layer)) {
return true;
}
}
@@ -117,25 +113,21 @@ void ED_mask_spline_select_set(MaskSpline *spline, const bool do_select)
}
}
-void ED_mask_layer_select_set(MaskLayer *masklay, const bool do_select)
+void ED_mask_layer_select_set(MaskLayer *mask_layer, const bool do_select)
{
- MaskSpline *spline;
-
- if (masklay->restrictflag & MASK_RESTRICT_SELECT) {
+ if (mask_layer->restrictflag & MASK_RESTRICT_SELECT) {
if (do_select == true) {
return;
}
}
- for (spline = masklay->splines.first; spline; spline = spline->next) {
+ for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
ED_mask_spline_select_set(spline, do_select);
}
}
void ED_mask_select_toggle_all(Mask *mask, int action)
{
- MaskLayer *masklay;
-
if (action == SEL_TOGGLE) {
if (ED_mask_select_check(mask)) {
action = SEL_DESELECT;
@@ -145,9 +137,9 @@ void ED_mask_select_toggle_all(Mask *mask, int action)
}
}
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
- if (masklay->restrictflag & MASK_RESTRICT_VIEW) {
+ if (mask_layer->restrictflag & MASK_RESTRICT_VIEW) {
continue;
}
@@ -155,11 +147,10 @@ void ED_mask_select_toggle_all(Mask *mask, int action)
/* we don't have generic functions for this, its restricted to this operator
* if one day we need to re-use such functionality, they can be split out */
- MaskSpline *spline;
- if (masklay->restrictflag & MASK_RESTRICT_SELECT) {
+ if (mask_layer->restrictflag & MASK_RESTRICT_SELECT) {
continue;
}
- for (spline = masklay->splines.first; spline; spline = spline->next) {
+ for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
int i;
for (i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
@@ -168,30 +159,24 @@ void ED_mask_select_toggle_all(Mask *mask, int action)
}
}
else {
- ED_mask_layer_select_set(masklay, (action == SEL_SELECT) ? true : false);
+ ED_mask_layer_select_set(mask_layer, (action == SEL_SELECT) ? true : false);
}
}
}
void ED_mask_select_flush_all(Mask *mask)
{
- MaskLayer *masklay;
-
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- MaskSpline *spline;
-
- for (spline = masklay->splines.first; spline; spline = spline->next) {
- int i;
-
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
spline->flag &= ~SELECT;
- /* intentionally _dont_ do this in the masklay loop
+ /* intentionally _dont_ do this in the mask layer loop
* so we clear flags on all splines */
- if (masklay->restrictflag & MASK_RESTRICT_VIEW) {
+ if (mask_layer->restrictflag & MASK_RESTRICT_VIEW) {
continue;
}
- for (i = 0; i < spline->tot_point; i++) {
+ for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *cur_point = &spline->points[i];
if (MASKPOINT_ISSEL_ANY(cur_point)) {
@@ -270,7 +255,7 @@ void MASK_OT_select_all(wmOperatorType *ot)
static int select_exec(bContext *C, wmOperator *op)
{
Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *masklay;
+ MaskLayer *mask_layer;
MaskSpline *spline;
MaskSplinePoint *point = NULL;
float co[2];
@@ -284,7 +269,7 @@ static int select_exec(bContext *C, wmOperator *op)
RNA_float_get_array(op->ptr, "location", co);
point = ED_mask_point_find_nearest(
- C, mask, co, threshold, &masklay, &spline, &which_handle, NULL);
+ C, mask, co, threshold, &mask_layer, &spline, &which_handle, NULL);
if (extend == false && deselect == false && toggle == false) {
ED_mask_select_toggle_all(mask, SEL_DESELECT);
@@ -293,8 +278,8 @@ static int select_exec(bContext *C, wmOperator *op)
if (point) {
if (which_handle != MASK_WHICH_HANDLE_NONE) {
if (extend) {
- masklay->act_spline = spline;
- masklay->act_point = point;
+ mask_layer->act_spline = spline;
+ mask_layer->act_point = point;
BKE_mask_point_select_set_handle(point, which_handle, true);
}
@@ -302,8 +287,8 @@ static int select_exec(bContext *C, wmOperator *op)
BKE_mask_point_select_set_handle(point, which_handle, false);
}
else {
- masklay->act_spline = spline;
- masklay->act_point = point;
+ mask_layer->act_spline = spline;
+ mask_layer->act_point = point;
if (!MASKPOINT_ISSEL_HANDLE(point, which_handle)) {
BKE_mask_point_select_set_handle(point, which_handle, true);
@@ -315,8 +300,8 @@ static int select_exec(bContext *C, wmOperator *op)
}
else {
if (extend) {
- masklay->act_spline = spline;
- masklay->act_point = point;
+ mask_layer->act_spline = spline;
+ mask_layer->act_point = point;
BKE_mask_point_select_set(point, true);
}
@@ -324,8 +309,8 @@ static int select_exec(bContext *C, wmOperator *op)
BKE_mask_point_select_set(point, false);
}
else {
- masklay->act_spline = spline;
- masklay->act_point = point;
+ mask_layer->act_spline = spline;
+ mask_layer->act_point = point;
if (!MASKPOINT_ISSEL_ANY(point)) {
BKE_mask_point_select_set(point, true);
@@ -336,8 +321,8 @@ static int select_exec(bContext *C, wmOperator *op)
}
}
- masklay->act_spline = spline;
- masklay->act_point = point;
+ mask_layer->act_spline = spline;
+ mask_layer->act_point = point;
ED_mask_select_flush_all(mask);
@@ -350,11 +335,11 @@ static int select_exec(bContext *C, wmOperator *op)
MaskSplinePointUW *uw;
if (ED_mask_feather_find_nearest(
- C, mask, co, threshold, &masklay, &spline, &point, &uw, NULL)) {
+ C, mask, co, threshold, &mask_layer, &spline, &point, &uw, NULL)) {
if (extend) {
- masklay->act_spline = spline;
- masklay->act_point = point;
+ mask_layer->act_spline = spline;
+ mask_layer->act_point = point;
if (uw) {
uw->flag |= SELECT;
@@ -366,8 +351,8 @@ static int select_exec(bContext *C, wmOperator *op)
}
}
else {
- masklay->act_spline = spline;
- masklay->act_point = point;
+ mask_layer->act_spline = spline;
+ mask_layer->act_point = point;
if (uw) {
if (!(uw->flag & SELECT)) {
@@ -454,8 +439,6 @@ static int box_select_exec(bContext *C, wmOperator *op)
ARegion *ar = CTX_wm_region(C);
Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *masklay;
- int i;
rcti rect;
rctf rectf;
@@ -475,17 +458,15 @@ static int box_select_exec(bContext *C, wmOperator *op)
ED_mask_point_pos(sa, ar, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
/* do actual selection */
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- MaskSpline *spline;
-
- if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (spline = masklay->splines.first; spline; spline = spline->next) {
+ for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
- for (i = 0; i < spline->tot_point; i++) {
+ for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
MaskSplinePoint *point_deform = &points_array[i];
@@ -548,8 +529,6 @@ static bool do_lasso_select_mask(bContext *C,
ARegion *ar = CTX_wm_region(C);
Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *masklay;
- int i;
rcti rect;
bool changed = false;
@@ -564,17 +543,15 @@ static bool do_lasso_select_mask(bContext *C,
BLI_lasso_boundbox(&rect, mcords, moves);
/* do actual selection */
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- MaskSpline *spline;
-
- if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (spline = masklay->splines.first; spline; spline = spline->next) {
+ for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
- for (i = 0; i < spline->tot_point; i++) {
+ for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
MaskSplinePoint *point_deform = &points_array[i];
@@ -678,7 +655,6 @@ static int circle_select_exec(bContext *C, wmOperator *op)
ARegion *ar = CTX_wm_region(C);
Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *masklay;
int i;
float zoomx, zoomy, offset[2], ellipse[2];
@@ -709,14 +685,12 @@ static int circle_select_exec(bContext *C, wmOperator *op)
}
/* do actual selection */
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- MaskSpline *spline;
-
- if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (spline = masklay->splines.first; spline; spline = spline->next) {
+ for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
for (i = 0; i < spline->tot_point; i++) {
@@ -778,7 +752,7 @@ static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmE
ARegion *ar = CTX_wm_region(C);
Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *masklay;
+ MaskLayer *mask_layer;
MaskSpline *spline;
MaskSplinePoint *point = NULL;
float co[2];
@@ -788,12 +762,12 @@ static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmE
ED_mask_mouse_pos(sa, ar, event->mval, co);
- point = ED_mask_point_find_nearest(C, mask, co, threshold, &masklay, &spline, NULL, NULL);
+ point = ED_mask_point_find_nearest(C, mask, co, threshold, &mask_layer, &spline, NULL, NULL);
if (point) {
ED_mask_spline_select_set(spline, do_select);
- masklay->act_spline = spline;
- masklay->act_point = point;
+ mask_layer->act_spline = spline;
+ mask_layer->act_point = point;
changed = true;
}
@@ -836,19 +810,16 @@ void MASK_OT_select_linked_pick(wmOperatorType *ot)
static int mask_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
{
Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *masklay;
bool changed = false;
/* do actual selection */
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- MaskSpline *spline;
-
- if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (spline = masklay->splines.first; spline; spline = spline->next) {
+ for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
if (ED_mask_spline_select_check(spline)) {
ED_mask_spline_select_set(spline, true);
changed = true;
@@ -892,16 +863,13 @@ void MASK_OT_select_linked(wmOperatorType *ot)
static int mask_select_more_less(bContext *C, bool more)
{
Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *masklay;
-
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- MaskSpline *spline;
- if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (spline = masklay->splines.first; spline; spline = spline->next) {
+ for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
const bool cyclic = (spline->flag & MASK_SPLINE_CYCLIC) != 0;
bool start_sel, end_sel, prev_sel, cur_sel;
int i;
diff --git a/source/blender/editors/mask/mask_shapekey.c b/source/blender/editors/mask/mask_shapekey.c
index 1abe805192d..2300289fd3b 100644
--- a/source/blender/editors/mask/mask_shapekey.c
+++ b/source/blender/editors/mask/mask_shapekey.c
@@ -51,18 +51,17 @@ static int mask_shape_key_insert_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;
bool changed = false;
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- MaskLayerShape *masklay_shape;
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ MaskLayerShape *mask_layer_shape;
- if (!ED_mask_layer_select_check(masklay)) {
+ if (!ED_mask_layer_select_check(mask_layer)) {
continue;
}
- masklay_shape = BKE_mask_layer_shape_verify_frame(masklay, frame);
- BKE_mask_layer_shape_from_mask(masklay, masklay_shape);
+ mask_layer_shape = BKE_mask_layer_shape_verify_frame(mask_layer, frame);
+ BKE_mask_layer_shape_from_mask(mask_layer, mask_layer_shape);
changed = true;
}
@@ -97,20 +96,19 @@ static int mask_shape_key_clear_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;
bool changed = false;
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- MaskLayerShape *masklay_shape;
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ MaskLayerShape *mask_layer_shape;
- if (!ED_mask_layer_select_check(masklay)) {
+ if (!ED_mask_layer_select_check(mask_layer)) {
continue;
}
- masklay_shape = BKE_mask_layer_shape_find_frame(masklay, frame);
+ mask_layer_shape = BKE_mask_layer_shape_find_frame(mask_layer, frame);
- if (masklay_shape) {
- BKE_mask_layer_shape_unlink(masklay, masklay_shape);
+ if (mask_layer_shape) {
+ BKE_mask_layer_shape_unlink(mask_layer, mask_layer_shape);
changed = true;
}
}
@@ -146,39 +144,36 @@ 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;
bool changed = false;
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
- if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
+ if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- if (masklay->splines_shapes.first) {
- MaskLayerShape *masklay_shape_reset;
- MaskLayerShape *masklay_shape;
+ if (mask_layer->splines_shapes.first) {
+ MaskLayerShape *mask_layer_shape_reset;
+ MaskLayerShape *mask_layer_shape;
/* get the shapekey of the current state */
- masklay_shape_reset = BKE_mask_layer_shape_alloc(masklay, frame);
+ mask_layer_shape_reset = BKE_mask_layer_shape_alloc(mask_layer, frame);
/* initialize from mask - as if inseting a keyframe */
- BKE_mask_layer_shape_from_mask(masklay, masklay_shape_reset);
+ BKE_mask_layer_shape_from_mask(mask_layer, mask_layer_shape_reset);
- for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
- masklay_shape = masklay_shape->next) {
+ for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape;
+ mask_layer_shape = mask_layer_shape->next) {
- if (masklay_shape_reset->tot_vert == masklay_shape->tot_vert) {
+ if (mask_layer_shape_reset->tot_vert == mask_layer_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;
+ shape_ele_src = (MaskLayerShapeElem *)mask_layer_shape_reset->data;
+ shape_ele_dst = (MaskLayerShapeElem *)mask_layer_shape->data;
- for (spline = masklay->splines.first; spline; spline = spline->next) {
- for (i = 0; i < spline->tot_point; i++) {
+ for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
if (MASKPOINT_ISSEL_ANY(point)) {
@@ -200,7 +195,7 @@ static int mask_shape_key_feather_reset_exec(bContext *C, wmOperator *UNUSED(op)
changed = true;
}
- BKE_mask_layer_shape_free(masklay_shape_reset);
+ BKE_mask_layer_shape_free(mask_layer_shape_reset);
}
}
@@ -243,98 +238,94 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
const int frame = CFRA;
Mask *mask = CTX_data_edit_mask(C);
- MaskLayer *masklay;
bool changed = false;
const bool do_feather = RNA_boolean_get(op->ptr, "feather");
const bool do_location = RNA_boolean_get(op->ptr, "location");
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
-
- if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
/* we need at least one point selected here to bother re-interpolating */
- if (!ED_mask_layer_select_check(masklay)) {
+ if (!ED_mask_layer_select_check(mask_layer)) {
continue;
}
- if (masklay->splines_shapes.first) {
- MaskLayerShape *masklay_shape, *masklay_shape_next;
- MaskLayerShape *masklay_shape_lastsel = NULL;
+ if (mask_layer->splines_shapes.first) {
+ MaskLayerShape *mask_layer_shape, *mask_layer_shape_next;
+ MaskLayerShape *mask_layer_shape_lastsel = NULL;
- for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
- masklay_shape = masklay_shape_next) {
- MaskLayerShape *masklay_shape_a = NULL;
- MaskLayerShape *masklay_shape_b = NULL;
+ for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape;
+ mask_layer_shape = mask_layer_shape_next) {
+ MaskLayerShape *mask_layer_shape_a = NULL;
+ MaskLayerShape *mask_layer_shape_b = NULL;
- masklay_shape_next = masklay_shape->next;
+ mask_layer_shape_next = mask_layer_shape->next;
/* find contiguous selections */
- if (masklay_shape->flag & MASK_SHAPE_SELECT) {
- if (masklay_shape_lastsel == NULL) {
- masklay_shape_lastsel = masklay_shape;
+ if (mask_layer_shape->flag & MASK_SHAPE_SELECT) {
+ if (mask_layer_shape_lastsel == NULL) {
+ mask_layer_shape_lastsel = mask_layer_shape;
}
- if ((masklay_shape->next == NULL) ||
- (((MaskLayerShape *)masklay_shape->next)->flag & MASK_SHAPE_SELECT) == 0) {
- masklay_shape_a = masklay_shape_lastsel;
- masklay_shape_b = masklay_shape;
- masklay_shape_lastsel = NULL;
+ if ((mask_layer_shape->next == NULL) ||
+ (((MaskLayerShape *)mask_layer_shape->next)->flag & MASK_SHAPE_SELECT) == 0) {
+ mask_layer_shape_a = mask_layer_shape_lastsel;
+ mask_layer_shape_b = mask_layer_shape;
+ mask_layer_shape_lastsel = NULL;
/* this will be freed below, step over selection */
- masklay_shape_next = masklay_shape->next;
+ mask_layer_shape_next = mask_layer_shape->next;
}
}
/* we have a from<>to? - re-interpolate! */
- if (masklay_shape_a && masklay_shape_b) {
+ if (mask_layer_shape_a && mask_layer_shape_b) {
ListBase shapes_tmp = {NULL, NULL};
- MaskLayerShape *masklay_shape_tmp;
- MaskLayerShape *masklay_shape_tmp_next;
- MaskLayerShape *masklay_shape_tmp_last = masklay_shape_b->next;
- MaskLayerShape *masklay_shape_tmp_rekey;
+ MaskLayerShape *mask_layer_shape_tmp;
+ MaskLayerShape *mask_layer_shape_tmp_next;
+ MaskLayerShape *mask_layer_shape_tmp_last = mask_layer_shape_b->next;
+ MaskLayerShape *mask_layer_shape_tmp_rekey;
/* move keys */
- for (masklay_shape_tmp = masklay_shape_a;
- masklay_shape_tmp && (masklay_shape_tmp != masklay_shape_tmp_last);
- masklay_shape_tmp = masklay_shape_tmp_next) {
- masklay_shape_tmp_next = masklay_shape_tmp->next;
- BLI_remlink(&masklay->splines_shapes, masklay_shape_tmp);
- BLI_addtail(&shapes_tmp, masklay_shape_tmp);
+ for (mask_layer_shape_tmp = mask_layer_shape_a;
+ mask_layer_shape_tmp && (mask_layer_shape_tmp != mask_layer_shape_tmp_last);
+ mask_layer_shape_tmp = mask_layer_shape_tmp_next) {
+ mask_layer_shape_tmp_next = mask_layer_shape_tmp->next;
+ BLI_remlink(&mask_layer->splines_shapes, mask_layer_shape_tmp);
+ BLI_addtail(&shapes_tmp, mask_layer_shape_tmp);
}
/* re-key, note: cant modify the keys here since it messes uop */
- for (masklay_shape_tmp = shapes_tmp.first; masklay_shape_tmp;
- masklay_shape_tmp = masklay_shape_tmp->next) {
- BKE_mask_layer_evaluate(masklay, masklay_shape_tmp->frame, true);
- masklay_shape_tmp_rekey = BKE_mask_layer_shape_verify_frame(masklay,
- masklay_shape_tmp->frame);
- BKE_mask_layer_shape_from_mask(masklay, masklay_shape_tmp_rekey);
- masklay_shape_tmp_rekey->flag = masklay_shape_tmp->flag & MASK_SHAPE_SELECT;
+ for (mask_layer_shape_tmp = shapes_tmp.first; mask_layer_shape_tmp;
+ mask_layer_shape_tmp = mask_layer_shape_tmp->next) {
+ BKE_mask_layer_evaluate(mask_layer, mask_layer_shape_tmp->frame, true);
+ mask_layer_shape_tmp_rekey = BKE_mask_layer_shape_verify_frame(
+ mask_layer, mask_layer_shape_tmp->frame);
+ BKE_mask_layer_shape_from_mask(mask_layer, mask_layer_shape_tmp_rekey);
+ mask_layer_shape_tmp_rekey->flag = mask_layer_shape_tmp->flag & MASK_SHAPE_SELECT;
}
/* restore unselected points and free copies */
- for (masklay_shape_tmp = shapes_tmp.first; masklay_shape_tmp;
- masklay_shape_tmp = masklay_shape_tmp_next) {
+ for (mask_layer_shape_tmp = shapes_tmp.first; mask_layer_shape_tmp;
+ mask_layer_shape_tmp = mask_layer_shape_tmp_next) {
/* restore */
int i_abs = 0;
- int i;
- MaskSpline *spline;
MaskLayerShapeElem *shape_ele_src;
MaskLayerShapeElem *shape_ele_dst;
- masklay_shape_tmp_next = masklay_shape_tmp->next;
+ mask_layer_shape_tmp_next = mask_layer_shape_tmp->next;
/* we know this exists, added above */
- masklay_shape_tmp_rekey = BKE_mask_layer_shape_find_frame(masklay,
- masklay_shape_tmp->frame);
+ mask_layer_shape_tmp_rekey = BKE_mask_layer_shape_find_frame(
+ mask_layer, mask_layer_shape_tmp->frame);
- shape_ele_src = (MaskLayerShapeElem *)masklay_shape_tmp->data;
- shape_ele_dst = (MaskLayerShapeElem *)masklay_shape_tmp_rekey->data;
+ shape_ele_src = (MaskLayerShapeElem *)mask_layer_shape_tmp->data;
+ shape_ele_dst = (MaskLayerShapeElem *)mask_layer_shape_tmp_rekey->data;
- for (spline = masklay->splines.first; spline; spline = spline->next) {
- for (i = 0; i < spline->tot_point; i++) {
+ for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
/* not especially efficient but makes this easier to follow */
@@ -356,7 +347,7 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op)
}
}
- BKE_mask_layer_shape_free(masklay_shape_tmp);
+ BKE_mask_layer_shape_free(mask_layer_shape_tmp);
}
changed = true;
@@ -364,7 +355,7 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op)
}
/* re-evaluate */
- BKE_mask_layer_evaluate(masklay, frame, true);
+ BKE_mask_layer_evaluate(mask_layer, frame, true);
}
}
@@ -401,21 +392,20 @@ void MASK_OT_shape_key_rekey(wmOperatorType *ot)
/* *** Shape Key Utils *** */
-void ED_mask_layer_shape_auto_key(MaskLayer *masklay, const int frame)
+void ED_mask_layer_shape_auto_key(MaskLayer *mask_layer, const int frame)
{
- MaskLayerShape *masklay_shape;
+ MaskLayerShape *mask_layer_shape;
- masklay_shape = BKE_mask_layer_shape_verify_frame(masklay, frame);
- BKE_mask_layer_shape_from_mask(masklay, masklay_shape);
+ mask_layer_shape = BKE_mask_layer_shape_verify_frame(mask_layer, frame);
+ BKE_mask_layer_shape_from_mask(mask_layer, mask_layer_shape);
}
bool ED_mask_layer_shape_auto_key_all(Mask *mask, const int frame)
{
- MaskLayer *masklay;
bool changed = false;
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
- ED_mask_layer_shape_auto_key(masklay, frame);
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ ED_mask_layer_shape_auto_key(mask_layer, frame);
changed = true;
}
@@ -424,16 +414,15 @@ bool ED_mask_layer_shape_auto_key_all(Mask *mask, const int frame)
bool ED_mask_layer_shape_auto_key_select(Mask *mask, const int frame)
{
- MaskLayer *masklay;
bool changed = false;
- for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+ for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
- if (!ED_mask_layer_select_check(masklay)) {
+ if (!ED_mask_layer_select_check(mask_layer)) {
continue;
}
- ED_mask_layer_shape_auto_key(masklay, frame);
+ ED_mask_layer_shape_auto_key(mask_layer, frame);
changed = true;
}
diff --git a/source/blender/editors/render/render_view.c b/source/blender/editors/render/render_view.c
index a54701f8725..8bc84388a1b 100644
--- a/source/blender/editors/render/render_view.c
+++ b/source/blender/editors/render/render_view.c
@@ -118,7 +118,7 @@ static ScrArea *find_area_image_empty(bContext *C)
for (sa = sc->areabase.first; sa; sa = sa->next) {
if (sa->spacetype == SPACE_IMAGE) {
sima = sa->spacedata.first;
- if (!sima->image) {
+ if ((sima->mode == SI_MODE_VIEW) && !sima->image) {
break;
}
}
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index bf45fa24923..41c3a2ca285 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -2869,7 +2869,7 @@ void ED_region_info_draw(ARegion *ar,
float fill_color[4],
const bool full_redraw)
{
- ED_region_info_draw_multiline(ar, (const char * [2]){text, NULL}, fill_color, full_redraw);
+ ED_region_info_draw_multiline(ar, (const char *[2]){text, NULL}, fill_color, full_redraw);
}
#define MAX_METADATA_STR 1024
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index cc1f53eabde..c5e7d578e71 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -2119,7 +2119,7 @@ static void area_split_preview_update_cursor(bContext *C, wmOperator *op)
{
wmWindow *win = CTX_wm_window(C);
int dir = RNA_enum_get(op->ptr, "direction");
- WM_cursor_set(win, (dir == 'n' || dir == 's') ? WM_CURSOR_H_SPLIT : WM_CURSOR_V_SPLIT);
+ WM_cursor_set(win, dir == 'h' ? WM_CURSOR_H_SPLIT : WM_CURSOR_V_SPLIT);
}
/* UI callback, adds new handler */
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 5ea95383892..3cdcc07f081 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -2395,60 +2395,49 @@ void FILE_OT_filenum(struct wmOperatorType *ot)
RNA_def_int(ot->srna, "increment", 1, -100, 100, "Increment", "", -100, 100);
}
-static int file_rename_exec(bContext *C, wmOperator *UNUSED(op))
+static void file_rename_state_activate(SpaceFile *sfile, int file_idx, bool require_selected)
{
- ScrArea *sa = CTX_wm_area(C);
- SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C);
+ const int numfiles = filelist_files_ensure(sfile->files);
- if (sfile->params) {
- int idx = sfile->params->highlight_file;
- int numfiles = filelist_files_ensure(sfile->files);
- if ((0 <= idx) && (idx < numfiles)) {
- FileDirEntry *file = filelist_file(sfile->files, idx);
+ if ((file_idx >= 0) && (file_idx < numfiles)) {
+ FileDirEntry *file = filelist_file(sfile->files, file_idx);
+
+ if ((require_selected == false) ||
+ (filelist_entry_select_get(sfile->files, file, CHECK_ALL) & FILE_SEL_SELECTED)) {
filelist_entry_select_index_set(
- sfile->files, idx, FILE_SEL_ADD, FILE_SEL_EDITING, CHECK_ALL);
+ sfile->files, file_idx, FILE_SEL_ADD, FILE_SEL_EDITING, CHECK_ALL);
BLI_strncpy(sfile->params->renamefile, file->relpath, FILE_MAXFILE);
/* We can skip the pending state,
* as we can directly set FILE_SEL_EDITING on the expected entry here. */
sfile->params->rename_flag = FILE_PARAMS_RENAME_ACTIVE;
}
+ }
+}
+
+static int file_rename_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
+{
+ ScrArea *sa = CTX_wm_area(C);
+ SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C);
+
+ if (sfile->params) {
+ file_rename_state_activate(sfile, sfile->params->active_file, true);
ED_area_tag_redraw(sa);
}
return OPERATOR_FINISHED;
}
-static bool file_rename_poll(bContext *C)
+static int file_rename_exec(bContext *C, wmOperator *UNUSED(op))
{
- bool poll = ED_operator_file_active(C);
- SpaceFile *sfile = CTX_wm_space_file(C);
-
- if (sfile && sfile->params) {
- int idx = sfile->params->highlight_file;
- int numfiles = filelist_files_ensure(sfile->files);
-
- if ((0 <= idx) && (idx < numfiles)) {
- FileDirEntry *file = filelist_file(sfile->files, idx);
- if (FILENAME_IS_CURRPAR(file->relpath)) {
- poll = false;
- }
- }
+ ScrArea *sa = CTX_wm_area(C);
+ SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C);
- if (sfile->params->highlight_file < 0) {
- poll = false;
- }
- else {
- char dir[FILE_MAX_LIBEXTRA];
- if (filelist_islibrary(sfile->files, dir, NULL)) {
- poll = false;
- }
- }
- }
- else {
- poll = false;
+ if (sfile->params) {
+ file_rename_state_activate(sfile, sfile->params->highlight_file, false);
+ ED_area_tag_redraw(sa);
}
- return poll;
+ return OPERATOR_FINISHED;
}
void FILE_OT_rename(struct wmOperatorType *ot)
@@ -2459,8 +2448,9 @@ void FILE_OT_rename(struct wmOperatorType *ot)
ot->idname = "FILE_OT_rename";
/* api callbacks */
+ ot->invoke = file_rename_invoke;
ot->exec = file_rename_exec;
- ot->poll = file_rename_poll;
+ ot->poll = ED_operator_file_active;
}
static bool file_delete_poll(bContext *C)
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index d29233618de..1ea7d81f9da 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -338,7 +338,7 @@ enum {
enum {
SPECIAL_IMG_DOCUMENT = 0,
- SPECIAL_IMG_UNSUPORTED = 1,
+ SPECIAL_IMG_DRIVE_DISC = 1,
SPECIAL_IMG_FOLDER = 2,
SPECIAL_IMG_PARENT = 3,
SPECIAL_IMG_DRIVE_FIXED = 4,
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 3776b660859..bb3906a961b 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -103,11 +103,9 @@ short ED_fileselect_set_params(SpaceFile *sfile)
sizeof(sfile->params->dir),
sizeof(sfile->params->file));
sfile->params->filter_glob[0] = '\0';
- /* set the default thumbnails size */
sfile->params->thumbnail_size = U_default.file_space_data.thumbnail_size;
- /* Show size column by default. */
sfile->params->details_flags = U_default.file_space_data.details_flags;
- sfile->params->filter_id = FILTER_ID_ALL;
+ sfile->params->filter_id = U_default.file_space_data.filter_id;
}
params = sfile->params;
@@ -346,6 +344,7 @@ void ED_fileselect_set_params_from_userdef(SpaceFile *sfile)
}
sfile->params->thumbnail_size = sfile_udata->thumbnail_size;
sfile->params->details_flags = sfile_udata->details_flags;
+ sfile->params->filter_id = sfile_udata->filter_id;
/* Combine flags we take from params with the flags we take from userdef. */
sfile->params->flag = (sfile->params->flag & ~PARAMS_FLAGS_REMEMBERED) |
@@ -369,6 +368,7 @@ void ED_fileselect_params_to_userdef(SpaceFile *sfile, int temp_win_size[2])
sfile_udata_new->sort_type = sfile->params->sort;
sfile_udata_new->details_flags = sfile->params->details_flags;
sfile_udata_new->flag = sfile->params->flag & PARAMS_FLAGS_REMEMBERED;
+ sfile_udata_new->filter_id = sfile->params->filter_id;
if (temp_win_size) {
sfile_udata_new->temp_win_sizex = temp_win_size[0];
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index 91e5ab61dd9..95ad56a35e6 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -303,8 +303,10 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
}
/* preview range */
- UI_view2d_view_ortho(v2d);
- ANIM_draw_previewrange(C, v2d, 0);
+ if (sipo->mode != SIPO_MODE_DRIVERS) {
+ UI_view2d_view_ortho(v2d);
+ ANIM_draw_previewrange(C, v2d, 0);
+ }
/* callback */
UI_view2d_view_ortho(v2d);
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 1a788237e6e..5b2ea9d4793 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -1767,8 +1767,8 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar)
static void seq_draw_sfra_efra(Scene *scene, View2D *v2d)
{
const Editing *ed = BKE_sequencer_editing_get(scene, false);
- const int frame_sta = PSFRA;
- const int frame_end = PEFRA + 1;
+ const int frame_sta = scene->r.sfra;
+ const int frame_end = scene->r.efra + 1;
GPU_blend(true);
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index ca1c55b80eb..ed384cfc1a8 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -219,8 +219,7 @@ static void seq_proxy_build_job(const bContext *C, ReportList *reports)
bool success = BKE_sequencer_proxy_rebuild_context(
pj->main, pj->depsgraph, pj->scene, seq, file_list, &pj->queue);
if (!success) {
-
- BKE_reportf(reports, RPT_ERROR, "Could not build proxy for strip %s", &seq->name);
+ BKE_reportf(reports, RPT_ERROR, "Could not build proxy for strip %s", seq->name);
}
}
}
@@ -4185,3 +4184,67 @@ void SEQUENCER_OT_export_subtitles(struct wmOperatorType *ot)
FILE_DEFAULTDISPLAY,
FILE_SORT_ALPHA);
}
+
+static int sequencer_set_range_to_strips_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq;
+
+ int sfra = MAXFRAME;
+ int efra = -MAXFRAME;
+ bool selected = false;
+ const bool preview = RNA_boolean_get(op->ptr, "preview");
+
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if (seq->flag & SELECT) {
+ selected = true;
+ sfra = min_ii(sfra, seq->startdisp);
+ efra = max_ii(efra, seq->enddisp - 1);
+ }
+ }
+
+ if (!selected) {
+ BKE_report(op->reports, RPT_WARNING, "Select one or more strips");
+ return OPERATOR_CANCELLED;
+ }
+ else if (efra < 0) {
+ BKE_report(op->reports, RPT_ERROR, "Can't set a negative range");
+ return OPERATOR_CANCELLED;
+ }
+
+ if (preview) {
+ scene->r.flag |= SCER_PRV_RANGE;
+ scene->r.psfra = max_ii(0, sfra);
+ scene->r.pefra = efra;
+ }
+ else {
+ scene->r.flag &= ~SCER_PRV_RANGE;
+ scene->r.sfra = max_ii(0, sfra);
+ scene->r.efra = efra;
+ }
+
+ WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
+
+ return OPERATOR_FINISHED;
+}
+
+void SEQUENCER_OT_set_range_to_strips(struct wmOperatorType *ot)
+{
+ PropertyRNA *prop;
+
+ /* identifiers */
+ ot->name = "Set Range to Strips";
+ ot->idname = "SEQUENCER_OT_set_range_to_strips";
+ ot->description = "Set the frame range to the selected strips start and end";
+
+ /* api callbacks */
+ ot->exec = sequencer_set_range_to_strips_exec;
+ ot->poll = sequencer_edit_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ prop = RNA_def_boolean(ot->srna, "preview", false, "Preview", "Set the preview range instead");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+}
diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h
index 851d3b5f3aa..0a51578da3b 100644
--- a/source/blender/editors/space_sequencer/sequencer_intern.h
+++ b/source/blender/editors/space_sequencer/sequencer_intern.h
@@ -149,6 +149,8 @@ void SEQUENCER_OT_enable_proxies(struct wmOperatorType *ot);
void SEQUENCER_OT_export_subtitles(struct wmOperatorType *ot);
+void SEQUENCER_OT_set_range_to_strips(struct wmOperatorType *ot);
+
/* preview specific operators */
void SEQUENCER_OT_view_all_preview(struct wmOperatorType *ot);
@@ -160,7 +162,7 @@ void SEQUENCER_OT_select_less(struct wmOperatorType *ot);
void SEQUENCER_OT_select_linked(struct wmOperatorType *ot);
void SEQUENCER_OT_select_linked_pick(struct wmOperatorType *ot);
void SEQUENCER_OT_select_handles(struct wmOperatorType *ot);
-void SEQUENCER_OT_select_active_side(struct wmOperatorType *ot);
+void SEQUENCER_OT_select_side(struct wmOperatorType *ot);
void SEQUENCER_OT_select_box(struct wmOperatorType *ot);
void SEQUENCER_OT_select_inverse(struct wmOperatorType *ot);
void SEQUENCER_OT_select_grouped(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c
index b0bb775de83..af03035d10f 100644
--- a/source/blender/editors/space_sequencer/sequencer_ops.c
+++ b/source/blender/editors/space_sequencer/sequencer_ops.c
@@ -88,6 +88,8 @@ void sequencer_operatortypes(void)
WM_operatortype_append(SEQUENCER_OT_change_effect_type);
WM_operatortype_append(SEQUENCER_OT_change_path);
+ WM_operatortype_append(SEQUENCER_OT_set_range_to_strips);
+
/* sequencer_select.c */
WM_operatortype_append(SEQUENCER_OT_select_all);
WM_operatortype_append(SEQUENCER_OT_select);
@@ -96,7 +98,7 @@ void sequencer_operatortypes(void)
WM_operatortype_append(SEQUENCER_OT_select_linked_pick);
WM_operatortype_append(SEQUENCER_OT_select_linked);
WM_operatortype_append(SEQUENCER_OT_select_handles);
- WM_operatortype_append(SEQUENCER_OT_select_active_side);
+ WM_operatortype_append(SEQUENCER_OT_select_side);
WM_operatortype_append(SEQUENCER_OT_select_box);
WM_operatortype_append(SEQUENCER_OT_select_grouped);
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index 4c20fc1707a..a51b08f7525 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -27,6 +27,7 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
+#include "BLI_math.h"
#include "DNA_scene_types.h"
@@ -81,7 +82,7 @@ static void select_surrounding_handles(Scene *scene, Sequence *test) /* XXX BRIN
}
}
-/* used for mouse selection and for SEQUENCER_OT_select_active_side() */
+/* Used for mouse selection in SEQUENCER_OT_select. */
static void select_active_side(ListBase *seqbase, int sel_side, int channel, int frame)
{
Sequence *seq;
@@ -110,7 +111,43 @@ static void select_active_side(ListBase *seqbase, int sel_side, int channel, int
}
}
-/* used for mouse selection and for SEQUENCER_OT_select_active_side() */
+/* Used for mouse selection in SEQUENCER_OT_select_side. */
+static void select_active_side_range(ListBase *seqbase,
+ const int sel_side,
+ const int frame_ranges[MAXSEQ],
+ const int frame_ignore)
+{
+ Sequence *seq;
+
+ for (seq = seqbase->first; seq; seq = seq->next) {
+ if (seq->machine < MAXSEQ) {
+ const int frame = frame_ranges[seq->machine];
+ if (frame == frame_ignore) {
+ continue;
+ }
+ switch (sel_side) {
+ case SEQ_SIDE_LEFT:
+ if (frame > (seq->startdisp)) {
+ seq->flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
+ seq->flag |= SELECT;
+ }
+ break;
+ case SEQ_SIDE_RIGHT:
+ if (frame < (seq->startdisp)) {
+ seq->flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
+ seq->flag |= SELECT;
+ }
+ break;
+ case SEQ_SIDE_BOTH:
+ seq->flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
+ seq->flag |= SELECT;
+ break;
+ }
+ }
+ }
+}
+
+/* used for mouse selection in SEQUENCER_OT_select */
static void select_linked_time(ListBase *seqbase, Sequence *seq_link)
{
Sequence *seq;
@@ -913,20 +950,39 @@ void SEQUENCER_OT_select_handles(wmOperatorType *ot)
}
/* select side operator */
-static int sequencer_select_active_side_exec(bContext *C, wmOperator *op)
+static int sequencer_select_side_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq_act = BKE_sequencer_active_get(scene);
- if (ed == NULL || seq_act == NULL) {
- return OPERATOR_CANCELLED;
+ const int sel_side = RNA_enum_get(op->ptr, "side");
+ const int frame_init = sel_side == SEQ_SIDE_LEFT ? INT_MIN : INT_MAX;
+ int frame_ranges[MAXSEQ];
+ bool selected = false;
+
+ copy_vn_i(frame_ranges, ARRAY_SIZE(frame_ranges), frame_init);
+
+ for (Sequence *seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if (UNLIKELY(seq->machine >= MAXSEQ)) {
+ continue;
+ }
+ int *frame_limit_p = &frame_ranges[seq->machine];
+ if (seq->flag & SELECT) {
+ selected = true;
+ if (sel_side == SEQ_SIDE_LEFT) {
+ *frame_limit_p = max_ii(*frame_limit_p, seq->startdisp);
+ }
+ else {
+ *frame_limit_p = min_ii(*frame_limit_p, seq->startdisp);
+ }
+ }
}
- seq_act->flag |= SELECT;
+ if (selected == false) {
+ return OPERATOR_CANCELLED;
+ }
- select_active_side(
- ed->seqbasep, RNA_enum_get(op->ptr, "side"), seq_act->machine, seq_act->startdisp);
+ select_active_side_range(ed->seqbasep, sel_side, frame_ranges, frame_init);
ED_outliner_select_sync_from_sequence_tag(C);
@@ -935,15 +991,15 @@ static int sequencer_select_active_side_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-void SEQUENCER_OT_select_active_side(wmOperatorType *ot)
+void SEQUENCER_OT_select_side(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Select Active Side";
- ot->idname = "SEQUENCER_OT_select_active_side";
- ot->description = "Select strips on the nominated side of the active strip";
+ ot->name = "Select Side";
+ ot->idname = "SEQUENCER_OT_select_side";
+ ot->description = "Select strips on the nominated side of the selected strips";
/* api callbacks */
- ot->exec = sequencer_select_active_side_exec;
+ ot->exec = sequencer_select_side_exec;
ot->poll = sequencer_edit_poll;
/* flags */
@@ -955,7 +1011,7 @@ void SEQUENCER_OT_select_active_side(wmOperatorType *ot)
prop_side_types,
SEQ_SIDE_BOTH,
"Side",
- "The side of the handle that is selected");
+ "The side to which the selection is applied");
}
/* box_select operator */
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index aafd36a5bb8..3ee9755cb06 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -1422,18 +1422,24 @@ static void draw_grid_unit_name(
{
if (!rv3d->is_persp && RV3D_VIEW_IS_AXIS(rv3d->view)) {
const char *grid_unit = NULL;
+ int font_id = BLF_default();
ED_view3d_grid_view_scale(scene, v3d, rv3d, &grid_unit);
if (grid_unit) {
char numstr[32] = "";
- UI_FontThemeColor(BLF_default(), TH_TEXT_HI);
+ UI_FontThemeColor(font_id, TH_TEXT_HI);
if (v3d->grid != 1.0f) {
BLI_snprintf(numstr, sizeof(numstr), "%s x %.4g", grid_unit, v3d->grid);
}
*yoffset -= U.widget_unit;
+ BLF_enable(font_id, BLF_SHADOW);
+ BLF_shadow(font_id, 5, (const float[4]){0.0f, 0.0f, 0.0f, 1.0f});
+ BLF_shadow_offset(font_id, 1, -1);
BLF_draw_default_ascii(
xoffset, *yoffset, 0.0f, numstr[0] ? numstr : grid_unit, sizeof(numstr));
+
+ BLF_disable(font_id, BLF_SHADOW);
}
}
}
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index d7af307bc53..c64ace77a79 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -1254,6 +1254,9 @@ static bool view3d_localview_init(const Depsgraph *depsgraph,
else {
Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
if (obedit) {
+ for (base = FIRSTBASE(view_layer); base; base = base->next) {
+ base->local_view_bits &= ~local_view_bit;
+ }
FOREACH_BASE_IN_EDIT_MODE_BEGIN (view_layer, v3d, base_iter) {
BKE_object_minmax(base_iter->object, min, max, false);
base_iter->local_view_bits |= local_view_bit;
@@ -1268,6 +1271,9 @@ static bool view3d_localview_init(const Depsgraph *depsgraph,
base->local_view_bits |= local_view_bit;
ok = true;
}
+ else {
+ base->local_view_bits &= ~local_view_bit;
+ }
}
}
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index a66e76abc58..15208c1a7d2 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -379,6 +379,8 @@ void applyProject(TransInfo *t)
.snap_select = t->tsnap.modeSelect,
.use_object_edit_cage = (t->flag & T_EDIT) != 0,
.use_occlusion_test = false,
+ .use_backface_culling = (t->scene->toolsettings->snap_flag &
+ SCE_SNAP_BACKFACE_CULLING) != 0,
},
mval_fl,
NULL,
@@ -1364,6 +1366,8 @@ short snapObjectsTransform(
.snap_select = t->tsnap.modeSelect,
.use_object_edit_cage = (t->flag & T_EDIT) != 0,
.use_occlusion_test = t->scene->toolsettings->snap_mode != SCE_SNAP_MODE_FACE,
+ .use_backface_culling = (t->scene->toolsettings->snap_flag &
+ SCE_SNAP_BACKFACE_CULLING) != 0,
},
mval,
t->tsnap.snapTarget,
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index f35a2808f22..14e8b8f97e0 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -201,8 +201,12 @@ static SnapObjectData_EditMesh *snap_object_data_editmesh_get(SnapObjectContext
return *sod_p;
}
-typedef void (*IterSnapObjsCallback)(
- SnapObjectContext *sctx, bool is_obedit, Object *ob, float obmat[4][4], void *data);
+typedef void (*IterSnapObjsCallback)(SnapObjectContext *sctx,
+ bool is_obedit,
+ bool use_backface_culling,
+ Object *ob,
+ float obmat[4][4],
+ void *data);
/**
* Walks through all objects in the scene to create the list of objects to snap.
@@ -219,6 +223,7 @@ static void iter_snap_objects(SnapObjectContext *sctx,
const View3D *v3d = sctx->v3d_data.v3d;
const eSnapSelect snap_select = params->snap_select;
const bool use_object_edit_cage = params->use_object_edit_cage;
+ const bool use_backface_culling = params->use_backface_culling;
Base *base_act = view_layer->basact;
for (Base *base = view_layer->object_bases.first; base != NULL; base = base->next) {
@@ -250,12 +255,14 @@ static void iter_snap_objects(SnapObjectContext *sctx,
DupliObject *dupli_ob;
ListBase *lb = object_duplilist(sctx->depsgraph, sctx->scene, obj_eval);
for (dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next) {
- sob_callback(sctx, use_object_edit_cage, dupli_ob->ob, dupli_ob->mat, data);
+ sob_callback(
+ sctx, use_object_edit_cage, use_backface_culling, dupli_ob->ob, dupli_ob->mat, data);
}
free_object_duplilist(lb);
}
- sob_callback(sctx, use_object_edit_cage, obj_eval, obj_eval->obmat, data);
+ sob_callback(
+ sctx, use_object_edit_cage, use_backface_culling, obj_eval, obj_eval->obmat, data);
}
}
@@ -350,6 +357,70 @@ static void raycast_all_cb(void *userdata, int index, const BVHTreeRay *ray, BVH
}
}
+static bool raycast_tri_backface_culling_test(
+ const float dir[3], const float v0[3], const float v1[3], const float v2[3], float no[3])
+{
+ cross_tri_v3(no, v0, v1, v2);
+ return dot_v3v3(no, dir) < 0.0f;
+}
+
+/* Callback to raycast with backface culling (Mesh). */
+static void mesh_looptri_raycast_backface_culling_cb(void *userdata,
+ int index,
+ const BVHTreeRay *ray,
+ BVHTreeRayHit *hit)
+{
+ const BVHTreeFromMesh *data = (BVHTreeFromMesh *)userdata;
+ const MVert *vert = data->vert;
+ const MLoopTri *lt = &data->looptri[index];
+ const float *vtri_co[3] = {
+ vert[data->loop[lt->tri[0]].v].co,
+ vert[data->loop[lt->tri[1]].v].co,
+ vert[data->loop[lt->tri[2]].v].co,
+ };
+ float dist = bvhtree_ray_tri_intersection(ray, hit->dist, UNPACK3(vtri_co));
+
+ if (dist >= 0 && dist < hit->dist) {
+ float no[3];
+ if (raycast_tri_backface_culling_test(ray->direction, UNPACK3(vtri_co), no)) {
+ hit->index = index;
+ hit->dist = dist;
+ madd_v3_v3v3fl(hit->co, ray->origin, ray->direction, dist);
+ normalize_v3_v3(hit->no, no);
+ }
+ }
+}
+
+/* Callback to raycast with backface culling (EditMesh). */
+static void editmesh_looptri_raycast_backface_culling_cb(void *userdata,
+ int index,
+ const BVHTreeRay *ray,
+ BVHTreeRayHit *hit)
+{
+ const BVHTreeFromEditMesh *data = (BVHTreeFromEditMesh *)userdata;
+ BMEditMesh *em = data->em;
+ const BMLoop **ltri = (const BMLoop **)em->looptris[index];
+
+ const float *t0, *t1, *t2;
+ t0 = ltri[0]->v->co;
+ t1 = ltri[1]->v->co;
+ t2 = ltri[2]->v->co;
+
+ {
+ float dist = bvhtree_ray_tri_intersection(ray, hit->dist, t0, t1, t2);
+
+ if (dist >= 0 && dist < hit->dist) {
+ float no[3];
+ if (raycast_tri_backface_culling_test(ray->direction, t0, t1, t2, no)) {
+ hit->index = index;
+ hit->dist = dist;
+ madd_v3_v3v3fl(hit->co, ray->origin, ray->direction, dist);
+ normalize_v3_v3(hit->no, no);
+ }
+ }
+ }
+}
+
static bool raycastMesh(SnapObjectContext *sctx,
const float ray_start[3],
const float ray_dir[3],
@@ -358,6 +429,7 @@ static bool raycastMesh(SnapObjectContext *sctx,
const float obmat[4][4],
const unsigned int ob_index,
bool use_hide,
+ bool use_backface_culling,
/* read/write args */
float *ray_depth,
/* return args */
@@ -494,7 +566,8 @@ static bool raycastMesh(SnapObjectContext *sctx,
ray_normal_local,
0.0f,
&hit,
- treedata->raycast_callback,
+ use_backface_culling ? mesh_looptri_raycast_backface_culling_cb :
+ treedata->raycast_callback,
treedata) != -1) {
hit.dist += len_diff;
hit.dist /= local_scale;
@@ -530,6 +603,7 @@ static bool raycastEditMesh(SnapObjectContext *sctx,
BMEditMesh *em,
const float obmat[4][4],
const unsigned int ob_index,
+ bool use_backface_culling,
/* read/write args */
float *ray_depth,
/* return args */
@@ -670,7 +744,8 @@ static bool raycastEditMesh(SnapObjectContext *sctx,
ray_normal_local,
0.0f,
&hit,
- treedata->raycast_callback,
+ use_backface_culling ? editmesh_looptri_raycast_backface_culling_cb :
+ treedata->raycast_callback,
treedata) != -1) {
hit.dist += len_diff;
hit.dist /= local_scale;
@@ -715,6 +790,7 @@ static bool raycastObj(SnapObjectContext *sctx,
const unsigned int ob_index,
bool use_obedit,
bool use_occlusion_test,
+ bool use_backface_culling,
/* read/write args */
float *ray_depth,
/* return args */
@@ -753,6 +829,7 @@ static bool raycastObj(SnapObjectContext *sctx,
em,
obmat,
ob_index,
+ use_backface_culling,
ray_depth,
r_loc,
r_no,
@@ -773,6 +850,7 @@ static bool raycastObj(SnapObjectContext *sctx,
obmat,
ob_index,
use_hide,
+ use_backface_culling,
ray_depth,
r_loc,
r_no,
@@ -792,6 +870,7 @@ static bool raycastObj(SnapObjectContext *sctx,
obmat,
ob_index,
false,
+ use_backface_culling,
ray_depth,
r_loc,
r_no,
@@ -832,8 +911,12 @@ struct RaycastObjUserData {
bool ret;
};
-static void raycast_obj_cb(
- SnapObjectContext *sctx, bool use_obedit, Object *ob, float obmat[4][4], void *data)
+static void raycast_obj_cb(SnapObjectContext *sctx,
+ bool use_obedit,
+ bool use_backface_culling,
+ Object *ob,
+ float obmat[4][4],
+ void *data)
{
struct RaycastObjUserData *dt = data;
@@ -845,6 +928,7 @@ static void raycast_obj_cb(
dt->ob_index++,
use_obedit,
dt->use_occlusion_test,
+ use_backface_culling,
dt->ray_depth,
dt->r_loc,
dt->r_no,
@@ -1088,8 +1172,6 @@ typedef void (*Nearest2DGetTriEdgesCallback)(const int index, int e_index[3], vo
typedef void (*Nearest2DCopyVertNoCallback)(const int index, float r_no[3], void *data);
typedef struct Nearest2dUserData {
- bool is_persp;
-
void *userdata;
Nearest2DGetVertCoCallback get_vert_co;
Nearest2DGetEdgeVertsCallback get_edge_verts_index;
@@ -1097,6 +1179,8 @@ typedef struct Nearest2dUserData {
Nearest2DGetTriEdgesCallback get_tri_edges_index;
Nearest2DCopyVertNoCallback copy_vert_no;
+ bool is_persp;
+ bool use_backface_culling;
} Nearest2dUserData;
static void cb_snap_vert(void *userdata,
@@ -1181,6 +1265,20 @@ static void cb_snap_tri_edges(void *userdata,
{
struct Nearest2dUserData *data = userdata;
+ if (data->use_backface_culling) {
+ int vindex[3];
+ data->get_tri_verts_index(index, vindex, data->userdata);
+
+ const float *t0, *t1, *t2;
+ data->get_vert_co(vindex[0], &t0, data->userdata);
+ data->get_vert_co(vindex[1], &t1, data->userdata);
+ data->get_vert_co(vindex[2], &t2, data->userdata);
+ float dummy[3];
+ if (raycast_tri_backface_culling_test(precalc->ray_direction, t0, t1, t2, dummy)) {
+ return;
+ }
+ }
+
int eindex[3];
data->get_tri_edges_index(index, eindex, data->userdata);
for (int i = 3; i--;) {
@@ -1204,6 +1302,18 @@ static void cb_snap_tri_verts(void *userdata,
int vindex[3];
data->get_tri_verts_index(index, vindex, data->userdata);
+
+ if (data->use_backface_culling) {
+ const float *t0, *t1, *t2;
+ data->get_vert_co(vindex[0], &t0, data->userdata);
+ data->get_vert_co(vindex[1], &t1, data->userdata);
+ data->get_vert_co(vindex[2], &t2, data->userdata);
+ float dummy[3];
+ if (raycast_tri_backface_culling_test(precalc->ray_direction, t0, t1, t2, dummy)) {
+ return;
+ }
+ }
+
for (int i = 3; i--;) {
if (vindex[i] == nearest->index) {
continue;
@@ -1222,6 +1332,7 @@ static short snap_mesh_polygon(SnapObjectContext *sctx,
SnapData *snapdata,
Object *ob,
const float obmat[4][4],
+ bool use_backface_culling,
/* read/write args */
float *dist_px,
/* return args */
@@ -1246,6 +1357,7 @@ static short snap_mesh_polygon(SnapObjectContext *sctx,
Nearest2dUserData nearest2d = {
.is_persp = snapdata->view_proj == VIEW_PROJ_PERSP,
+ .use_backface_culling = use_backface_culling,
};
BVHTreeNearest nearest = {
@@ -1366,6 +1478,7 @@ static short snap_mesh_edge_verts_mixed(SnapObjectContext *sctx,
const float obmat[4][4],
float original_dist_px,
const float prev_co[3],
+ bool use_backface_culling,
/* read/write args */
float *dist_px,
/* return args */
@@ -1392,6 +1505,7 @@ static short snap_mesh_edge_verts_mixed(SnapObjectContext *sctx,
Nearest2dUserData nearest2d;
{
nearest2d.is_persp = snapdata->view_proj == VIEW_PROJ_PERSP;
+ nearest2d.use_backface_culling = use_backface_culling;
if (sod->type == SNAP_MESH) {
nearest2d.userdata = &((SnapObjectData_Mesh *)sod)->treedata;
nearest2d.get_vert_co = (Nearest2DGetVertCoCallback)cb_mvert_co_get;
@@ -1995,6 +2109,7 @@ static short snapMesh(SnapObjectContext *sctx,
Object *ob,
Mesh *me,
const float obmat[4][4],
+ bool use_backface_culling,
/* read/write args */
float *dist_px,
/* return args */
@@ -2107,13 +2222,14 @@ static short snapMesh(SnapObjectContext *sctx,
}
Nearest2dUserData nearest2d = {
- .is_persp = snapdata->view_proj == VIEW_PROJ_PERSP,
.userdata = treedata,
.get_vert_co = (Nearest2DGetVertCoCallback)cb_mvert_co_get,
.get_edge_verts_index = (Nearest2DGetEdgeVertsCallback)cb_medge_verts_get,
.get_tri_verts_index = (Nearest2DGetTriVertsCallback)cb_mlooptri_verts_get,
.get_tri_edges_index = (Nearest2DGetTriEdgesCallback)cb_mlooptri_edges_get,
.copy_vert_no = (Nearest2DCopyVertNoCallback)cb_mvert_no_copy,
+ .is_persp = snapdata->view_proj == VIEW_PROJ_PERSP,
+ .use_backface_culling = use_backface_culling,
};
BVHTreeNearest nearest = {
@@ -2233,6 +2349,7 @@ static short snapEditMesh(SnapObjectContext *sctx,
Object *ob,
BMEditMesh *em,
const float obmat[4][4],
+ bool use_backface_culling,
/* read/write args */
float *dist_px,
/* return args */
@@ -2346,11 +2463,12 @@ static short snapEditMesh(SnapObjectContext *sctx,
}
Nearest2dUserData nearest2d = {
- .is_persp = snapdata->view_proj == VIEW_PROJ_PERSP,
.userdata = em,
.get_vert_co = (Nearest2DGetVertCoCallback)cb_bvert_co_get,
.get_edge_verts_index = (Nearest2DGetEdgeVertsCallback)cb_bedge_verts_get,
.copy_vert_no = (Nearest2DCopyVertNoCallback)cb_bvert_no_copy,
+ .is_persp = snapdata->view_proj == VIEW_PROJ_PERSP,
+ .use_backface_culling = use_backface_culling,
};
BVHTreeNearest nearest = {
@@ -2436,6 +2554,7 @@ static short snapObject(SnapObjectContext *sctx,
Object *ob,
float obmat[4][4],
bool use_obedit,
+ bool use_backface_culling,
/* read/write args */
float *dist_px,
/* return args */
@@ -2453,7 +2572,8 @@ static short snapObject(SnapObjectContext *sctx,
if (BKE_object_is_in_editmode(ob)) {
BMEditMesh *em = BKE_editmesh_from_object(ob);
if (use_obedit) {
- retval = snapEditMesh(sctx, snapdata, ob, em, obmat, dist_px, r_loc, r_no, r_index);
+ retval = snapEditMesh(
+ sctx, snapdata, ob, em, obmat, use_backface_culling, dist_px, r_loc, r_no, r_index);
break;
}
else if (em->mesh_eval_final) {
@@ -2465,7 +2585,8 @@ static short snapObject(SnapObjectContext *sctx,
return 0;
}
- retval = snapMesh(sctx, snapdata, ob, me, obmat, dist_px, r_loc, r_no, r_index);
+ retval = snapMesh(
+ sctx, snapdata, ob, me, obmat, use_backface_culling, dist_px, r_loc, r_no, r_index);
break;
}
case OB_ARMATURE:
@@ -2477,8 +2598,16 @@ static short snapObject(SnapObjectContext *sctx,
case OB_SURF:
case OB_FONT: {
if (ob->runtime.mesh_eval) {
- retval |= snapMesh(
- sctx, snapdata, ob, ob->runtime.mesh_eval, obmat, dist_px, r_loc, r_no, r_index);
+ retval |= snapMesh(sctx,
+ snapdata,
+ ob,
+ ob->runtime.mesh_eval,
+ obmat,
+ use_backface_culling,
+ dist_px,
+ r_loc,
+ r_no,
+ r_index);
}
break;
}
@@ -2519,8 +2648,12 @@ struct SnapObjUserData {
short ret;
};
-static void sanp_obj_cb(
- SnapObjectContext *sctx, bool is_obedit, Object *ob, float obmat[4][4], void *data)
+static void sanp_obj_cb(SnapObjectContext *sctx,
+ bool is_obedit,
+ bool use_backface_culling,
+ Object *ob,
+ float obmat[4][4],
+ void *data)
{
struct SnapObjUserData *dt = data;
@@ -2529,6 +2662,7 @@ static void sanp_obj_cb(
ob,
obmat,
is_obedit,
+ use_backface_culling,
/* read/write args */
dt->dist_px,
/* return args */
@@ -2881,7 +3015,8 @@ static short transform_snap_context_project_view3d_mixed_impl(
new_clipplane[3] += 0.01f;
/* Try to snap only to the polygon. */
- elem_test = snap_mesh_polygon(sctx, &snapdata, ob, obmat, &dist_px_tmp, loc, no, &index);
+ elem_test = snap_mesh_polygon(
+ sctx, &snapdata, ob, obmat, params->use_backface_culling, &dist_px_tmp, loc, no, &index);
if (elem_test) {
elem = elem_test;
}
@@ -2904,8 +3039,17 @@ static short transform_snap_context_project_view3d_mixed_impl(
(snap_to_flag & (SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE_MIDPOINT |
SCE_SNAP_MODE_EDGE_PERPENDICULAR))) {
snapdata.snap_to_flag = snap_to_flag;
- elem = snap_mesh_edge_verts_mixed(
- sctx, &snapdata, ob, obmat, *dist_px, prev_co, &dist_px_tmp, loc, no, &index);
+ elem = snap_mesh_edge_verts_mixed(sctx,
+ &snapdata,
+ ob,
+ obmat,
+ *dist_px,
+ prev_co,
+ params->use_backface_culling,
+ &dist_px_tmp,
+ loc,
+ no,
+ &index);
}
if (elem & snap_to_flag) {