Update scripts to account for removal of the context override to bpy.ops
[blender-addons.git] / mesh_tissue / tissue_properties.py
blobdf33dfbc202dc3bc7765e45ee7b681a984893eae
1 # SPDX-License-Identifier: GPL-2.0-or-later
3 # ---------------------------- ADAPTIVE DUPLIFACES --------------------------- #
4 # ------------------------------- version 0.84 ------------------------------- #
5 # #
6 # Creates duplicates of selected mesh to active morphing the shape according #
7 # to target faces. #
8 # #
9 # (c) Alessandro Zomparelli #
10 # (2017) #
11 # #
12 # http://www.co-de-it.com/ #
13 # #
14 # ############################################################################ #
16 import bpy
17 from bpy.types import (
18 Operator,
19 Panel,
20 PropertyGroup,
22 from bpy.props import (
23 BoolProperty,
24 EnumProperty,
25 FloatProperty,
26 IntProperty,
27 StringProperty,
28 PointerProperty
30 from . import config
33 def update_dependencies(ob, objects):
34 type = ob.tissue.tissue_type
35 if type == 'NONE': return objects
36 if ob.tissue.bool_dependencies:
37 deps = get_deps(ob)
38 for o in deps:
39 if o.tissue.tissue_type == 'NONE' or o.tissue.bool_lock or o in objects:
40 continue
41 objects.append(o)
42 objects = update_dependencies(o, objects)
43 return objects
45 def get_deps(ob):
46 type = ob.tissue.tissue_type
47 if type == 'TESSELLATE':
48 return [ob.tissue_tessellate.generator, ob.tissue_tessellate.component]
49 elif type == 'TO_CURVE':
50 return [ob.tissue_to_curve.object]
51 else: return []
53 def anim_tessellate_active(self, context):
54 ob = context.object
55 props = ob.tissue_tessellate
56 if not (ob.tissue.bool_lock or props.bool_hold):
57 try:
58 props.generator.name
59 if props.component_mode == 'OBJECT':
60 props.component.name
61 elif props.component_mode == 'COLLECTION':
62 props.component_coll.name
63 bpy.ops.object.tissue_update_tessellate()
64 except: pass
66 def anim_tessellate_object(ob):
67 try:
68 #bpy.context.view_layer.objects.active = ob
69 bpy.ops.object.tissue_update_tessellate()
70 except:
71 return None
73 #from bpy.app.handlers import persistent
76 def anim_tessellate(scene, depsgraph=None):
77 print('Tissue: animating tessellations...')
79 #config.evaluatedDepsgraph = depsgraph
81 try:
82 active_object = bpy.context.object
83 old_mode = bpy.context.object.mode
84 selected_objects = bpy.context.selected_objects
85 except: active_object = old_mode = selected_objects = None
87 if old_mode in ('OBJECT', 'PAINT_WEIGHT'):
88 update_objects = []
89 for ob in scene.objects:
90 if ob.tissue.bool_run and not ob.tissue.bool_lock:
91 if ob not in update_objects: update_objects.append(ob)
92 update_objects = list(reversed(update_dependencies(ob, update_objects)))
93 for ob in update_objects:
94 #override = {'object': ob}
95 for window in bpy.context.window_manager.windows:
96 screen = window.screen
97 for area in screen.areas:
98 if area.type == 'VIEW_3D':
99 override = bpy.context.copy()
100 override['window'] = window
101 override['screen'] = screen
102 override['area'] = area
103 override['selected_objects'] = [ob]
104 override['object'] = ob
105 override['active_object'] = ob
106 override['selected_editable_objects'] = [ob]
107 override['mode'] = 'OBJECT'
108 override['view_layer'] = scene.view_layers[0]
109 break
110 if ob.tissue.tissue_type == 'TESSELLATE':
111 bpy.ops.object.tissue_update_tessellate(override)
112 elif ob.tissue.tissue_type == 'TO_CURVE':
113 bpy.ops.object.tissue_convert_to_curve_update(override)
115 if old_mode != None:
116 objects = bpy.context.view_layer.objects
117 objects.active = active_object
118 for o in objects: o.select_set(o in selected_objects)
119 bpy.ops.object.mode_set(mode=old_mode)
121 config.evaluatedDepsgraph = None
122 print('end')
123 return
125 def OLD_anim_tessellate(scene, depsgraph):
126 print('Tissue: animating tessellations...')
128 #global evaluatedDepsgraph
129 #print(evaluatedDepsgraph)
130 print(config.evaluatedDepsgraph)
131 config.evaluatedDepsgraph = depsgraph
132 print(config.evaluatedDepsgraph)
134 try:
135 active_object = bpy.context.object
136 old_mode = bpy.context.object.mode
137 selected_objects = bpy.context.selected_objects
138 except: active_object = old_mode = selected_objects = None
140 if old_mode in ('OBJECT', 'PAINT_WEIGHT') or True:
141 update_objects = []
142 for ob in scene.objects:
143 if ob.tissue.bool_run and not ob.tissue.bool_lock:
144 if ob not in update_objects: update_objects.append(ob)
145 update_objects = list(reversed(update_dependencies(ob, update_objects)))
146 for ob in update_objects:
147 for window in bpy.context.window_manager.windows:
148 screen = window.screen
149 for area in screen.areas:
150 if area.type == 'VIEW_3D':
151 override = bpy.context.copy()
152 override['window'] = window
153 override['screen'] = screen
154 override['area'] = area
155 override['selected_objects'] = [ob]
156 override['object'] = ob
157 override['active_object'] = ob
158 override['selected_editable_objects'] = [ob]
159 override['mode'] = 'OBJECT'
160 override['view_layer'] = scene.view_layers[0]
161 break
162 bpy.ops.object.tissue_update_tessellate(override)
164 config.evaluatedDepsgraph = None
165 print('end')
166 print(config.evaluatedDepsgraph)
167 return
169 def remove_tessellate_handler():
170 tissue_handlers = []
171 blender_handlers = bpy.app.handlers.frame_change_post
172 for h in blender_handlers:
173 if "anim_tessellate" in str(h):
174 tissue_handlers.append(h)
175 for h in tissue_handlers: blender_handlers.remove(h)
177 def set_tessellate_handler(self, context):
179 remove_tessellate_handler()
180 for o in context.scene.objects:
181 if o.tissue.bool_run:
182 blender_handlers = bpy.app.handlers.frame_change_post
183 blender_handlers.append(anim_tessellate)
184 break
185 return
188 class tissue_prop(PropertyGroup):
189 bool_lock : BoolProperty(
190 name="Lock",
191 description="Prevent automatic update on settings changes or if other objects have it in the hierarchy",
192 default=False
194 bool_dependencies : BoolProperty(
195 name="Update Dependencies",
196 description="Automatically updates source objects, when possible",
197 default=False
199 bool_run : BoolProperty(
200 name="Animatable",
201 description="Automatically recompute the geometry when the frame is changed. Tessellations may not work using the default Render Animation",
202 default = False,
203 update = set_tessellate_handler
205 tissue_type : EnumProperty(
206 items=(
207 ('NONE', "None", ""),
208 ('TESSELLATE', "Tessellate", ""),
209 ('TO_CURVE', "To Curve", "")
211 default='NONE',
212 name=""
215 class tissue_tessellate_prop(PropertyGroup):
216 bool_hold : BoolProperty(
217 name="Hold",
218 description="Wait...",
219 default=False
221 zscale : FloatProperty(
222 name="Scale", default=1, soft_min=0, soft_max=10,
223 description="Scale factor for the component thickness",
224 update = anim_tessellate_active
226 component_mode : EnumProperty(
227 items=(
228 ('OBJECT', "Object", "Use the same component object for all the faces"),
229 ('COLLECTION', "Collection", "Use multiple components from Collection"),
230 ('MATERIALS', "Materials", "Use multiple components by materials name")
232 default='OBJECT',
233 name="Component Mode",
234 update = anim_tessellate_active
236 scale_mode : EnumProperty(
237 items=(
238 ('CONSTANT', "Constant", "Uniform thinkness"),
239 ('ADAPTIVE', "Relative", "Preserve component's proportions")
241 default='ADAPTIVE',
242 name="Z-Scale according to faces size",
243 update = anim_tessellate_active
245 offset : FloatProperty(
246 name="Surface Offset",
247 default=1,
248 min=-1,
249 max=1,
250 soft_min=-1,
251 soft_max=1,
252 description="Surface offset",
253 update = anim_tessellate_active
255 mode : EnumProperty(
256 items=(
257 ('BOUNDS', "Bounds", "The component fits automatically the size of the target face"),
258 ('LOCAL', "Local", "Based on Local coordinates, from 0 to 1"),
259 ('GLOBAL', 'Global', "Based on Global coordinates, from 0 to 1")),
260 default='BOUNDS',
261 name="Component Mode",
262 update = anim_tessellate_active
264 rotation_mode : EnumProperty(
265 items=(('RANDOM', "Random", "Random faces rotation"),
266 ('UV', "Active UV", "Rotate according to UV coordinates"),
267 ('WEIGHT', "Weight Gradient", "Rotate according to Vertex Group gradient"),
268 ('DEFAULT', "Default", "Default rotation")),
269 default='DEFAULT',
270 name="Component Rotation",
271 update = anim_tessellate_active
273 rotation_direction : EnumProperty(
274 items=(('ORTHO', "Orthogonal", "Component main directions in XY"),
275 ('DIAG', "Diagonal", "Component main direction aligned with diagonal")),
276 default='ORTHO',
277 name="Direction",
278 update = anim_tessellate_active
280 rotation_shift : IntProperty(
281 name="Shift",
282 default=0,
283 soft_min=0,
284 soft_max=3,
285 description="Shift components rotation",
286 update = anim_tessellate_active
288 fill_mode : EnumProperty(
289 items=(
290 ('TRI', 'Tri', 'Triangulate the base mesh'),
291 ('QUAD', 'Quad', 'Regular quad tessellation. Uses only 3 or 4 vertices'),
292 ('FAN', 'Fan', 'Radial tessellation for polygonal faces'),
293 ('PATCH', 'Patch', 'Curved tessellation according to the last ' +
294 'Subsurf\n(or Multires) modifiers. Works only with 4 sides ' +
295 'patches.\nAfter the last Subsurf (or Multires) only ' +
296 'deformation\nmodifiers can be used'),
297 ('FRAME', 'Frame', 'Tessellation along the edges of each face')),
298 default='QUAD',
299 name="Fill Mode",
300 update = anim_tessellate_active
302 combine_mode : EnumProperty(
303 items=(
304 ('LAST', 'Last', 'Show only the last iteration'),
305 ('UNUSED', 'Unused', 'Combine each iteration with the unused faces of the previous iteration. Used for branching systems'),
306 ('ALL', 'All', 'Combine the result of all iterations')),
307 default='LAST',
308 name="Combine Mode",
309 update = anim_tessellate_active
311 gen_modifiers : BoolProperty(
312 name="Generator Modifiers",
313 default=True,
314 description="Apply Modifiers and Shape Keys to the base object",
315 update = anim_tessellate_active
317 com_modifiers : BoolProperty(
318 name="Component Modifiers",
319 default=True,
320 description="Apply Modifiers and Shape Keys to the component object",
321 update = anim_tessellate_active
323 merge : BoolProperty(
324 name="Merge",
325 default=False,
326 description="Merge vertices in adjacent duplicates",
327 update = anim_tessellate_active
329 merge_open_edges_only : BoolProperty(
330 name="Open edges only",
331 default=False,
332 description="Merge only open edges",
333 update = anim_tessellate_active
335 merge_thres : FloatProperty(
336 name="Distance",
337 default=0.0001,
338 soft_min=0,
339 soft_max=10,
340 description="Limit below which to merge vertices",
341 update = anim_tessellate_active
343 generator : PointerProperty(
344 type=bpy.types.Object,
345 name="",
346 description="Base object for the tessellation",
347 update = anim_tessellate_active
349 component : PointerProperty(
350 type=bpy.types.Object,
351 name="",
352 description="Component object for the tessellation",
353 #default="",
354 update = anim_tessellate_active
356 component_coll : PointerProperty(
357 type=bpy.types.Collection,
358 name="",
359 description="Use objects inside the collection",
360 #default="",
361 update = anim_tessellate_active
363 target : PointerProperty(
364 type=bpy.types.Object,
365 name="",
366 description="Target object for custom direction",
367 #default="",
368 update = anim_tessellate_active
370 even_thickness : BoolProperty(
371 name="Even Thickness",
372 default=False,
373 description="Iterative sampling method for determine the correct length of the vectors (Experimental)",
374 update = anim_tessellate_active
376 even_thickness_iter : IntProperty(
377 name="Even Thickness Iterations",
378 default=3,
379 min = 1,
380 soft_max = 20,
381 description="More iterations produces more accurate results but make the tessellation slower",
382 update = anim_tessellate_active
384 bool_random : BoolProperty(
385 name="Randomize",
386 default=False,
387 description="Randomize component rotation",
388 update = anim_tessellate_active
390 rand_seed : IntProperty(
391 name="Seed",
392 default=0,
393 soft_min=0,
394 soft_max=50,
395 description="Random seed",
396 update = anim_tessellate_active
398 coll_rand_seed : IntProperty(
399 name="Seed",
400 default=0,
401 soft_min=0,
402 soft_max=50,
403 description="Random seed",
404 update = anim_tessellate_active
406 rand_step : IntProperty(
407 name="Steps",
408 default=1,
409 min=1,
410 soft_max=2,
411 description="Random step",
412 update = anim_tessellate_active
414 bool_vertex_group : BoolProperty(
415 name="Map Vertex Group",
416 default=False,
417 description="Transfer all Vertex Groups from Base object",
418 update = anim_tessellate_active
420 bool_selection : BoolProperty(
421 name="On selected Faces",
422 default=False,
423 description="Create Tessellation only on selected faces",
424 update = anim_tessellate_active
426 bool_shapekeys : BoolProperty(
427 name="Use Shape Keys",
428 default=False,
429 description="Transfer Component's Shape Keys. If the name of Vertex "
430 "Groups and Shape Keys are the same, they will be "
431 "automatically combined",
432 update = anim_tessellate_active
434 bool_smooth : BoolProperty(
435 name="Smooth Shading",
436 default=False,
437 description="Output faces with smooth shading rather than flat shaded",
438 update = anim_tessellate_active
440 bool_materials : BoolProperty(
441 name="Transfer Materials",
442 default=False,
443 description="Preserve component's materials",
444 update = anim_tessellate_active
446 bool_material_id : BoolProperty(
447 name="Tessellation on Material ID",
448 default=False,
449 description="Apply the component only on the selected Material",
450 update = anim_tessellate_active
452 material_id : IntProperty(
453 name="Index",
454 default=0,
455 min=0,
456 description="Only the faces with the chosen Material Index will be used",
457 update = anim_tessellate_active
459 bool_dissolve_seams : BoolProperty(
460 name="Dissolve Seams",
461 default=False,
462 description="Dissolve all seam edges",
463 update = anim_tessellate_active
465 iterations : IntProperty(
466 name="Iterations",
467 default=1,
468 min=1,
469 soft_max=5,
470 description="Automatically repeat the Tessellation using the "
471 + "generated geometry as new base object.\nUsefull for "
472 + "for branching systems. Dangerous!",
473 update = anim_tessellate_active
475 bool_combine : BoolProperty(
476 name="Combine unused",
477 default=False,
478 description="Combine the generated geometry with unused faces",
479 update = anim_tessellate_active
481 bool_advanced : BoolProperty(
482 name="Advanced Settings",
483 default=False,
484 description="Show more settings"
486 normals_mode : EnumProperty(
487 items=(
488 ('VERTS', 'Normals', 'Consistent direction based on vertices normal'),
489 ('FACES', 'Faces', 'Based on individual faces normal'),
490 ('CUSTOM', 'Custom', 'Custom split normals'),
491 ('SHAPEKEYS', 'Keys', "According to base object's shape keys"),
492 ('OBJECT', 'Object', "According to a target object")),
493 default='VERTS',
494 name="Direction",
495 update = anim_tessellate_active
497 error_message : StringProperty(
498 name="Error Message",
499 default=""
501 warning_message : StringProperty(
502 name="Warning Message",
503 default=""
505 warning_message_thickness : StringProperty(
506 name="Warning Message Thickness",
507 default=""
509 warning_message_merge : StringProperty(
510 name="Warning Message Merge",
511 default=""
513 bounds_x : EnumProperty(
514 items=(
515 ('EXTEND', 'Extend', 'Default X coordinates'),
516 ('CLIP', 'Clip', 'Trim out of bounds in X direction'),
517 ('CYCLIC', 'Cyclic', 'Cyclic components in X direction')),
518 default='EXTEND',
519 name="Bounds X",
520 update = anim_tessellate_active
522 bounds_y : EnumProperty(
523 items=(
524 ('EXTEND', 'Extend', 'Default Y coordinates'),
525 ('CLIP', 'Clip', 'Trim out of bounds in Y direction'),
526 ('CYCLIC', 'Cyclic', 'Cyclic components in Y direction')),
527 default='EXTEND',
528 name="Bounds Y",
529 update = anim_tessellate_active
531 close_mesh : EnumProperty(
532 items=(
533 ('NONE', 'None', 'Keep the mesh open'),
534 ('CAP', 'Cap Holes', 'Automatically cap open loops'),
535 ('BRIDGE', 'Bridge Open Loops', 'Automatically bridge loop pairs'),
536 ('BRIDGE_CAP', 'Custom', 'Bridge loop pairs and cap holes according to vertex groups')),
537 default='NONE',
538 name="Close Mesh",
539 update = anim_tessellate_active
541 cap_faces : BoolProperty(
542 name="Cap Holes",
543 default=False,
544 description="Cap open edges loops",
545 update = anim_tessellate_active
547 frame_boundary : BoolProperty(
548 name="Frame Boundary",
549 default=False,
550 description="Support face boundaries",
551 update = anim_tessellate_active
553 fill_frame : BoolProperty(
554 name="Fill Frame",
555 default=False,
556 description="Fill inner faces with Fan tessellation",
557 update = anim_tessellate_active
559 boundary_mat_offset : IntProperty(
560 name="Material Offset",
561 default=0,
562 description="Material Offset for boundaries (with Multi Components or Material ID)",
563 update = anim_tessellate_active
565 fill_frame_mat : IntProperty(
566 name="Material Offset",
567 default=0,
568 description="Material Offset for inner faces (with Multi Components or Material ID)",
569 update = anim_tessellate_active
571 open_edges_crease : FloatProperty(
572 name="Open Edges Crease",
573 default=0,
574 min=0,
575 max=1,
576 description="Automatically set crease for open edges",
577 update = anim_tessellate_active
579 bridge_edges_crease : FloatProperty(
580 name="Bridge Edges Crease",
581 default=0,
582 min=0,
583 max=1,
584 description="Automatically set crease for bridge edges",
585 update = anim_tessellate_active
587 bridge_smoothness : FloatProperty(
588 name="Smoothness",
589 default=1,
590 min=0,
591 max=1,
592 description="Bridge Smoothness",
593 update = anim_tessellate_active
595 frame_thickness : FloatProperty(
596 name="Frame Thickness",
597 default=0.2,
598 min=0,
599 soft_max=2,
600 description="Frame Thickness",
601 update = anim_tessellate_active
603 frame_mode : EnumProperty(
604 items=(
605 ('CONSTANT', 'Constant', 'Even thickness'),
606 ('RELATIVE', 'Relative', 'Frame offset depends on face areas')),
607 default='CONSTANT',
608 name="Offset",
609 update = anim_tessellate_active
611 bridge_cuts : IntProperty(
612 name="Cuts",
613 default=0,
614 min=0,
615 max=20,
616 description="Bridge Cuts",
617 update = anim_tessellate_active
619 cap_material_offset : IntProperty(
620 name="Material Offset",
621 default=0,
622 min=0,
623 description="Material index offset for the cap faces",
624 update = anim_tessellate_active
626 bridge_material_offset : IntProperty(
627 name="Material Offset",
628 default=0,
629 min=0,
630 description="Material index offset for the bridge faces",
631 update = anim_tessellate_active
633 patch_subs : IntProperty(
634 name="Patch Subdivisions",
635 default=0,
636 min=0,
637 description="Subdivisions levels for Patch tessellation after the first iteration",
638 update = anim_tessellate_active
640 use_origin_offset : BoolProperty(
641 name="Align to Origins",
642 default=False,
643 description="Define offset according to components origin and local Z coordinate",
644 update = anim_tessellate_active
647 vertex_group_thickness : StringProperty(
648 name="Thickness weight", default='',
649 description="Vertex Group used for thickness",
650 update = anim_tessellate_active
652 invert_vertex_group_thickness : BoolProperty(
653 name="Invert", default=False,
654 description="Invert the vertex group influence",
655 update = anim_tessellate_active
657 vertex_group_thickness_factor : FloatProperty(
658 name="Factor",
659 default=0,
660 min=0,
661 max=1,
662 description="Thickness factor to use for zero vertex group influence",
663 update = anim_tessellate_active
666 vertex_group_cap_owner : EnumProperty(
667 items=(
668 ('BASE', 'Base', 'Use base vertex group'),
669 ('COMP', 'Component', 'Use component vertex group')),
670 default='COMP',
671 name="Source",
672 update = anim_tessellate_active
674 vertex_group_cap : StringProperty(
675 name="Cap Vertex Group", default='',
676 description="Vertex Group used for cap open edges",
677 update = anim_tessellate_active
679 invert_vertex_group_cap : BoolProperty(
680 name="Invert", default=False,
681 description="Invert the vertex group influence",
682 update = anim_tessellate_active
685 vertex_group_bridge_owner : EnumProperty(
686 items=(
687 ('BASE', 'Base', 'Use base vertex group'),
688 ('COMP', 'Component', 'Use component vertex group')),
689 default='COMP',
690 name="Source",
691 update = anim_tessellate_active
693 vertex_group_bridge : StringProperty(
694 name="Bridge Vertex Group", default='',
695 description="Vertex Group used for bridge open edges",
696 update = anim_tessellate_active
698 invert_vertex_group_bridge : BoolProperty(
699 name="Invert", default=False,
700 description="Invert the vertex group influence",
701 update = anim_tessellate_active
704 vertex_group_rotation : StringProperty(
705 name="Rotation weight", default='',
706 description="Vertex Group used for rotation",
707 update = anim_tessellate_active
709 invert_vertex_group_rotation : BoolProperty(
710 name="Invert", default=False,
711 description="Invert the vertex group influence",
712 update = anim_tessellate_active
714 smooth_normals : BoolProperty(
715 name="Smooth Normals", default=False,
716 description="Smooth normals of the surface in order to reduce intersections",
717 update = anim_tessellate_active
719 smooth_normals_iter : IntProperty(
720 name="Iterations",
721 default=5,
722 min=0,
723 description="Smooth iterations",
724 update = anim_tessellate_active
726 smooth_normals_uv : FloatProperty(
727 name="UV Anisotropy",
728 default=0,
729 min=-1,
730 max=1,
731 description="0 means no anisotropy, -1 represent the U direction, while 1 represent the V direction",
732 update = anim_tessellate_active
734 vertex_group_smooth_normals : StringProperty(
735 name="Smooth normals weight", default='',
736 description="Vertex Group used for smooth normals",
737 update = anim_tessellate_active
739 invert_vertex_group_smooth_normals : BoolProperty(
740 name="Invert", default=False,
741 description="Invert the vertex group influence",
742 update = anim_tessellate_active
745 vertex_group_distribution : StringProperty(
746 name="Distribution weight", default='',
747 description="Vertex Group used for gradient distribution",
748 update = anim_tessellate_active
750 invert_vertex_group_distribution : BoolProperty(
751 name="Invert", default=False,
752 description="Invert the vertex group influence",
753 update = anim_tessellate_active
755 vertex_group_distribution_factor : FloatProperty(
756 name="Factor",
757 default=0,
758 min=0,
759 max=1,
760 description="Randomness factor to use for zero vertex group influence",
761 update = anim_tessellate_active
763 consistent_wedges : BoolProperty(
764 name="Consistent Wedges", default=True,
765 description="Use same component for the wedges generated by the Fan tessellation",
766 update = anim_tessellate_active
768 normals_x : FloatProperty(
769 name="X", default=1, min=0, max=1,
770 description="Scale X component of the normals",
771 update = anim_tessellate_active
773 normals_y : FloatProperty(
774 name="Y", default=1, min=0, max=1,
775 description="Scale Y component of the normals",
776 update = anim_tessellate_active
778 normals_z : FloatProperty(
779 name="Z", default=1, min=0, max=1,
780 description="Scale Z component of the normals",
781 update = anim_tessellate_active
783 vertex_group_scale_normals : StringProperty(
784 name="Scale normals weight", default='',
785 description="Vertex Group used for editing the normals directions",
786 update = anim_tessellate_active
788 invert_vertex_group_scale_normals : BoolProperty(
789 name="Invert", default=False,
790 description="Invert the vertex group influence",
791 update = anim_tessellate_active
793 boundary_variable_offset : BoolProperty(
794 name="Boundary Variable Offset", default=False,
795 description="Additional material offset based on the number of boundary vertices",
796 update = anim_tessellate_active
798 auto_rotate_boundary : BoolProperty(
799 name="Automatic Rotation", default=False,
800 description="Automatically rotate the boundary faces",
801 update = anim_tessellate_active
804 def store_parameters(operator, ob):
805 ob.tissue_tessellate.bool_hold = True
806 if operator.generator in bpy.data.objects.keys():
807 ob.tissue_tessellate.generator = bpy.data.objects[operator.generator]
808 if operator.component in bpy.data.objects.keys():
809 ob.tissue_tessellate.component = bpy.data.objects[operator.component]
810 if operator.component_coll in bpy.data.collections.keys():
811 ob.tissue_tessellate.component_coll = bpy.data.collections[operator.component_coll]
812 if operator.target in bpy.data.objects.keys():
813 ob.tissue_tessellate.target = bpy.data.objects[operator.target]
814 ob.tissue_tessellate.even_thickness = operator.even_thickness
815 ob.tissue_tessellate.even_thickness_iter = operator.even_thickness_iter
816 ob.tissue_tessellate.zscale = operator.zscale
817 ob.tissue_tessellate.offset = operator.offset
818 ob.tissue_tessellate.gen_modifiers = operator.gen_modifiers
819 ob.tissue_tessellate.com_modifiers = operator.com_modifiers
820 ob.tissue_tessellate.mode = operator.mode
821 ob.tissue_tessellate.rotation_mode = operator.rotation_mode
822 ob.tissue_tessellate.rotation_shift = operator.rotation_shift
823 ob.tissue_tessellate.rotation_direction = operator.rotation_direction
824 ob.tissue_tessellate.merge = operator.merge
825 ob.tissue_tessellate.merge_open_edges_only = operator.merge_open_edges_only
826 ob.tissue_tessellate.merge_thres = operator.merge_thres
827 ob.tissue_tessellate.scale_mode = operator.scale_mode
828 ob.tissue_tessellate.bool_random = operator.bool_random
829 ob.tissue_tessellate.rand_seed = operator.rand_seed
830 ob.tissue_tessellate.coll_rand_seed = operator.coll_rand_seed
831 ob.tissue_tessellate.rand_step = operator.rand_step
832 ob.tissue_tessellate.fill_mode = operator.fill_mode
833 ob.tissue_tessellate.bool_vertex_group = operator.bool_vertex_group
834 ob.tissue_tessellate.bool_selection = operator.bool_selection
835 ob.tissue_tessellate.bool_shapekeys = operator.bool_shapekeys
836 ob.tissue_tessellate.bool_smooth = operator.bool_smooth
837 ob.tissue_tessellate.bool_materials = operator.bool_materials
838 ob.tissue_tessellate.bool_material_id = operator.bool_material_id
839 ob.tissue_tessellate.material_id = operator.material_id
840 ob.tissue_tessellate.bool_dissolve_seams = operator.bool_dissolve_seams
841 ob.tissue_tessellate.iterations = operator.iterations
842 ob.tissue_tessellate.bool_advanced = operator.bool_advanced
843 ob.tissue_tessellate.normals_mode = operator.normals_mode
844 ob.tissue_tessellate.bool_combine = operator.bool_combine
845 ob.tissue_tessellate.combine_mode = operator.combine_mode
846 ob.tissue_tessellate.bounds_x = operator.bounds_x
847 ob.tissue_tessellate.bounds_y = operator.bounds_y
848 ob.tissue_tessellate.cap_faces = operator.cap_faces
849 ob.tissue_tessellate.close_mesh = operator.close_mesh
850 ob.tissue_tessellate.bridge_cuts = operator.bridge_cuts
851 ob.tissue_tessellate.bridge_smoothness = operator.bridge_smoothness
852 ob.tissue_tessellate.frame_thickness = operator.frame_thickness
853 ob.tissue_tessellate.frame_mode = operator.frame_mode
854 ob.tissue_tessellate.frame_boundary = operator.frame_boundary
855 ob.tissue_tessellate.fill_frame = operator.fill_frame
856 ob.tissue_tessellate.boundary_mat_offset = operator.boundary_mat_offset
857 ob.tissue_tessellate.fill_frame_mat = operator.fill_frame_mat
858 ob.tissue_tessellate.cap_material_offset = operator.cap_material_offset
859 ob.tissue_tessellate.patch_subs = operator.patch_subs
860 ob.tissue_tessellate.use_origin_offset = operator.use_origin_offset
861 ob.tissue_tessellate.vertex_group_thickness = operator.vertex_group_thickness
862 ob.tissue_tessellate.invert_vertex_group_thickness = operator.invert_vertex_group_thickness
863 ob.tissue_tessellate.vertex_group_thickness_factor = operator.vertex_group_thickness_factor
864 ob.tissue_tessellate.vertex_group_distribution = operator.vertex_group_distribution
865 ob.tissue_tessellate.invert_vertex_group_distribution = operator.invert_vertex_group_distribution
866 ob.tissue_tessellate.vertex_group_distribution_factor = operator.vertex_group_distribution_factor
867 ob.tissue_tessellate.vertex_group_cap_owner = operator.vertex_group_cap_owner
868 ob.tissue_tessellate.vertex_group_cap = operator.vertex_group_cap
869 ob.tissue_tessellate.invert_vertex_group_cap = operator.invert_vertex_group_cap
870 ob.tissue_tessellate.vertex_group_bridge_owner = operator.vertex_group_bridge_owner
871 ob.tissue_tessellate.vertex_group_bridge = operator.vertex_group_bridge
872 ob.tissue_tessellate.invert_vertex_group_bridge = operator.invert_vertex_group_bridge
873 ob.tissue_tessellate.vertex_group_rotation = operator.vertex_group_rotation
874 ob.tissue_tessellate.invert_vertex_group_rotation = operator.invert_vertex_group_rotation
875 ob.tissue_tessellate.smooth_normals = operator.smooth_normals
876 ob.tissue_tessellate.smooth_normals_iter = operator.smooth_normals_iter
877 ob.tissue_tessellate.smooth_normals_uv = operator.smooth_normals_uv
878 ob.tissue_tessellate.vertex_group_smooth_normals = operator.vertex_group_smooth_normals
879 ob.tissue_tessellate.invert_vertex_group_smooth_normals = operator.invert_vertex_group_smooth_normals
880 ob.tissue_tessellate.component_mode = operator.component_mode
881 ob.tissue_tessellate.consistent_wedges = operator.consistent_wedges
882 ob.tissue_tessellate.normals_x = operator.normals_x
883 ob.tissue_tessellate.normals_y = operator.normals_y
884 ob.tissue_tessellate.normals_z = operator.normals_z
885 ob.tissue_tessellate.vertex_group_scale_normals = operator.vertex_group_scale_normals
886 ob.tissue_tessellate.invert_vertex_group_scale_normals = operator.invert_vertex_group_scale_normals
887 ob.tissue_tessellate.boundary_variable_offset = operator.boundary_variable_offset
888 ob.tissue_tessellate.auto_rotate_boundary = operator.auto_rotate_boundary
889 ob.tissue_tessellate.bool_hold = False
890 return ob
892 def load_parameters(operator, ob):
893 operator.generator = ob.tissue_tessellate.generator.name
894 operator.component = ob.tissue_tessellate.component.name
895 operator.component_coll = ob.tissue_tessellate.component_coll.name
896 operator.zscale = ob.tissue_tessellate.zscale
897 operator.offset = ob.tissue_tessellate.offset
898 operator.gen_modifiers = ob.tissue_tessellate.gen_modifiers
899 operator.com_modifiers = ob.tissue_tessellate.com_modifiers
900 operator.mode = ob.tissue_tessellate.mode
901 operator.rotation_mode = ob.tissue_tessellate.rotation_mode
902 operator.rotation_shift = ob.tissue_tessellate.rotation_shift
903 operator.rotation_direction = ob.tissue_tessellate.rotation_direction
904 operator.merge = ob.tissue_tessellate.merge
905 operator.merge_open_edges_only = ob.tissue_tessellate.merge_open_edges_only
906 operator.merge_thres = ob.tissue_tessellate.merge_thres
907 operator.scale_mode = ob.tissue_tessellate.scale_mode
908 operator.bool_random = ob.tissue_tessellate.bool_random
909 operator.rand_seed = ob.tissue_tessellate.rand_seed
910 operator.coll_rand_seed = ob.tissue_tessellate.coll_rand_seed
911 operator.rand_step = ob.tissue_tessellate.rand_step
912 operator.fill_mode = ob.tissue_tessellate.fill_mode
913 operator.bool_vertex_group = ob.tissue_tessellate.bool_vertex_group
914 operator.bool_selection = ob.tissue_tessellate.bool_selection
915 operator.bool_shapekeys = ob.tissue_tessellate.bool_shapekeys
916 operator.bool_smooth = ob.tissue_tessellate.bool_smooth
917 operator.bool_materials = ob.tissue_tessellate.bool_materials
918 operator.bool_material_id = ob.tissue_tessellate.bool_material_id
919 operator.material_id = ob.tissue_tessellate.material_id
920 operator.bool_dissolve_seams = ob.tissue_tessellate.bool_dissolve_seams
921 operator.iterations = ob.tissue_tessellate.iterations
922 operator.bool_advanced = ob.tissue_tessellate.bool_advanced
923 operator.normals_mode = ob.tissue_tessellate.normals_mode
924 operator.bool_combine = ob.tissue_tessellate.bool_combine
925 operator.combine_mode = ob.tissue_tessellate.combine_mode
926 operator.bounds_x = ob.tissue_tessellate.bounds_x
927 operator.bounds_y = ob.tissue_tessellate.bounds_y
928 operator.cap_faces = ob.tissue_tessellate.cap_faces
929 operator.close_mesh = ob.tissue_tessellate.close_mesh
930 operator.bridge_cuts = ob.tissue_tessellate.bridge_cuts
931 operator.bridge_smoothness = ob.tissue_tessellate.bridge_smoothness
932 operator.cap_material_offset = ob.tissue_tessellate.cap_material_offset
933 operator.patch_subs = ob.tissue_tessellate.patch_subs
934 operator.frame_boundary = ob.tissue_tessellate.frame_boundary
935 operator.fill_frame = ob.tissue_tessellate.fill_frame
936 operator.boundary_mat_offset = ob.tissue_tessellate.boundary_mat_offset
937 operator.fill_frame_mat = ob.tissue_tessellate.fill_frame_mat
938 operator.frame_thickness = ob.tissue_tessellate.frame_thickness
939 operator.frame_mode = ob.tissue_tessellate.frame_mode
940 operator.use_origin_offset = ob.tissue_tessellate.use_origin_offset
941 operator.vertex_group_thickness = ob.tissue_tessellate.vertex_group_thickness
942 operator.invert_vertex_group_thickness = ob.tissue_tessellate.invert_vertex_group_thickness
943 operator.vertex_group_thickness_factor = ob.tissue_tessellate.vertex_group_thickness_factor
944 operator.vertex_group_distribution = ob.tissue_tessellate.vertex_group_distribution
945 operator.invert_vertex_group_distribution = ob.tissue_tessellate.invert_vertex_group_distribution
946 operator.vertex_group_distribution_factor = ob.tissue_tessellate.vertex_group_distribution_factor
947 operator.vertex_group_cap_owner = ob.tissue_tessellate.vertex_group_cap_owner
948 operator.vertex_group_cap = ob.tissue_tessellate.vertex_group_cap
949 operator.invert_vertex_group_cap = ob.tissue_tessellate.invert_vertex_group_cap
950 operator.vertex_group_bridge_owner = ob.tissue_tessellate.vertex_group_bridge_owner
951 operator.vertex_group_bridge = ob.tissue_tessellate.vertex_group_bridge
952 operator.invert_vertex_group_bridge = ob.tissue_tessellate.invert_vertex_group_bridge
953 operator.vertex_group_rotation = ob.tissue_tessellate.vertex_group_rotation
954 operator.invert_vertex_group_rotation = ob.tissue_tessellate.invert_vertex_group_rotation
955 operator.smooth_normals = ob.tissue_tessellate.smooth_normals
956 operator.smooth_normals_iter = ob.tissue_tessellate.smooth_normals_iter
957 operator.smooth_normals_uv = ob.tissue_tessellate.smooth_normals_uv
958 operator.vertex_group_smooth_normals = ob.tissue_tessellate.vertex_group_smooth_normals
959 operator.invert_vertex_group_smooth_normals = ob.tissue_tessellate.invert_vertex_group_smooth_normals
960 operator.component_mode = ob.tissue_tessellate.component_mode
961 operator.consistent_wedges = ob.tissue_tessellate.consistent_wedges
962 operator.normals_x = ob.tissue_tessellate.normals_x
963 operator.normals_y = ob.tissue_tessellate.normals_y
964 operator.normals_z = ob.tissue_tessellate.normals_z
965 operator.vertex_group_scale_normals = ob.tissue_tessellate.vertex_group_scale_normals
966 operator.invert_vertex_group_scale_normals = ob.tissue_tessellate.invert_vertex_group_scale_normals
967 operator.boundary_variable_offset = ob.tissue_tessellate.boundary_variable_offset
968 operator.auto_rotate_boundary = ob.tissue_tessellate.auto_rotate_boundary
969 return ob
971 def props_to_dict(ob):
972 props = ob.tissue_tessellate
973 tessellate_dict = {}
974 tessellate_dict['self'] = ob
975 tessellate_dict['generator'] = props.generator
976 tessellate_dict['component'] = props.component
977 tessellate_dict['component_coll'] = props.component_coll
978 tessellate_dict['offset'] = props.offset
979 tessellate_dict['zscale'] = props.zscale
980 tessellate_dict['gen_modifiers'] = props.gen_modifiers
981 tessellate_dict['com_modifiers'] = props.com_modifiers
982 tessellate_dict['mode'] = props.mode
983 tessellate_dict['scale_mode'] = props.scale_mode
984 tessellate_dict['rotation_mode'] = props.rotation_mode
985 tessellate_dict['rotation_shift'] = props.rotation_shift
986 tessellate_dict['rotation_direction'] = props.rotation_direction
987 tessellate_dict['rand_seed'] = props.rand_seed
988 tessellate_dict['coll_rand_seed'] = props.coll_rand_seed
989 tessellate_dict['rand_step'] = props.rand_step
990 tessellate_dict['fill_mode'] = props.fill_mode
991 tessellate_dict['bool_vertex_group'] = props.bool_vertex_group
992 tessellate_dict['bool_selection'] = props.bool_selection
993 tessellate_dict['bool_shapekeys'] = props.bool_shapekeys
994 tessellate_dict['bool_material_id'] = props.bool_material_id
995 tessellate_dict['material_id'] = props.material_id
996 tessellate_dict['normals_mode'] = props.normals_mode
997 tessellate_dict['bounds_x'] = props.bounds_x
998 tessellate_dict['bounds_y'] = props.bounds_y
999 tessellate_dict['use_origin_offset'] = props.use_origin_offset
1000 tessellate_dict['target'] = props.target
1001 tessellate_dict['even_thickness'] = props.even_thickness
1002 tessellate_dict['even_thickness_iter'] = props.even_thickness_iter
1003 tessellate_dict['frame_thickness'] = props.frame_thickness
1004 tessellate_dict['frame_mode'] = props.frame_mode
1005 tessellate_dict['frame_boundary'] = props.frame_boundary
1006 tessellate_dict['fill_frame'] = props.fill_frame
1007 tessellate_dict['boundary_mat_offset'] = props.boundary_mat_offset
1008 tessellate_dict['fill_frame_mat'] = props.fill_frame_mat
1009 tessellate_dict['vertex_group_thickness'] = props.vertex_group_thickness
1010 tessellate_dict['invert_vertex_group_thickness'] = props.invert_vertex_group_thickness
1011 tessellate_dict['vertex_group_thickness_factor'] = props.vertex_group_thickness_factor
1012 tessellate_dict['vertex_group_distribution'] = props.vertex_group_distribution
1013 tessellate_dict['invert_vertex_group_distribution'] = props.invert_vertex_group_distribution
1014 tessellate_dict['vertex_group_distribution_factor'] = props.vertex_group_distribution_factor
1015 tessellate_dict['vertex_group_cap_owner'] = props.vertex_group_cap_owner
1016 tessellate_dict['vertex_group_cap'] = props.vertex_group_cap
1017 tessellate_dict['invert_vertex_group_cap'] = props.invert_vertex_group_cap
1018 tessellate_dict['vertex_group_bridge_owner'] = props.vertex_group_bridge_owner
1019 tessellate_dict['vertex_group_bridge'] = props.vertex_group_bridge
1020 tessellate_dict['invert_vertex_group_bridge'] = props.invert_vertex_group_bridge
1021 tessellate_dict['vertex_group_rotation'] = props.vertex_group_rotation
1022 tessellate_dict['invert_vertex_group_rotation'] = props.invert_vertex_group_rotation
1023 tessellate_dict['smooth_normals'] = props.smooth_normals
1024 tessellate_dict['smooth_normals_iter'] = props.smooth_normals_iter
1025 tessellate_dict['smooth_normals_uv'] = props.smooth_normals_uv
1026 tessellate_dict['vertex_group_smooth_normals'] = props.vertex_group_smooth_normals
1027 tessellate_dict['invert_vertex_group_smooth_normals'] = props.invert_vertex_group_smooth_normals
1028 tessellate_dict['component_mode'] = props.component_mode
1029 tessellate_dict['consistent_wedges'] = props.consistent_wedges
1030 tessellate_dict["normals_x"] = props.normals_x
1031 tessellate_dict["normals_y"] = props.normals_y
1032 tessellate_dict["normals_z"] = props.normals_z
1033 tessellate_dict["vertex_group_scale_normals"] = props.vertex_group_scale_normals
1034 tessellate_dict["invert_vertex_group_scale_normals"] = props.invert_vertex_group_scale_normals
1035 tessellate_dict["boundary_variable_offset"] = props.boundary_variable_offset
1036 tessellate_dict["auto_rotate_boundary"] = props.auto_rotate_boundary
1037 return tessellate_dict
1039 def copy_tessellate_props(source_ob, target_ob):
1040 source_props = source_ob.tissue_tessellate
1041 target_props = target_ob.tissue_tessellate
1042 for key in source_props.keys():
1043 target_props[key] = source_props[key]
1044 return