diff options
Diffstat (limited to 'source/blender/draw/engines/gpencil')
3 files changed, 36 insertions, 10 deletions
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c index 1f3874e70ba..b72a6ebebbd 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c +++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c @@ -270,7 +270,7 @@ GPUBatch *DRW_gpencil_get_buffer_stroke_geom(bGPdata *gpd, short thickness) for (int i = 0; i < totpoints; i++, tpt++) { ED_gpencil_tpoint_to_point(ar, origin, tpt, &pt); - ED_gp_project_point_to_plane(ob, rv3d, origin, ts->gp_sculpt.lock_axis - 1, &pt); + ED_gp_project_point_to_plane(scene, ob, rv3d, origin, ts->gp_sculpt.lock_axis - 1, &pt); /* first point for adjacency (not drawn) */ if (i == 0) { @@ -361,7 +361,7 @@ GPUBatch *DRW_gpencil_get_buffer_point_geom(bGPdata *gpd, short thickness) for (int i = 0; i < totpoints; i++, tpt++) { ED_gpencil_tpoint_to_point(ar, origin, tpt, &pt); - ED_gp_project_point_to_plane(ob, rv3d, origin, ts->gp_sculpt.lock_axis - 1, &pt); + ED_gp_project_point_to_plane(scene, ob, rv3d, origin, ts->gp_sculpt.lock_axis - 1, &pt); /* set point */ gpencil_set_stroke_point( diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c index a50b4fac15c..2710ecc5e5b 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c +++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c @@ -506,7 +506,7 @@ DRWShadingGroup *DRW_gpencil_shgroup_stroke_create( DRW_shgroup_uniform_float(grp, "pixsize", stl->storage->pixsize, 1); /* avoid wrong values */ - if ((gpd) && (gpd->pixfactor == 0)) { + if ((gpd) && (gpd->pixfactor == 0.0f)) { gpd->pixfactor = GP_DEFAULT_PIX_FACTOR; } @@ -627,7 +627,7 @@ static DRWShadingGroup *DRW_gpencil_shgroup_point_create( DRW_shgroup_uniform_float(grp, "pixsize", stl->storage->pixsize, 1); /* avoid wrong values */ - if ((gpd) && (gpd->pixfactor == 0)) { + if ((gpd) && (gpd->pixfactor == 0.0f)) { gpd->pixfactor = GP_DEFAULT_PIX_FACTOR; } diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index 5f2652b0bfb..7fbae5e98ea 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -582,6 +582,7 @@ void GPENCIL_cache_populate(void *vedata, Object *ob) Scene *scene = draw_ctx->scene; ToolSettings *ts = scene->toolsettings; View3D *v3d = draw_ctx->v3d; + const View3DCursor *cursor = &scene->cursor; if (ob->type == OB_GPENCIL && ob->data) { bGPdata *gpd = (bGPdata *)ob->data; @@ -626,7 +627,9 @@ void GPENCIL_cache_populate(void *vedata, Object *ob) if ((v3d) && ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) && (v3d->gp_flag & V3D_GP_SHOW_GRID) && - (ob->type == OB_GPENCIL) && (ob == draw_ctx->obact)) + (ob->type == OB_GPENCIL) && (ob == draw_ctx->obact) && + ((ts->gpencil_v3d_align & GP_PROJECT_DEPTH_VIEW) == 0) && + ((ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) == 0)) { GPU_BATCH_DISCARD_SAFE(e_data.batch_grid); MEM_SAFE_FREE(e_data.batch_grid); @@ -634,13 +637,36 @@ void GPENCIL_cache_populate(void *vedata, Object *ob) e_data.batch_grid = DRW_gpencil_get_grid(ob); /* define grid orientation */ - if (ts->gp_sculpt.lock_axis != GP_LOCKAXIS_VIEW) { - copy_m4_m4(stl->storage->grid_matrix, ob->obmat); + switch (ts->gp_sculpt.lock_axis) { + case GP_LOCKAXIS_VIEW: + { + /* align always to view */ + invert_m4_m4(stl->storage->grid_matrix, draw_ctx->rv3d->viewmat); + /* copy ob location */ + copy_v3_v3(stl->storage->grid_matrix[3], ob->obmat[3]); + break; + } + case GP_LOCKAXIS_CURSOR: + { + float scale[3] = { 1.0f, 1.0f, 1.0f }; + loc_eul_size_to_mat4(stl->storage->grid_matrix, + cursor->location, + cursor->rotation_euler, + scale); + break; + } + default: + { + copy_m4_m4(stl->storage->grid_matrix, ob->obmat); + break; + } + } + + /* Move the origin to Object or Cursor */ + if (ts->gpencil_v3d_align & GP_PROJECT_CURSOR) { + copy_v3_v3(stl->storage->grid_matrix[3], cursor->location); } else { - /* align always to view */ - invert_m4_m4(stl->storage->grid_matrix, draw_ctx->rv3d->viewmat); - /* copy ob location */ copy_v3_v3(stl->storage->grid_matrix[3], ob->obmat[3]); } |