Browse Source

Fix #260.

Adds the ability to reset and/or delete all modifiers on a single
blender object.
pull/268/head
Adam Johnson 3 years ago
parent
commit
9884e7a061
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 25
      korman/operators/op_modifier.py
  2. 3
      korman/ui/ui_modifiers.py

25
korman/operators/op_modifier.py

@ -220,12 +220,14 @@ class ModifierRemoveOperator(ModifierOperator, bpy.types.Operator):
return {"FINISHED"}
def invoke(self, context, event):
assert self.active_modifier >= -1
mods = context.object.plasma_modifiers
self.mods2delete.clear()
want2delete = OrderedSet()
want2delete.add(self._get_modifier(context).pl_id)
if self.active_modifier == -1:
want2delete.update((i.pl_id for i in context.object.plasma_modifiers.modifiers))
else:
want2delete.add(self._get_modifier(context).pl_id)
# Here's the rub
# When we start, we should have just one modifier in want2delete
@ -249,8 +251,8 @@ class ModifierRemoveOperator(ModifierOperator, bpy.types.Operator):
class ModifierResetOperator(ModifierOperator, bpy.types.Operator):
bl_idname = "object.plasma_modifier_reset"
bl_label = "Reset the modifier to its default state?"
bl_description = "Reset the modifier to its default state"
bl_label = "Reset the modifier(s) to the default state?"
bl_description = "Reset the modifier(s) to the default state"
active_modifier = IntProperty(name="Modifier Display Order",
default=-1,
@ -260,13 +262,18 @@ class ModifierResetOperator(ModifierOperator, bpy.types.Operator):
pass
def execute(self, context):
assert self.active_modifier >= 0
mod = self._get_modifier(context)
props = set(mod.keys()) - {"display_order", "display_name"}
for i in props:
mod.property_unset(i)
if self.active_modifier == -1:
for i in context.object.plasma_modifiers.modifiers:
self._reset(i)
else:
self._reset(self._get_modifier(context))
return {"FINISHED"}
def _reset(self, modifier):
props = set(modifier.keys()) - {"display_order", "display_name"}
for i in props:
modifier.property_unset(i)
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self)

3
korman/ui/ui_modifiers.py

@ -99,3 +99,6 @@ class PlasmaModifiersSpecialMenu(ModifierButtonsPanel, bpy.types.Menu):
layout.separator()
layout.operator("object.plasma_modifier_copy", icon="COPYDOWN", text="Copy Modifiers").active_modifier = -1
layout.operator("object.plasma_modifier_paste", icon="PASTEDOWN", text="Paste Modifier(s)")
layout.separator()
layout.operator("object.plasma_modifier_reset", text="Reset Modifiers", icon="FILE_REFRESH").active_modifier = -1
layout.operator("object.plasma_modifier_remove", text="Remove Modifiers", icon="X").active_modifier = -1

Loading…
Cancel
Save