diff options
author | Chris Blackbourn <chrisbblend@gmail.com> | 2022-09-18 08:03:40 +0300 |
---|---|---|
committer | Chris Blackbourn <chrisbblend@gmail.com> | 2022-09-20 01:00:41 +0300 |
commit | a24fc6bbc1ae3c0ee5a26c5b964af219215de692 (patch) | |
tree | 007f58081ebdc48a90102390796ce7a3deba9971 /source/blender/editors/space_image | |
parent | 7a67d69ca4fe807ea36c57166b89a6e42c25b909 (diff) |
UV: extend custom grid sizes to set each axis separately
For example, allows a custom UV grid size of 4 x 12.
TODO: Fix snapping with custom UV grid sizes.
Manifest Tasks: T78391
Differential Revision: https://developer.blender.org/D16000
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r-- | source/blender/editors/space_image/image_draw.c | 19 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 3 |
2 files changed, 12 insertions, 10 deletions
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 37a6e6dfcb1..8a934396229 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -585,18 +585,19 @@ float ED_space_image_zoom_level(const View2D *v2d, const int grid_dimension) } void ED_space_image_grid_steps(SpaceImage *sima, - float grid_steps[SI_GRID_STEPS_LEN], + float grid_steps_x[SI_GRID_STEPS_LEN], + float grid_steps_y[SI_GRID_STEPS_LEN], const int grid_dimension) { - if (sima->flag & SI_CUSTOM_GRID) { - for (int step = 0; step < SI_GRID_STEPS_LEN; step++) { - grid_steps[step] = powf(1, step) * (1.0f / ((float)sima->custom_grid_subdiv)); + const int flag = sima->flag; + for (int step = 0; step < SI_GRID_STEPS_LEN; step++) { + if (flag & SI_CUSTOM_GRID) { + grid_steps_x[step] = 1.0f / sima->custom_grid_subdiv[0]; + grid_steps_y[step] = 1.0f / sima->custom_grid_subdiv[1]; } - } - else { - for (int step = 0; step < SI_GRID_STEPS_LEN; step++) { - grid_steps[step] = powf(grid_dimension, step) * - (1.0f / (powf(grid_dimension, SI_GRID_STEPS_LEN))); + else { + grid_steps_x[step] = powf(grid_dimension, step - SI_GRID_STEPS_LEN); + grid_steps_y[step] = powf(grid_dimension, step - SI_GRID_STEPS_LEN); } } } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 096ae4fd328..2b65267644a 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -112,7 +112,8 @@ static SpaceLink *image_create(const ScrArea *UNUSED(area), const Scene *UNUSED( simage->tile_grid_shape[0] = 1; simage->tile_grid_shape[1] = 1; - simage->custom_grid_subdiv = 10; + simage->custom_grid_subdiv[0] = 10; + simage->custom_grid_subdiv[1] = 10; /* header */ region = MEM_callocN(sizeof(ARegion), "header for image"); |