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:
authorGermano Cavalcante <mano-wii>2020-08-31 16:14:40 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2020-08-31 17:24:37 +0300
commit546b900194f0f0464d126e1e18ea4fc7c9b1c1ff (patch)
tree002a8d8d326a5261c34f103e8d3347d00f00d87f /source/blender/editors/transform/transform_mode_translate.c
parenta1df2fc44388a92ba539f764203170902dd2a663 (diff)
Cleanup/Refactor: Split the snap to increments code
Now we have a better distinction of what is snap to grid and what is snap to increments. The code also allows the implementation of mixed snap for these modes.
Diffstat (limited to 'source/blender/editors/transform/transform_mode_translate.c')
-rw-r--r--source/blender/editors/transform/transform_mode_translate.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/source/blender/editors/transform/transform_mode_translate.c b/source/blender/editors/transform/transform_mode_translate.c
index c083e1654dc..36be26049d3 100644
--- a/source/blender/editors/transform/transform_mode_translate.c
+++ b/source/blender/editors/transform/transform_mode_translate.c
@@ -362,15 +362,28 @@ static void applyTranslation(TransInfo *t, const int UNUSED(mval[2]))
}
else {
copy_v3_v3(global_dir, t->values);
- if ((t->con.mode & CON_APPLY) == 0) {
- snapGridIncrement(t, global_dir);
- }
-
if (applyNumInput(&t->num, global_dir)) {
removeAspectRatio(t, global_dir);
}
+ else {
+ applySnapping(t, global_dir);
+
+ if (!validSnap(t) && !(t->con.mode & CON_APPLY)) {
+ float dist_sq = FLT_MAX;
+ if (transform_snap_grid(t, global_dir)) {
+ dist_sq = len_squared_v3v3(t->values, global_dir);
+ }
- applySnapping(t, global_dir);
+ /* Check the snap distance to the initial value to work with mixed snap. */
+ float increment_loc[3];
+ copy_v3_v3(increment_loc, t->values);
+ if (transform_snap_increment(t, increment_loc)) {
+ if ((dist_sq == FLT_MAX) || (len_squared_v3v3(t->values, increment_loc) < dist_sq)) {
+ copy_v3_v3(global_dir, increment_loc);
+ }
+ }
+ }
+ }
}
if (t->con.mode & CON_APPLY) {