Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions operators/node_relax_brush.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,7 @@ class NodeRelaxBrush(bpy.types.Operator):
bl_idname = "node_relax.brush"
bl_label = "Relax Nodes"

bl_options = {"UNDO", "REGISTER"}

def __init__(self):
self.radius = 100
self.lmb = False
self.delta = mathutils.Vector((0, 0))
self.cursor_pos = mathutils.Vector((0, 0))
self.cursor_prev_pos = mathutils.Vector((0, 0))
self.slide_vec = mathutils.Vector((0, 0))
self. drag_mode = False
self.is_dragging = False
self.dragging_node = None
#bl_options = {"UNDO", "REGISTER"}

@classmethod
def poll(cls, context):
Expand Down Expand Up @@ -120,8 +109,8 @@ def update_dragging_node(self, nodes):
nearest = dist

def finish(self, context, props):
st = bpy.types.SpaceNodeEditor
st.draw_handler_remove(self.draw_handler, 'WINDOW')
bpy.types.SpaceNodeEditor.draw_handler_remove(
self.draw_handler, 'WINDOW')
props.IsRunning = False

def modal(self, context, event):
Expand All @@ -133,7 +122,7 @@ def modal(self, context, event):
if event.type == 'LEFT_SHIFT' or event.type == 'RIGHT_SHIFT': # drag individual node
if event.value == 'PRESS':
self.drag_mode = True
if event.value == 'RELEASE':
elif event.value == 'RELEASE':
self.drag_mode = False
self.is_dragging = False
self.update_dragging_node(self.tree.nodes)
Expand Down Expand Up @@ -187,12 +176,24 @@ def invoke(self, context, event):
if props.IsRunning:
return {'CANCELLED'}

self.some_state = None
self.radius = 100
self.lmb = False
self.delta = mathutils.Vector((0, 0))
self.cursor_pos = mathutils.Vector((0, 0))
self.cursor_prev_pos = mathutils.Vector((0, 0))
self.slide_vec = mathutils.Vector((0, 0))
self.drag_mode = False
self.is_dragging = False
self.dragging_node = None


self.tree = context.space_data.edit_tree
context.window_manager.modal_handler_add(self)
st = bpy.types.SpaceNodeEditor
self.draw_handler = st.draw_handler_add(draw_callback, (self,), 'WINDOW', 'POST_VIEW')
self.draw_handler = bpy.types.SpaceNodeEditor.draw_handler_add(
draw_callback, (self,), 'WINDOW', 'POST_VIEW'
)

self.lmb = False
props.IsRunning = True
self.update_cursor_pos(context, event)
self.update_radius(context, props.BrushSize)
Expand Down