Cleanup: rename uuid to uid for local-view functionality

Follow up to 311ca3e6af.
This commit is contained in:
Campbell Barton 2024-01-23 16:06:45 +11:00
parent 25e15660ac
commit 5574a2790f
18 changed files with 62 additions and 60 deletions

View File

@ -590,7 +590,7 @@ static void view3d_data_consistency_ensure(wmWindow *win, Scene *scene, ViewLaye
* be found. */
Base *base;
for (base = static_cast<Base *>(view_layer->object_bases.first); base; base = base->next) {
if (base->local_view_bits & v3d->local_view_uuid) {
if (base->local_view_bits & v3d->local_view_uid) {
break;
}
}
@ -602,7 +602,7 @@ static void view3d_data_consistency_ensure(wmWindow *win, Scene *scene, ViewLaye
/* No valid object found for the local view3D, it has to be cleared off. */
MEM_freeN(v3d->localvd);
v3d->localvd = nullptr;
v3d->local_view_uuid = 0;
v3d->local_view_uid = 0;
/* Region-base storage is different depending on whether the space is active or not. */
ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase;

View File

@ -559,7 +559,7 @@ static void loose_data_instantiate_object_base_instance_init(Main *bmain,
Base *base = BKE_view_layer_base_find(view_layer, ob);
if (v3d != nullptr) {
base->local_view_bits |= v3d->local_view_uuid;
base->local_view_bits |= v3d->local_view_uid;
}
if (flag & FILE_AUTOSELECT) {

View File

@ -1609,7 +1609,7 @@ bool BKE_base_is_visible(const View3D *v3d, const Base *base)
return base->flag & BASE_ENABLED_AND_VISIBLE_IN_DEFAULT_VIEWPORT;
}
if ((v3d->localvd) && ((v3d->local_view_uuid & base->local_view_bits) == 0)) {
if ((v3d->localvd) && ((v3d->local_view_uid & base->local_view_bits) == 0)) {
return false;
}
@ -1618,7 +1618,7 @@ bool BKE_base_is_visible(const View3D *v3d, const Base *base)
}
if (v3d->flag & V3D_LOCAL_COLLECTIONS) {
return (v3d->local_collections_uuid & base->local_collections_bits) != 0;
return (v3d->local_collections_uid & base->local_collections_bits) != 0;
}
return base->flag & BASE_ENABLED_AND_VISIBLE_IN_DEFAULT_VIEWPORT;
@ -1636,12 +1636,12 @@ bool BKE_object_is_visible_in_viewport(const View3D *v3d, const Object *ob)
return false;
}
if (v3d->localvd && ((v3d->local_view_uuid & ob->base_local_view_bits) == 0)) {
if (v3d->localvd && ((v3d->local_view_uid & ob->base_local_view_bits) == 0)) {
return false;
}
if ((v3d->flag & V3D_LOCAL_COLLECTIONS) &&
((v3d->local_collections_uuid & ob->runtime->local_collections_bits) == 0))
((v3d->local_collections_uid & ob->runtime->local_collections_bits) == 0))
{
return false;
}
@ -1725,30 +1725,30 @@ void BKE_layer_collection_isolate_global(Scene * /*scene*/,
}
static void layer_collection_local_visibility_set_recursive(LayerCollection *layer_collection,
const int local_collections_uuid)
const int local_collections_uid)
{
layer_collection->local_collections_bits |= local_collections_uuid;
layer_collection->local_collections_bits |= local_collections_uid;
LISTBASE_FOREACH (LayerCollection *, child, &layer_collection->layer_collections) {
layer_collection_local_visibility_set_recursive(child, local_collections_uuid);
layer_collection_local_visibility_set_recursive(child, local_collections_uid);
}
}
static void layer_collection_local_visibility_unset_recursive(LayerCollection *layer_collection,
const int local_collections_uuid)
const int local_collections_uid)
{
layer_collection->local_collections_bits &= ~local_collections_uuid;
layer_collection->local_collections_bits &= ~local_collections_uid;
LISTBASE_FOREACH (LayerCollection *, child, &layer_collection->layer_collections) {
layer_collection_local_visibility_unset_recursive(child, local_collections_uuid);
layer_collection_local_visibility_unset_recursive(child, local_collections_uid);
}
}
static void layer_collection_local_sync(const Scene *scene,
ViewLayer *view_layer,
LayerCollection *layer_collection,
const ushort local_collections_uuid,
const ushort local_collections_uid,
bool visible)
{
if ((layer_collection->local_collections_bits & local_collections_uuid) == 0) {
if ((layer_collection->local_collections_bits & local_collections_uid) == 0) {
visible = false;
}
@ -1760,13 +1760,13 @@ static void layer_collection_local_sync(const Scene *scene,
BKE_view_layer_synced_ensure(scene, view_layer);
Base *base = BKE_view_layer_base_find(view_layer, cob->ob);
base->local_collections_bits |= local_collections_uuid;
base->local_collections_bits |= local_collections_uid;
}
}
LISTBASE_FOREACH (LayerCollection *, child, &layer_collection->layer_collections) {
if ((child->flag & LAYER_COLLECTION_EXCLUDE) == 0) {
layer_collection_local_sync(scene, view_layer, child, local_collections_uuid, visible);
layer_collection_local_sync(scene, view_layer, child, local_collections_uid, visible);
}
}
}
@ -1777,16 +1777,16 @@ void BKE_layer_collection_local_sync(const Scene *scene, ViewLayer *view_layer,
return;
}
const ushort local_collections_uuid = v3d->local_collections_uuid;
const ushort local_collections_uid = v3d->local_collections_uid;
/* Reset flags and set the bases visible by default. */
BKE_view_layer_synced_ensure(scene, view_layer);
LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) {
base->local_collections_bits &= ~local_collections_uuid;
base->local_collections_bits &= ~local_collections_uid;
}
LISTBASE_FOREACH (LayerCollection *, layer_collection, &view_layer->layer_collections) {
layer_collection_local_sync(scene, view_layer, layer_collection, local_collections_uuid, true);
layer_collection_local_sync(scene, view_layer, layer_collection, local_collections_uid, true);
}
}
@ -1817,18 +1817,18 @@ void BKE_layer_collection_isolate_local(
const Scene *scene, ViewLayer *view_layer, const View3D *v3d, LayerCollection *lc, bool extend)
{
LayerCollection *lc_master = static_cast<LayerCollection *>(view_layer->layer_collections.first);
bool hide_it = extend && ((v3d->local_collections_uuid & lc->local_collections_bits) != 0);
bool hide_it = extend && ((v3d->local_collections_uid & lc->local_collections_bits) != 0);
if (!extend) {
/* Hide all collections. */
LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_master->layer_collections) {
layer_collection_local_visibility_unset_recursive(lc_iter, v3d->local_collections_uuid);
layer_collection_local_visibility_unset_recursive(lc_iter, v3d->local_collections_uid);
}
}
/* Make all the direct parents visible. */
if (hide_it) {
lc->local_collections_bits &= ~(v3d->local_collections_uuid);
lc->local_collections_bits &= ~(v3d->local_collections_uid);
}
else {
LayerCollection *lc_parent = lc;
@ -1840,7 +1840,7 @@ void BKE_layer_collection_isolate_local(
}
while (lc_parent != lc) {
lc_parent->local_collections_bits |= v3d->local_collections_uuid;
lc_parent->local_collections_bits |= v3d->local_collections_uid;
LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_parent->layer_collections) {
if (BKE_layer_collection_has_layer_collection(lc_iter, lc)) {
@ -1851,7 +1851,7 @@ void BKE_layer_collection_isolate_local(
}
/* Make all the children visible. */
layer_collection_local_visibility_set_recursive(lc, v3d->local_collections_uuid);
layer_collection_local_visibility_set_recursive(lc, v3d->local_collections_uid);
}
BKE_layer_collection_local_sync(scene, view_layer, v3d);

View File

@ -219,7 +219,7 @@ static int gpencil_bake_grease_pencil_animation_exec(bContext *C, wmOperator *op
/* Create a new grease pencil object. */
Object *ob_gpencil = nullptr;
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uuid : 0;
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uid : 0;
ob_gpencil = ED_gpencil_add_object(C, scene->cursor.location, local_view_bits);
float invmat[4][4];
invert_m4_m4(invmat, ob_gpencil->object_to_world);

View File

@ -226,7 +226,7 @@ static int gpencil_bake_mesh_animation_exec(bContext *C, wmOperator *op)
}
if (ob_gpencil == nullptr) {
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uuid : 0;
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uid : 0;
const float loc[3] = {0.0f, 0.0f, 0.0f};
ob_gpencil = ED_gpencil_add_object(C, loc, local_view_bits);
newob = true;

View File

@ -2093,7 +2093,7 @@ static bool gpencil_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
ushort local_view_bits = 0;
if (v3d->localvd) {
local_view_bits = v3d->local_view_uuid;
local_view_bits = v3d->local_view_uid;
}
/* create new default object */
obact = ED_gpencil_add_object(C, cur, local_view_bits);

View File

@ -177,7 +177,7 @@ static void trace_initialize_job_data(TraceJob *trace_job)
/* Create a new grease pencil object. */
if (trace_job->ob_gpencil == nullptr) {
ushort local_view_bits = (trace_job->v3d && trace_job->v3d->localvd) ?
trace_job->v3d->local_view_uuid :
trace_job->v3d->local_view_uid :
0;
trace_job->ob_gpencil = ED_gpencil_add_object(
trace_job->C, trace_job->ob_active->loc, local_view_bits);

View File

@ -201,7 +201,7 @@ static int geometry_extract_apply(bContext *C,
ushort local_view_bits = 0;
if (v3d && v3d->localvd) {
local_view_bits = v3d->local_view_uuid;
local_view_bits = v3d->local_view_uid;
}
Object *new_ob = ED_object_add_type(
C, OB_MESH, nullptr, ob->loc, ob->rot, false, local_view_bits);
@ -495,7 +495,7 @@ static int paint_mask_slice_exec(bContext *C, wmOperator *op)
if (RNA_boolean_get(op->ptr, "new_object")) {
ushort local_view_bits = 0;
if (v3d && v3d->localvd) {
local_view_bits = v3d->local_view_uuid;
local_view_bits = v3d->local_view_uid;
}
Object *new_ob = ED_object_add_type(
C, OB_MESH, nullptr, ob->loc, ob->rot, false, local_view_bits);

View File

@ -498,7 +498,7 @@ bool ED_object_add_generic_get_opts(bContext *C,
if (r_local_view_bits) {
View3D *v3d = CTX_wm_view3d(C);
*r_local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uuid : 0;
*r_local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uid : 0;
}
/* Location! */
@ -3177,7 +3177,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
ob->flag |= OB_DONE;
/* Create a new grease pencil object and copy transformations. */
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uuid : 0;
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uid : 0;
float loc[3], size[3], rot[3][3], eul[3];
float matrix[4][4];
mat4_to_loc_rot_size(loc, rot, size, ob->object_to_world);
@ -3430,7 +3430,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
BKE_object_free_curve_cache(newob);
}
else if (target == OB_GPENCIL_LEGACY) {
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uuid : 0;
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uid : 0;
Object *ob_gpencil = ED_gpencil_add_object(C, newob->loc, local_view_bits);
copy_v3_v3(ob_gpencil->rot, newob->rot);
copy_v3_v3(ob_gpencil->scale, newob->scale);
@ -3473,7 +3473,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
/* Create a new grease pencil object and copy transformations.
* Nurbs Surface are not supported.
*/
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uuid : 0;
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uid : 0;
Object *ob_gpencil = ED_gpencil_add_object(C, ob->loc, local_view_bits);
copy_v3_v3(ob_gpencil->rot, ob->rot);
copy_v3_v3(ob_gpencil->scale, ob->scale);

View File

@ -415,7 +415,7 @@ static int object_hide_collection_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
if (toggle) {
lc->local_collections_bits ^= v3d->local_collections_uuid;
lc->local_collections_bits ^= v3d->local_collections_uid;
BKE_layer_collection_local_sync(scene, view_layer, v3d);
}
else {

View File

@ -497,7 +497,7 @@ static Object *add_hook_object_new(
Base *basact = BKE_view_layer_active_base_get(view_layer);
BLI_assert(basact->object == ob);
if (v3d && v3d->localvd) {
basact->local_view_bits |= v3d->local_view_uuid;
basact->local_view_bits |= v3d->local_view_uid;
}
/* icky, BKE_object_add sets new base as active.

View File

@ -325,7 +325,7 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl)
v3dn->localvd = nullptr;
}
v3dn->local_collections_uuid = 0;
v3dn->local_collections_uid = 0;
v3dn->flag &= ~(V3D_LOCAL_COLLECTIONS | V3D_XR_SESSION_MIRROR);
if (v3dn->shading.type == OB_RENDER) {

View File

@ -803,7 +803,7 @@ static uint free_localview_bit(Main *bmain)
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = reinterpret_cast<View3D *>(sl);
if (v3d->localvd) {
local_view_bits |= v3d->local_view_uuid;
local_view_bits |= v3d->local_view_uid;
}
}
}
@ -889,7 +889,7 @@ static bool view3d_localview_init(const Depsgraph *depsgraph,
v3d->localvd = static_cast<View3D *>(MEM_mallocN(sizeof(View3D), "localview"));
*v3d->localvd = blender::dna::shallow_copy(*v3d);
v3d->local_view_uuid = local_view_bit;
v3d->local_view_uid = local_view_bit;
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->regiontype == RGN_TYPE_WINDOW) {
@ -964,15 +964,15 @@ static void view3d_localview_exit(const Depsgraph *depsgraph,
}
BKE_view_layer_synced_ensure(scene, view_layer);
LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) {
if (base->local_view_bits & v3d->local_view_uuid) {
base->local_view_bits &= ~v3d->local_view_uuid;
if (base->local_view_bits & v3d->local_view_uid) {
base->local_view_bits &= ~v3d->local_view_uid;
}
}
Object *camera_old = v3d->camera;
Object *camera_new = v3d->localvd->camera;
v3d->local_view_uuid = 0;
v3d->local_view_uid = 0;
v3d->camera = v3d->localvd->camera;
MEM_freeN(v3d->localvd);
@ -1096,7 +1096,7 @@ static int localview_remove_from_exec(bContext *C, wmOperator *op)
BKE_view_layer_synced_ensure(scene, view_layer);
LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) {
if (BASE_SELECTED(v3d, base)) {
base->local_view_bits &= ~v3d->local_view_uuid;
base->local_view_bits &= ~v3d->local_view_uid;
ED_object_base_select(base, BA_DESELECT);
if (base == view_layer->basact) {
@ -1147,7 +1147,7 @@ void VIEW3D_OT_localview_remove_from(wmOperatorType *ot)
/** \name Local Collections
* \{ */
static uint free_localcollection_bit(Main *bmain, ushort local_collections_uuid, bool *r_reset)
static uint free_localcollection_bit(Main *bmain, ushort local_collections_uid, bool *r_reset)
{
ushort local_view_bits = 0;
@ -1158,7 +1158,7 @@ static uint free_localcollection_bit(Main *bmain, ushort local_collections_uuid,
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = reinterpret_cast<View3D *>(sl);
if (v3d->flag & V3D_LOCAL_COLLECTIONS) {
local_view_bits |= v3d->local_collections_uuid;
local_view_bits |= v3d->local_collections_uid;
}
}
}
@ -1166,8 +1166,8 @@ static uint free_localcollection_bit(Main *bmain, ushort local_collections_uuid,
}
/* First try to keep the old uuid. */
if (local_collections_uuid && ((local_collections_uuid & local_view_bits) == 0)) {
return local_collections_uuid;
if (local_collections_uid && ((local_collections_uid & local_view_bits) == 0)) {
return local_collections_uid;
}
/* Otherwise get the first free available. */
@ -1215,13 +1215,13 @@ bool ED_view3d_local_collections_set(Main *bmain, View3D *v3d)
bool reset = false;
v3d->flag &= ~V3D_LOCAL_COLLECTIONS;
uint local_view_bit = free_localcollection_bit(bmain, v3d->local_collections_uuid, &reset);
uint local_view_bit = free_localcollection_bit(bmain, v3d->local_collections_uid, &reset);
if (local_view_bit == 0) {
return false;
}
v3d->local_collections_uuid = local_view_bit;
v3d->local_collections_uid = local_view_bit;
v3d->flag |= V3D_LOCAL_COLLECTIONS;
if (reset) {
@ -1243,9 +1243,9 @@ void ED_view3d_local_collections_reset(bContext *C, const bool reset_all)
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = reinterpret_cast<View3D *>(sl);
if (v3d->local_collections_uuid) {
if (v3d->local_collections_uid) {
if (v3d->flag & V3D_LOCAL_COLLECTIONS) {
local_view_bit &= ~v3d->local_collections_uuid;
local_view_bit &= ~v3d->local_collections_uid;
}
else {
do_reset = true;
@ -1262,7 +1262,7 @@ void ED_view3d_local_collections_reset(bContext *C, const bool reset_all)
else if (reset_all && (do_reset || (local_view_bit != ~(0)))) {
view3d_local_collections_reset(bmain, ~(0));
View3D v3d = {};
v3d.local_collections_uuid = ~(0);
v3d.local_collections_uid = ~(0);
BKE_layer_collection_local_sync(CTX_data_scene(C), CTX_data_view_layer(C), &v3d);
DEG_id_tag_update(&CTX_data_scene(C)->id, ID_RECALC_BASE_FLAGS);
}

View File

@ -31,7 +31,7 @@ Object *GpencilImporter::create_object()
{
const float *cur_loc = scene_->cursor.location;
const float rot[3] = {0.0f};
ushort local_view_bits = (params_.v3d && params_.v3d->localvd) ? params_.v3d->local_view_uuid :
ushort local_view_bits = (params_.v3d && params_.v3d->localvd) ? params_.v3d->local_view_uid :
ushort(0);
Object *ob_gpencil = ED_object_add_type(params_.C,

View File

@ -297,10 +297,10 @@ typedef struct View3D {
/** Optional string for armature bone to define center, MAXBONENAME. */
char ob_center_bone[64];
unsigned short local_view_uuid;
unsigned short local_view_uid;
char _pad6[2];
int layact DNA_DEPRECATED;
unsigned short local_collections_uuid;
unsigned short local_collections_uid;
short _pad7[2];
short debug_flag;

View File

@ -178,10 +178,13 @@ DNA_STRUCT_RENAME_ELEM(Text, name, filepath)
DNA_STRUCT_RENAME_ELEM(ThemeSpace, scrubbing_background, time_scrub_background)
DNA_STRUCT_RENAME_ELEM(ThemeSpace, show_back_grad, background_type)
DNA_STRUCT_RENAME_ELEM(UVProjectModifierData, num_projectors, projectors_num)
DNA_STRUCT_RENAME_ELEM(UserDef, autokey_flag, keying_flag)
DNA_STRUCT_RENAME_ELEM(UserDef, gp_manhattendist, gp_manhattandist)
DNA_STRUCT_RENAME_ELEM(UserDef, pythondir, pythondir_legacy)
DNA_STRUCT_RENAME_ELEM(VFont, name, filepath)
DNA_STRUCT_RENAME_ELEM(View3D, far, clip_end)
DNA_STRUCT_RENAME_ELEM(View3D, local_collections_uuid, local_collections_uid)
DNA_STRUCT_RENAME_ELEM(View3D, local_view_uuid, local_view_uid)
DNA_STRUCT_RENAME_ELEM(View3D, near, clip_start)
DNA_STRUCT_RENAME_ELEM(View3D, ob_centre, ob_center)
DNA_STRUCT_RENAME_ELEM(View3D, ob_centre_bone, ob_center_bone)
@ -219,7 +222,6 @@ DNA_STRUCT_RENAME_ELEM(bTheme, ttopbar, space_topbar)
DNA_STRUCT_RENAME_ELEM(bTheme, tuserpref, space_preferences)
DNA_STRUCT_RENAME_ELEM(bTheme, tv3d, space_view3d)
DNA_STRUCT_RENAME_ELEM(bUserAssetLibrary, path, dirpath)
DNA_STRUCT_RENAME_ELEM(UserDef, autokey_flag, keying_flag)
/* NOTE: Keep sorted! */
/* Write with a different name, old Blender versions crash loading files with non-NULL

View File

@ -142,7 +142,7 @@ static bool rna_LayerCollection_visible_get(LayerCollection *layer_collection, b
return (layer_collection->runtime_flag & LAYER_COLLECTION_VISIBLE_VIEW_LAYER) != 0;
}
if (v3d->local_collections_uuid & layer_collection->local_collections_bits) {
if (v3d->local_collections_uid & layer_collection->local_collections_bits) {
return (layer_collection->runtime_flag & LAYER_COLLECTION_HIDE_VIEWPORT) == 0;
}

View File

@ -252,7 +252,7 @@ static bool rna_Object_local_view_get(Object *ob, ReportList *reports, View3D *v
return false;
}
return ((ob->base_local_view_bits & v3d->local_view_uuid) != 0);
return ((ob->base_local_view_bits & v3d->local_view_uid) != 0);
}
static void rna_Object_local_view_set(Object *ob,
@ -268,7 +268,7 @@ static void rna_Object_local_view_set(Object *ob,
return; /* Error reported. */
}
const short local_view_bits_prev = base->local_view_bits;
SET_FLAG_FROM_TEST(base->local_view_bits, state, v3d->local_view_uuid);
SET_FLAG_FROM_TEST(base->local_view_bits, state, v3d->local_view_uid);
if (local_view_bits_prev != base->local_view_bits) {
DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
ScrArea *area = ED_screen_area_find_with_spacedata(screen, (SpaceLink *)v3d, true);