Overlay Engine: Option to Disable AA Ortho Grid

When in Axis alligned orthographic view a grid was always displayed.
With this change the user can enable/disable this grid.

The Grid is always visible and editable, but only rendered active when user is in quad view, or axis aligned ortho view.

Reviewers: brecht, fclem

Maniphest Tasks: T63517

Differential Revision: https://developer.blender.org/D4699
This commit is contained in:
Jeroen Bakker 2019-04-17 11:35:20 +02:00
parent f7a28f0e11
commit 63bae864f4
6 changed files with 46 additions and 12 deletions

@ -4836,15 +4836,19 @@ class VIEW3D_PT_overlay_guides(Panel):
split = col.split()
sub = split.column()
sub.prop(overlay, "show_floor", text="Grid")
if overlay.show_floor:
sub = col.column(align=True)
sub.active = bool(overlay.show_floor or view.region_quadviews or not view.region_3d.is_perspective)
subsub = sub.row(align=True)
subsub.active = overlay.show_floor
subsub.prop(overlay, "grid_scale", text="Scale")
subsub.prop(overlay, "grid_subdivisions", text="Subdivisions")
row = sub.row()
row_el = row.column()
row_el.prop(overlay, "show_ortho_grid", text="Grid")
grid_active = view.region_quadviews or (view.region_3d.is_orthographic_side_view and not view.region_3d.is_perspective)
row_el.active = grid_active
row.prop(overlay, "show_floor", text="Floor")
if overlay.show_floor or overlay.show_ortho_grid:
sub = col.row(align=True)
sub.active = (overlay.show_floor and not view.region_3d.is_orthographic_side_view) or (overlay.show_ortho_grid and grid_active)
sub.prop(overlay, "grid_scale", text="Scale")
sub.prop(overlay, "grid_subdivisions", text="Subdivisions")
sub = split.column()
row = sub.row()

@ -3116,6 +3116,18 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
/* enable the axis aligned ortho grid by default */
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *area = screen->areabase.first; area; area = area->next) {
for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->gridflag |= V3D_SHOW_ORTHO_GRID;
}
}
}
}
}
{

@ -511,6 +511,7 @@ static void OBJECT_engine_init(void *vedata)
const bool show_axis_y = (v3d->gridflag & V3D_SHOW_Y) != 0;
const bool show_axis_z = (v3d->gridflag & V3D_SHOW_Z) != 0;
const bool show_floor = (v3d->gridflag & V3D_SHOW_FLOOR) != 0;
const bool show_ortho_grid = (v3d->gridflag & V3D_SHOW_ORTHO_GRID) != 0;
e_data.draw_grid = show_axis_x || show_axis_y || show_axis_z || show_floor;
DRW_viewport_matrix_get(winmat, DRW_MAT_WIN);
@ -559,15 +560,15 @@ static void OBJECT_engine_init(void *vedata)
grid_res = viewdist / grid_scale;
if (ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT)) {
e_data.draw_grid = true;
e_data.draw_grid = show_ortho_grid;
e_data.grid_flag = PLANE_YZ | SHOW_AXIS_Y | SHOW_AXIS_Z | SHOW_GRID | GRID_BACK;
}
else if (ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) {
e_data.draw_grid = true;
e_data.draw_grid = show_ortho_grid;
e_data.grid_flag = PLANE_XY | SHOW_AXIS_X | SHOW_AXIS_Y | SHOW_GRID | GRID_BACK;
}
else if (ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK)) {
e_data.draw_grid = true;
e_data.draw_grid = show_ortho_grid;
e_data.grid_flag = PLANE_XZ | SHOW_AXIS_X | SHOW_AXIS_Z | SHOW_GRID | GRID_BACK;
}
else { /* RV3D_VIEW_USER */

@ -337,7 +337,7 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene)
V3D_OVERLAY_EDIT_CREASES | V3D_OVERLAY_EDIT_BWEIGHTS |
V3D_OVERLAY_EDIT_CU_HANDLES | V3D_OVERLAY_EDIT_CU_NORMALS;
v3d->gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR;
v3d->gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR | V3D_SHOW_ORTHO_GRID;
v3d->flag = V3D_SELECT_OUTLINE;
v3d->flag2 = V3D_SHOW_RECONSTRUCTION | V3D_SHOW_ANNOTATION;

@ -525,6 +525,7 @@ enum {
#define V3D_SHOW_X (1 << 1)
#define V3D_SHOW_Y (1 << 2)
#define V3D_SHOW_Z (1 << 3)
#define V3D_SHOW_ORTHO_GRID (1 << 4)
/** #TransformOrientationSlot.type */
enum {

@ -747,6 +747,12 @@ static void rna_RegionView3D_view_matrix_set(PointerRNA *ptr, const float *value
ED_view3d_from_m4(mat, rv3d->ofs, rv3d->viewquat, &rv3d->dist);
}
static bool rna_RegionView3D_is_orthographic_side_view_get(PointerRNA *ptr)
{
RegionView3D *rv3d = (RegionView3D *)(ptr->data);
return RV3D_VIEW_IS_AXIS(rv3d->view);
}
static void rna_3DViewShading_type_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
ID *id = ptr->id.data;
@ -2931,6 +2937,11 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Show Overlays", "Display overlays like gizmos and outlines");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPencil_update");
prop = RNA_def_property(srna, "show_ortho_grid", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "gridflag", V3D_SHOW_ORTHO_GRID);
RNA_def_property_ui_text(prop, "Display Grid", "Show grid in othographic side view");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "show_floor", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "gridflag", V3D_SHOW_FLOOR);
RNA_def_property_ui_text(
@ -3777,6 +3788,11 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Is Perspective", "");
RNA_def_property_flag(prop, PROP_EDITABLE);
prop = RNA_def_property(srna, "is_orthographic_side_view", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "view", 0);
RNA_def_property_boolean_funcs(prop, "rna_RegionView3D_is_orthographic_side_view_get", NULL);
RNA_def_property_ui_text(prop, "Is Axis Aligned", "Is current view an orthographic side view");
/* This isn't directly accessible from the UI, only an operator. */
prop = RNA_def_property(srna, "use_clip_planes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "rflag", RV3D_CLIPPING);