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