[Bf-blender-cvs] [c7085be6c6b] master: Fix T84345: Transforming the cursor fails with absolute grid-snap
Campbell Barton
noreply at git.blender.org
Mon Jan 4 11:17:13 CET 2021
Commit: c7085be6c6ba2f7415b5b69f451287456296a3b6
Author: Campbell Barton
Date: Mon Jan 4 21:09:35 2021 +1100
Branches: master
https://developer.blender.org/rBc7085be6c6ba2f7415b5b69f451287456296a3b6
Fix T84345: Transforming the cursor fails with absolute grid-snap
Absolute grid snapping was using the pivot, which doesn't make sense
when transforming the cursor.
===================================================================
M source/blender/editors/transform/transform_convert.c
M source/blender/editors/transform/transform_snap.c
===================================================================
diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c
index c81c954bd0a..dd35d67e1fa 100644
--- a/source/blender/editors/transform/transform_convert.c
+++ b/source/blender/editors/transform/transform_convert.c
@@ -993,6 +993,10 @@ void createTransData(bContext *C, TransInfo *t)
else {
convert_type = TC_CURSOR_VIEW3D;
}
+
+ /* Since we're transforming the cursor, initialize this value before it's modified.
+ * Needed for #snap_grid_apply to access the cursor location. */
+ transformCenter_from_type(t, V3D_AROUND_CURSOR);
}
else if (!(t->options & CTX_PAINT_CURVE) && (t->spacetype == SPACE_VIEW3D) && ob &&
(ob->mode == OB_MODE_SCULPT) && ob->sculpt) {
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index d407cea0033..e5b16d0ef6e 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -1424,10 +1424,21 @@ static void snap_grid_apply(
const float *center_global = t->center_global;
const float *asp = t->aspect;
- /* use a fallback for cursor selection,
- * this isn't useful as a global center for absolute grid snapping
- * since its not based on the position of the selection. */
- if (t->around == V3D_AROUND_CURSOR) {
+ if (t->options & CTX_CURSOR) {
+ /* Note that we must already have called #transformCenter_from_type, otherwise
+ * we would be lazy-initializing data which is being transformed,
+ * causing the transformed cursor location to be used instead of it's initial location. */
+ BLI_assert(t->center_cache[V3D_AROUND_CURSOR].is_set);
+
+ /* Use a fallback when transforming the cursor.
+ * In this case the center is _not_ derived from the cursor which is being transformed. */
+ const TransCenterData *cd = transformCenter_from_type(t, V3D_AROUND_CURSOR);
+ center_global = cd->global;
+ }
+ else if (t->around == V3D_AROUND_CURSOR) {
+ /* Use a fallback for cursor selection,
+ * this isn't useful as a global center for absolute grid snapping
+ * since its not based on the position of the selection. */
const TransCenterData *cd = transformCenter_from_type(t, V3D_AROUND_CENTER_MEDIAN);
center_global = cd->global;
}
More information about the Bf-blender-cvs
mailing list