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:
authorSiddhartha Jejurkar <sidd017>2021-09-29 10:47:32 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-09-29 10:48:35 +0300
commitbf06f76be6316be92a4655a41391e163d2fb1221 (patch)
tree5dac6a12fb65f0897806739d5ef8e00407112041 /source/blender/editors/transform/transform.c
parent008ae26712f85475a8a9dc4d031447e12fb05522 (diff)
UV Editor: Grid and snapping improvements
Implements T89789, T89792, custom grid (described as dynamic grid in T78389) and UV grid snapping (T78391) Replaces the default UV editor grid with 2 new types of grid : * Custom grid: Allows the user to create an NxN grid, where the value of N is specified by the user. * Subdividing grid: Subdivides the UV editor grid when the user zooms in the viewport and vice versa when zooming out. UV snapping improvements : * Increment snapping: Increment values for snapping are calculated based on which grid type is being used in the UV editor (subdividing or custom). In general the increment value is equal to the distance between 2 visible grid lines. * Absolute grid snap: New toggle added to increment snapping option in the UV editor, allows UV grid snapping during translation. Reviewed By: campbellbarton Ref D12684
Diffstat (limited to 'source/blender/editors/transform/transform.c')
-rw-r--r--source/blender/editors/transform/transform.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index e58e524e341..6ed2c28a7eb 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -28,6 +28,7 @@
#include "DNA_gpencil_types.h"
#include "DNA_mask_types.h"
#include "DNA_mesh_types.h"
+#include "DNA_screen_types.h"
#include "BLI_math.h"
#include "BLI_rect.h"
@@ -1609,8 +1610,16 @@ static void initSnapSpatial(TransInfo *t, float r_snap[2])
}
}
else if (t->spacetype == SPACE_IMAGE) {
- r_snap[0] = 0.0625f;
- r_snap[1] = 0.03125f;
+ SpaceImage *sima = t->area->spacedata.first;
+ View2D *v2d = &t->region->v2d;
+ int grid_size = SI_GRID_STEPS_LEN;
+ float zoom_factor = ED_space_image_zoom_level(v2d, grid_size);
+ float grid_steps[SI_GRID_STEPS_LEN];
+
+ ED_space_image_grid_steps(sima, grid_steps, grid_size);
+ /* Snapping value based on what type of grid is used (adaptive-subdividing or custom-grid). */
+ r_snap[0] = ED_space_image_increment_snap_value(grid_size, grid_steps, zoom_factor);
+ r_snap[1] = r_snap[0] / 2.0f;
}
else if (t->spacetype == SPACE_CLIP) {
r_snap[0] = 0.125f;