From a24fc6bbc1ae3c0ee5a26c5b964af219215de692 Mon Sep 17 00:00:00 2001 From: Chris Blackbourn Date: Sun, 18 Sep 2022 17:03:40 +1200 Subject: 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 --- source/blender/editors/space_image/image_draw.c | 19 ++++++++++--------- source/blender/editors/space_image/space_image.c | 3 ++- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'source/blender/editors/space_image') 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"); -- cgit v1.2.3