Collection Manager: Fix isolation when history has only one. Task: T69577

This commit is contained in:
Ryan Inch 2020-01-24 02:09:21 -05:00
parent 0ad43f9c85
commit 0ef0b20339
2 changed files with 6 additions and 42 deletions

View File

@ -22,7 +22,7 @@ bl_info = {
"name": "Collection Manager",
"description": "Manage collections and their objects",
"author": "Ryan Inch",
"version": (1,8,8),
"version": (1,8,9),
"blender": (2, 80, 0),
"location": "View3D - Object Mode (Shortcut - M)",
"warning": '', # used for warning icon and text in addons panel

View File

@ -192,7 +192,7 @@ class CMExcludeOperator(Operator):
# check if collection isolated
if len(active_layer_collections) == 1 and active_layer_collections[0]["name"] == self.name:
if len(exclude_history) > 1:
if len(exclude_history) > 0:
# restore previous state
for x, item in enumerate(layer_collections.values()):
item["ptr"].exclude = exclude_history[x]
@ -212,17 +212,9 @@ class CMExcludeOperator(Operator):
exclude_history.clear()
# save state
keep_history = -1
for item in layer_collections.values():
exclude_history.append(item["ptr"].exclude)
if item["ptr"].exclude == False:
keep_history += 1
if not keep_history:
del rto_history["exclude"][view_layer]
# isolate collection
for item in layer_collections.values():
if item["name"] != laycol_ptr.name:
@ -378,7 +370,7 @@ class CMRestrictSelectOperator(Operator):
# check if reversed layerchain matches active collections
if layerchain[::-1] == active_layer_collections:
if len(select_history) > 1:
if len(select_history) > 0:
# restore previous state
for x, item in enumerate(layer_collections.values()):
item["ptr"].collection.hide_select = select_history[x]
@ -396,16 +388,9 @@ class CMRestrictSelectOperator(Operator):
select_history.clear()
# save state
keep_history = -1
for item in layer_collections.values():
select_history.append(item["ptr"].collection.hide_select)
if item["ptr"].collection.hide_select == False:
keep_history += 1
if not keep_history:
del rto_history["select"][view_layer]
# make all collections unselectable
for item in layer_collections.values():
item["ptr"].collection.hide_select = True
@ -538,7 +523,7 @@ class CMHideOperator(Operator):
# check if reversed layerchain matches active collections
if layerchain[::-1] == active_layer_collections:
if len(hide_history) > 1:
if len(hide_history) > 0:
# restore previous state
for x, item in enumerate(layer_collections.values()):
item["ptr"].hide_viewport = hide_history[x]
@ -556,16 +541,9 @@ class CMHideOperator(Operator):
hide_history.clear()
# save state
keep_history = -1
for item in layer_collections.values():
hide_history.append(item["ptr"].hide_viewport)
if item["ptr"].hide_viewport == False:
keep_history += 1
if not keep_history:
del rto_history["hide"][view_layer]
# hide all collections
for laycol in layer_collections.values():
laycol["ptr"].hide_viewport = True
@ -697,7 +675,7 @@ class CMDisableViewportOperator(Operator):
# check if reversed layerchain matches active collections
if layerchain[::-1] == active_layer_collections:
if len(disable_history) > 1:
if len(disable_history) > 0:
# restore previous state
for x, item in enumerate(layer_collections.values()):
item["ptr"].collection.hide_viewport = disable_history[x]
@ -715,16 +693,9 @@ class CMDisableViewportOperator(Operator):
disable_history.clear()
# save state
keep_history = -1
for item in layer_collections.values():
disable_history.append(item["ptr"].collection.hide_viewport)
if item["ptr"].collection.hide_viewport == False:
keep_history += 1
if not keep_history:
del rto_history["disable"][view_layer]
# disable all collections in viewport
for laycol in layer_collections.values():
laycol["ptr"].collection.hide_viewport = True
@ -857,7 +828,7 @@ class CMDisableRenderOperator(Operator):
# check if reversed layerchain matches active collections
if layerchain[::-1] == active_layer_collections:
if len(render_history) > 1:
if len(render_history) > 0:
# restore previous state
for x, item in enumerate(layer_collections.values()):
item["ptr"].collection.hide_render = render_history[x]
@ -875,16 +846,9 @@ class CMDisableRenderOperator(Operator):
render_history.clear()
# save state
keep_history = -1
for item in layer_collections.values():
render_history.append(item["ptr"].collection.hide_render)
if item["ptr"].collection.hide_render == False:
keep_history += 1
if not keep_history:
del rto_history["render"][view_layer]
# disallow render of all collections
for laycol in layer_collections.values():
laycol["ptr"].collection.hide_render = True