-
Notifications
You must be signed in to change notification settings - Fork 40
/
mi_linear_deformer_curve.py
586 lines (471 loc) · 25.6 KB
/
mi_linear_deformer_curve.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
# ***** BEGIN GPL LICENSE BLOCK *****
#
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ***** END GPL LICENCE BLOCK *****
import bpy
from bpy.props import *
from bpy.types import Operator, AddonPreferences
from bpy_extras import view3d_utils
from mathutils import Vector, Matrix
from . import mi_utils_base as ut_base
from . import mi_widget_linear_deform as l_widget
from . import mi_inputs
def linear_deform_button(self, context):
layout = self.layout
layout.operator("mira.linear_deformer_curve", text="linear deformer")
# Linear Deformer Settings
class MI_LDeformer_Settings(bpy.types.PropertyGroup):
manual_update: BoolProperty(default=False)
class MI_OT_Linear_Deformer(bpy.types.Operator):
"""Draw a line with the mouse"""
bl_idname = "mira.linear_deformer_curve"
bl_label = "LinearDeformerCurve"
bl_description = "Linear Deformer Curve"
bl_options = {'REGISTER', 'UNDO'}
# curve tool mode
tool_modes = ('IDLE', 'MOVE_POINT', 'DRAW_TOOL', 'SCALE_ALL', 'SCALE_FRONT', 'MOVE_ALL', 'TWIST', 'TAPE', 'ROTATE_ALL', 'BEND_ALL', 'BEND_SPIRAL')
tool_mode = 'IDLE'
manipulator = None
do_update = None
lw_tool = None
lw_tool_axis = None
active_lw_point = None
deform_mouse_pos = None
deform_vec_pos = None
bend_scale_len = None
start_work_center = None
pointsCurv = None
apply_tool_verts = None
bmCurvePoints ={}
# history
h_undo = None
h_redo = None
def get_selected_points(self,curveData):
points = []
for polyline in curveData.splines: # for strand point
if polyline.type == 'NURBS' or polyline.type == 'POLY':
points += [p for p in polyline.points if p.select]
else:
points += [p for p in polyline.bezier_points if p.select_control_point]
return points
def get_not_hidden_points(self,curveData):
points = []
for polyline in curveData.splines: # for strand point
if polyline.type == 'NURBS' or polyline.type == 'POLY':
points += [p for p in polyline.points if p.hide is False]
else:
points += [p for p in polyline.bezier_points if p.hide is False]
return points
def get_points(self,curveData):
points = []
for polyline in curveData.splines: # for strand point
if polyline.type == 'NURBS' or polyline.type == 'POLY':
points += [p for p in polyline.points]
else:
points += [p for p in polyline.bezier_points]
return points
def invoke(self, context, event):
reset_params(self)
if context.area.type == 'VIEW_3D':
# the arguments we pass the the callbackection
args = (self, context)
active_obj = context.active_object
# bm = bmesh.from_edit_mesh(active_obj.data)
curveData = active_obj.data
points = self.get_points(curveData)
for i,point in enumerate(points):
self.bmCurvePoints[i]=point
if points:
pre_work_points = self.get_selected_points(curveData)
if not pre_work_points:
pre_work_points = self.get_not_hidden_points(curveData)
if pre_work_points:
self.start_work_center = ut_base.get_vertices_center(pre_work_points, active_obj, False) #works ok on curve it seems
# self.work_verts_ids = [vert.index for vert in pre_work_points] #TODO: change it, curve points have no ids
self.pointsCurv = pre_work_points #TODO: change it, curve points have no ids
# add original vert to history
add_history(pre_work_points, self.h_undo)
# change manipulator
self.manipulator = context.space_data.show_gizmo
context.space_data.show_gizmo = False
# Add the region OpenGL drawing callback
# draw in view space with 'POST_VIEW' and 'PRE_VIEW'
# self.lin_deform_handle_3d = bpy.types.SpaceView3D.draw_handler_add(lin_def_draw_3d, args, 'WINDOW', 'POST_VIEW')
self.lin_deform_handle_2d = bpy.types.SpaceView3D.draw_handler_add(lin_def_draw_2d, args, 'WINDOW', 'POST_PIXEL')
context.window_manager.modal_handler_add(self)
return {'RUNNING_MODAL'}
else:
self.report({'WARNING'}, "No verts!!")
return {'CANCELLED'}
else:
self.report({'WARNING'}, "No verts!!")
return {'CANCELLED'}
else:
self.report({'WARNING'}, "View3D not found, cannot run operator")
return {'CANCELLED'}
def modal(self, context, event):
context.area.tag_redraw()
preferences = context.preferences
addon_prefs = preferences.addons[__package__].preferences
lin_def_settings = context.scene.mi_ldeformer_settings
region = context.region
rv3d = context.region_data
m_coords = event.mouse_region_x, event.mouse_region_y
active_obj = context.active_object
# bm = bmesh.from_edit_mesh(active_obj.data)
# update check
if lin_def_settings.manual_update is True:
if event.type == 'U':
if event.value == 'PRESS':
self.do_update = True
else:
self.do_update = False
else:
self.do_update = True
# tooltip
tooltip_text = None
if lin_def_settings.manual_update is True and self.tool_mode not in {'IDLE', 'MOVE_POINT'}:
tooltip_text = "Press U key to udate!"
else:
tooltip_text = "I:Invert, Z:Z-Constraint, X:X-Constraint, S:Scale, Shift-S:ScaleForward, G:Move, R:Rotate, B:Bend, Shift-B:BendSpiral, T:Tape, Shift-T:Twist, Ctrl+Z:Undo, Ctrl+Shift+Z:Redo"
context.area.header_text_set(tooltip_text)
keys_pass = mi_inputs.get_input_pass(mi_inputs.pass_keys, addon_prefs.key_inputs, event)
# key pressed
if self.tool_mode == 'IDLE' and event.value == 'PRESS' and keys_pass is False:
if event.type in {'LEFTMOUSE', 'SELECTMOUSE'}:
if self.lw_tool:
# pick linear widget point
picked_point = l_widget.pick_lw_point(context, m_coords, self.lw_tool)
if picked_point:
self.deform_mouse_pos = Vector(m_coords)
self.active_lw_point = picked_point
self.tool_mode = 'MOVE_POINT'
else:
picked_point = ut_base.get_mouse_on_plane(context, self.start_work_center, None, m_coords)
if picked_point:
self.lw_tool = l_widget.MI_Linear_Widget()
self.lw_tool.start_point = l_widget.MI_LW_Point(picked_point.copy())
self.lw_tool.middle_point = l_widget.MI_LW_Point(picked_point.copy())
self.lw_tool.end_point = l_widget.MI_LW_Point(picked_point)
self.active_lw_point = self.lw_tool.end_point
self.tool_mode = 'MOVE_POINT'
elif event.type in {'S', 'G', 'R', 'B', 'T'}:
# set tool type
if event.type == 'S':
if event.shift:
self.tool_mode = 'SCALE_FRONT'
else:
self.tool_mode = 'SCALE_ALL'
elif event.type == 'R':
self.tool_mode = 'ROTATE_ALL'
elif event.type == 'G':
self.tool_mode = 'MOVE_ALL'
elif event.type == 'B':
if event.shift:
self.tool_mode = 'BEND_SPIRAL'
else:
self.tool_mode = 'BEND_ALL'
elif event.type == 'T':
if event.shift:
self.tool_mode = 'TWIST'
else:
self.tool_mode = 'TAPE'
# get tool verts
if self.tool_mode in {'SCALE_FRONT', 'TAPE'}:
# do not clamp for SCALE_FRONT mode
self.apply_tool_verts = l_widget.get_tool_verts_curv(self.lw_tool, self.pointsCurv, active_obj, False, True)
else:
self.apply_tool_verts = l_widget.get_tool_verts_curv(self.lw_tool, self.pointsCurv, active_obj, True, True)
# set some settings for tools
if self.tool_mode in {'SCALE_ALL', 'SCALE_FRONT', 'TAPE'}:
self.deform_mouse_pos = Vector(m_coords)
elif self.tool_mode == 'MOVE_ALL':
mouse_pos_3d = ut_base.get_mouse_on_plane(context, self.lw_tool.start_point.position, None, m_coords)
self.deform_vec_pos = mouse_pos_3d # 3d location
elif self.tool_mode in {'ROTATE_ALL', 'TWIST', 'BEND_ALL', 'BEND_SPIRAL'}:
start_2d = view3d_utils.location_3d_to_region_2d(region, rv3d, self.lw_tool.start_point.position)
self.deform_vec_pos = (Vector(m_coords) - start_2d).normalized() # 2d direction
self.deform_mouse_pos = 0.0 # we will use it as angle counter
if self.tool_mode in {'BEND_SPIRAL', 'BEND_ALL'}:
self.bend_scale_len = (Vector(m_coords) - start_2d).length
#return {'RUNNING_MODAL'}
elif event.type in {'Z', 'X'} and self.lw_tool:
if event.type == 'Z' and event.ctrl:
if event.shift:
redo_history(self.h_undo, self.h_redo, active_obj)
else:
undo_history(self.h_undo, self.h_redo, active_obj)
else:
pre_verts = [p for p in self.pointsCurv]
if event.type == 'X':
if self.lw_tool_axis:
if self.lw_tool_axis == 'X':
l_widget.setup_lw_tool(rv3d, self.lw_tool, active_obj, pre_verts, 'X_Left', 1.0)
self.lw_tool_axis = 'X_Left'
elif self.lw_tool_axis == 'X_Left':
l_widget.setup_lw_tool(rv3d, self.lw_tool, active_obj, pre_verts, 'X_Right', 1.0)
## revert direction
#stp = self.lw_tool.start_point.position.copy()
#self.lw_tool.start_point.position = self.lw_tool.end_point.position
#self.lw_tool.end_point.position = stp
self.lw_tool_axis = 'X_Right'
elif self.lw_tool_axis == 'X_Right':
l_widget.setup_lw_tool(rv3d, self.lw_tool, active_obj, pre_verts, 'X', 1.0)
self.lw_tool_axis = 'X'
else:
l_widget.setup_lw_tool(rv3d, self.lw_tool, active_obj, pre_verts, 'X', 1.0)
self.lw_tool_axis = 'X'
else:
l_widget.setup_lw_tool(rv3d, self.lw_tool, active_obj, pre_verts, 'X', 1.0)
self.lw_tool_axis = 'X'
else:
if self.lw_tool_axis:
if self.lw_tool_axis == 'Z':
l_widget.setup_lw_tool(rv3d, self.lw_tool, active_obj, pre_verts, 'Z_Top', 1.0)
self.lw_tool_axis = 'Z_Top'
elif self.lw_tool_axis == 'Z_Top':
l_widget.setup_lw_tool(rv3d, self.lw_tool, active_obj, pre_verts, 'Z_Bottom', 1.0)
## revert direction
#stp = self.lw_tool.start_point.position.copy()
#self.lw_tool.start_point.position = self.lw_tool.end_point.position
#self.lw_tool.end_point.position = stp
self.lw_tool_axis = 'Z_Bottom'
elif self.lw_tool_axis == 'Z_Bottom':
l_widget.setup_lw_tool(rv3d, self.lw_tool, active_obj, pre_verts, 'Z', 1.0)
self.lw_tool_axis = 'Z'
else:
l_widget.setup_lw_tool(rv3d, self.lw_tool, active_obj, pre_verts, 'Z', 1.0)
self.lw_tool_axis = 'Z'
else:
l_widget.setup_lw_tool(rv3d, self.lw_tool, active_obj, pre_verts, 'Z', 1.0)
self.lw_tool_axis = 'Z'
elif event.type == 'I' and self.lw_tool:
start_copy = self.lw_tool.start_point.position.copy()
self.lw_tool.start_point.position = self.lw_tool.end_point.position
self.lw_tool.end_point.position = start_copy
# TOOL WORK!
if self.tool_mode == 'MOVE_POINT':
if event.value == 'RELEASE':
self.tool_mode = 'IDLE'
return {'RUNNING_MODAL'}
else:
# move points
new_point_pos = ut_base.get_mouse_on_plane(context, self.active_lw_point.position, None, m_coords)
if self.active_lw_point.position == self.lw_tool.start_point.position or self.active_lw_point.position == self.lw_tool.end_point.position:
self.active_lw_point.position = new_point_pos
l_widget.update_middle_point(self.lw_tool)
elif self.active_lw_point.position == self.lw_tool.middle_point.position:
self.lw_tool.start_point.position += new_point_pos - self.active_lw_point.position
self.lw_tool.end_point.position += new_point_pos - self.active_lw_point.position
self.lw_tool.middle_point.position = new_point_pos
return {'RUNNING_MODAL'}
elif self.tool_mode in {'SCALE_ALL', 'SCALE_FRONT', 'TAPE'}:
if event.value == 'RELEASE' and event.type in {'LEFTMOUSE', 'SELECTMOUSE'}:
# add to undo history
self.h_redo.clear()
pre_work_verts = [p for p in self.pointsCurv]
add_history(pre_work_verts, self.h_undo)
self.tool_mode = 'IDLE'
elif self.do_update:
# move points
start_point_2d = view3d_utils.location_3d_to_region_2d(region, rv3d, self.lw_tool.start_point.position)
if start_point_2d:
tool_dist = (start_point_2d - self.deform_mouse_pos).length
now_dist = (start_point_2d - Vector(m_coords)).length
apply_value = (now_dist - tool_dist) / tool_dist
if apply_value != 0.0:
tool_orig = active_obj.matrix_world.inverted() @ self.lw_tool.start_point.position
tool_end = active_obj.matrix_world.inverted() @ self.lw_tool.end_point.position
tool_vec = tool_end - tool_orig
tool_dir = (tool_end - tool_orig).normalized()
for vert_data in self.apply_tool_verts:
scale_vec = None
scale_value = vert_data[1]
if self.tool_mode == 'SCALE_ALL':
scale_vec = (vert_data[2].resized(3) - tool_orig)
elif self.tool_mode == 'SCALE_FRONT':
scale_vec = (tool_end - tool_orig)
else:
# TAPE
scale_vec = vert_data[2].resized(3) - ( tool_orig + (tool_dir * vert_data[1] * (tool_vec).length) )
scale_value = min(1.0, vert_data[1])
out = vert_data[2].resized(3) + ( scale_vec * (scale_value * apply_value))
out.resize_4d()
vert_data[0].co = out
#bm.normal_update()
# bmesh.update_edit_mesh(active_obj.data)
self.do_update = False
return {'RUNNING_MODAL'}
elif self.tool_mode == 'MOVE_ALL':
if event.value == 'RELEASE' and event.type in {'LEFTMOUSE', 'SELECTMOUSE'}:
# add to undo history
self.h_redo.clear()
pre_work_verts = [p for p in self.pointsCurv]
add_history(pre_work_verts, self.h_undo)
self.tool_mode = 'IDLE'
elif self.do_update:
mouse_pos_3d = ut_base.get_mouse_on_plane(context, self.lw_tool.start_point.position, None, m_coords)
mouse_pos_3d = active_obj.matrix_world.inverted() @ mouse_pos_3d
start_pos = active_obj.matrix_world.inverted() @ self.lw_tool.start_point.position
orig_pos = active_obj.matrix_world.inverted() @ self.deform_vec_pos
orig_vec = orig_pos - start_pos
move_vec = (mouse_pos_3d - start_pos) - orig_vec
for vert_data in self.apply_tool_verts:
move_value = vert_data[1]
vert_data[0].co.xyz = vert_data[2] + (move_vec * move_value)
#bm.normal_update()
# bmesh.update_edit_mesh(active_obj.data)
self.do_update = False
return {'RUNNING_MODAL'}
elif self.tool_mode in {'ROTATE_ALL', 'TWIST', 'BEND_ALL', 'BEND_SPIRAL'}:
if event.value == 'RELEASE' and event.type in {'LEFTMOUSE', 'SELECTMOUSE'}:
# add to undo history
self.h_redo.clear()
pre_work_verts = [p for p in self.pointsCurv]
add_history(pre_work_verts, self.h_undo)
self.tool_mode = 'IDLE'
elif self.do_update:
m_coords = Vector(m_coords) # convert into vector for operations
start_2d = view3d_utils.location_3d_to_region_2d(region, rv3d, self.lw_tool.start_point.position)
new_vec_dir = (m_coords - start_2d).normalized()
rot_angle = new_vec_dir.angle(self.deform_vec_pos)
start_3d = self.lw_tool.start_point.position
end_3d = self.lw_tool.end_point.position
if rot_angle != 0.0:
# check for left or right direction to rotate
vec_check_1 = Vector((new_vec_dir[0], new_vec_dir[1], 0))
vec_check_2 = Vector((new_vec_dir[0]-self.deform_vec_pos[0], new_vec_dir[1]-self.deform_vec_pos[1], 0))
checker_side_dir = vec_check_1.cross(vec_check_2).normalized()[2]
if checker_side_dir > 0.0:
rot_angle = -rot_angle
start_pos = self.lw_tool.start_point.position
rot_dir = None
if self.tool_mode == 'ROTATE_FRONT' or self.tool_mode == 'TWIST':
# ROTATE_FRONT code
rot_dir = (end_3d - start_3d).normalized()
else:
rot_dir = (rv3d.view_rotation @ Vector((0.0, 0.0, -1.0))).normalized()
rot_angle += self.deform_mouse_pos # add rot angle
bend_side_dir = None
faloff_len = None
spiral_value = 0.0 # only for BEND_SPIRAL
bend_scale_value = 1.0 # only for BEND_ALL
if self.tool_mode == 'BEND_ALL' or self.tool_mode == 'BEND_SPIRAL':
bend_side_dir = (((end_3d - start_3d).normalized()).cross(rot_dir)).normalized()
faloff_len = end_3d - start_3d
if self.tool_mode == 'BEND_SPIRAL':
val_scale = None
if rot_angle > 0.0:
val_scale = ( 1.0 - ( (m_coords - start_2d).length / self.bend_scale_len) )
else:
val_scale = ( ( (m_coords - start_2d).length / self.bend_scale_len) )
spiral_value = 1.0 - ( faloff_len.length * val_scale )
else:
val_scale = ( ( (m_coords - start_2d).length / self.bend_scale_len) )
bend_scale_value = (( val_scale) )
do_bend = False
if self.tool_mode == 'BEND_ALL' or self.tool_mode == 'BEND_SPIRAL':
do_bend = True
for vert_data in self.apply_tool_verts:
apply_value = vert_data[1]
final_apply_value = rot_angle * apply_value
# do rotation
if final_apply_value != 0.0:
rot_mat = Matrix.Rotation(final_apply_value, 3, rot_dir)
vert = vert_data[0]
if do_bend:
vert_temp = (active_obj.matrix_world @ vert_data[2].resized(3)) - ((faloff_len) * apply_value)
back_offset = (((faloff_len).length / (final_apply_value)) + spiral_value) * (apply_value * bend_scale_value)
vert_temp += bend_side_dir * back_offset
vert.co.xyz = vert_temp.xyz
else:
# set original position
vert.co[0] = vert_data[2][0]
vert.co[1] = vert_data[2][1]
vert.co[2] = vert_data[2][2]
# ROTATE VERTS!
if do_bend:
vert.co.xyz = rot_mat @ ( (vert.co.xyz) - start_pos) + start_pos
back_offset = ((faloff_len).length / (final_apply_value)) * (apply_value * bend_scale_value)
vert.co.xyz = active_obj.matrix_world.inverted() @ ( vert.co.xyz - (bend_side_dir * back_offset))
else:
vert.co.xyz = active_obj.matrix_world.inverted() @ (rot_mat @ ( (active_obj.matrix_world @ vert.co.xyz) - start_pos) + start_pos)
self.deform_vec_pos = new_vec_dir
self.deform_mouse_pos = rot_angle # set new angle rotation for next step
#bm.normal_update()
# bmesh.update_edit_mesh(active_obj.data)
self.do_update = False
return {'RUNNING_MODAL'}
else:
if event.value == 'RELEASE' and event.type in {'LEFTMOUSE', 'SELECTMOUSE'}:
self.tool_mode = 'IDLE'
return {'RUNNING_MODAL'}
# get keys
if keys_pass is True:
# allow navigation
return {'PASS_THROUGH'}
elif event.type in {'RIGHTMOUSE', 'ESC'}:
context.space_data.show_gizmo = self.manipulator
# bpy.types.SpaceView3D.draw_handler_remove(self.lin_deform_handle_3d, 'WINDOW')
bpy.types.SpaceView3D.draw_handler_remove(self.lin_deform_handle_2d, 'WINDOW')
context.area.header_text_set(None)
return {'FINISHED'}
return {'RUNNING_MODAL'}
def reset_params(self):
self.tool_mode = 'IDLE'
self.manipulator = None
self.deform_mouse_pos = None
self.deform_vec_pos = None
self.bend_scale_len = None
self.do_update = False
self.lw_tool = None
self.lw_tool_axis = None
self.active_lw_point = None
self.start_work_center = None
self.work_verts = None
self.apply_tool_verts = None
self.h_undo = []
self.h_redo = []
def add_history(verts, h_undo):
history = []
for vert in verts:
history.append( (vert, vert.co.copy()) )
h_undo.append(history)
def undo_history(h_undo, h_redo, active_obj):
if h_undo:
pre_history = h_undo[-1]
if len(h_undo) > 1: # 0 index is always original verts
h_undo.remove(pre_history)
h_redo.append(pre_history)
history = h_undo[-1]
for h_vert in history:
h_vert[0].co = h_vert[1].copy()
def redo_history(h_undo, h_redo, active_obj):
if h_redo:
history = h_redo[-1]
for h_vert in history:
h_vert[0].co = h_vert[1].copy()
h_redo.remove(history)
h_undo.append(history)
def lin_def_draw_2d(self, context):
# active_obj = context.active_object
rv3d = context.region_data
if self.lw_tool:
lw_dir = (self.lw_tool.start_point.position - self.lw_tool.end_point.position).normalized()
cam_view = (rv3d.view_rotation @ Vector((0.0, 0.0, -1.0))).normalized()
side_dir = lw_dir.cross(cam_view).normalized()
l_widget.draw_lw(context, self.lw_tool, side_dir, True)