IO: remove BKE_layer_collection_resync_forbid & allow

Part of T101073: after the view layer sync was made lazy (D15885), the
BKE_layer_collection_resync_forbid and BKE_layer_collection_resync_allow
in Alembic/USD/OBJ importers is no longer needed, as long as they do
view layer dependent operations (selecting new objects) in a separate
loop after creating all the objects.

Verified that this does not regress import times for 26k objects OBJ
scene (Blender 3.0 splash) and 250k objects USD scene (Moana).
This commit is contained in:
Aras Pranckevicius 2022-10-10 14:06:36 +03:00
parent b099cf73ae
commit 499af28a35
3 changed files with 4 additions and 18 deletions

View File

@ -608,15 +608,11 @@ static void import_endjob(void *user_data)
lc = BKE_layer_collection_get_active(view_layer);
/* Add all objects to the collection (don't do sync for each object). */
BKE_layer_collection_resync_forbid();
for (AbcObjectReader *reader : data->readers) {
Object *ob = reader->object();
BKE_collection_object_add(data->bmain, lc->collection, ob);
}
/* Sync the collection, and do view layer operations. */
BKE_layer_collection_resync_allow();
BKE_main_collection_sync(data->bmain);
/* Sync and do the view layer operations. */
BKE_view_layer_synced_ensure(scene, view_layer);
for (AbcObjectReader *reader : data->readers) {
Object *ob = reader->object();

View File

@ -317,8 +317,7 @@ static void import_endjob(void *customdata)
lc = BKE_layer_collection_get_active(view_layer);
/* Add all objects to the collection (don't do sync for each object). */
BKE_layer_collection_resync_forbid();
/* Add all objects to the collection. */
for (USDPrimReader *reader : data->archive->readers()) {
if (!reader) {
continue;
@ -330,9 +329,7 @@ static void import_endjob(void *customdata)
BKE_collection_object_add(data->bmain, lc->collection, ob);
}
/* Sync the collection, and do view layer operations. */
BKE_layer_collection_resync_allow();
BKE_main_collection_sync(data->bmain);
/* Sync and do the view layer operations. */
BKE_view_layer_synced_ensure(scene, view_layer);
for (USDPrimReader *reader : data->archive->readers()) {
if (!reader) {

View File

@ -42,9 +42,6 @@ static void geometry_to_blender_objects(Main *bmain,
{
LayerCollection *lc = BKE_layer_collection_get_active(view_layer);
/* Don't do collection syncs for each object, will do once after the loop. */
BKE_layer_collection_resync_forbid();
/* Sort objects by name: creating many objects is much faster if the creation
* order is sorted by name. */
blender::parallel_sort(
@ -73,12 +70,8 @@ static void geometry_to_blender_objects(Main *bmain,
}
}
/* Sync the collection after all objects are created. */
BKE_layer_collection_resync_allow();
BKE_main_collection_sync(bmain);
/* Do object selections in a separate loop (allows just one view layer sync). */
BKE_view_layer_synced_ensure(scene, view_layer);
/* After collection sync, select objects in the view layer and do DEG updates. */
for (Object *obj : objects) {
Base *base = BKE_view_layer_base_find(view_layer, obj);
BKE_view_layer_base_select_and_set_active(view_layer, base);