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.
This commit is contained in:
Sergey Sharybin 2017-11-30 15:03:48 +01:00
parent 47a4a7c8b7
commit c241d79dc8
3 changed files with 15 additions and 13 deletions

View File

@ -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);
}
}

View File

@ -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)))
{

View File

@ -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)