[Bf-blender-cvs] [c241d79dc8a] master: Transform: Use single flag with more meaningful name to prevent snapping to a dependent object

Sergey Sharybin noreply at git.blender.org
Thu Nov 30 15:06:57 CET 2017


Commit: c241d79dc8a8ee144bc904f0a9b039b452df44bd
Author: Sergey Sharybin
Date:   Thu Nov 30 15:03:48 2017 +0100
Branches: master
https://developer.blender.org/rBc241d79dc8a8ee144bc904f0a9b039b452df44bd

Transform: Use single flag with more meaningful name to prevent snapping to a dependent object

The idea of this flag was to prevent snapping onto an object which depends on
currently modifying ones. Using single flag makes more sense here, and also
makes it possible to replace some ob->recalc based magic with depsgraph query
to set those flags.

===================================================================

M	source/blender/editors/transform/transform_conversions.c
M	source/blender/editors/transform/transform_snap_object.c
M	source/blender/makesdna/DNA_object_types.h

===================================================================

diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 9f0f4429f98..34cc143f3a9 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -5608,10 +5608,9 @@ static void set_trans_object_base_flags(TransInfo *t)
 	/* and we store them temporal in base (only used for transform code) */
 	/* this because after doing updates, the object->recalc is cleared */
 	for (base = scene->base.first; base; base = base->next) {
-		if (base->object->recalc & OB_RECALC_OB)
-			base->flag |= BA_HAS_RECALC_OB;
-		if (base->object->recalc & OB_RECALC_DATA)
-			base->flag |= BA_HAS_RECALC_DATA;
+		if (base->object->recalc & (OB_RECALC_OB | OB_RECALC_DATA)) {
+			base->flag |= BA_SNAP_FIX_DEPS_FIASCO;
+		}
 	}
 }
 
@@ -5687,10 +5686,9 @@ static int count_proportional_objects(TransInfo *t)
 	/* and we store them temporal in base (only used for transform code) */
 	/* this because after doing updates, the object->recalc is cleared */
 	for (base = scene->base.first; base; base = base->next) {
-		if (base->object->recalc & OB_RECALC_OB)
-			base->flag |= BA_HAS_RECALC_OB;
-		if (base->object->recalc & OB_RECALC_DATA)
-			base->flag |= BA_HAS_RECALC_DATA;
+		if (base->object->recalc & (OB_RECALC_OB | OB_RECALC_DATA)) {
+			base->flag |= BA_SNAP_FIX_DEPS_FIASCO;
+		}
 	}
 
 	return total;
@@ -5705,7 +5703,7 @@ static void clear_trans_object_base_flags(TransInfo *t)
 		if (base->flag & BA_WAS_SEL)
 			base->flag |= SELECT;
 
-		base->flag &= ~(BA_WAS_SEL | BA_HAS_RECALC_OB | BA_HAS_RECALC_DATA | BA_TEMP_TAG | BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT);
+		base->flag &= ~(BA_WAS_SEL | BA_SNAP_FIX_DEPS_FIASCO | BA_TEMP_TAG | BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT);
 	}
 }
 
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index bf4893c2c52..63bdf3ac010 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -158,7 +158,7 @@ static void iter_snap_objects(
 	Base *base_act = sctx->scene->basact;
 	for (Base *base = sctx->scene->base.first; base != NULL; base = base->next) {
 		if ((BASE_VISIBLE_BGMODE(sctx->v3d_data.v3d, sctx->scene, base)) &&
-		    (base->flag & (BA_HAS_RECALC_OB | BA_HAS_RECALC_DATA)) == 0 &&
+		    (base->flag & BA_SNAP_FIX_DEPS_FIASCO) == 0 &&
 		    !((snap_select == SNAP_NOT_SELECTED && (base->flag & (SELECT | BA_WAS_SEL))) ||
 		      (snap_select == SNAP_NOT_ACTIVE && base == base_act)))
 		{
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index d08bca4f244..80fa29a9c43 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -496,9 +496,13 @@ enum {
 
 /* also needed for base!!!!! or rather, they interfere....*/
 /* base->flag and ob->flag */
-#define BA_WAS_SEL          (1 << 1)
-#define BA_HAS_RECALC_OB    (1 << 2)
-#define BA_HAS_RECALC_DATA  (1 << 3)
+enum {
+	BA_WAS_SEL = (1 << 1),
+	/* NOTE: BA_HAS_RECALC_DATA can be re-used later if freed in readfile.c. */
+	// BA_HAS_RECALC_OB = (1 << 2),  /* DEPRECATED */
+	// BA_HAS_RECALC_DATA =  (1 << 3),  /* DEPRECATED */
+	BA_SNAP_FIX_DEPS_FIASCO = (1 << 2),  /* Yes, re-use deprecated bit, all fine since it's runtime only. */
+};
 
 	/* NOTE: this was used as a proper setting in past, so nullify before using */
 #define BA_TEMP_TAG         (1 << 5)



More information about the Bf-blender-cvs mailing list