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