Skip to content

Commit

Permalink
feat: add extrusion mode option to solidify operator
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-hm committed Jun 24, 2022
1 parent 9fdd252 commit 5011a6f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions extrusion/solidify.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ def modal(self, context, event):
elif pressed(event, {'W'}):
self.weighting = self.weighting + 1 if self.weighting < 1 else -1
self.dirty = True

elif pressed(event, {'M'}):
self.complex_mode = not self.complex_mode
self.dirty = True

elif self.key_increase_factor:
if no_stream(self.thickness_input_stream) and self.key_no_modifiers:
Expand Down Expand Up @@ -142,6 +146,8 @@ def invoke(self, context, event):
self.base_thickness_factor = 0.01
self.base_offset_factor = 0.001

self.complex_mode = False

self.thickness_input_stream = new_stream()
self.offset_input_stream = new_stream()

Expand Down Expand Up @@ -192,6 +198,7 @@ def summon_old_operator(self, context, mods):

self.thickness_prev = self.thickness = self.solidify.thickness
self.weighting_prev = self.weighting = self.solidify.offset
self.complex_mode_prev = self.complex_mode = (self.solidify.solidify_mode == 'NON_MANIFOLD')
self.offset_prev = self.offset = self.displace.strength


Expand All @@ -213,13 +220,15 @@ def add_solidify_modifier(self, context):
solidify = context.active_object.modifiers.new(mod_solidify, 'SOLIDIFY')
solidify.use_even_offset = True
solidify.show_expanded = False
solidify.nonmanifold_thickness_mode = 'EVEN'

self.solidify = solidify


def operate(self, context):
self.solidify.thickness = self.thickness
self.solidify.offset = self.weighting
self.solidify.solidify_mode = 'NON_MANIFOLD' if self.complex_mode else 'EXTRUDE'
self.displace.strength = self.offset

self.dirty = False
Expand All @@ -237,6 +246,7 @@ def revert(self, context):
if self.summoned:
self.solidify.thickness = self.thickness_prev
self.solidify.offset = self.weighting_prev
self.solidify.solidify_mode = 'NON_MANIFOLD' if self.complex_mode_prev else 'EXTRUDE'
self.displace.strength = self.offset_prev

unregister_draw_handler()
Expand Down Expand Up @@ -268,6 +278,11 @@ def draw_text_callback(self):
"Weighting [W]: {}".format(['Negative', 'Neutral', 'Positive'][1 + round(self.weighting)]),
"Negative, Neutral, Positive")

draw_hint(
self,
"Mode [M]: {}".format("Complex" if self.complex_mode else "Simple"),
"Extrusion Algorithm (Simple, Complex)")


def register():
bpy.utils.register_class(ND_OT_solidify)
Expand Down

0 comments on commit 5011a6f

Please sign in to comment.