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:
authorJacques Lucke <jacques@blender.org>2020-04-06 13:04:40 +0300
committerJacques Lucke <jacques@blender.org>2020-04-06 13:04:40 +0300
commit2b1e84c0de47e9771ef0e4d51ced2123bc195864 (patch)
treee2fd38d8697ddb9f6944437affae59ee57de715d /source/blender/editors/gpencil
parent3fab8acfd8b4fab15b04c0b37a44070d00e3ff08 (diff)
parent2cc55bcdc24683210a42e784cdb4636187a48077 (diff)
Merge branch 'simulation-tree-arc' into embedded_simulation_node_tree
Diffstat (limited to 'source/blender/editors/gpencil')
-rw-r--r--source/blender/editors/gpencil/annotate_draw.c16
-rw-r--r--source/blender/editors/gpencil/annotate_paint.c59
-rw-r--r--source/blender/editors/gpencil/gpencil_armature.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_convert.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_data.c34
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c34
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c10
-rw-r--r--source/blender/editors/gpencil/gpencil_intern.h6
-rw-r--r--source/blender/editors/gpencil/gpencil_interpolate.c14
-rw-r--r--source/blender/editors/gpencil/gpencil_merge.c14
-rw-r--r--source/blender/editors/gpencil/gpencil_ops.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_ops_versioning.c10
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c55
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c8
-rw-r--r--source/blender/editors/gpencil/gpencil_sculpt_paint.c8
-rw-r--r--source/blender/editors/gpencil/gpencil_select.c12
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c73
-rw-r--r--source/blender/editors/gpencil/gpencil_uv.c12
18 files changed, 192 insertions, 185 deletions
diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c
index fc62defd757..26ba2661072 100644
--- a/source/blender/editors/gpencil/annotate_draw.c
+++ b/source/blender/editors/gpencil/annotate_draw.c
@@ -353,7 +353,7 @@ static void annotation_draw_stroke_2d(const bGPDspoint *points,
/* Tessellation code - draw stroke as series of connected quads
* (triangle strips in fact) with connection edges rotated to minimize shrinking artifacts,
- * and rounded endcaps.
+ * and rounded end-caps.
*/
{
const bGPDspoint *pt1, *pt2;
@@ -1013,7 +1013,7 @@ static void annotation_draw_data_all(Scene *scene,
void ED_annotation_draw_2dimage(const bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
@@ -1026,7 +1026,7 @@ void ED_annotation_draw_2dimage(const bContext *C)
}
/* calculate rect */
- switch (sa->spacetype) {
+ switch (area->spacetype) {
case SPACE_IMAGE: /* image */
case SPACE_CLIP: /* clip */
{
@@ -1075,7 +1075,7 @@ void ED_annotation_draw_2dimage(const bContext *C)
}
/* draw it! */
- annotation_draw_data_all(scene, gpd, offsx, offsy, sizex, sizey, CFRA, dflag, sa->spacetype);
+ annotation_draw_data_all(scene, gpd, offsx, offsy, sizex, sizey, CFRA, dflag, area->spacetype);
}
/**
@@ -1088,13 +1088,13 @@ void ED_annotation_draw_2dimage(const bContext *C)
void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d)
{
wmWindowManager *wm = CTX_wm_manager(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
int dflag = 0;
/* check that we have grease-pencil stuff to draw */
- if (sa == NULL) {
+ if (area == NULL) {
return;
}
bGPdata *gpd = ED_annotation_data_get_active(C);
@@ -1105,7 +1105,7 @@ void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d)
/* special hack for Image Editor */
/* FIXME: the opengl poly-strokes don't draw at right thickness when done this way,
* so disabled. */
- if (ELEM(sa->spacetype, SPACE_IMAGE, SPACE_CLIP)) {
+ if (ELEM(area->spacetype, SPACE_IMAGE, SPACE_CLIP)) {
dflag |= GP_DRAWDATA_IEDITHACK;
}
@@ -1118,7 +1118,7 @@ void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d)
}
annotation_draw_data_all(
- scene, gpd, 0, 0, region->winx, region->winy, CFRA, dflag, sa->spacetype);
+ scene, gpd, 0, 0, region->winx, region->winy, CFRA, dflag, area->spacetype);
/* draw status text (if in screen/pixel-space) */
if (!onlyv2d) {
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index 53ada341cc9..8d50e24b7f0 100644
--- a/source/blender/editors/gpencil/annotate_paint.c
+++ b/source/blender/editors/gpencil/annotate_paint.c
@@ -114,7 +114,7 @@ typedef struct tGPsdata {
/** window where painting originated. */
wmWindow *win;
/** area where painting originated. */
- ScrArea *sa;
+ ScrArea *area;
/** region where painting originated. */
ARegion *region;
/** needed for GP_STROKE_2DSPACE. */
@@ -521,7 +521,7 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
* so initialize depth buffer before converting coordinates
*/
if (gpencil_project_check(p)) {
- View3D *v3d = p->sa->spacedata.first;
+ View3D *v3d = p->area->spacedata.first;
view3d_region_operator_needs_opengl(p->win, p->region);
ED_view3d_autodist_init(p->depsgraph,
@@ -793,7 +793,7 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p,
const int x,
const int y)
{
- if ((p->sa->spacetype == SPACE_VIEW3D) && (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH)) {
+ if ((p->area->spacetype == SPACE_VIEW3D) && (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH)) {
RegionView3D *rv3d = p->region->regiondata;
const int mval_i[2] = {x, y};
float mval_3d[3];
@@ -920,9 +920,9 @@ static void gp_stroke_doeraser(tGPsdata *p)
rect.xmax = p->mval[0] + p->radius;
rect.ymax = p->mval[1] + p->radius;
- if (p->sa->spacetype == SPACE_VIEW3D) {
+ if (p->area->spacetype == SPACE_VIEW3D) {
if (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH) {
- View3D *v3d = p->sa->spacedata.first;
+ View3D *v3d = p->area->spacedata.first;
view3d_region_operator_needs_opengl(p->win, p->region);
ED_view3d_autodist_init(p->depsgraph, p->region, v3d, 0);
}
@@ -936,7 +936,7 @@ static void gp_stroke_doeraser(tGPsdata *p)
/* Not all strokes in the datablock may be valid in the current editor/context
* (e.g. 2D space strokes in the 3D view, if the same datablock is shared)
*/
- if (ED_gpencil_stroke_can_use_direct(p->sa, gps)) {
+ if (ED_gpencil_stroke_can_use_direct(p->area, gps)) {
gp_stroke_eraser_dostroke(p, gpf, gps, p->mval, p->radius, &rect);
}
}
@@ -997,7 +997,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
* - must verify that region data is 3D-view (and not something else)
*/
/* CAUTION: If this is the "toolbar", then this will change on the first stroke */
- p->sa = curarea;
+ p->area = curarea;
p->region = region;
p->align_flag = &ts->annotate_v3d_align;
@@ -1016,7 +1016,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
/* SpaceNode *snode = curarea->spacedata.first; */
/* set current area */
- p->sa = curarea;
+ p->area = curarea;
p->region = region;
p->v2d = &region->v2d;
p->align_flag = &ts->gpencil_v2d_align;
@@ -1026,7 +1026,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
SpaceSeq *sseq = curarea->spacedata.first;
/* set current area */
- p->sa = curarea;
+ p->area = curarea;
p->region = region;
p->v2d = &region->v2d;
p->align_flag = &ts->gpencil_seq_align;
@@ -1045,7 +1045,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
/* SpaceImage *sima = curarea->spacedata.first; */
/* set the current area */
- p->sa = curarea;
+ p->area = curarea;
p->region = region;
p->v2d = &region->v2d;
p->align_flag = &ts->gpencil_ima_align;
@@ -1061,7 +1061,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
}
/* set the current area */
- p->sa = curarea;
+ p->area = curarea;
p->region = region;
p->v2d = &region->v2d;
p->align_flag = &ts->gpencil_v2d_align;
@@ -1279,7 +1279,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
p->gpd->runtime.sbuffer_sflag |= GP_STROKE_ERASER;
/* check if we should respect depth while erasing */
- if (p->sa->spacetype == SPACE_VIEW3D) {
+ if (p->area->spacetype == SPACE_VIEW3D) {
if (p->gpl->flag & GP_LAYER_NO_XRAY) {
p->flags |= GP_PAINTFLAG_V3D_ERASER_DEPTH;
}
@@ -1289,7 +1289,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
/* disable eraser flags - so that we can switch modes during a session */
p->gpd->runtime.sbuffer_sflag &= ~GP_STROKE_ERASER;
- if (p->sa->spacetype == SPACE_VIEW3D) {
+ if (p->area->spacetype == SPACE_VIEW3D) {
if (p->gpl->flag & GP_LAYER_NO_XRAY) {
p->flags &= ~GP_PAINTFLAG_V3D_ERASER_DEPTH;
}
@@ -1302,8 +1302,8 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
/* when drawing in the camera view, in 2D space, set the subrect */
p->subrect = NULL;
if ((*p->align_flag & GP_PROJECT_VIEWSPACE) == 0) {
- if (p->sa->spacetype == SPACE_VIEW3D) {
- View3D *v3d = p->sa->spacedata.first;
+ if (p->area->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = p->area->spacedata.first;
RegionView3D *rv3d = p->region->regiondata;
/* for camera view set the subrect */
@@ -1320,7 +1320,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
p->gsc.gpd = p->gpd;
p->gsc.gpl = p->gpl;
- p->gsc.sa = p->sa;
+ p->gsc.area = p->area;
p->gsc.region = p->region;
p->gsc.v2d = p->v2d;
@@ -1331,7 +1331,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
/* check if points will need to be made in view-aligned space */
if (*p->align_flag & GP_PROJECT_VIEWSPACE) {
- switch (p->sa->spacetype) {
+ switch (p->area->spacetype) {
case SPACE_VIEW3D: {
p->gpd->runtime.sbuffer_sflag |= GP_STROKE_3DSPACE;
break;
@@ -1355,7 +1355,7 @@ static void gp_paint_strokeend(tGPsdata *p)
* the conversions will project the values correctly...
*/
if (gpencil_project_check(p)) {
- View3D *v3d = p->sa->spacedata.first;
+ View3D *v3d = p->area->spacedata.first;
/* need to restore the original projection settings before packing up */
view3d_region_operator_needs_opengl(p->win, p->region);
@@ -1931,10 +1931,10 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event
}
/* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */
-static bool gpencil_area_exists(bContext *C, ScrArea *sa_test)
+static bool gpencil_area_exists(bContext *C, ScrArea *area_test)
{
- bScreen *sc = CTX_wm_screen(C);
- return (BLI_findindex(&sc->areabase, sa_test) != -1);
+ bScreen *screen = CTX_wm_screen(C);
+ return (BLI_findindex(&screen->areabase, area_test) != -1);
}
static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op)
@@ -1944,7 +1944,7 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op)
/* we must check that we're still within the area that we're set up to work from
* otherwise we could crash (see bug #20586)
*/
- if (CTX_wm_area(C) != p->sa) {
+ if (CTX_wm_area(C) != p->area) {
printf("\t\t\tGP - wrong area execution abort!\n");
p->status = GP_STATUS_ERROR;
}
@@ -2168,18 +2168,19 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
*/
if ((p->region) && (p->region->regiontype == RGN_TYPE_TOOLS)) {
/* Change to whatever region is now under the mouse */
- ARegion *current_region = BKE_area_find_region_xy(p->sa, RGN_TYPE_ANY, event->x, event->y);
+ ARegion *current_region = BKE_area_find_region_xy(
+ p->area, RGN_TYPE_ANY, event->x, event->y);
if (G.debug & G_DEBUG) {
- printf("found alternative region %p (old was %p) - at %d %d (sa: %d %d -> %d %d)\n",
+ printf("found alternative region %p (old was %p) - at %d %d (area: %d %d -> %d %d)\n",
current_region,
p->region,
event->x,
event->y,
- p->sa->totrct.xmin,
- p->sa->totrct.ymin,
- p->sa->totrct.xmax,
- p->sa->totrct.ymax);
+ p->area->totrct.xmin,
+ p->area->totrct.ymin,
+ p->area->totrct.xmax,
+ p->area->totrct.ymax);
}
if (current_region) {
@@ -2314,7 +2315,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
/* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */
- if (0 == gpencil_area_exists(C, p->sa)) {
+ if (0 == gpencil_area_exists(C, p->area)) {
estate = OPERATOR_CANCELLED;
}
else {
diff --git a/source/blender/editors/gpencil/gpencil_armature.c b/source/blender/editors/gpencil/gpencil_armature.c
index 9566495715a..1528c448c0b 100644
--- a/source/blender/editors/gpencil/gpencil_armature.c
+++ b/source/blender/editors/gpencil/gpencil_armature.c
@@ -543,7 +543,7 @@ static bool gpencil_generate_weights_poll(bContext *C)
}
/* need some armature in the view layer */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (base->object->type == OB_ARMATURE) {
return true;
}
@@ -630,7 +630,7 @@ static const EnumPropertyItem *gpencil_armatures_enum_itemf(bContext *C,
RNA_enum_item_add(&item, &totitem, &item_tmp);
i++;
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
if (ob->type == OB_ARMATURE) {
item_tmp.identifier = item_tmp.name = ob->id.name + 2;
diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c
index 8470fcad9d7..28e632d2b82 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -1465,12 +1465,12 @@ static bool gp_convert_poll(bContext *C)
bGPdata *gpd = (bGPdata *)ob->data;
bGPDlayer *gpl = NULL;
bGPDframe *gpf = NULL;
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
/* only if the current view is 3D View, if there's valid data (i.e. at least one stroke!),
* and if we are not in edit mode!
*/
- return ((sa && sa->spacetype == SPACE_VIEW3D) && (gpl = BKE_gpencil_layer_active_get(gpd)) &&
+ return ((area && area->spacetype == SPACE_VIEW3D) && (gpl = BKE_gpencil_layer_active_get(gpd)) &&
(gpf = BKE_gpencil_layer_frame_get(gpl, CFRA, GP_GETFRAME_USE_PREV)) &&
(gpf->strokes.first) && (!GPENCIL_ANY_EDIT_MODE(gpd)));
}
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index 898facb86e8..1e49195140c 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -50,6 +50,7 @@
#include "DNA_space_types.h"
#include "DNA_view3d_types.h"
+#include "BKE_anim_data.h"
#include "BKE_animsys.h"
#include "BKE_brush.h"
#include "BKE_context.h"
@@ -240,10 +241,10 @@ static int gp_layer_add_exec(bContext *C, wmOperator *op)
if ((ob != NULL) && (ob->type == OB_GPENCIL)) {
gpd = (bGPdata *)ob->data;
bGPDlayer *gpl = BKE_gpencil_layer_addnew(gpd, DATA_("GP_Layer"), true);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
/* In dopesheet add a new frame. */
- if ((gpl != NULL) && (sa->spacetype == SPACE_ACTION)) {
+ if ((gpl != NULL) && (area->spacetype == SPACE_ACTION)) {
gpl->actframe = BKE_gpencil_layer_frame_get(gpl, CFRA, GP_GETFRAME_ADD_NEW);
}
}
@@ -331,6 +332,7 @@ static int gp_layer_remove_exec(bContext *C, wmOperator *op)
/* notifiers */
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
@@ -478,6 +480,7 @@ static int gp_layer_copy_exec(bContext *C, wmOperator *UNUSED(op))
/* notifiers */
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
@@ -519,7 +522,7 @@ static bool gp_layer_duplicate_object_poll(bContext *C)
}
/* check there are more grease pencil objects */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if ((base->object != ob) && (base->object->type == OB_GPENCIL)) {
return true;
}
@@ -568,7 +571,7 @@ static int gp_layer_duplicate_object_exec(bContext *C, wmOperator *op)
gpl_dst->opacity = gpl_src->opacity;
/* Create all frames. */
- for (bGPDframe *gpf_src = gpl_src->frames.first; gpf_src; gpf_src = gpf_src->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf_src, &gpl_src->frames) {
if ((mode == GP_LAYER_COPY_OBJECT_ACT_FRAME) && (gpf_src != gpl_src->actframe)) {
continue;
@@ -578,7 +581,7 @@ static int gp_layer_duplicate_object_exec(bContext *C, wmOperator *op)
bGPDframe *gpf_dst = BKE_gpencil_frame_addnew(gpl_dst, gpf_src->framenum);
/* Copy strokes. */
- for (bGPDstroke *gps_src = gpf_src->strokes.first; gps_src; gps_src = gps_src->next) {
+ LISTBASE_FOREACH (bGPDstroke *, gps_src, &gpf_src->strokes) {
/* Make copy of source stroke. */
bGPDstroke *gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true);
@@ -1181,12 +1184,12 @@ static int gp_merge_layer_exec(bContext *C, wmOperator *op)
/* Collect frames of gpl_current in hash table to avoid O(n^2) lookups */
GHash *gh_frames_cur = BLI_ghash_int_new_ex(__func__, 64);
- for (bGPDframe *gpf = gpl_current->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl_current->frames) {
BLI_ghash_insert(gh_frames_cur, POINTER_FROM_INT(gpf->framenum), gpf);
}
/* read all frames from next layer and add any missing in current layer */
- for (bGPDframe *gpf = gpl_next->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl_next->frames) {
/* try to find frame in current layer */
bGPDframe *frame = BLI_ghash_lookup(gh_frames_cur, POINTER_FROM_INT(gpf->framenum));
if (!frame) {
@@ -1228,6 +1231,7 @@ static int gp_merge_layer_exec(bContext *C, wmOperator *op)
/* notifiers */
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
@@ -1291,6 +1295,7 @@ static int gp_layer_change_exec(bContext *C, wmOperator *op)
/* updates */
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
@@ -1336,6 +1341,7 @@ static int gp_layer_active_exec(bContext *C, wmOperator *op)
/* updates */
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
@@ -1433,7 +1439,7 @@ static int gp_stroke_arrange_exec(bContext *C, wmOperator *op)
switch (direction) {
/* Bring to Front */
case GP_STROKE_MOVE_TOP:
- for (LinkData *link = selected.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &selected) {
gps = link->data;
BLI_remlink(&gpf->strokes, gps);
BLI_addtail(&gpf->strokes, gps);
@@ -1448,7 +1454,7 @@ static int gp_stroke_arrange_exec(bContext *C, wmOperator *op)
break;
/* Send Backward */
case GP_STROKE_MOVE_DOWN:
- for (LinkData *link = selected.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &selected) {
gps = link->data;
BLI_listbase_link_move(&gpf->strokes, gps, -1);
}
@@ -2523,7 +2529,7 @@ static void joined_gpencil_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data)
/* Fix driver targets */
if (fcu->driver) {
/* Fix driver references to invalid ID's */
- for (DriverVar *dvar = fcu->driver->variables.first; dvar; dvar = dvar->next) {
+ LISTBASE_FOREACH (DriverVar *, dvar, &fcu->driver->variables) {
/* Only change the used targets, since the others will need fixing manually anyway. */
DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) {
/* Change the ID's used. */
@@ -2614,7 +2620,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
bGPdata *gpd_src = ob_iter->data;
/* Apply all GP modifiers before */
- for (GpencilModifierData *md = ob_iter->greasepencil_modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (GpencilModifierData *, md, &ob_iter->greasepencil_modifiers) {
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifierType_getInfo(md->type);
if (mti->bakeModifier) {
mti->bakeModifier(bmain, depsgraph, md, ob_iter);
@@ -2623,7 +2629,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
/* copy vertex groups to the base one's */
int old_idx = 0;
- for (bDeformGroup *dg = ob_iter->defbase.first; dg; dg = dg->next) {
+ LISTBASE_FOREACH (bDeformGroup *, dg, &ob_iter->defbase) {
bDeformGroup *vgroup = MEM_dupallocN(dg);
int idx = BLI_listbase_count(&ob_active->defbase);
BKE_object_defgroup_unique_name(vgroup, ob_active);
@@ -2675,7 +2681,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
mul_m3_v3(imat, offset_global);
mul_v3_m3v3(offset_local, imat, offset_global);
- for (bGPDlayer *gpl_src = gpd_src->layers.first; gpl_src; gpl_src = gpl_src->next) {
+ LISTBASE_FOREACH (bGPDlayer *, gpl_src, &gpd_src->layers) {
bGPDlayer *gpl_new = BKE_gpencil_layer_duplicate(gpl_src);
float diff_mat[4][4];
float inverse_diff_mat[4][4];
@@ -2685,7 +2691,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
invert_m4_m4(inverse_diff_mat, diff_mat);
Material *ma_src = NULL;
- for (bGPDframe *gpf = gpl_new->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl_new->frames) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
/* Reassign material. Look old material and try to find in destination. */
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index dc7bbfb99fa..947da9e7877 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -1333,7 +1333,7 @@ static int gp_strokes_copy_exec(bContext *C, wmOperator *op)
if (gp_strokes_copypastebuf.first) {
gp_strokes_copypastebuf_colors = BLI_ghash_int_new("GPencil CopyBuf Colors");
GHash *ma_to_name = gp_strokes_copypastebuf_colors_material_to_name_create(bmain);
- for (bGPDstroke *gps = gp_strokes_copypastebuf.first; gps; gps = gps->next) {
+ LISTBASE_FOREACH (bGPDstroke *, gps, &gp_strokes_copypastebuf) {
if (ED_gpencil_stroke_can_use(C, gps)) {
Material *ma = BKE_object_material_get(ob, gps->mat_nr + 1);
/* Avoid default material. */
@@ -1379,8 +1379,8 @@ void GPENCIL_OT_copy(wmOperatorType *ot)
static bool gp_strokes_paste_poll(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
- if (!((sa != NULL) && (sa->spacetype == SPACE_VIEW3D))) {
+ ScrArea *area = CTX_wm_area(C);
+ if (!((area != NULL) && (area->spacetype == SPACE_VIEW3D))) {
return false;
}
/* 1) Must have GP datablock to paste to
@@ -1569,7 +1569,13 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator *op)
}
/* Try to get layer */
- target_layer = BLI_findlink(&gpd->layers, layer_num);
+ if (layer_num > -1) {
+ target_layer = BLI_findlink(&gpd->layers, layer_num);
+ }
+ else {
+ /* Create a new layer. */
+ target_layer = BKE_gpencil_layer_addnew(gpd, "GP_Layer", true);
+ }
if (target_layer == NULL) {
/* back autolock status */
@@ -1655,7 +1661,8 @@ void GPENCIL_OT_move_to_layer(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* GPencil layer to use. */
- ot->prop = RNA_def_int(ot->srna, "layer", 0, 0, INT_MAX, "Grease Pencil Layer", "", 0, INT_MAX);
+ ot->prop = RNA_def_int(
+ ot->srna, "layer", 0, -1, INT_MAX, "Grease Pencil Layer", "", -1, INT_MAX);
RNA_def_property_flag(ot->prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
@@ -2599,11 +2606,11 @@ void GPENCIL_OT_dissolve(wmOperatorType *ot)
*/
static bool gp_snap_poll(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
Object *ob = CTX_data_active_object(C);
return (ob != NULL) && (ob->type == OB_GPENCIL) &&
- ((sa != NULL) && (sa->spacetype == SPACE_VIEW3D));
+ ((area != NULL) && (area->spacetype == SPACE_VIEW3D));
}
/* --------------------------------- */
@@ -3233,9 +3240,9 @@ static void gpencil_stroke_join_strokes(bGPDstroke *gps_a,
}
/* define start and end points of each stroke */
- float sa[3], sb[3], ea[3], eb[3];
+ float area[3], sb[3], ea[3], eb[3];
pt = &gps_a->points[0];
- copy_v3_v3(sa, &pt->x);
+ copy_v3_v3(area, &pt->x);
pt = &gps_a->points[gps_a->totpoints - 1];
copy_v3_v3(ea, &pt->x);
@@ -4357,6 +4364,7 @@ static int gp_stroke_separate_exec(bContext *C, wmOperator *op)
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
@@ -4617,7 +4625,7 @@ static int gpencil_cutter_lasso_select(bContext *C,
void *user_data)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ToolSettings *ts = CTX_data_tool_settings(C);
const float scale = ts->gp_sculpt.isect_threshold;
@@ -4628,7 +4636,7 @@ static int gpencil_cutter_lasso_select(bContext *C,
bool changed = false;
/* sanity checks */
- if (sa == NULL) {
+ if (area == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active area");
return OPERATOR_CANCELLED;
}
@@ -4724,9 +4732,9 @@ static bool gpencil_cutter_poll(bContext *C)
static int gpencil_cutter_exec(bContext *C, wmOperator *op)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
/* sanity checks */
- if (sa == NULL) {
+ if (area == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active area");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index e56017d0bed..a3f6e10ccb0 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -92,7 +92,7 @@ typedef struct tGPDfill {
/** current active gp object */
struct Object *ob;
/** area where painting originated */
- struct ScrArea *sa;
+ struct ScrArea *area;
/** region where painting originated */
struct RegionView3D *rv3d;
/** view3 where painting originated */
@@ -1248,8 +1248,8 @@ static bool gpencil_fill_poll(bContext *C)
Object *obact = CTX_data_active_object(C);
if (ED_operator_regionactive(C)) {
- ScrArea *sa = CTX_wm_area(C);
- if (sa->spacetype == SPACE_VIEW3D) {
+ ScrArea *area = CTX_wm_area(C);
+ if (area->spacetype == SPACE_VIEW3D) {
if ((obact == NULL) || (obact->type != OB_GPENCIL) ||
(obact->mode != OB_MODE_PAINT_GPENCIL)) {
return false;
@@ -1283,10 +1283,10 @@ static tGPDfill *gp_session_init_fill(bContext *C, wmOperator *UNUSED(op))
tgpf->bmain = CTX_data_main(C);
tgpf->scene = CTX_data_scene(C);
tgpf->ob = CTX_data_active_object(C);
- tgpf->sa = CTX_wm_area(C);
+ tgpf->area = CTX_wm_area(C);
tgpf->region = CTX_wm_region(C);
tgpf->rv3d = tgpf->region->regiondata;
- tgpf->v3d = tgpf->sa->spacedata.first;
+ tgpf->v3d = tgpf->area->spacedata.first;
tgpf->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
tgpf->win = CTX_wm_window(C);
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index 61bca235d17..c5e5a0b79ef 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -116,7 +116,7 @@ typedef struct tGPDinterpolate {
/** current scene from context */
struct Scene *scene;
/** area where painting originated */
- struct ScrArea *sa;
+ struct ScrArea *area;
/** region where painting originated */
struct ARegion *region;
/** current GP datablock */
@@ -156,7 +156,7 @@ typedef struct tGPDprimitive {
/** current evaluated gp object */
struct Object *ob_eval;
/** area where painting originated */
- struct ScrArea *sa;
+ struct ScrArea *area;
/** region where painting originated */
struct RegionView3D *rv3d;
/** view3d where painting originated */
@@ -247,7 +247,7 @@ typedef struct GP_SpaceConversion {
struct bGPdata *gpd;
struct bGPDlayer *gpl;
- struct ScrArea *sa;
+ struct ScrArea *area;
struct ARegion *region;
struct View2D *v2d;
diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c
index fef88007542..e6661e886b1 100644
--- a/source/blender/editors/gpencil/gpencil_interpolate.c
+++ b/source/blender/editors/gpencil/gpencil_interpolate.c
@@ -86,8 +86,8 @@ static bool gpencil_view3d_poll(bContext *C)
bGPDlayer *gpl = CTX_data_active_gpencil_layer(C);
/* only 3D view */
- ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype != SPACE_VIEW3D) {
+ ScrArea *area = CTX_wm_area(C);
+ if (area && area->spacetype != SPACE_VIEW3D) {
return 0;
}
@@ -383,7 +383,7 @@ static void gpencil_interpolate_status_indicators(bContext *C, tGPDinterpolate *
(int)((p->init_factor + p->shift) * 100.0f));
}
- ED_area_status_text(p->sa, status_str);
+ ED_area_status_text(p->area, status_str);
ED_workspace_status_text(
C, TIP_("ESC/RMB to cancel, Enter/LMB to confirm, WHEEL/MOVE to adjust factor"));
}
@@ -410,7 +410,7 @@ static void gpencil_interpolate_exit(bContext *C, wmOperator *op)
/* don't assume that operator data exists at all */
if (tgpi) {
/* clear status message area */
- ED_area_status_text(tgpi->sa, NULL);
+ ED_area_status_text(tgpi->area, NULL);
ED_workspace_status_text(C, NULL);
/* Clear any temp stroke. */
@@ -445,7 +445,7 @@ static bool gp_interpolate_set_init_values(bContext *C, wmOperator *op, tGPDinte
/* set current scene and window */
tgpi->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
tgpi->scene = CTX_data_scene(C);
- tgpi->sa = CTX_wm_area(C);
+ tgpi->area = CTX_wm_area(C);
tgpi->region = CTX_wm_region(C);
tgpi->flag = ts->gp_interpolate.flag;
@@ -567,7 +567,7 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent
case EVT_PADENTER:
case EVT_RETKEY: {
/* return to normal cursor and header status */
- ED_area_status_text(tgpi->sa, NULL);
+ ED_area_status_text(tgpi->area, NULL);
ED_workspace_status_text(C, NULL);
WM_cursor_modal_restore(win);
@@ -602,7 +602,7 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent
case EVT_ESCKEY: /* cancel */
case RIGHTMOUSE: {
/* return to normal cursor and header status */
- ED_area_status_text(tgpi->sa, NULL);
+ ED_area_status_text(tgpi->area, NULL);
ED_workspace_status_text(C, NULL);
WM_cursor_modal_restore(win);
diff --git a/source/blender/editors/gpencil/gpencil_merge.c b/source/blender/editors/gpencil/gpencil_merge.c
index bd9daa83411..6a5c5f7eb07 100644
--- a/source/blender/editors/gpencil/gpencil_merge.c
+++ b/source/blender/editors/gpencil/gpencil_merge.c
@@ -132,18 +132,8 @@ static bGPDstroke *gpencil_prepare_stroke(bContext *C, wmOperator *op, int totpo
bGPDframe *gpf = BKE_gpencil_layer_frame_get(gpl, CFRA, add_frame_mode);
/* stroke */
- bGPDstroke *gps = MEM_callocN(sizeof(bGPDstroke), "gp_stroke");
- gps->totpoints = totpoints;
- gps->inittime = 0.0f;
- gps->thickness = brush->size;
- gps->hardeness = brush->gpencil_settings->hardeness;
- copy_v2_v2(gps->aspect_ratio, brush->gpencil_settings->aspect_ratio);
+ bGPDstroke *gps = BKE_gpencil_stroke_new(ob->actcol - 1, totpoints, brush->size);
gps->flag |= GP_STROKE_SELECT;
- gps->flag |= GP_STROKE_3DSPACE;
- gps->mat_nr = ob->actcol - 1;
-
- /* allocate memory for points */
- gps->points = MEM_callocN(sizeof(bGPDspoint) * totpoints, "gp_stroke_points");
if (cyclic) {
gps->flag |= GP_STROKE_CYCLIC;
@@ -529,6 +519,8 @@ static int gp_stroke_merge_exec(bContext *C, wmOperator *op)
gpencil_dissolve_points(C);
}
+ BKE_gpencil_stroke_geometry_update(gps);
+
/* free memory */
MEM_SAFE_FREE(original_array);
MEM_SAFE_FREE(sorted_array);
diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c
index 8b126912efc..0171a81f5eb 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -178,10 +178,10 @@ static bool gp_stroke_sculptmode_poll(bContext *C)
{
bGPdata *gpd = CTX_data_gpencil_data(C);
Object *ob = CTX_data_active_object(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
/* if not gpencil object and not view3d, need sculpt keys if edit mode */
- if (sa->spacetype != SPACE_VIEW3D) {
+ if (area->spacetype != SPACE_VIEW3D) {
return ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE));
}
else {
diff --git a/source/blender/editors/gpencil/gpencil_ops_versioning.c b/source/blender/editors/gpencil/gpencil_ops_versioning.c
index 96146c60acb..2dd98bb8df1 100644
--- a/source/blender/editors/gpencil/gpencil_ops_versioning.c
+++ b/source/blender/editors/gpencil/gpencil_ops_versioning.c
@@ -117,9 +117,8 @@ static int gpencil_convert_old_files_exec(bContext *C, wmOperator *op)
DEG_relations_tag_update(bmain); /* added object */
/* convert grease pencil palettes (version >= 2.78) to materials and weights */
- for (const bGPDpalette *palette = gpd->palettes.first; palette; palette = palette->next) {
- for (bGPDpalettecolor *palcolor = palette->colors.first; palcolor;
- palcolor = palcolor->next) {
+ LISTBASE_FOREACH (const bGPDpalette *, palette, &gpd->palettes) {
+ LISTBASE_FOREACH (bGPDpalettecolor *, palcolor, &palette->colors) {
/* create material slot */
Material *ma = BKE_gpencil_object_material_new(bmain, ob, palcolor->info, NULL);
@@ -168,9 +167,8 @@ static int gpencil_convert_old_files_exec(bContext *C, wmOperator *op)
}
if (is_annotation) {
- for (const bGPDpalette *palette = gpd->palettes.first; palette; palette = palette->next) {
- for (bGPDpalettecolor *palcolor = palette->colors.first; palcolor;
- palcolor = palcolor->next) {
+ LISTBASE_FOREACH (const bGPDpalette *, palette, &gpd->palettes) {
+ LISTBASE_FOREACH (bGPDpalettecolor *, palcolor, &palette->colors) {
/* fix layers */
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
/* unlock/unhide layer */
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 1a169f9ec89..40068b0fb85 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -156,7 +156,7 @@ typedef struct tGPsdata {
/** window where painting originated. */
wmWindow *win;
/** area where painting originated. */
- ScrArea *sa;
+ ScrArea *area;
/** region where painting originated. */
ARegion *region;
/** needed for GP_STROKE_2DSPACE. */
@@ -297,9 +297,9 @@ static void gp_session_validatebuffer(tGPsdata *p);
static bool gpencil_draw_poll(bContext *C)
{
if (ED_operator_regionactive(C)) {
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
/* 3D Viewport */
- if (sa->spacetype != SPACE_VIEW3D) {
+ if (area->spacetype != SPACE_VIEW3D) {
return false;
}
@@ -812,7 +812,7 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
pt->time = (float)(curtime - p->inittime);
/* point uv (only 3d view) */
- if ((p->sa->spacetype == SPACE_VIEW3D) && (gpd->runtime.sbuffer_used > 0)) {
+ if ((p->area->spacetype == SPACE_VIEW3D) && (gpd->runtime.sbuffer_used > 0)) {
tGPspoint *ptb = (tGPspoint *)gpd->runtime.sbuffer + gpd->runtime.sbuffer_used - 1;
bGPDspoint spt, spt2;
@@ -1242,7 +1242,7 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p,
gp_settings = eraser->gpencil_settings;
}
- if ((gp_settings != NULL) && (p->sa->spacetype == SPACE_VIEW3D) &&
+ if ((gp_settings != NULL) && (p->area->spacetype == SPACE_VIEW3D) &&
(gp_settings->flag & GP_BRUSH_OCCLUDE_ERASER)) {
RegionView3D *rv3d = p->region->regiondata;
bGPDlayer *gpl = p->gpl;
@@ -1593,9 +1593,9 @@ static void gp_stroke_doeraser(tGPsdata *p)
rect.xmax = p->mval[0] + calc_radius;
rect.ymax = p->mval[1] + calc_radius;
- if (p->sa->spacetype == SPACE_VIEW3D) {
+ if (p->area->spacetype == SPACE_VIEW3D) {
if ((gp_settings != NULL) && (gp_settings->flag & GP_BRUSH_OCCLUDE_ERASER)) {
- View3D *v3d = p->sa->spacedata.first;
+ View3D *v3d = p->area->spacedata.first;
view3d_region_operator_needs_opengl(p->win, p->region);
ED_view3d_autodist_init(p->depsgraph, p->region, v3d, 0);
}
@@ -1633,7 +1633,7 @@ static void gp_stroke_doeraser(tGPsdata *p)
/* Not all strokes in the datablock may be valid in the current editor/context
* (e.g. 2D space strokes in the 3D view, if the same datablock is shared)
*/
- if (ED_gpencil_stroke_can_use_direct(p->sa, gps)) {
+ if (ED_gpencil_stroke_can_use_direct(p->area, gps)) {
gp_stroke_eraser_dostroke(p, gpf, gps, p->mval, calc_radius, &rect);
}
}
@@ -1816,7 +1816,7 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
* - must verify that region data is 3D-view (and not something else)
*/
/* CAUTION: If this is the "toolbar", then this will change on the first stroke */
- p->sa = curarea;
+ p->area = curarea;
p->region = region;
p->align_flag = &ts->gpencil_v3d_align;
@@ -1831,7 +1831,7 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
}
if ((!obact) || (obact->type != OB_GPENCIL)) {
- View3D *v3d = p->sa->spacedata.first;
+ View3D *v3d = p->area->spacedata.first;
/* if active object doesn't exist or isn't a GP Object, create one */
const float *cur = p->scene->cursor.location;
@@ -2058,8 +2058,8 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
/* when drawing in the camera view, in 2D space, set the subrect */
p->subrect = NULL;
if ((*p->align_flag & GP_PROJECT_VIEWSPACE) == 0) {
- if (p->sa->spacetype == SPACE_VIEW3D) {
- View3D *v3d = p->sa->spacedata.first;
+ if (p->area->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = p->area->spacedata.first;
RegionView3D *rv3d = p->region->regiondata;
/* for camera view set the subrect */
@@ -2076,7 +2076,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
p->gsc.gpd = p->gpd;
p->gsc.gpl = p->gpl;
- p->gsc.sa = p->sa;
+ p->gsc.area = p->area;
p->gsc.region = p->region;
p->gsc.v2d = p->v2d;
@@ -2087,7 +2087,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
/* check if points will need to be made in view-aligned space */
if (*p->align_flag & GP_PROJECT_VIEWSPACE) {
- switch (p->sa->spacetype) {
+ switch (p->area->spacetype) {
case SPACE_VIEW3D: {
p->gpd->runtime.sbuffer_sflag |= GP_STROKE_3DSPACE;
break;
@@ -2112,7 +2112,7 @@ static void gp_paint_strokeend(tGPsdata *p)
* the conversions will project the values correctly...
*/
if (gpencil_project_check(p)) {
- View3D *v3d = p->sa->spacedata.first;
+ View3D *v3d = p->area->spacedata.first;
/* need to restore the original projection settings before packing up */
view3d_region_operator_needs_opengl(p->win, p->region);
@@ -2243,7 +2243,7 @@ static void gpencil_draw_exit(bContext *C, wmOperator *op)
}
/* restore cursor to indicate end of drawing */
- if (p->sa->spacetype != SPACE_VIEW3D) {
+ if (p->area->spacetype != SPACE_VIEW3D) {
WM_cursor_modal_restore(CTX_wm_window(C));
}
else {
@@ -3096,10 +3096,10 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event
}
/* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */
-static bool gpencil_area_exists(bContext *C, ScrArea *sa_test)
+static bool gpencil_area_exists(bContext *C, ScrArea *area_test)
{
- bScreen *sc = CTX_wm_screen(C);
- return (BLI_findindex(&sc->areabase, sa_test) != -1);
+ bScreen *screen = CTX_wm_screen(C);
+ return (BLI_findindex(&screen->areabase, area_test) != -1);
}
static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op)
@@ -3109,7 +3109,7 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op)
/* we must check that we're still within the area that we're set up to work from
* otherwise we could crash (see bug #20586)
*/
- if (CTX_wm_area(C) != p->sa) {
+ if (CTX_wm_area(C) != p->area) {
printf("\t\t\tGP - wrong area execution abort!\n");
p->status = GP_STATUS_ERROR;
}
@@ -3504,18 +3504,19 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
*/
if ((p->region) && (p->region->regiontype == RGN_TYPE_TOOLS)) {
/* Change to whatever region is now under the mouse */
- ARegion *current_region = BKE_area_find_region_xy(p->sa, RGN_TYPE_ANY, event->x, event->y);
+ ARegion *current_region = BKE_area_find_region_xy(
+ p->area, RGN_TYPE_ANY, event->x, event->y);
if (G.debug & G_DEBUG) {
- printf("found alternative region %p (old was %p) - at %d %d (sa: %d %d -> %d %d)\n",
+ printf("found alternative region %p (old was %p) - at %d %d (area: %d %d -> %d %d)\n",
current_region,
p->region,
event->x,
event->y,
- p->sa->totrct.xmin,
- p->sa->totrct.ymin,
- p->sa->totrct.xmax,
- p->sa->totrct.ymax);
+ p->area->totrct.xmin,
+ p->area->totrct.ymin,
+ p->area->totrct.xmax,
+ p->area->totrct.ymax);
}
if (current_region) {
@@ -3660,7 +3661,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
/* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */
- if (0 == gpencil_area_exists(C, p->sa)) {
+ if (0 == gpencil_area_exists(C, p->area)) {
estate = OPERATOR_CANCELLED;
}
else {
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index dfd11484d22..11aeeba5a24 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -240,8 +240,8 @@ static void gp_primitive_update_cps(tGPDprimitive *tgpi)
static bool gpencil_primitive_add_poll(bContext *C)
{
/* only 3D view */
- ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype != SPACE_VIEW3D) {
+ ScrArea *area = CTX_wm_area(C);
+ if (area && area->spacetype != SPACE_VIEW3D) {
return 0;
}
@@ -1137,10 +1137,10 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op)
tgpi->scene = scene;
tgpi->ob = CTX_data_active_object(C);
tgpi->ob_eval = (Object *)DEG_get_evaluated_object(tgpi->depsgraph, tgpi->ob);
- tgpi->sa = CTX_wm_area(C);
+ tgpi->area = CTX_wm_area(C);
tgpi->region = CTX_wm_region(C);
tgpi->rv3d = tgpi->region->regiondata;
- tgpi->v3d = tgpi->sa->spacedata.first;
+ tgpi->v3d = tgpi->area->spacedata.first;
tgpi->win = CTX_wm_window(C);
/* save original type */
diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
index 8f3fc5fa268..7b6054e4156 100644
--- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c
+++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
@@ -91,7 +91,7 @@ typedef struct tGP_BrushEditData {
Scene *scene;
Object *object;
- ScrArea *sa;
+ ScrArea *area;
ARegion *region;
/* Current GPencil datablock */
@@ -1181,7 +1181,7 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op)
gso->is_transformed = false;
}
- gso->sa = CTX_wm_area(C);
+ gso->area = CTX_wm_area(C);
gso->region = CTX_wm_region(C);
Paint *paint = &ts->gp_sculptpaint->paint;
@@ -1307,8 +1307,8 @@ static void gpsculpt_brush_exit(bContext *C, wmOperator *op)
/* poll callback for stroke sculpting operator(s) */
static bool gpsculpt_brush_poll(bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
- if (sa && sa->spacetype != SPACE_VIEW3D) {
+ ScrArea *area = CTX_wm_area(C);
+ if (area && area->spacetype != SPACE_VIEW3D) {
return false;
}
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index 97f0a578d9d..e25576f32aa 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -1015,7 +1015,7 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
const int mx = RNA_int_get(op->ptr, "x");
const int my = RNA_int_get(op->ptr, "y");
@@ -1028,7 +1028,7 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op)
bool changed = false;
/* sanity checks */
- if (sa == NULL) {
+ if (area == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active area");
return OPERATOR_CANCELLED;
}
@@ -1126,7 +1126,7 @@ static int gpencil_generic_select_exec(bContext *C,
Object *ob = CTX_data_active_object(C);
bGPdata *gpd = ED_gpencil_data_get_active(C);
ToolSettings *ts = CTX_data_tool_settings(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
int selectmode;
if (ob && ob->mode == OB_MODE_SCULPT_GPENCIL) {
@@ -1153,7 +1153,7 @@ static int gpencil_generic_select_exec(bContext *C,
bool changed = false;
/* sanity checks */
- if (sa == NULL) {
+ if (area == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active area");
return OPERATOR_CANCELLED;
}
@@ -1416,7 +1416,7 @@ static void deselect_all_selected(bContext *C)
static int gpencil_select_exec(bContext *C, wmOperator *op)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
Object *ob = CTX_data_active_object(C);
bGPdata *gpd = ED_gpencil_data_get_active(C);
ToolSettings *ts = CTX_data_tool_settings(C);
@@ -1444,7 +1444,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
int hit_distance = radius_squared;
/* sanity checks */
- if (sa == NULL) {
+ if (area == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active area");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 312cb1b50c0..3d571773bc8 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -93,13 +93,13 @@
* and an RNA-pointer to trace back to whatever owns it,
* when context info is not available.
*/
-bGPdata **ED_gpencil_data_get_pointers_direct(ScrArea *sa, Object *ob, PointerRNA *r_ptr)
+bGPdata **ED_gpencil_data_get_pointers_direct(ScrArea *area, Object *ob, PointerRNA *r_ptr)
{
/* if there's an active area, check if the particular editor may
* have defined any special Grease Pencil context for editing...
*/
- if (sa) {
- switch (sa->spacetype) {
+ if (area) {
+ switch (area->spacetype) {
case SPACE_PROPERTIES: /* properties */
case SPACE_INFO: /* header info */
case SPACE_TOPBAR: /* Topbar */
@@ -132,16 +132,16 @@ bGPdata **ED_gpencil_data_get_pointers_direct(ScrArea *sa, Object *ob, PointerRN
* when context info is not available.
*/
bGPdata **ED_annotation_data_get_pointers_direct(ID *screen_id,
- ScrArea *sa,
+ ScrArea *area,
Scene *scene,
PointerRNA *r_ptr)
{
/* If there's an active area, check if the particular editor may
* have defined any special Grease Pencil context for editing. */
- if (sa) {
- SpaceLink *sl = sa->spacedata.first;
+ if (area) {
+ SpaceLink *sl = area->spacedata.first;
- switch (sa->spacetype) {
+ switch (area->spacetype) {
case SPACE_PROPERTIES: /* properties */
case SPACE_INFO: /* header info */
{
@@ -236,10 +236,10 @@ bGPdata **ED_annotation_data_get_pointers_direct(ID *screen_id,
* and an RNA-pointer to trace back to whatever owns it. */
bGPdata **ED_gpencil_data_get_pointers(const bContext *C, PointerRNA *r_ptr)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
Object *ob = CTX_data_active_object(C);
- return ED_gpencil_data_get_pointers_direct(sa, ob, r_ptr);
+ return ED_gpencil_data_get_pointers_direct(area, ob, r_ptr);
}
/* Get pointer to active Grease Pencil datablock,
@@ -248,23 +248,23 @@ bGPdata **ED_annotation_data_get_pointers(const bContext *C, PointerRNA *r_ptr)
{
ID *screen_id = (ID *)CTX_wm_screen(C);
Scene *scene = CTX_data_scene(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
- return ED_annotation_data_get_pointers_direct(screen_id, sa, scene, r_ptr);
+ return ED_annotation_data_get_pointers_direct(screen_id, area, scene, r_ptr);
}
/* -------------------------------------------------------- */
/* Get the active Grease Pencil datablock, when context is not available */
-bGPdata *ED_gpencil_data_get_active_direct(ScrArea *sa, Object *ob)
+bGPdata *ED_gpencil_data_get_active_direct(ScrArea *area, Object *ob)
{
- bGPdata **gpd_ptr = ED_gpencil_data_get_pointers_direct(sa, ob, NULL);
+ bGPdata **gpd_ptr = ED_gpencil_data_get_pointers_direct(area, ob, NULL);
return (gpd_ptr) ? *(gpd_ptr) : NULL;
}
/* Get the active Grease Pencil datablock, when context is not available */
-bGPdata *ED_annotation_data_get_active_direct(ID *screen_id, ScrArea *sa, Scene *scene)
+bGPdata *ED_annotation_data_get_active_direct(ID *screen_id, ScrArea *area, Scene *scene)
{
- bGPdata **gpd_ptr = ED_annotation_data_get_pointers_direct(screen_id, sa, scene, NULL);
+ bGPdata **gpd_ptr = ED_annotation_data_get_pointers_direct(screen_id, area, scene, NULL);
return (gpd_ptr) ? *(gpd_ptr) : NULL;
}
@@ -299,13 +299,13 @@ bGPdata *ED_annotation_data_get_active(const bContext *C)
*/
bGPdata *ED_gpencil_data_get_active_evaluated(const bContext *C)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *ob = CTX_data_active_object(C);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
- return ED_gpencil_data_get_active_direct(sa, ob_eval);
+ return ED_gpencil_data_get_active_direct(area, ob_eval);
}
/* -------------------------------------------------------- */
@@ -513,25 +513,25 @@ bool gp_stroke_inside_circle(const float mval[2], int rad, int x0, int y0, int x
/* Check whether given stroke can be edited given the supplied context */
/* TODO: do we need additional flags for screenspace vs dataspace? */
-bool ED_gpencil_stroke_can_use_direct(const ScrArea *sa, const bGPDstroke *gps)
+bool ED_gpencil_stroke_can_use_direct(const ScrArea *area, const bGPDstroke *gps)
{
/* sanity check */
- if (ELEM(NULL, sa, gps)) {
+ if (ELEM(NULL, area, gps)) {
return false;
}
/* filter stroke types by flags + spacetype */
if (gps->flag & GP_STROKE_3DSPACE) {
/* 3D strokes - only in 3D view */
- return ((sa->spacetype == SPACE_VIEW3D) || (sa->spacetype == SPACE_PROPERTIES));
+ return ((area->spacetype == SPACE_VIEW3D) || (area->spacetype == SPACE_PROPERTIES));
}
else if (gps->flag & GP_STROKE_2DIMAGE) {
/* Special "image" strokes - only in Image Editor */
- return (sa->spacetype == SPACE_IMAGE);
+ return (area->spacetype == SPACE_IMAGE);
}
else if (gps->flag & GP_STROKE_2DSPACE) {
/* 2D strokes (dataspace) - for any 2D view (i.e. everything other than 3D view) */
- return (sa->spacetype != SPACE_VIEW3D);
+ return (area->spacetype != SPACE_VIEW3D);
}
else {
/* view aligned - anything goes */
@@ -542,8 +542,8 @@ bool ED_gpencil_stroke_can_use_direct(const ScrArea *sa, const bGPDstroke *gps)
/* Check whether given stroke can be edited in the current context */
bool ED_gpencil_stroke_can_use(const bContext *C, const bGPDstroke *gps)
{
- ScrArea *sa = CTX_wm_area(C);
- return ED_gpencil_stroke_can_use_direct(sa, gps);
+ ScrArea *area = CTX_wm_area(C);
+ return ED_gpencil_stroke_can_use_direct(area, gps);
}
/* Check whether given stroke can be edited for the current color */
@@ -574,7 +574,7 @@ bool ED_gpencil_stroke_color_use(Object *ob, const bGPDlayer *gpl, const bGPDstr
*/
void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc)
{
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
/* zero out the storage (just in case) */
@@ -585,12 +585,12 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc)
r_gsc->scene = CTX_data_scene(C);
r_gsc->ob = CTX_data_active_object(C);
- r_gsc->sa = sa;
+ r_gsc->area = area;
r_gsc->region = region;
r_gsc->v2d = &region->v2d;
/* init region-specific stuff */
- if (sa->spacetype == SPACE_VIEW3D) {
+ if (area->spacetype == SPACE_VIEW3D) {
wmWindow *win = CTX_wm_window(C);
Scene *scene = CTX_data_scene(C);
struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
@@ -685,8 +685,8 @@ void gp_point_to_xy(
int xyval[2];
/* sanity checks */
- BLI_assert(!(gps->flag & GP_STROKE_3DSPACE) || (gsc->sa->spacetype == SPACE_VIEW3D));
- BLI_assert(!(gps->flag & GP_STROKE_2DSPACE) || (gsc->sa->spacetype != SPACE_VIEW3D));
+ BLI_assert(!(gps->flag & GP_STROKE_3DSPACE) || (gsc->area->spacetype == SPACE_VIEW3D));
+ BLI_assert(!(gps->flag & GP_STROKE_2DSPACE) || (gsc->area->spacetype != SPACE_VIEW3D));
if (gps->flag & GP_STROKE_3DSPACE) {
if (ED_view3d_project_int_global(region, &pt->x, xyval, V3D_PROJ_TEST_NOP) ==
@@ -743,8 +743,8 @@ void gp_point_to_xy_fl(const GP_SpaceConversion *gsc,
float xyval[2];
/* sanity checks */
- BLI_assert(!(gps->flag & GP_STROKE_3DSPACE) || (gsc->sa->spacetype == SPACE_VIEW3D));
- BLI_assert(!(gps->flag & GP_STROKE_2DSPACE) || (gsc->sa->spacetype != SPACE_VIEW3D));
+ BLI_assert(!(gps->flag & GP_STROKE_3DSPACE) || (gsc->area->spacetype == SPACE_VIEW3D));
+ BLI_assert(!(gps->flag & GP_STROKE_2DSPACE) || (gsc->area->spacetype != SPACE_VIEW3D));
if (gps->flag & GP_STROKE_3DSPACE) {
if (ED_view3d_project_float_global(region, &pt->x, xyval, V3D_PROJ_TEST_NOP) ==
@@ -802,7 +802,7 @@ void gp_point_3d_to_xy(const GP_SpaceConversion *gsc,
float xyval[2];
/* sanity checks */
- BLI_assert((gsc->sa->spacetype == SPACE_VIEW3D));
+ BLI_assert((gsc->area->spacetype == SPACE_VIEW3D));
if (flag & GP_STROKE_3DSPACE) {
if (ED_view3d_project_float_global(region, pt, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
@@ -1563,7 +1563,7 @@ void ED_gpencil_vgroup_deselect(bContext *C, Object *ob)
static bool gp_check_cursor_region(bContext *C, int mval_i[2])
{
ARegion *region = CTX_wm_region(C);
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
Object *ob = CTX_data_active_object(C);
if ((ob == NULL) || (!ELEM(ob->mode,
@@ -1575,7 +1575,7 @@ static bool gp_check_cursor_region(bContext *C, int mval_i[2])
}
/* TODO: add more spacetypes */
- if (!ELEM(sa->spacetype, SPACE_VIEW3D)) {
+ if (!ELEM(area->spacetype, SPACE_VIEW3D)) {
return false;
}
if ((region) && (region->regiontype != RGN_TYPE_WINDOW)) {
@@ -2173,7 +2173,8 @@ int ED_gpencil_select_stroke_segment(bGPDlayer *gpl,
float f = 0.0f;
int i2 = 0;
- bGPDframe *gpf = gpl->actframe;
+ bGPDlayer *gpl_orig = (gpl->runtime.gpl_orig) ? gpl->runtime.gpl_orig : gpl;
+ bGPDframe *gpf = gpl_orig->actframe;
if (gpf == NULL) {
return 0;
}
@@ -2186,7 +2187,7 @@ int ED_gpencil_select_stroke_segment(bGPDlayer *gpl,
/* Save list of strokes to check */
int totstrokes = 0;
- for (bGPDstroke *gps_iter = gpf->strokes.first; gps_iter; gps_iter = gps_iter->next) {
+ LISTBASE_FOREACH (bGPDstroke *, gps_iter, &gpf->strokes) {
if (gps_iter->totpoints < 2) {
continue;
}
diff --git a/source/blender/editors/gpencil/gpencil_uv.c b/source/blender/editors/gpencil/gpencil_uv.c
index 5f15a6f5411..114d916d1e2 100644
--- a/source/blender/editors/gpencil/gpencil_uv.c
+++ b/source/blender/editors/gpencil/gpencil_uv.c
@@ -92,9 +92,9 @@ static void gpencil_uv_transform_update_header(wmOperator *op, bContext *C)
const char *str = TIP_("Confirm: Enter/LClick, Cancel: (Esc/RClick) %s");
char msg[UI_MAX_DRAW_STR];
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
- if (sa) {
+ if (area) {
char flts_str[NUM_STR_REP_LEN * 2];
switch (mode) {
case GP_UV_TRANSLATE: {
@@ -120,7 +120,7 @@ static void gpencil_uv_transform_update_header(wmOperator *op, bContext *C)
break;
}
BLI_snprintf(msg, sizeof(msg), str, flts_str, flts_str + NUM_STR_REP_LEN);
- ED_area_status_text(sa, msg);
+ ED_area_status_text(area, msg);
}
}
@@ -214,7 +214,7 @@ static bool gpencil_uv_transform_init(bContext *C, wmOperator *op, const bool is
static void gpencil_uv_transform_exit(bContext *C, wmOperator *op)
{
GpUvData *opdata;
- ScrArea *sa = CTX_wm_area(C);
+ ScrArea *area = CTX_wm_area(C);
opdata = op->customdata;
@@ -226,8 +226,8 @@ static void gpencil_uv_transform_exit(bContext *C, wmOperator *op)
WM_cursor_set(CTX_wm_window(C), WM_CURSOR_DEFAULT);
- if (sa) {
- ED_area_status_text(sa, NULL);
+ if (area) {
+ ED_area_status_text(area, NULL);
}
WM_main_add_notifier(NC_GEOM | ND_DATA, NULL);