Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
General: We should keep current subset version when we switch only th…
Browse files Browse the repository at this point in the history
…e representation type (#4629)

* keep current subset version when switch repre

* added comment and safe switch repres

* more clearly variable names and revert last feat

* check selected but no change

* fix switch hero version
  • Loading branch information
kaamaurice authored Jan 4, 2024
1 parent 6043d5f commit 91a1fb1
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions openpype/tools/sceneinventory/switch_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -1230,12 +1230,12 @@ def _trigger_switch(self, loader=None):

version_ids = list()

version_docs_by_parent_id = {}
version_docs_by_parent_id_and_name = collections.defaultdict(dict)
for version_doc in version_docs:
parent_id = version_doc["parent"]
if parent_id not in version_docs_by_parent_id:
version_ids.append(version_doc["_id"])
version_docs_by_parent_id[parent_id] = version_doc
version_ids.append(version_doc["_id"])
name = version_doc["name"]
version_docs_by_parent_id_and_name[parent_id][name] = version_doc

hero_version_docs_by_parent_id = {}
for hero_version_doc in hero_version_docs:
Expand Down Expand Up @@ -1293,13 +1293,32 @@ def _trigger_switch(self, loader=None):
repre_doc = _repres.get(container_repre_name)

if not repre_doc:
version_doc = version_docs_by_parent_id[subset_id]
version_docs_by_name = version_docs_by_parent_id_and_name[
subset_id
]

# If asset or subset are selected for switching, we use latest
# version else we try to keep the current container version.
if (
selected_asset not in (None, container_asset_name)
or selected_subset not in (None, container_subset_name)
):
version_name = max(version_docs_by_name)
else:
version_name = container_version["name"]

version_doc = version_docs_by_name[version_name]
version_id = version_doc["_id"]
repres_by_name = repre_docs_by_parent_id_by_name[version_id]
repres_docs_by_name = repre_docs_by_parent_id_by_name[
version_id
]

if selected_representation:
repre_doc = repres_by_name[selected_representation]
repres_name = selected_representation
else:
repre_doc = repres_by_name[container_repre_name]
repres_name = container_repre_name

repre_doc = repres_docs_by_name[repres_name]

error = None
try:
Expand Down

0 comments on commit 91a1fb1

Please sign in to comment.