diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-05-31 20:04:03 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-05-31 20:04:03 +0400 |
commit | c3a7db28d31780329f8402f3f26c7bd575031474 (patch) | |
tree | f206c22ced73ce277560776a0e46da5be2eee180 /source/blender/editors/space_view3d/view3d_draw.c | |
parent | b04cd3a76561f17ef0951837ae0ea169e563a571 (diff) |
Fix #31657: adding mesh objects did not take units into account for the grid
scale that sets the default size.
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_draw.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index ee02f99d5b7..14afcaa855f 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -437,16 +437,9 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** } #undef GRID_MIN_PX -static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) +float ED_view3d_grid_scale(Scene *scene, View3D *v3d, const char **grid_unit) { - float grid, grid_scale; - unsigned char col_grid[3]; - const int gridlines = v3d->gridlines / 2; - - if (v3d->gridlines < 3) return; - - grid_scale = v3d->grid; - /* use 'grid_scale' instead of 'v3d->grid' from now on */ + float grid_scale = v3d->grid; /* apply units */ if (scene->unit.system) { @@ -457,11 +450,25 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) if (usys) { int i = bUnit_GetBaseUnit(usys); - *grid_unit = bUnit_GetNameDisplay(usys, i); + if (grid_unit) + *grid_unit = bUnit_GetNameDisplay(usys, i); grid_scale = (grid_scale * (float)bUnit_GetScaler(usys, i)) / scene->unit.scale_length; } } + return grid_scale; +} + +static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) +{ + float grid, grid_scale; + unsigned char col_grid[3]; + const int gridlines = v3d->gridlines / 2; + + if (v3d->gridlines < 3) return; + + /* use 'grid_scale' instead of 'v3d->grid' from now on */ + grid_scale = ED_view3d_grid_scale(scene, v3d, grid_unit); grid = gridlines * grid_scale; if (v3d->zbuf && scene->obedit) glDepthMask(0); // for zbuffer-select |