diff options
author | Joshua Leung <aligorith@gmail.com> | 2011-01-18 04:04:14 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2011-01-18 04:04:14 +0300 |
commit | e49df9e09fca37fc1c85392574f9b68c48e92e57 (patch) | |
tree | 060cb27b133840b4f67915df0728e1b21eb6696d /source/blender/editors/gpencil/gpencil_paint.c | |
parent | 86baf7c937c4bcac1c9ebf516e2aa2a79ec2f6fc (diff) |
Bugfix [#25684b] Surface and Stroke options are not working with Use
Sketching Sessions.
Fix for secondary issue noted in this bug report. Some of the code for
the fancy 3d view sketching options needed to be moved around so that
there is a clearer "paint/sketch session" and "stroke" separation
between various stages. There's still some more stuff that needs to be
done here before I think it's totally cleaned up.
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_paint.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_paint.c | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 3a82274e356..86f3e3c0b91 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -45,6 +45,7 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_gpencil_types.h" +#include "DNA_windowmanager_types.h" #include "UI_view2d.h" @@ -66,6 +67,8 @@ /* Temporary 'Stroke' Operation data */ typedef struct tGPsdata { Scene *scene; /* current scene from context */ + + wmWindow *win; /* window where painting originated */ ScrArea *sa; /* area where painting originated */ ARegion *ar; /* region where painting originated */ View2D *v2d; /* needed for GP_STROKE_2DSPACE */ @@ -888,8 +891,9 @@ static tGPsdata *gp_session_initpaint (bContext *C) /* create new context data */ p= MEM_callocN(sizeof(tGPsdata), "GPencil Drawing Data"); - /* pass on current scene */ + /* pass on current scene and window */ p->scene= CTX_data_scene(C); + p->win= CTX_wm_window(C); switch (curarea->spacetype) { /* supported views first */ @@ -910,12 +914,6 @@ static tGPsdata *gp_session_initpaint (bContext *C) printf("Error: 3D-View active region doesn't have any region data, so cannot be drawable \n"); return p; } - - /* for camera view set the subrect */ - if(rv3d->persp == RV3D_CAMOB) { - view3d_calc_camera_border(p->scene, p->ar, NULL, v3d, &p->subrect_data, -1); /* negative shift */ - p->subrect= &p->subrect_data; - } #if 0 // XXX will this sort of antiquated stuff be restored? /* check that gpencil data is allowed to be drawn */ @@ -1097,9 +1095,17 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) switch (p->sa->spacetype) { case SPACE_VIEW3D: { + View3D *v3d= p->sa->spacedata.first; RegionView3D *rv3d= p->ar->regiondata; float rvec[3]; + /* for camera view set the subrect */ + if (rv3d->persp == RV3D_CAMOB) { + view3d_calc_camera_border(p->scene, p->ar, NULL, v3d, &p->subrect_data, -1); /* negative shift */ + p->subrect= &p->subrect_data; + } + + /* get reference point for 3d space placement */ gp_get_3d_reference(p, rvec); initgrabz(rv3d, rvec[0], rvec[1], rvec[2]); @@ -1172,6 +1178,17 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) /* finish off a stroke (clears buffer, but doesn't finish the paint operation) */ static void gp_paint_strokeend (tGPsdata *p) { + /* for surface sketching, need to set the right OpenGL context stuff so that + * the conversions will project the values correctly... + */ + if (gpencil_project_check(p)) { + View3D *v3d= p->sa->spacedata.first; + + /* need to restore the original projection settings before packing up */ + view3d_region_operator_needs_opengl(p->win, p->ar); + view_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1:0); + } + /* check if doing eraser or not */ if ((p->gpd->sbuffer_sflag & GP_STROKE_ERASER) == 0) { /* smooth stroke before transferring? */ @@ -1247,14 +1264,6 @@ static void gpencil_draw_exit (bContext *C, wmOperator *op) } /* cleanup */ - if (gpencil_project_check(p)) { - View3D *v3d= p->sa->spacedata.first; - - /* need to restore the original projection settings before packing up */ - view3d_operator_needs_opengl(C); - view_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1:0); - } - gp_paint_cleanup(p); gp_session_cleanup(p); @@ -1573,7 +1582,7 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) if (GPENCIL_SKETCH_SESSIONS_ON(p->scene)) { /* end stroke only, and then wait to resume painting soon */ //printf("\t\tGP - end stroke only\n"); - gp_paint_strokeend(p); + gp_paint_cleanup(p); p->status= GP_STATUS_IDLING; /* we've just entered idling state, so this event was processed (but no others yet) */ |