Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormano-wii <germano.costa@ig.com.br>2019-08-20 14:56:48 +0300
committermano-wii <germano.costa@ig.com.br>2019-08-20 14:58:07 +0300
commit859f2561c858e5a5d809e42eff73f960ed1036ee (patch)
treeb6fef22620723a2fc32d46a0d6accc4c827709ca
parentf2cab8267f22293fc28de9a87f81b535b7955020 (diff)
Fix T61286: Viewport grid units not visible
The original code was commented on. Unlike blender 2.79, the grid units are now displayed only when RV3D_VIEW_IS_AXIS. The visible subdivisions in the grid are made by the GPU and depending on the pixel. The code used here only mimics this behavior and adds a bit of overhead. Reviewers: fclem, campbellbarton Subscribers: FloridaJo, zlsa, rl.amorato, EitanSomething Differential Revision: https://developer.blender.org/D4325
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c47
1 files changed, 34 insertions, 13 deletions
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 038d32c4d20..aa4b92062a3 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -920,12 +920,23 @@ float ED_view3d_grid_view_scale(Scene *scene,
float min_dist = 0.38f * (rv3d->dist / v3d->lens);
float grid_steps[8];
ED_view3d_grid_steps(scene, v3d, rv3d, grid_steps);
- for (int i = 0; i < ARRAY_SIZE(grid_steps); i++) {
+ int i;
+ for (i = 0; i < ARRAY_SIZE(grid_steps); i++) {
grid_scale = grid_steps[i];
if (grid_scale > min_dist) {
break;
}
}
+
+ if (grid_unit) {
+ const void *usys;
+ int len;
+ bUnit_GetSystem(scene->unit.system, B_UNIT_LENGTH, &usys, &len);
+
+ if (usys) {
+ *grid_unit = bUnit_GetNameDisplay(usys, len - i - 1);
+ }
+ }
}
else {
grid_scale = ED_view3d_grid_scale(scene, v3d, grid_unit);
@@ -1405,6 +1416,25 @@ static void draw_selected_name(
BLF_disable(font_id, BLF_SHADOW);
}
+static void draw_grid_unit_name(
+ Scene *scene, RegionView3D *rv3d, View3D *v3d, int xoffset, int *yoffset)
+{
+ if (!rv3d->is_persp && RV3D_VIEW_IS_AXIS(rv3d->view)) {
+ char numstr[32] = "";
+ const char *grid_unit;
+ ED_view3d_grid_view_scale(scene, v3d, rv3d, &grid_unit);
+
+ UI_FontThemeColor(BLF_default(), TH_TEXT_HI);
+ if (v3d->grid != 1.0f) {
+ BLI_snprintf(numstr, sizeof(numstr), "%s x %.4g", grid_unit, v3d->grid);
+ }
+
+ *yoffset -= U.widget_unit;
+ BLF_draw_default_ascii(
+ xoffset, *yoffset, 0.0f, numstr[0] ? numstr : grid_unit, sizeof(numstr));
+ }
+}
+
/**
* Information drawn on top of the solid plates and composed data
*/
@@ -1466,19 +1496,10 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar)
draw_selected_name(scene, view_layer, ob, xoffset, &yoffset);
}
-#if 0 /* TODO */
- if (grid_unit) { /* draw below the viewport name */
- char numstr[32] = "";
-
- UI_FontThemeColor(BLF_default(), TH_TEXT_HI);
- if (v3d->grid != 1.0f) {
- BLI_snprintf(numstr, sizeof(numstr), "%s x %.4g", grid_unit, v3d->grid);
- }
-
- *yoffset -= U.widget_unit;
- BLF_draw_default_ascii(xoffset, *yoffset, numstr[0] ? numstr : grid_unit, sizeof(numstr));
+ if (v3d->gridflag & (V3D_SHOW_FLOOR | V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_Z)) {
+ /* draw below the viewport name */
+ draw_grid_unit_name(scene, rv3d, v3d, xoffset, &yoffset);
}
-#endif
}
if ((v3d->overlay.flag & V3D_OVERLAY_HIDE_TEXT) == 0) {