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:
authorAntonio Vazquez <blendergit@gmail.com>2021-10-05 18:09:44 +0300
committerAntonio Vazquez <blendergit@gmail.com>2021-10-05 18:11:21 +0300
commit6eefcd7d78389fbcb92f6d482024224ceea5d1fa (patch)
treee0f2745d1374d0ff7681af9592d1863b3e92488b /source/blender/editors/gpencil/gpencil_paint.c
parent11be9edae263194d0ce4fa0d43ad44f04db9a491 (diff)
GPencil: Remove unused spacetype check in Paint operator
The Paint operator only works in SPACE_VIEW3D and this is checked in the poll mtehod, so it's not logic check again. These checkings were part of the old grease pencil but it was not removed.
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_paint.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c111
1 files changed, 41 insertions, 70 deletions
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index ffc50a86fc6..2aa4b3b3282 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -869,7 +869,7 @@ static short gpencil_stroke_addpoint(tGPsdata *p,
pt->time = (float)(curtime - p->inittime);
/* point uv (only 3d view) */
- if ((p->area->spacetype == SPACE_VIEW3D) && (gpd->runtime.sbuffer_used > 0)) {
+ if (gpd->runtime.sbuffer_used > 0) {
tGPspoint *ptb = (tGPspoint *)gpd->runtime.sbuffer + gpd->runtime.sbuffer_used - 1;
bGPDspoint spt, spt2;
@@ -1335,8 +1335,7 @@ static bool gpencil_stroke_eraser_is_occluded(
gp_settings = eraser->gpencil_settings;
}
- if ((gp_settings != NULL) && (p->area->spacetype == SPACE_VIEW3D) &&
- (gp_settings->flag & GP_BRUSH_OCCLUDE_ERASER)) {
+ if ((gp_settings != NULL) && (gp_settings->flag & GP_BRUSH_OCCLUDE_ERASER)) {
RegionView3D *rv3d = p->region->regiondata;
const int mval_i[2] = {x, y};
@@ -1729,12 +1728,10 @@ static void gpencil_stroke_doeraser(tGPsdata *p)
rect.xmax = p->mval[0] + calc_radius;
rect.ymax = p->mval[1] + calc_radius;
- if (p->area->spacetype == SPACE_VIEW3D) {
- if ((gp_settings != NULL) && (gp_settings->flag & GP_BRUSH_OCCLUDE_ERASER)) {
- View3D *v3d = p->area->spacedata.first;
- view3d_region_operator_needs_opengl(p->win, p->region);
- ED_view3d_depth_override(p->depsgraph, p->region, v3d, NULL, V3D_DEPTH_NO_GPENCIL, NULL);
- }
+ if ((gp_settings != NULL) && (gp_settings->flag & GP_BRUSH_OCCLUDE_ERASER)) {
+ View3D *v3d = p->area->spacedata.first;
+ view3d_region_operator_needs_opengl(p->win, p->region);
+ ED_view3d_depth_override(p->depsgraph, p->region, v3d, NULL, V3D_DEPTH_NO_GPENCIL, NULL);
}
/* loop over all layers too, since while it's easy to restrict editing to
@@ -1961,47 +1958,34 @@ static bool gpencil_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
unit_m4(p->imat);
unit_m4(p->mat);
- switch (curarea->spacetype) {
- /* supported views first */
- case SPACE_VIEW3D: {
- /* set current area
- * - 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->area = curarea;
- p->region = region;
- p->align_flag = &ts->gpencil_v3d_align;
-
- if (region->regiondata == NULL) {
- p->status = GP_STATUS_ERROR;
- return 0;
- }
-
- if ((!obact) || (obact->type != OB_GPENCIL)) {
- 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;
+ /* set current area
+ * - 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->area = curarea;
+ p->region = region;
+ p->align_flag = &ts->gpencil_v3d_align;
- ushort local_view_bits = 0;
- if (v3d->localvd) {
- local_view_bits = v3d->local_view_uuid;
- }
- /* create new default object */
- obact = ED_gpencil_add_object(C, cur, local_view_bits);
- }
- /* assign object after all checks to be sure we have one active */
- p->ob = obact;
- p->ob_eval = (Object *)DEG_get_evaluated_object(p->depsgraph, p->ob);
+ if (region->regiondata == NULL) {
+ p->status = GP_STATUS_ERROR;
+ return 0;
+ }
- break;
- }
+ if ((!obact) || (obact->type != OB_GPENCIL)) {
+ 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;
- /* unsupported views */
- default: {
- p->status = GP_STATUS_ERROR;
- return 0;
+ ushort local_view_bits = 0;
+ if (v3d->localvd) {
+ local_view_bits = v3d->local_view_uuid;
}
+ /* create new default object */
+ obact = ED_gpencil_add_object(C, cur, local_view_bits);
}
+ /* assign object after all checks to be sure we have one active */
+ p->ob = obact;
+ p->ob_eval = (Object *)DEG_get_evaluated_object(p->depsgraph, p->ob);
/* get gp-data */
gpd_ptr = ED_gpencil_data_get_pointers(C, &p->ownerPtr);
@@ -2238,17 +2222,15 @@ static void gpencil_paint_initstroke(tGPsdata *p,
/* 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->area->spacetype == SPACE_VIEW3D) {
- View3D *v3d = p->area->spacedata.first;
- RegionView3D *rv3d = p->region->regiondata;
+ View3D *v3d = p->area->spacedata.first;
+ RegionView3D *rv3d = p->region->regiondata;
- /* for camera view set the subrect */
- if (rv3d->persp == RV3D_CAMOB) {
- /* no shift */
- ED_view3d_calc_camera_border(
- p->scene, depsgraph, p->region, v3d, rv3d, &p->subrect_data, true);
- p->subrect = &p->subrect_data;
- }
+ /* for camera view set the subrect */
+ if (rv3d->persp == RV3D_CAMOB) {
+ /* no shift */
+ ED_view3d_calc_camera_border(
+ p->scene, depsgraph, p->region, v3d, rv3d, &p->subrect_data, true);
+ p->subrect = &p->subrect_data;
}
}
@@ -2267,12 +2249,7 @@ static void gpencil_paint_initstroke(tGPsdata *p,
/* check if points will need to be made in view-aligned space */
if (*p->align_flag & GP_PROJECT_VIEWSPACE) {
- switch (p->area->spacetype) {
- case SPACE_VIEW3D: {
- p->gpd->runtime.sbuffer_sflag |= GP_STROKE_3DSPACE;
- break;
- }
- }
+ p->gpd->runtime.sbuffer_sflag |= GP_STROKE_3DSPACE;
}
if (!changed) {
/* Copy the brush to avoid a full tag (very slow). */
@@ -2425,15 +2402,9 @@ static void gpencil_draw_exit(bContext *C, wmOperator *op)
p->eraser->size = p->radius;
}
- /* restore cursor to indicate end of drawing */
- if (p->area->spacetype != SPACE_VIEW3D) {
- WM_cursor_modal_restore(CTX_wm_window(C));
- }
- else {
- /* drawing batch cache is dirty now */
- bGPdata *gpd = CTX_data_gpencil_data(C);
- gpencil_update_cache(gpd);
- }
+ /* drawing batch cache is dirty now */
+ bGPdata *gpd = CTX_data_gpencil_data(C);
+ gpencil_update_cache(gpd);
/* clear undo stack */
gpencil_undo_finish();