Skip to content
Snippets Groups Projects
Commit 9077f67a authored by lijenstina's avatar lijenstina
Browse files

Fix T53406: Avoid toggling visibility on Collision modifier

Bumped version to 0.2.5
Since the Collision modifier visibility was not exposed in the UI
trying to avoid unreliable results related to physics
and possibly broken setups, for now skip it in the add-on

Add reports about skipping:
- Skipped modifier name is appended
- If there are only skipped modifiers, add a new message about it

Correct bl_name of some operators so they are easier to search
parent 1f2b5156
No related branches found
No related tags found
No related merge requests found
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
bl_info = { bl_info = {
"name": "Modifier Tools", "name": "Modifier Tools",
"author": "Meta Androcto, saidenka", "author": "Meta Androcto, saidenka",
"version": (0, 2, 4), "version": (0, 2, 5),
"blender": (2, 77, 0), "blender": (2, 77, 0),
"location": "Properties > Modifiers", "location": "Properties > Modifiers",
"description": "Modifiers Specials Show/Hide/Apply Selected", "description": "Modifiers Specials Show/Hide/Apply Selected",
...@@ -36,7 +36,7 @@ from bpy.types import Operator ...@@ -36,7 +36,7 @@ from bpy.types import Operator
class ApplyAllModifiers(Operator): class ApplyAllModifiers(Operator):
bl_idname = "object.apply_all_modifiers" bl_idname = "object.apply_all_modifiers"
bl_label = "Apply All" bl_label = "Apply All Modifiers"
bl_description = ("Apply All modifiers of the selected object(s) \n" bl_description = ("Apply All modifiers of the selected object(s) \n"
"Active object has to have modifiers for the option to show up") "Active object has to have modifiers for the option to show up")
bl_options = {'REGISTER', 'UNDO'} bl_options = {'REGISTER', 'UNDO'}
...@@ -94,7 +94,7 @@ class ApplyAllModifiers(Operator): ...@@ -94,7 +94,7 @@ class ApplyAllModifiers(Operator):
class DeleteAllModifiers(Operator): class DeleteAllModifiers(Operator):
bl_idname = "object.delete_all_modifiers" bl_idname = "object.delete_all_modifiers"
bl_label = "Remove All" bl_label = "Remove All Modifiers"
bl_description = "Remove All modifiers of the selected object(s)" bl_description = "Remove All modifiers of the selected object(s)"
bl_options = {'REGISTER', 'UNDO'} bl_options = {'REGISTER', 'UNDO'}
...@@ -127,8 +127,8 @@ class DeleteAllModifiers(Operator): ...@@ -127,8 +127,8 @@ class DeleteAllModifiers(Operator):
class ToggleApplyModifiersView(Operator): class ToggleApplyModifiersView(Operator):
bl_idname = "object.toggle_apply_modifiers_view" bl_idname = "object.toggle_apply_modifiers_view"
bl_label = "Hide Viewport" bl_label = "Toggle Visibility of Modifiers"
bl_description = "Shows/Hide modifiers of the active / selected object(s) in 3d View" bl_description = "Shows/Hide modifiers of the active / selected object(s) in the 3D View"
bl_options = {'REGISTER'} bl_options = {'REGISTER'}
@classmethod @classmethod
...@@ -139,31 +139,69 @@ class ToggleApplyModifiersView(Operator): ...@@ -139,31 +139,69 @@ class ToggleApplyModifiersView(Operator):
is_apply = True is_apply = True
message_a = "" message_a = ""
for mod in context.active_object.modifiers: # avoid toggling not exposed modifiers (currently only Collision, see T53406)
if mod.show_viewport: skip_type = ["COLLISION"] # types of modifiers to skip
is_apply = False skipped = set() # collect names
break count_modifiers = 0 # check for message_a (all skipped)
# check if the active object has only one non exposed modifier as the logic will fail
if len(context.active_object.modifiers) == 1 and \
context.active_object.modifiers[0].type in skip_type:
for obj in context.selected_objects:
for mod in obj.modifiers:
if mod.type in skip_type:
skipped.add(mod.name)
continue
if mod.show_viewport:
is_apply = False
break
else:
for mod in context.active_object.modifiers:
if mod.type in skip_type:
skipped.add(mod.name)
continue
if mod.show_viewport:
is_apply = False
break
count_modifiers = len(context.active_object.modifiers)
# active object - no selection # active object - no selection
for mod in context.active_object.modifiers: for mod in context.active_object.modifiers:
if mod.type in skip_type:
count_modifiers -= 1
skipped.add(mod.name)
continue
mod.show_viewport = is_apply mod.show_viewport = is_apply
for obj in context.selected_objects: for obj in context.selected_objects:
count_modifiers += len(obj.modifiers)
for mod in obj.modifiers: for mod in obj.modifiers:
if mod.type in skip_type:
skipped.add(mod.name)
count_modifiers -= 1
continue
mod.show_viewport = is_apply mod.show_viewport = is_apply
if is_apply: message_a = "{} modifiers in the 3D View".format("Displaying" if is_apply else "Hidding")
message_a = "Displaying modifiers in the 3D View"
else: if skipped:
message_a = "Hiding modifiers in the 3D View" message_a = "{}, {}".format(message_a, "skipping: " + ", ".join(skipped)) if \
count_modifiers > 0 else "No change of Modifiers' Visibility, all skipped"
self.report({"INFO"}, message_a) self.report({"INFO"}, message_a)
return {'FINISHED'} return {'FINISHED'}
class ToggleAllShowExpanded(Operator): class ToggleAllShowExpanded(Operator):
bl_idname = "wm.toggle_all_show_expanded" bl_idname = "wm.toggle_all_show_expanded"
bl_label = "Expand/Collapse All" bl_label = "Expand/Collapse All Modifiers"
bl_description = "Expand/Collapse Modifier Stack" bl_description = "Expand/Collapse Modifier Stack"
bl_options = {'REGISTER'} bl_options = {'REGISTER'}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment