Cleanup: make transform data in object mode flag public

This fits better with intended flag usage.
This commit is contained in:
Campbell Barton 2019-08-28 13:42:22 +10:00
parent ed066f231d
commit f88022b96f
Notes: blender-bot 2023-02-14 07:25:51 +01:00
Referenced by issue #69266, [ Material > Viewport Display > Color ] no longer saved with the scene
Referenced by issue #69257, Crash when adding hook to curve with vertex parenting
Referenced by issue #69262, VIEWPORT RENDER IMAGE dont render quad view images
Referenced by issue #69248, no edit the mesh in alembic animation
Referenced by issue #68843, Invalid (pink) shader when using wireframe node [ Eevee ]
5 changed files with 14 additions and 18 deletions

View File

@ -90,6 +90,8 @@ enum TfmMode {
#define CTX_PAINT_CURVE (1 << 8)
#define CTX_GPENCIL_STROKES (1 << 9)
#define CTX_CURSOR (1 << 10)
/** When transforming object's, adjust the object data so it stays in the same place. */
#define CTX_OBMODE_XFORM_OBDATA (1 << 11)
/* Standalone call to get the transformation center corresponding to the current situation
* returns 1 if successful, 0 otherwise (usually means there's no selection)

View File

@ -802,10 +802,6 @@ enum {
T_MODAL_CURSOR_SET = 1 << 26,
T_CLNOR_REBUILD = 1 << 27,
/** When transforming object's, adjust the object data so it stays in the same place. */
T_OBJECT_DATA_IN_OBJECT_MODE = 1 << 28,
};
/** #TransInfo.modifiers */

View File

@ -6539,7 +6539,7 @@ static void flush_trans_object_base_deps_flag(Depsgraph *depsgraph, Object *obje
static void trans_object_base_deps_flag_finish(const TransInfo *t, ViewLayer *view_layer)
{
if ((t->flag & T_OBJECT_DATA_IN_OBJECT_MODE) == 0) {
if ((t->options & CTX_OBMODE_XFORM_OBDATA) == 0) {
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
if (base->object->id.tag & LIB_TAG_DOIT) {
base->flag_legacy |= BA_SNAP_FIX_DEPS_FIASCO;
@ -7811,7 +7811,7 @@ static void createTransObject(bContext *C, TransInfo *t)
td->flag |= TD_SKIP;
}
if (t->flag & T_OBJECT_DATA_IN_OBJECT_MODE) {
if (t->options & CTX_OBMODE_XFORM_OBDATA) {
ID *id = ob->data;
if (!id || id->lib) {
td->flag |= TD_SKIP;
@ -7823,7 +7823,7 @@ static void createTransObject(bContext *C, TransInfo *t)
}
}
if (t->flag & T_OBJECT_DATA_IN_OBJECT_MODE) {
if (t->options & CTX_OBMODE_XFORM_OBDATA) {
if ((td->flag & TD_SKIP) == 0) {
trans_obdata_in_obmode_ensure_object(t, ob);
}
@ -7861,7 +7861,7 @@ static void createTransObject(bContext *C, TransInfo *t)
}
}
if (t->flag & T_OBJECT_DATA_IN_OBJECT_MODE) {
if (t->options & CTX_OBMODE_XFORM_OBDATA) {
GSet *objects_in_transdata = BLI_gset_ptr_new_ex(__func__, tc->data_len);
td = tc->data;
for (int i = 0; i < tc->data_len; i++, td++) {
@ -9888,7 +9888,7 @@ void createTransData(bContext *C, TransInfo *t)
BKE_scene_graph_evaluated_ensure(t->depsgraph, CTX_data_main(t->context));
if ((scene->toolsettings->transform_flag & SCE_XFORM_DATA_ORIGIN) != 0) {
t->flag |= T_OBJECT_DATA_IN_OBJECT_MODE;
t->options |= CTX_OBMODE_XFORM_OBDATA;
}
createTransObject(C, t);

View File

@ -1151,7 +1151,7 @@ static void recalcData_objects(TransInfo *t)
ED_objects_recalculate_paths(t->context, t->scene, true);
}
if (t->flag & T_OBJECT_DATA_IN_OBJECT_MODE) {
if (t->options & CTX_OBMODE_XFORM_OBDATA) {
trans_obdata_in_obmode_update_all(t);
}
}
@ -1923,7 +1923,7 @@ void postTrans(bContext *C, TransInfo *t)
BLI_rng_free(t->rng);
}
if (t->flag & T_OBJECT_DATA_IN_OBJECT_MODE) {
if (t->options & CTX_OBMODE_XFORM_OBDATA) {
trans_obdata_in_obmode_free_all(t);
}

View File

@ -633,14 +633,12 @@ static void initSnappingMode(TransInfo *t)
(obedit_type == -1)) // Object Mode
{
if (t->options & (CTX_GPENCIL_STROKES | CTX_CURSOR)) {
if (t->options & (CTX_GPENCIL_STROKES | CTX_CURSOR | CTX_OBMODE_XFORM_OBDATA)) {
/* In "Edit Strokes" mode,
* snap tool can perform snap to selected or active objects (see T49632)
* TODO: perform self snap in gpencil_strokes */
t->tsnap.modeSelect = SNAP_ALL;
}
else if (t->flag & T_OBJECT_DATA_IN_OBJECT_MODE) {
/* When we're moving the origins, allow snapping onto our own geometry (see T69132). */
* TODO: perform self snap in gpencil_strokes.
*
* When we're moving the origins, allow snapping onto our own geometry (see T69132). */
t->tsnap.modeSelect = SNAP_ALL;
}
else {
@ -1251,7 +1249,7 @@ static void TargetSnapClosest(TransInfo *t)
for (td = tc->data, i = 0; i < tc->data_len && td->flag & TD_SELECTED; i++, td++) {
const BoundBox *bb = NULL;
if ((t->flag & T_OBJECT_DATA_IN_OBJECT_MODE) == 0) {
if ((t->options & CTX_OBMODE_XFORM_OBDATA) == 0) {
bb = BKE_object_boundbox_get(td->ob);
}