Commit: d157584f5993fbee35f0f4acaa3b3507ab38ea55 Author: Antonioya Date: Sat Jul 28 16:29:49 2018 +0200 Branches: greasepencil-object https://developer.blender.org/rBd157584f5993fbee35f0f4acaa3b3507ab38ea55
Enable grid in different axis Before only Y axis was supported. =================================================================== M release/scripts/startup/bl_ui/space_view3d.py M source/blender/blenloader/intern/versioning_280.c M source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c M source/blender/editors/space_view3d/space_view3d.c M source/blender/makesdna/DNA_view3d_types.h M source/blender/makesrna/intern/rna_space.c =================================================================== diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 67260e42ec3..10c15b6e8ce 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -4736,7 +4736,9 @@ class VIEW3D_PT_overlay_gpencil_options(Panel): layout.prop(overlay, "use_gpencil_grid", text="Show Plane Grid") if overlay.use_gpencil_grid: layout.prop(overlay, "gpencil_grid_scale") - layout.prop(overlay, "gpencil_grid_lines") + row = layout.row() + row.prop(overlay, "gpencil_grid_lines") + row.prop(overlay, "gpencil_grid_axis") layout.prop(overlay, "use_gpencil_onion_skin", text="Onion Skin") diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 5a323d3c969..b7b549c96d7 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -992,6 +992,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) v3d->gpencil_grid_scale = 1.0f; // Scale v3d->gpencil_grid_lines = GP_DEFAULT_GRID_LINES; // NUmber of lines v3d->gpencil_paper_opacity = 0.5f; + v3d->gpencil_grid_axis = V3D_GP_GRID_AXIS_Y; } } } 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 cdb73c151a5..159ea4d2eb7 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c +++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c @@ -602,11 +602,31 @@ GPUBatch *DRW_gpencil_get_edlin_geom(bGPDstroke *gps, float alpha, short UNUSED( static void set_grid_point(GPUVertBuf *vbo, int idx, uchar col_grid[3], uint pos_id, uint color_id, - float x, float y, float z) + float v1, float v2, const int axis) { GPU_vertbuf_attr_set(vbo, color_id, idx, col_grid); - float pos[3] = { x, y, z }; + float pos[3]; + /* Set the grid in the selected axis (default is always Y axis) */ + if (axis & V3D_GP_GRID_AXIS_X) { + pos[0] = 0.0f; + pos[1] = v1; + pos[2] = v2; + } + else if (axis & V3D_GP_GRID_AXIS_Z) { + pos[0] = v1; + pos[1] = v2; + pos[2] = 0.0f; + } + else + { + pos[0] = v1; + pos[1] = 0.0f; + pos[2] = v2; + } + + + GPU_vertbuf_attr_set(vbo, pos_id, idx, pos); } @@ -629,6 +649,11 @@ GPUBatch *DRW_gpencil_get_grid(void) v3d->gpencil_grid_scale = 1.0f; } + if (v3d->gpencil_grid_axis == 0) { + v3d->gpencil_grid_axis |= V3D_GP_GRID_AXIS_Y; + } + + const int axis = v3d->gpencil_grid_axis; const char *grid_unit = NULL; const int gridlines = v3d->gpencil_grid_lines; const float grid_scale = v3d->gpencil_grid_scale * ED_scene_grid_scale(scene, &grid_unit); @@ -650,33 +675,33 @@ GPUBatch *DRW_gpencil_get_grid(void) for (int a = 1; a <= gridlines; a++) { const float line = a * grid_scale; - set_grid_point(vbo, idx, col_grid, pos_id, color_id, -grid, 0.0f, -line); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, -grid, -line, axis); idx++; - set_grid_point(vbo, idx, col_grid, pos_id, color_id, +grid, 0.0f, -line); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, +grid, -line, axis); idx++; - set_grid_point(vbo, idx, col_grid, pos_id, color_id, -grid, 0.0f, +line); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, -grid, +line, axis); idx++; - set_grid_point(vbo, idx, col_grid, pos_id, color_id, +grid, 0.0f, +line); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, +grid, +line, axis); idx++; - set_grid_point(vbo, idx, col_grid, pos_id, color_id, -line, 0.0f, -grid); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, -line, -grid, axis); idx++; - set_grid_point(vbo, idx, col_grid, pos_id, color_id, -line, 0.0f, +grid); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, -line, +grid, axis); idx++; - set_grid_point(vbo, idx, col_grid, pos_id, color_id, +line, 0.0f, -grid); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, +line, -grid, axis); idx++; - set_grid_point(vbo, idx, col_grid, pos_id, color_id, +line, 0.0f, +grid); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, +line, +grid, axis); idx++; } /* center lines */ - set_grid_point(vbo, idx, col_grid, pos_id, color_id, -grid, 0.0f, 0.0f); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, -grid, 0.0f, axis); idx++; - set_grid_point(vbo, idx, col_grid, pos_id, color_id, +grid, 0.0f, 0.0f); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, +grid, 0.0f, axis); idx++; - set_grid_point(vbo, idx, col_grid, pos_id, color_id, 0.0f, 0.0f, -grid); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, 0.0f, -grid, axis); idx++; - set_grid_point(vbo, idx, col_grid, pos_id, color_id, 0.0f, 0.0f, +grid); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, 0.0f, +grid, axis); idx++; return GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 19149270b7e..1fe3a39e49d 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -345,6 +345,7 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene) v3d->gpencil_grid_scale = 1.0; // Scales v3d->gpencil_grid_lines = GP_DEFAULT_GRID_LINES; // NUmber of Lines v3d->gpencil_paper_opacity = 0.5f; + v3d->gpencil_grid_axis = V3D_GP_GRID_AXIS_Y; v3d->bundle_size = 0.2f; v3d->bundle_drawtype = OB_PLAINAXES; diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 6980f5862ad..f2b3fec81e6 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -270,7 +270,7 @@ typedef struct View3D { float gpencil_grid_scale; float gpencil_paper_opacity; int gpencil_grid_lines; - char pad6[4]; + int gpencil_grid_axis; /* Stereoscopy settings */ short stereo3d_flag; @@ -491,4 +491,11 @@ enum { #define RV3D_CAMZOOM_MIN_FACTOR 0.1657359312880714853f #define RV3D_CAMZOOM_MAX_FACTOR 44.9852813742385702928f +/* View3d.gpencil_grid_axis */ +enum { + V3D_GP_GRID_AXIS_X = (1 << 1), + V3D_GP_GRID_AXIS_Y = (1 << 2), + V3D_GP_GRID_AXIS_Z = (1 << 3) +}; + #endif diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index d08b1bb8f50..51972374533 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -309,6 +309,13 @@ const EnumPropertyItem rna_enum_file_sort_items[] = { {0, NULL, 0, NULL, NULL} }; +static const EnumPropertyItem rna_enum_gpencil_grid_axis_items[] = { + {V3D_GP_GRID_AXIS_X, "X", 0, "X", ""}, + {V3D_GP_GRID_AXIS_Y, "Y", 0, "Y", ""}, + {V3D_GP_GRID_AXIS_Z, "Z", 0, "Z", ""}, + {0, NULL, 0, NULL, NULL} +}; + #ifdef RNA_RUNTIME #include "DNA_anim_types.h" @@ -2881,6 +2888,12 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Lines", "Number of lines"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "gpencil_grid_axis", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "gpencil_grid_axis"); + RNA_def_property_enum_items(prop, rna_enum_gpencil_grid_axis_items); + RNA_def_property_ui_text(prop, "Axis", "Axis to display grid"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + /* Paper opacity factor */ prop = RNA_def_property(srna, "gpencil_paper_opacity", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "gpencil_paper_opacity"); _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs