Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/overlay_grid.c
| Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | void OVERLAY_grid_init(OVERLAY_Data *vedata) | ||||
| const bool show_axis_x = (pd->v3d_gridflag & V3D_SHOW_X) != 0; | const bool show_axis_x = (pd->v3d_gridflag & V3D_SHOW_X) != 0; | ||||
| const bool show_axis_y = (pd->v3d_gridflag & V3D_SHOW_Y) != 0; | const bool show_axis_y = (pd->v3d_gridflag & V3D_SHOW_Y) != 0; | ||||
| const bool show_axis_z = (pd->v3d_gridflag & V3D_SHOW_Z) != 0; | const bool show_axis_z = (pd->v3d_gridflag & V3D_SHOW_Z) != 0; | ||||
| const bool show_floor = (pd->v3d_gridflag & V3D_SHOW_FLOOR) != 0; | const bool show_floor = (pd->v3d_gridflag & V3D_SHOW_FLOOR) != 0; | ||||
| const bool show_ortho_grid = (pd->v3d_gridflag & V3D_SHOW_ORTHO_GRID) != 0; | const bool show_ortho_grid = (pd->v3d_gridflag & V3D_SHOW_ORTHO_GRID) != 0; | ||||
| shd->grid_flag = 0; | shd->grid_flag = 0; | ||||
| if (pd->hide_overlays || !(show_axis_y || show_axis_z || show_floor || show_ortho_grid)) { | |||||
| return; | |||||
| } | |||||
| float viewinv[4][4], wininv[4][4]; | float viewinv[4][4], wininv[4][4]; | ||||
jbakker: This line is not clear and perhaps not complete or the issue is elsewhere. Think we should dive… | |||||
Done Inline ActionsOh right. The return statement is never being used.. ankitm: Oh right. The return statement is never being used..
Z axis is causing some trouble. Checking. | |||||
Done Inline ActionsAt this point I think checking for pd->v3d_gridflag == 0 is better and less error prone. fclem: At this point I think checking for `pd->v3d_gridflag == 0` is better and less error prone. | |||||
| float viewmat[4][4], winmat[4][4]; | float viewmat[4][4], winmat[4][4]; | ||||
| if (!pd->hide_overlays && | |||||
| (show_axis_x || show_axis_y || show_axis_z || show_floor || show_ortho_grid)) { | |||||
| DRW_view_winmat_get(NULL, winmat, false); | DRW_view_winmat_get(NULL, winmat, false); | ||||
| DRW_view_winmat_get(NULL, wininv, true); | DRW_view_winmat_get(NULL, wininv, true); | ||||
| DRW_view_viewmat_get(NULL, viewmat, false); | DRW_view_viewmat_get(NULL, viewmat, false); | ||||
| DRW_view_viewmat_get(NULL, viewinv, true); | DRW_view_viewmat_get(NULL, viewinv, true); | ||||
| /* if perps */ | /* if perps */ | ||||
| if (winmat[3][3] == 0.0f || rv3d->view == RV3D_VIEW_USER) { | if (winmat[3][3] == 0.0f || rv3d->view == RV3D_VIEW_USER) { | ||||
| if (show_axis_x) { | if (show_axis_x) { | ||||
| shd->grid_flag |= PLANE_XY | SHOW_AXIS_X; | shd->grid_flag |= PLANE_XY | SHOW_AXIS_X; | ||||
| } | } | ||||
| if (show_axis_y) { | if (show_axis_y) { | ||||
| shd->grid_flag |= PLANE_XY | SHOW_AXIS_Y; | shd->grid_flag |= PLANE_XY | SHOW_AXIS_Y; | ||||
| } | } | ||||
| if (show_floor) { | if (show_floor) { | ||||
| shd->grid_flag |= PLANE_XY | SHOW_GRID; | shd->grid_flag |= PLANE_XY | SHOW_GRID; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if (show_ortho_grid && ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT)) { | if (show_ortho_grid && ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT)) { | ||||
| shd->grid_flag = PLANE_YZ | SHOW_AXIS_Y | SHOW_AXIS_Z | SHOW_GRID | GRID_BACK; | shd->grid_flag = PLANE_YZ | SHOW_AXIS_Y | SHOW_AXIS_Z | SHOW_GRID | GRID_BACK; | ||||
| } | } | ||||
| else if (show_ortho_grid && ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) { | else if (show_ortho_grid && ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) { | ||||
| shd->grid_flag = PLANE_XY | SHOW_AXIS_X | SHOW_AXIS_Y | SHOW_GRID | GRID_BACK; | shd->grid_flag = PLANE_XY | SHOW_AXIS_X | SHOW_AXIS_Y | SHOW_GRID | GRID_BACK; | ||||
| } | } | ||||
| else if (show_ortho_grid && ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK)) { | else if (show_ortho_grid && ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK)) { | ||||
| shd->grid_flag = PLANE_XZ | SHOW_AXIS_X | SHOW_AXIS_Z | SHOW_GRID | GRID_BACK; | shd->grid_flag = PLANE_XZ | SHOW_AXIS_X | SHOW_AXIS_Z | SHOW_GRID | GRID_BACK; | ||||
| } | } | ||||
| } | } | ||||
| shd->grid_axes[0] = (float)((shd->grid_flag & (PLANE_XZ | PLANE_XY)) != 0); | shd->grid_axes[0] = (float)((shd->grid_flag & (PLANE_XZ | PLANE_XY)) != 0); | ||||
| shd->grid_axes[1] = (float)((shd->grid_flag & (PLANE_YZ | PLANE_XY)) != 0); | shd->grid_axes[1] = (float)((shd->grid_flag & (PLANE_YZ | PLANE_XY)) != 0); | ||||
| shd->grid_axes[2] = (float)((shd->grid_flag & (PLANE_YZ | PLANE_XZ)) != 0); | shd->grid_axes[2] = (float)((shd->grid_flag & (PLANE_YZ | PLANE_XZ)) != 0); | ||||
| } | |||||
| /* Z axis if needed */ | /* Z axis if needed */ | ||||
| if (((rv3d->view == RV3D_VIEW_USER) || (rv3d->persp != RV3D_ORTHO)) && show_axis_z) { | if (((rv3d->view == RV3D_VIEW_USER) || (rv3d->persp != RV3D_ORTHO)) && show_axis_z) { | ||||
| shd->zpos_flag = SHOW_AXIS_Z; | shd->zpos_flag = SHOW_AXIS_Z; | ||||
| float zvec[3], campos[3]; | float zvec[3], campos[3]; | ||||
| negate_v3_v3(zvec, viewinv[2]); | negate_v3_v3(zvec, viewinv[2]); | ||||
| copy_v3_v3(campos, viewinv[3]); | copy_v3_v3(campos, viewinv[3]); | ||||
| ▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines | |||||
This line is not clear and perhaps not complete or the issue is elsewhere. Think we should dive deeper in the issue.