55b891c55f596aaa3ae714855d9eff62d66e0c3b
[blender.git] / release / scripts / startup / bl_ui / properties_particle.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
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.
7 #
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.
12 #
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.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from bpy.types import Panel, Menu
22 from rna_prop_ui import PropertyPanel
23 from bpy.app.translations import pgettext_iface as iface_
24 from bl_operators.presets import PresetMenu
25
26 from .properties_physics_common import (
27     point_cache_ui,
28     effector_weights_ui,
29     basic_force_field_settings_ui,
30     basic_force_field_falloff_ui,
31 )
32
33
34 def particle_panel_enabled(context, psys):
35     if psys is None:
36         return True
37     phystype = psys.settings.physics_type
38     if psys.settings.type in {'EMITTER', 'REACTOR'} and phystype in {'NO', 'KEYED'}:
39         return True
40     else:
41         return (psys.point_cache.is_baked is False) and (not psys.is_edited) and (not context.particle_system_editable)
42
43
44 def particle_panel_poll(cls, context):
45     psys = context.particle_system
46     engine = context.engine
47     settings = 0
48
49     if psys:
50         settings = psys.settings
51     elif isinstance(context.space_data.pin_id, bpy.types.ParticleSettings):
52         settings = context.space_data.pin_id
53
54     if not settings:
55         return False
56
57     return settings.is_fluid is False and (engine in cls.COMPAT_ENGINES)
58
59
60 def particle_get_settings(context):
61     if context.particle_system:
62         return context.particle_system.settings
63     elif isinstance(context.space_data.pin_id, bpy.types.ParticleSettings):
64         return context.space_data.pin_id
65     return None
66
67
68 class PARTICLE_MT_specials(Menu):
69     bl_label = "Particle Specials"
70     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
71
72     def draw(self, context):
73         layout = self.layout
74
75         props = layout.operator(
76             "particle.copy_particle_systems",
77             text="Copy Active to Selected Objects",
78             icon='COPYDOWN',
79         )
80         props.use_active = True
81         props.remove_target_particles = False
82
83         props = layout.operator(
84             "particle.copy_particle_systems",
85             text="Copy All to Selected Objects",
86         )
87         props.use_active = False
88         props.remove_target_particles = True
89
90         layout.separator()
91
92         layout.operator(
93             "particle.duplicate_particle_system",
94             icon='DUPLICATE',
95         )
96
97
98 class PARTICLE_PT_hair_dynamics_presets(PresetMenu):
99     bl_label = "Hair Dynamics Presets"
100     preset_subdir = "hair_dynamics"
101     preset_operator = "script.execute_preset"
102     preset_add_operator = "particle.hair_dynamics_preset_add"
103     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
104
105
106 class ParticleButtonsPanel:
107     bl_space_type = 'PROPERTIES'
108     bl_region_type = 'WINDOW'
109     bl_context = "particle"
110
111     @classmethod
112     def poll(cls, context):
113         return particle_panel_poll(cls, context)
114
115
116 def find_modifier(ob, psys):
117     for md in ob.modifiers:
118         if md.type == 'PARTICLE_SYSTEM':
119             if md.particle_system == psys:
120                 return md
121
122
123 class PARTICLE_UL_particle_systems(bpy.types.UIList):
124
125     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index, flt_flag):
126         ob = data
127         psys = item
128
129         if self.layout_type in {'DEFAULT', 'COMPACT'}:
130             md = find_modifier(ob, psys)
131             row = layout.row(align=True)
132
133             row.prop(psys, "name", text="", emboss=False, icon_value=icon)
134             if md:
135                 row.prop(
136                     md,
137                     "show_viewport",
138                     emboss=False,
139                     icon_only=True,
140                 )
141                 row.prop(
142                     md,
143                     "show_render",
144                     emboss=False,
145                     icon_only=True,
146                 )
147
148         elif self.layout_type == 'GRID':
149             layout.alignment = 'CENTER'
150             layout.label(text="", icon_value=icon)
151
152
153 class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel):
154     bl_label = ""
155     bl_options = {'HIDE_HEADER'}
156     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
157
158     @classmethod
159     def poll(cls, context):
160         engine = context.engine
161         return (context.particle_system or context.object or context.space_data.pin_id) and (engine in cls.COMPAT_ENGINES)
162
163     def draw(self, context):
164         layout = self.layout
165
166         ob = context.object
167         psys = context.particle_system
168         part = 0
169
170         if ob:
171             row = layout.row()
172
173             row.template_list("PARTICLE_UL_particle_systems", "particle_systems", ob, "particle_systems",
174                               ob.particle_systems, "active_index", rows=3)
175
176             col = row.column(align=True)
177             col.operator("object.particle_system_add", icon='ADD', text="")
178             col.operator("object.particle_system_remove", icon='REMOVE', text="")
179
180             col.separator()
181
182             col.menu("PARTICLE_MT_specials", icon='DOWNARROW_HLT', text="")
183
184         if psys is None:
185             part = particle_get_settings(context)
186
187             layout.operator("object.particle_system_add", icon='ADD', text="New")
188
189             if part is None:
190                 return
191
192             layout.template_ID(context.space_data, "pin_id")
193
194             if part.is_fluid:
195                 layout.label(text="Settings used for fluid")
196                 return
197
198             layout.prop(part, "type", text="Type")
199
200         elif not psys.settings:
201             col.template_ID(psys, "settings", new="particle.new")
202         else:
203             part = psys.settings
204
205             col = layout.column()
206
207             if part.is_fluid is False:
208                 row = col.row()
209                 row.enabled = particle_panel_enabled(context, psys)
210                 row.template_ID(psys, "settings", new="particle.new")
211
212             if part.is_fluid:
213                 layout.label(text=iface_("%d fluid particles for this frame") % part.count, translate=False)
214                 return
215
216             row = layout.row()
217             row.enabled = particle_panel_enabled(context, psys)
218             row.prop(part, "type", expand=True)
219
220         if part:
221             split = layout.split()
222             if part.type == 'HAIR':
223                 if psys is not None and psys.is_edited:
224                     split.operator("particle.edited_clear", text="Delete Edit")
225                 else:
226                     row = split.row()
227                     row.enabled = particle_panel_enabled(context, psys)
228                     row.prop(part, "regrow_hair")
229                     row.prop(part, "use_advanced_hair")
230
231                 if psys is not None and psys.is_edited:
232                     if psys.is_global_hair:
233                         row = layout.row(align=True)
234                         row.operator("particle.connect_hair").all = False
235                         row.operator("particle.connect_hair", text="Connect All").all = True
236                     else:
237                         row = layout.row(align=True)
238                         row.operator("particle.disconnect_hair").all = False
239                         row.operator("particle.disconnect_hair", text="Disconnect All").all = True
240             elif psys is not None and part.type == 'REACTOR':
241                 split.enabled = particle_panel_enabled(context, psys)
242                 split.prop(psys, "reactor_target_object")
243                 split.prop(psys, "reactor_target_particle_system", text="Particle System")
244
245
246 class PARTICLE_PT_emission(ParticleButtonsPanel, Panel):
247     bl_label = "Emission"
248     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
249
250     @classmethod
251     def poll(cls, context):
252         psys = context.particle_system
253         settings = particle_get_settings(context)
254
255         if settings is None:
256             return False
257         if settings.is_fluid:
258             return False
259         if particle_panel_poll(PARTICLE_PT_emission, context):
260             return psys is None or not context.particle_system.point_cache.use_external
261         return False
262
263     def draw(self, context):
264         layout = self.layout
265
266         psys = context.particle_system
267         part = particle_get_settings(context)
268
269         layout.use_property_split = True
270
271         layout.enabled = particle_panel_enabled(context, psys) and (psys is None or not psys.has_multiple_caches)
272
273         col = layout.column()
274         col.active = part.emit_from == 'VERT' or part.distribution != 'GRID'
275         col.prop(part, "count")
276         col.prop(psys, "seed")
277
278         if part.type == 'HAIR':
279             col.prop(part, "hair_length")
280             col.prop(part, "hair_step")
281
282         if part.type != 'HAIR':
283
284             col = layout.column()
285
286             sub = col.column(align=True)
287             sub.prop(part, "frame_start", text="Frame Start")
288             sub.prop(part, "frame_end", text="End")
289
290             col.prop(part, "lifetime")
291             col.prop(part, "lifetime_random", slider=True, text="Lifetime Randomness")
292
293
294 class PARTICLE_PT_emission_source(ParticleButtonsPanel, Panel):
295     bl_label = "Source"
296     bl_parent_id = "PARTICLE_PT_emission"
297     bl_options = {'DEFAULT_CLOSED'}
298     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
299
300     def draw(self, context):
301         layout = self.layout
302
303         part = particle_get_settings(context)
304
305         layout.use_property_split = True
306
307         col = layout.column()
308         col.prop(part, "emit_from")
309         col.prop(part, "use_modifier_stack")
310         if part.emit_from == 'FACE' or part.emit_from == 'VOLUME':
311             col.prop(part, "distribution")
312
313         if part.emit_from == 'VERT':
314             col.prop(part, "use_emit_random", text="Random Order")
315         elif part.distribution == 'GRID':
316             col.prop(part, "invert_grid")
317             col.prop(part, "hexagonal_grid")
318         else:
319             col.prop(part, "use_emit_random")
320             col.prop(part, "use_even_distribution")
321
322         if part.emit_from == 'FACE' or part.emit_from == 'VOLUME':
323
324             if part.distribution == 'JIT':
325                 col.prop(part, "userjit", text="Particles/Face")
326                 col.prop(part, "jitter_factor", text="Jittering Amount", slider=True)
327             elif part.distribution == 'GRID':
328                 col.prop(part, "grid_resolution")
329                 col.prop(part, "grid_random", text="Random", slider=True)
330
331
332 class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel):
333     bl_label = "Hair Dynamics"
334     bl_options = {'DEFAULT_CLOSED'}
335     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
336
337     @classmethod
338     def poll(cls, context):
339         psys = context.particle_system
340         engine = context.engine
341         if psys is None:
342             return False
343         if psys.settings is None:
344             return False
345         return psys.settings.type == 'HAIR' and (engine in cls.COMPAT_ENGINES)
346
347     def draw_header(self, context):
348         psys = context.particle_system
349         self.layout.prop(psys, "use_hair_dynamics", text="")
350
351     def draw_header_preset(self, context):
352         psys = context.particle_system
353
354         if not psys.cloth:
355             return
356
357         layout = self.layout
358         layout.enabled = psys.use_hair_dynamics and psys.point_cache.is_baked is False
359         PARTICLE_PT_hair_dynamics_presets.draw_panel_header(layout)
360
361     def draw(self, context):
362         layout = self.layout
363
364         psys = context.particle_system
365
366         if not psys.cloth:
367             layout.label(text="Hair dynamics disabled")
368             return
369
370         cloth_md = psys.cloth
371         cloth = cloth_md.settings
372         result = cloth_md.solver_result
373
374         layout.enabled = psys.use_hair_dynamics and psys.point_cache.is_baked is False
375
376         layout.use_property_split = True
377
378         layout.separator()
379
380         col = layout.column()
381         col.prop(cloth, "quality", text="Quality Steps", slider=True)
382         col.prop(psys.settings, "show_hair_grid", text="Display Hair Grid")
383
384         layout.separator()
385
386         col = layout.column()
387         col.prop(cloth, "pin_stiffness", text="Pin Goal Strength")
388
389         layout.separator()
390
391         if result:
392             box = layout.box()
393
394             if not result.status:
395                 label = " "
396                 icon = 'NONE'
397             elif result.status == {'SUCCESS'}:
398                 label = "Success"
399                 icon = 'NONE'
400             elif result.status - {'SUCCESS'} == {'NO_CONVERGENCE'}:
401                 label = "No Convergence"
402                 icon = 'ERROR'
403             else:
404                 label = "ERROR"
405                 icon = 'ERROR'
406             box.label(text=label, icon=icon)
407             box.label(text="Iterations: %d .. %d (avg. %d)" %
408                       (result.min_iterations, result.max_iterations, result.avg_iterations))
409             box.label(text="Error: %.5f .. %.5f (avg. %.5f)" % (result.min_error, result.max_error, result.avg_error))
410
411
412 class PARTICLE_PT_hair_dynamics_structure(ParticleButtonsPanel, Panel):
413     bl_label = "Structure"
414     bl_parent_id = "PARTICLE_PT_hair_dynamics"
415     bl_options = {'DEFAULT_CLOSED'}
416     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
417
418     @classmethod
419     def poll(cls, context):
420         return context.particle_system.cloth is not None
421
422     def draw(self, context):
423         layout = self.layout
424
425         psys = context.particle_system
426         cloth_md = psys.cloth
427         cloth = cloth_md.settings
428
429         layout.enabled = psys.use_hair_dynamics and psys.point_cache.is_baked is False
430
431         layout.use_property_split = True
432
433         col = layout.column()
434         col.prop(cloth, "mass")
435         sub = col.column(align=True)
436         sub.prop(cloth, "bending_stiffness", text="Stiffness")
437         sub.prop(psys.settings, "bending_random", text="Random")
438         col.prop(cloth, "bending_damping", text="Damping")
439         # XXX has no noticeable effect with stiff hair structure springs
440         #col.prop(cloth, "spring_damping", text="Damping")
441
442
443 class PARTICLE_PT_hair_dynamics_volume(ParticleButtonsPanel, Panel):
444     bl_label = "Volume"
445     bl_parent_id = "PARTICLE_PT_hair_dynamics"
446     bl_options = {'DEFAULT_CLOSED'}
447     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
448
449     @classmethod
450     def poll(cls, context):
451         return context.particle_system.cloth is not None
452
453     def draw(self, context):
454         layout = self.layout
455
456         psys = context.particle_system
457         cloth_md = psys.cloth
458         cloth = cloth_md.settings
459
460         layout.enabled = psys.use_hair_dynamics and psys.point_cache.is_baked is False
461
462         layout.use_property_split = True
463
464         col = layout.column()
465         col.prop(cloth, "air_damping", text="Air Drag")
466         col.prop(cloth, "internal_friction", slider=True)
467         col.prop(cloth, "voxel_cell_size")
468
469         col.separator()
470
471         col.prop(cloth, "density_target", text="Density Target")
472         col.prop(cloth, "density_strength", slider=True, text="Density Strength")
473
474
475 class PARTICLE_PT_cache(ParticleButtonsPanel, Panel):
476     bl_label = "Cache"
477     bl_options = {'DEFAULT_CLOSED'}
478     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
479
480     @classmethod
481     def poll(cls, context):
482         psys = context.particle_system
483         engine = context.engine
484         if psys is None:
485             return False
486         if psys.settings is None:
487             return False
488         if psys.settings.is_fluid:
489             return False
490         phystype = psys.settings.physics_type
491         if phystype == 'NO' or phystype == 'KEYED':
492             return False
493         return (
494             (psys.settings.type in {'EMITTER', 'REACTOR'} or
495              (psys.settings.type == 'HAIR' and
496               (psys.use_hair_dynamics or psys.point_cache.is_baked))) and
497             engine in cls.COMPAT_ENGINES
498         )
499
500     def draw(self, context):
501         psys = context.particle_system
502
503         point_cache_ui(self, context, psys.point_cache, True, 'HAIR' if (psys.settings.type == 'HAIR') else 'PSYS')
504
505
506 class PARTICLE_PT_velocity(ParticleButtonsPanel, Panel):
507     bl_label = "Velocity"
508     bl_options = {'DEFAULT_CLOSED'}
509     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
510
511     @classmethod
512     def poll(cls, context):
513         if particle_panel_poll(PARTICLE_PT_velocity, context):
514             psys = context.particle_system
515             settings = particle_get_settings(context)
516
517             if settings.type == 'HAIR' and not settings.use_advanced_hair:
518                 return False
519             return settings.physics_type != 'BOIDS' and (psys is None or not psys.point_cache.use_external)
520         else:
521             return False
522
523     def draw(self, context):
524         layout = self.layout
525
526         psys = context.particle_system
527         part = particle_get_settings(context)
528
529         layout.enabled = particle_panel_enabled(context, psys)
530         layout.use_property_split = True
531
532         col = layout.column()
533         col.prop(part, "normal_factor")
534         sub = col.column(align=True)
535         sub.prop(part, "tangent_factor", text="Tangent")
536         sub.prop(part, "tangent_phase", slider=True, text="Tangent Phase")
537
538         col.separator()
539
540         col.prop(part, "object_align_factor")
541
542         col.separator()
543
544         if part.emit_from == 'PARTICLE':
545             col.prop(part, "particle_factor")
546         else:
547             col.prop(part, "object_factor", slider=True)
548         col.prop(part, "factor_random", text="Randomize")
549
550         # if part.type=='REACTOR':
551         #     sub.prop(part, "reactor_factor")
552         #     sub.prop(part, "reaction_shape", slider=True)
553
554
555 class PARTICLE_PT_rotation(ParticleButtonsPanel, Panel):
556     bl_label = "Rotation"
557     bl_options = {'DEFAULT_CLOSED'}
558     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
559
560     @classmethod
561     def poll(cls, context):
562         if particle_panel_poll(PARTICLE_PT_rotation, context):
563             psys = context.particle_system
564             settings = particle_get_settings(context)
565
566             if settings.type == 'HAIR' and not settings.use_advanced_hair:
567                 return False
568             return settings.physics_type != 'BOIDS' and (psys is None or not psys.point_cache.use_external)
569         else:
570             return False
571
572     def draw_header(self, context):
573         psys = context.particle_system
574         if psys:
575             part = psys.settings
576         else:
577             part = context.space_data.pin_id
578
579         self.layout.prop(part, "use_rotations", text="")
580
581     def draw(self, context):
582         layout = self.layout
583
584         psys = context.particle_system
585         if psys:
586             part = psys.settings
587         else:
588             part = context.space_data.pin_id
589
590         layout.enabled = particle_panel_enabled(context, psys) and part.use_rotations
591         layout.use_property_split = True
592
593         col = layout.column()
594
595         col.prop(part, "rotation_mode")
596         col.prop(part, "rotation_factor_random", slider=True, text="Randomize")
597
598         col.separator()
599
600         col.prop(part, "phase_factor", slider=True)
601         col.prop(part, "phase_factor_random", text="Randomize Phase ", slider=True)
602
603         if part.type != 'HAIR':
604             col.prop(part, "use_dynamic_rotation")
605
606
607 class PARTICLE_PT_rotation_angular_velocity(ParticleButtonsPanel, Panel):
608     bl_label = "Angular Velocity"
609     bl_parent_id = "PARTICLE_PT_rotation"
610     bl_options = {'DEFAULT_CLOSED'}
611     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
612
613     def draw(self, context):
614         layout = self.layout
615
616         psys = context.particle_system
617         if psys:
618             part = psys.settings
619         else:
620             part = context.space_data.pin_id
621
622         layout.enabled = particle_panel_enabled(context, psys) and part.use_rotations
623         layout.use_property_split = True
624
625         col = layout.column()
626
627         col.prop(part, "angular_velocity_mode", text="Axis")
628         sub = col.column(align=True)
629         sub.active = part.angular_velocity_mode != 'NONE'
630         sub.prop(part, "angular_velocity_factor", text="Amount")
631
632
633 class PARTICLE_PT_physics(ParticleButtonsPanel, Panel):
634     bl_label = "Physics"
635     bl_options = {'DEFAULT_CLOSED'}
636     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
637
638     @classmethod
639     def poll(cls, context):
640         if particle_panel_poll(PARTICLE_PT_physics, context):
641             psys = context.particle_system
642             settings = particle_get_settings(context)
643
644             if settings.type == 'HAIR' and not settings.use_advanced_hair:
645                 return False
646             return psys is None or not psys.point_cache.use_external
647         else:
648             return False
649
650     def draw(self, context):
651         layout = self.layout
652         layout.use_property_split = True
653
654         psys = context.particle_system
655         part = particle_get_settings(context)
656
657         layout.enabled = particle_panel_enabled(context, psys)
658
659         layout.prop(part, "physics_type")
660
661         col = layout.column()
662         if part.physics_type != 'NO':
663             col = col.column()
664             col.prop(part, "mass")
665             col.prop(part, "use_multiply_size_mass", text="Multiply mass with size")
666
667         if part.physics_type == 'FLUID':
668             fluid = part.fluid
669
670             col.separator()
671             col.prop(fluid, "solver")
672             col.prop(fluid, "stiffness", text="Stiffness")
673             col.prop(fluid, "linear_viscosity", text="Viscosity")
674             col.prop(fluid, "buoyancy", text="Buoyancy", slider=True)
675
676         elif part.physics_type == 'KEYED':
677
678             sub = col.column()
679             sub.active = not psys.use_keyed_timing
680             sub.prop(part, "keyed_loops", text="Loops")
681             if psys:
682                 col.prop(psys, "use_keyed_timing", text="Use Timing")
683
684             col.label(text="Keys")
685
686
687 class PARTICLE_PT_physics_fluid_advanced(ParticleButtonsPanel, Panel):
688     bl_label = "Advanced"
689     bl_parent_id = "PARTICLE_PT_physics"
690     bl_options = {'DEFAULT_CLOSED'}
691     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
692
693     @classmethod
694     def poll(cls, context):
695         part = particle_get_settings(context)
696         if part.physics_type == 'FLUID':
697             return True
698         else:
699             return False
700
701     def draw(self, context):
702         layout = self.layout
703         layout.use_property_split = True
704
705         part = particle_get_settings(context)
706         fluid = part.fluid
707
708         col = layout.column()
709
710         if fluid.solver == 'DDR':
711             sub = col.column()
712             sub.prop(fluid, "repulsion", slider=fluid.factor_repulsion)
713             sub.prop(fluid, "factor_repulsion")
714
715             sub.prop(fluid, "stiff_viscosity", slider=fluid.factor_stiff_viscosity)
716             sub.prop(fluid, "factor_stiff_viscosity")
717
718         sub = col.column()
719         sub.prop(fluid, "fluid_radius", slider=fluid.factor_radius)
720         sub.prop(fluid, "factor_radius")
721
722         sub.prop(fluid, "rest_density", slider=fluid.use_factor_density)
723         sub.prop(fluid, "use_factor_density")
724
725         if fluid.solver == 'CLASSICAL':
726             # With the classical solver, it is possible to calculate the
727             # spacing between particles when the fluid is at rest. This
728             # makes it easier to set stable initial conditions.
729             particle_volume = part.mass / fluid.rest_density
730             spacing = pow(particle_volume, 1.0 / 3.0)
731
732             sub.label(text="Spacing: %g" % spacing)
733
734
735 class PARTICLE_PT_physics_fluid_springs(ParticleButtonsPanel, Panel):
736     bl_label = "Springs"
737     bl_parent_id = "PARTICLE_PT_physics"
738     bl_options = {'DEFAULT_CLOSED'}
739     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
740
741     @classmethod
742     def poll(cls, context):
743         part = particle_get_settings(context)
744         fluid = part.fluid
745         if part.physics_type == 'FLUID' and fluid.solver == 'DDR':
746             return True
747         else:
748             return False
749
750     def draw(self, context):
751         layout = self.layout
752         layout.use_property_split = True
753
754         part = particle_get_settings(context)
755         fluid = part.fluid
756
757         col = layout.column()
758
759         col.prop(fluid, "spring_force", text="Force")
760
761
762 class PARTICLE_PT_physics_fluid_springs_viscoelastic(ParticleButtonsPanel, Panel):
763     bl_label = "Viscoelastic Springs"
764     bl_parent_id = "PARTICLE_PT_physics_fluid_springs"
765     bl_options = {'DEFAULT_CLOSED'}
766     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
767
768     @classmethod
769     def poll(cls, context):
770         part = particle_get_settings(context)
771         fluid = part.fluid
772         if part.physics_type == 'FLUID' and fluid.solver == 'DDR':
773             return True
774         else:
775             return False
776
777     def draw_header(self, context):
778         part = particle_get_settings(context)
779         fluid = part.fluid
780
781         self.layout.prop(fluid, "use_viscoelastic_springs", text="")
782
783     def draw(self, context):
784         layout = self.layout
785         layout.use_property_split = True
786
787         part = particle_get_settings(context)
788         fluid = part.fluid
789
790         col = layout.column()
791         col.active = fluid.use_viscoelastic_springs
792         col.prop(fluid, "yield_ratio", slider=True)
793         col.prop(fluid, "plasticity", slider=True)
794
795         col.separator()
796
797         col.prop(fluid, "use_initial_rest_length")
798         col.prop(fluid, "spring_frames", text="Frames")
799
800
801 class PARTICLE_PT_physics_fluid_springs_advanced(ParticleButtonsPanel, Panel):
802     bl_label = "Advanced"
803     bl_parent_id = "PARTICLE_PT_physics_fluid_springs"
804     bl_options = {'DEFAULT_CLOSED'}
805     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
806
807     @classmethod
808     def poll(cls, context):
809         part = particle_get_settings(context)
810         fluid = part.fluid
811         if part.physics_type == 'FLUID' and fluid.solver == 'DDR':
812             return True
813         else:
814             return False
815
816     def draw(self, context):
817         layout = self.layout
818         layout.use_property_split = True
819
820         part = particle_get_settings(context)
821         fluid = part.fluid
822
823         sub = layout.column()
824         sub.prop(fluid, "rest_length", slider=fluid.factor_rest_length)
825         sub.prop(fluid, "factor_rest_length")
826
827
828 class PARTICLE_PT_physics_boids_movement(ParticleButtonsPanel, Panel):
829     bl_label = "Movement"
830     bl_parent_id = "PARTICLE_PT_physics"
831     bl_options = {'DEFAULT_CLOSED'}
832     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
833
834     @classmethod
835     def poll(cls, context):
836         part = particle_get_settings(context)
837         return part.physics_type in {'BOIDS'}
838
839     def draw(self, context):
840         layout = self.layout
841         layout.use_property_split = True
842
843         part = particle_get_settings(context)
844         boids = part.boids
845
846         col = layout.column()
847
848         col.prop(boids, "use_flight")
849         col.prop(boids, "use_land")
850         col.prop(boids, "use_climb")
851
852         col = layout.column()
853
854         col.active = boids.use_flight
855         sub = col.column()
856         sub.prop(boids, "air_speed_max")
857         sub.prop(boids, "air_speed_min", slider=True)
858         col.prop(boids, "air_acc_max", slider=True)
859         col.prop(boids, "air_ave_max", slider=True)
860         col.prop(boids, "air_personal_space")
861         row = col.row(align=True)
862         row.active = (boids.use_land or boids.use_climb) and boids.use_flight
863         row.prop(boids, "land_smooth")
864
865         layout.separator()
866
867         col = layout.column()
868         col.active = boids.use_land or boids.use_climb
869         col.prop(boids, "land_speed_max")
870         col.prop(boids, "land_jump_speed")
871         col.prop(boids, "land_acc_max", slider=True)
872         col.prop(boids, "land_ave_max", slider=True)
873         col.prop(boids, "land_personal_space")
874         col.prop(boids, "land_stick_force")
875
876         layout.separator()
877
878         layout.prop(part, "collision_collection")
879
880
881 class PARTICLE_PT_physics_boids_battle(ParticleButtonsPanel, Panel):
882     bl_label = "Battle"
883     bl_parent_id = "PARTICLE_PT_physics"
884     bl_options = {'DEFAULT_CLOSED'}
885     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
886
887     @classmethod
888     def poll(cls, context):
889         part = particle_get_settings(context)
890         return part.physics_type in {'BOIDS'}
891
892     def draw(self, context):
893         layout = self.layout
894         layout.use_property_split = True
895
896         part = particle_get_settings(context)
897         boids = part.boids
898
899         col = layout.column()
900
901         col.prop(boids, "health")
902         col.prop(boids, "strength")
903         col.prop(boids, "aggression")
904         col.prop(boids, "accuracy")
905         col.prop(boids, "range")
906
907
908 class PARTICLE_PT_physics_boids_misc(ParticleButtonsPanel, Panel):
909     bl_label = "Misc"
910     bl_parent_id = "PARTICLE_PT_physics"
911     bl_options = {'DEFAULT_CLOSED'}
912     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
913
914     @classmethod
915     def poll(cls, context):
916         part = particle_get_settings(context)
917         return part.physics_type in {'BOIDS'}
918
919     def draw(self, context):
920         layout = self.layout
921         layout.use_property_split = True
922
923         part = particle_get_settings(context)
924         boids = part.boids
925
926         col = layout.column()
927
928         col.prop(boids, "bank", slider=True)
929         col.prop(boids, "pitch", slider=True)
930         col.prop(boids, "height", slider=True)
931
932
933 class PARTICLE_PT_physics_relations(ParticleButtonsPanel, Panel):
934     bl_label = "Relations"
935     bl_parent_id = "PARTICLE_PT_physics"
936     bl_options = {'DEFAULT_CLOSED'}
937     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
938
939     @classmethod
940     def poll(cls, context):
941         part = particle_get_settings(context)
942         return part.physics_type in {'KEYED', 'BOIDS', 'FLUID'}
943
944     def draw(self, context):
945         layout = self.layout
946         layout.use_property_split = True
947
948         psys = context.particle_system
949         part = particle_get_settings(context)
950
951         row = layout.row()
952         row.template_list("UI_UL_list", "particle_targets", psys, "targets",
953                           psys, "active_particle_target_index", rows=4)
954
955         col = row.column()
956         sub = col.row()
957         subsub = sub.column(align=True)
958         subsub.operator("particle.new_target", icon='ADD', text="")
959         subsub.operator("particle.target_remove", icon='REMOVE', text="")
960         sub = col.row()
961         subsub = sub.column(align=True)
962         subsub.operator("particle.target_move_up", icon='TRIA_UP', text="")
963         subsub.operator("particle.target_move_down", icon='TRIA_DOWN', text="")
964
965         key = psys.active_particle_target
966
967         if key:
968             if part.physics_type == 'KEYED':
969                 col = layout.column()
970                 # doesn't work yet
971                 #col.alert = key.valid
972                 col.prop(key, "object")
973                 col.prop(key, "system", text="System")
974
975                 col.active = psys.use_keyed_timing
976                 col.prop(key, "time")
977                 col.prop(key, "duration")
978             elif part.physics_type == 'BOIDS':
979                 sub = layout.column()
980                 # doesn't work yet
981                 #sub.alert = key.valid
982                 sub.prop(key, "object")
983                 sub.prop(key, "system", text="System")
984                 layout.prop(key, "alliance")
985             elif part.physics_type == 'FLUID':
986                 sub = layout.column()
987                 # doesn't work yet
988                 #sub.alert = key.valid
989                 sub.prop(key, "object")
990                 sub.prop(key, "system", text="System")
991
992
993 class PARTICLE_PT_physics_deflection(ParticleButtonsPanel, Panel):
994     bl_label = "Deflection"
995     bl_parent_id = "PARTICLE_PT_physics"
996     bl_options = {'DEFAULT_CLOSED'}
997     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
998
999     @classmethod
1000     def poll(cls, context):
1001         part = particle_get_settings(context)
1002         return part.physics_type in {'NEWTON', 'FLUID'}
1003
1004     def draw(self, context):
1005         layout = self.layout
1006         layout.use_property_split = True
1007
1008         psys = context.particle_system
1009         part = particle_get_settings(context)
1010
1011         layout.enabled = particle_panel_enabled(context, psys)
1012
1013         col = layout.column()
1014         col.prop(part, "use_size_deflect")
1015         col.prop(part, "use_die_on_collision")
1016
1017         col.prop(part, "collision_collection")
1018
1019
1020 class PARTICLE_PT_physics_forces(ParticleButtonsPanel, Panel):
1021     bl_label = "Forces"
1022     bl_parent_id = "PARTICLE_PT_physics"
1023     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1024
1025     @classmethod
1026     def poll(cls, context):
1027         part = particle_get_settings(context)
1028         return part.physics_type == 'NEWTON'
1029
1030     def draw(self, context):
1031         layout = self.layout
1032         layout.use_property_split = True
1033
1034         psys = context.particle_system
1035         part = particle_get_settings(context)
1036
1037         layout.enabled = particle_panel_enabled(context, psys)
1038
1039         col = layout.column()
1040
1041         col.prop(part, "brownian_factor")
1042         col.prop(part, "drag_factor", slider=True)
1043         col.prop(part, "damping", slider=True)
1044
1045
1046 class PARTICLE_PT_physics_integration(ParticleButtonsPanel, Panel):
1047     bl_label = "Integration"
1048     bl_options = {'DEFAULT_CLOSED'}
1049     bl_parent_id = "PARTICLE_PT_physics"
1050     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1051
1052     @classmethod
1053     def poll(cls, context):
1054         part = particle_get_settings(context)
1055         return part.physics_type == 'NEWTON'
1056
1057     def draw(self, context):
1058         layout = self.layout
1059         layout.use_property_split = True
1060
1061         psys = context.particle_system
1062         part = particle_get_settings(context)
1063
1064         layout.enabled = particle_panel_enabled(context, psys)
1065
1066         col = layout.column()
1067
1068         col.prop(part, "integrator")
1069         col.prop(part, "timestep")
1070         sub = col.row()
1071         sub.prop(part, "subframes")
1072         supports_courant = part.physics_type == 'FLUID'
1073         subsub = sub.row()
1074         subsub.enabled = supports_courant
1075         subsub.prop(part, "use_adaptive_subframes", text="")
1076         if supports_courant and part.use_adaptive_subframes:
1077             col.prop(part, "courant_target", text="Threshold")
1078
1079
1080 class PARTICLE_PT_boidbrain(ParticleButtonsPanel, Panel):
1081     bl_label = "Boid Brain"
1082     bl_options = {'DEFAULT_CLOSED'}
1083     bl_parent_id = "PARTICLE_PT_physics"
1084
1085     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1086
1087     @classmethod
1088     def poll(cls, context):
1089         psys = context.particle_system
1090         settings = particle_get_settings(context)
1091         engine = context.engine
1092
1093         if settings is None:
1094             return False
1095         if psys is not None and psys.point_cache.use_external:
1096             return False
1097         return settings.physics_type == 'BOIDS' and engine in cls.COMPAT_ENGINES
1098
1099     def draw(self, context):
1100         layout = self.layout
1101
1102         boids = particle_get_settings(context).boids
1103
1104         layout.enabled = particle_panel_enabled(context, context.particle_system)
1105
1106         # Currently boids can only use the first state so these are commented out for now.
1107         #row = layout.row()
1108         # row.template_list("UI_UL_list", "particle_boids", boids, "states",
1109         #                  boids, "active_boid_state_index", compact="True")
1110         #col = row.row()
1111         #sub = col.row(align=True)
1112         #sub.operator("boid.state_add", icon='ADD', text="")
1113         #sub.operator("boid.state_del", icon='REMOVE', text="")
1114         #sub = row.row(align=True)
1115         #sub.operator("boid.state_move_up", icon='TRIA_UP', text="")
1116         #sub.operator("boid.state_move_down", icon='TRIA_DOWN', text="")
1117
1118         state = boids.active_boid_state
1119
1120         #layout.prop(state, "name", text="State name")
1121
1122         row = layout.row()
1123         row.prop(state, "ruleset_type")
1124         if state.ruleset_type == 'FUZZY':
1125             row.prop(state, "rule_fuzzy", slider=True)
1126         else:
1127             row.label(text="")
1128
1129         row = layout.row()
1130         row.template_list("UI_UL_list", "particle_boids_rules", state,
1131                           "rules", state, "active_boid_rule_index", rows=4)
1132
1133         col = row.column()
1134         sub = col.row()
1135         subsub = sub.column(align=True)
1136         subsub.operator_menu_enum("boid.rule_add", "type", icon='ADD', text="")
1137         subsub.operator("boid.rule_del", icon='REMOVE', text="")
1138         sub = col.row()
1139         subsub = sub.column(align=True)
1140         subsub.operator("boid.rule_move_up", icon='TRIA_UP', text="")
1141         subsub.operator("boid.rule_move_down", icon='TRIA_DOWN', text="")
1142
1143         rule = state.active_boid_rule
1144
1145         if rule:
1146             row = layout.row()
1147             row.prop(rule, "name", text="")
1148             # somebody make nice icons for boids here please! -jahka
1149             row.prop(rule, "use_in_air", icon='TRIA_UP', text="")
1150             row.prop(rule, "use_on_land", icon='TRIA_DOWN', text="")
1151
1152             row = layout.row()
1153
1154             if rule.type == 'GOAL':
1155                 row.prop(rule, "object")
1156                 row = layout.row()
1157                 row.prop(rule, "use_predict")
1158             elif rule.type == 'AVOID':
1159                 row.prop(rule, "object")
1160                 row = layout.row()
1161                 row.prop(rule, "use_predict")
1162                 row.prop(rule, "fear_factor")
1163             elif rule.type == 'FOLLOW_PATH':
1164                 row.label(text="Not yet functional")
1165             elif rule.type == 'AVOID_COLLISION':
1166                 row.prop(rule, "use_avoid")
1167                 row.prop(rule, "use_avoid_collision")
1168                 row.prop(rule, "look_ahead")
1169             elif rule.type == 'FOLLOW_LEADER':
1170                 row.prop(rule, "object", text="")
1171                 row.prop(rule, "distance")
1172                 row = layout.row()
1173                 row.prop(rule, "use_line")
1174                 sub = row.row()
1175                 sub.active = rule.line
1176                 sub.prop(rule, "queue_count")
1177             elif rule.type == 'AVERAGE_SPEED':
1178                 row.prop(rule, "speed", slider=True)
1179                 row.prop(rule, "wander", slider=True)
1180                 row.prop(rule, "level", slider=True)
1181             elif rule.type == 'FIGHT':
1182                 row.prop(rule, "distance")
1183                 row.prop(rule, "flee_distance")
1184
1185
1186 class PARTICLE_PT_render(ParticleButtonsPanel, Panel):
1187     bl_label = "Render"
1188     bl_options = {'DEFAULT_CLOSED'}
1189     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1190
1191     @classmethod
1192     def poll(cls, context):
1193         settings = particle_get_settings(context)
1194         engine = context.engine
1195         if settings is None:
1196             return False
1197
1198         return engine in cls.COMPAT_ENGINES
1199
1200     def draw(self, context):
1201         layout = self.layout
1202         layout.use_property_split = True
1203
1204         psys = context.particle_system
1205         part = particle_get_settings(context)
1206
1207         layout.prop(part, "render_type", text="Render As")
1208
1209         if (
1210                 part.type == 'EMITTER' or
1211                 (part.render_type in {'OBJECT', 'COLLECTION'} and part.type == 'HAIR')
1212         ):
1213             if part.render_type not in {'NONE'}:
1214
1215                 col = layout.column(align=True)
1216                 col.prop(part, "particle_size", text="Scale")
1217                 col.prop(part, "size_random", slider=True, text="Scale Randomness")
1218
1219         if psys:
1220             col = layout.column()
1221             if part.render_type not in {'OBJECT', 'COLLECTION', 'NONE'}:
1222                 # col.enabled = False
1223                 col.prop(part, "material_slot", text="Material")
1224                 col.prop(psys, "parent", text="Coordinate System")
1225
1226         if context.object:
1227             layout.separator()
1228             layout.prop(context.object, "show_instancer_for_render", text="Show Emitter")
1229
1230
1231 class PARTICLE_PT_render_extra(ParticleButtonsPanel, Panel):
1232     bl_label = "Extra"
1233     bl_parent_id = "PARTICLE_PT_render"
1234     bl_options = {'DEFAULT_CLOSED'}
1235     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1236
1237     @classmethod
1238     def poll(cls, context):
1239         part = particle_get_settings(context)
1240         return part.render_type != 'NONE'
1241
1242     def draw(self, context):
1243         layout = self.layout
1244         layout.use_property_split = True
1245
1246         part = particle_get_settings(context)
1247
1248         col = layout.column()
1249
1250         col = layout.column()
1251         col.prop(part, "use_parent_particles", text="Parent Particles")
1252         col.prop(part, "show_unborn", text="Unborn")
1253         col.prop(part, "use_dead", text="Dead")
1254
1255
1256 class PARTICLE_PT_render_line(ParticleButtonsPanel, Panel):
1257     bl_label = "Line"
1258     bl_parent_id = "PARTICLE_PT_render"
1259     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1260
1261     @classmethod
1262     def poll(cls, context):
1263         part = particle_get_settings(context)
1264         return part.render_type == 'LINE'
1265
1266     def draw(self, context):
1267         layout = self.layout
1268         layout.use_property_split = True
1269
1270         part = particle_get_settings(context)
1271
1272         col = layout.column()
1273
1274         col.separator()
1275         sub = col.column(align=True)
1276         sub.prop(part, "line_length_tail", text="Length Tail")
1277         sub.prop(part, "line_length_head", text="Head")
1278         col.prop(part, "use_velocity_length", text="Velocity Length")
1279
1280
1281 class PARTICLE_PT_render_path(ParticleButtonsPanel, Panel):
1282     bl_label = "Path"
1283     bl_parent_id = "PARTICLE_PT_render"
1284     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1285
1286     @classmethod
1287     def poll(cls, context):
1288         part = particle_get_settings(context)
1289         return part.render_type == 'PATH'
1290
1291     def draw(self, context):
1292         layout = self.layout
1293         layout.use_property_split = True
1294
1295         part = particle_get_settings(context)
1296
1297         col = layout.column()
1298
1299         col.prop(part, "use_strand_primitive")
1300         sub = col.column()
1301         sub.active = (part.use_strand_primitive is False)
1302         sub.prop(part, "use_render_adaptive")
1303         sub = col.column()
1304         sub.active = part.use_render_adaptive or part.use_strand_primitive is True
1305         sub.prop(part, "adaptive_angle")
1306         sub = col.column()
1307         sub.active = (part.use_render_adaptive is True and part.use_strand_primitive is False)
1308         sub.prop(part, "adaptive_pixel")
1309         col.prop(part, "use_hair_bspline")
1310         col.prop(part, "render_step", text="Steps")
1311
1312
1313 class PARTICLE_PT_render_path_timing(ParticleButtonsPanel, Panel):
1314     bl_label = "Timing"
1315     bl_parent_id = "PARTICLE_PT_render"
1316     bl_options = {'DEFAULT_CLOSED'}
1317     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1318
1319     @classmethod
1320     def poll(cls, context):
1321         part = particle_get_settings(context)
1322         return part.render_type == 'PATH'
1323
1324     def draw(self, context):
1325         layout = self.layout
1326         layout.use_property_split = True
1327
1328         psys = context.particle_system
1329         part = particle_get_settings(context)
1330
1331         col = layout.column()
1332
1333         col.prop(part, "use_absolute_path_time")
1334
1335         if part.type == 'HAIR' or psys.point_cache.is_baked:
1336             col.prop(part, "path_start", text="Start", slider=not part.use_absolute_path_time)
1337         else:
1338             col.prop(part, "trail_count")
1339
1340         col.prop(part, "path_end", text="End", slider=not part.use_absolute_path_time)
1341         col.prop(part, "length_random", text="Random", slider=True)
1342
1343
1344 class PARTICLE_PT_render_object(ParticleButtonsPanel, Panel):
1345     bl_label = "Object"
1346     bl_parent_id = "PARTICLE_PT_render"
1347     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1348
1349     @classmethod
1350     def poll(cls, context):
1351         part = particle_get_settings(context)
1352         return part.render_type == 'OBJECT'
1353
1354     def draw(self, context):
1355         layout = self.layout
1356         layout.use_property_split = True
1357
1358         part = particle_get_settings(context)
1359
1360         col = layout.column()
1361
1362         col.prop(part, "instance_object", text="Instance Object")
1363         sub = col.column()
1364         sub.prop(part, "use_global_instance", text="Global Coordinates")
1365         sub.prop(part, "use_rotation_instance", text="Object Rotation")
1366         sub.prop(part, "use_scale_instance", text="Object Scale")
1367
1368
1369 class PARTICLE_PT_render_collection(ParticleButtonsPanel, Panel):
1370     bl_label = "Collection"
1371     bl_parent_id = "PARTICLE_PT_render"
1372     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1373
1374     @classmethod
1375     def poll(cls, context):
1376         part = particle_get_settings(context)
1377         return part.render_type == 'COLLECTION'
1378
1379     def draw(self, context):
1380         layout = self.layout
1381         layout.use_property_split = True
1382
1383         part = particle_get_settings(context)
1384
1385         col = layout.column()
1386
1387         col.prop(part, "instance_collection", text="Instance Collection")
1388
1389         col.prop(part, "use_whole_collection")
1390         sub = col.column()
1391         sub.active = (part.use_whole_collection is False)
1392         sub.prop(part, "use_collection_pick_random")
1393         sub.prop(part, "use_global_instance", text="Global Coordinates")
1394         sub.prop(part, "use_rotation_instance", text="Object Rotation")
1395         sub.prop(part, "use_scale_instance", text="Object Scale")
1396
1397
1398 class PARTICLE_PT_render_collection_use_count(ParticleButtonsPanel, Panel):
1399     bl_label = "Use Count"
1400     bl_parent_id = "PARTICLE_PT_render_collection"
1401     bl_options = {'DEFAULT_CLOSED'}
1402     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1403
1404     @classmethod
1405     def poll(cls, context):
1406         part = particle_get_settings(context)
1407         return part.render_type == 'COLLECTION'
1408
1409     def draw_header(self, context):
1410         layout = self.layout
1411         part = particle_get_settings(context)
1412
1413         layout.active = not part.use_whole_collection
1414
1415         layout.prop(part, "use_collection_count", text="")
1416
1417     def draw(self, context):
1418         layout = self.layout
1419         layout.use_property_split = True
1420
1421         part = particle_get_settings(context)
1422
1423         col = layout.column()
1424
1425         layout.active = part.use_collection_count and not part.use_whole_collection
1426
1427         row = layout.row()
1428         row.template_list("UI_UL_list", "particle_instance_weights", part, "instance_weights",
1429                           part, "active_instanceweight_index")
1430
1431         col = row.column()
1432         sub = col.row()
1433         subsub = sub.column(align=True)
1434         subsub.operator("particle.dupliob_copy", icon='ADD', text="")
1435         subsub.operator("particle.dupliob_remove", icon='REMOVE', text="")
1436         subsub.operator("particle.dupliob_move_up", icon='TRIA_UP', text="")
1437         subsub.operator("particle.dupliob_move_down", icon='TRIA_DOWN', text="")
1438         subsub.separator()
1439         subsub.operator("particle.dupliob_refresh", icon='FILE_REFRESH', text="")
1440
1441         weight = part.active_instanceweight
1442         if weight:
1443             row = layout.row()
1444             row.prop(weight, "count")
1445
1446
1447 class PARTICLE_PT_render_billboards_alignment(ParticleButtonsPanel, Panel):
1448     bl_label = "Billboard Alignment"
1449     bl_parent_id = "PARTICLE_PT_render"
1450     bl_options = {'DEFAULT_CLOSED'}
1451     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1452
1453     @classmethod
1454     def poll(cls, context):
1455         part = particle_get_settings(context)
1456         return part.render_type == 'BILLBOARD'
1457
1458     def draw(self, context):
1459         layout = self.layout
1460         layout.use_property_split = True
1461
1462         part = particle_get_settings(context)
1463
1464         col = layout.column()
1465
1466         col.prop(part, "billboard_align", text="Align To")
1467         col.prop(part, "lock_billboard", text="Lock Axis")
1468         col.prop(part, "billboard_object")
1469
1470
1471 class PARTICLE_PT_render_billboards_tilt(ParticleButtonsPanel, Panel):
1472     bl_label = "Billboard Tilt"
1473     bl_parent_id = "PARTICLE_PT_render"
1474     bl_options = {'DEFAULT_CLOSED'}
1475     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1476
1477     @classmethod
1478     def poll(cls, context):
1479         part = particle_get_settings(context)
1480         return part.render_type == 'BILLBOARD'
1481
1482     def draw(self, context):
1483         layout = self.layout
1484         layout.use_property_split = True
1485
1486         part = particle_get_settings(context)
1487
1488         col = layout.column()
1489
1490         sub = col.column(align=True)
1491         sub.prop(part, "billboard_tilt", text="Angle", slider=True)
1492         sub.prop(part, "billboard_tilt_random", text="Random", slider=True)
1493
1494         sub = col.column(align=True)
1495         sub.prop(part, "billboard_offset")
1496         col.prop(part, "billboard_size", text="Scale")
1497         if part.billboard_align == 'VEL':
1498             col = col.column(align=True)
1499             col.prop(part, "billboard_velocity_head", text="Velocity ScaleHead")
1500             col.prop(part, "billboard_velocity_tail", text="Tail")
1501
1502
1503 class PARTICLE_PT_render_billboards_uv(ParticleButtonsPanel, Panel):
1504     bl_label = "Billboard UVs"
1505     bl_parent_id = "PARTICLE_PT_render"
1506     bl_options = {'DEFAULT_CLOSED'}
1507     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1508
1509     @classmethod
1510     def poll(cls, context):
1511         part = particle_get_settings(context)
1512         return part.render_type == 'BILLBOARD'
1513
1514     def draw(self, context):
1515         layout = self.layout
1516         layout.use_property_split = True
1517
1518         psys = context.particle_system
1519         ob = context.object
1520         part = particle_get_settings(context)
1521
1522         col = layout.column()
1523
1524         if psys:
1525             col.prop_search(psys, "billboard_normal_uv", ob.data, "uv_layers")
1526             col.prop_search(psys, "billboard_time_index_uv", ob.data, "uv_layers")
1527
1528         col.prop(part, "billboard_uv_split", text="Split UVs")
1529
1530         if psys:
1531             sub = col.column()
1532             sub.active = part.billboard_uv_split > 1
1533             sub.prop_search(psys, "billboard_split_uv", ob.data, "uv_layers")
1534
1535         sub.prop(part, "billboard_animation")
1536         sub.prop(part, "billboard_offset_split")
1537
1538
1539 class PARTICLE_PT_render_trails(ParticleButtonsPanel, Panel):
1540     bl_label = "Trails"
1541     bl_parent_id = "PARTICLE_PT_render"
1542     bl_options = {'DEFAULT_CLOSED'}
1543     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1544
1545     @classmethod
1546     def poll(cls, context):
1547         part = particle_get_settings(context)
1548         return part.render_type in {'HALO', 'LINE', 'BILLBOARD'}
1549
1550     def draw(self, context):
1551         layout = self.layout
1552         layout.use_property_split = True
1553
1554         part = particle_get_settings(context)
1555
1556         col = layout.column()
1557
1558         col.prop(part, "trail_count")
1559
1560         sub = col.column()
1561         sub.active = (part.trail_count > 1)
1562         sub.prop(part, "use_absolute_path_time", text="Length in Frames")
1563         sub.prop(part, "path_end", text="Length", slider=not part.use_absolute_path_time)
1564         sub.prop(part, "length_random", text="Random Length", slider=True)
1565
1566
1567 class PARTICLE_PT_draw(ParticleButtonsPanel, Panel):
1568     bl_label = "Viewport Display"
1569     bl_options = {'DEFAULT_CLOSED'}
1570     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1571
1572     @classmethod
1573     def poll(cls, context):
1574         settings = particle_get_settings(context)
1575         engine = context.engine
1576         if settings is None:
1577             return False
1578         return engine in cls.COMPAT_ENGINES
1579
1580     def draw(self, context):
1581         layout = self.layout
1582         layout.use_property_split = True
1583
1584         psys = context.particle_system
1585         part = particle_get_settings(context)
1586
1587         layout.prop(part, "display_method", text="Display As")
1588
1589         if part.display_method == 'NONE' or (part.render_type == 'NONE' and part.display_method == 'RENDER'):
1590             return
1591
1592         path = (part.render_type == 'PATH' and part.display_method == 'RENDER') or part.display_method == 'PATH'
1593
1594         layout.separator()
1595
1596         col = layout.column()
1597         col.prop(part, "display_color", text="Color")
1598         if part.display_color in {'VELOCITY', 'ACCELERATION'}:
1599             col.prop(part, "color_maximum", text="Fade Distance")
1600
1601         col = layout.column()
1602
1603         if path:
1604             col.prop(part, "display_step", text="Strand Steps")
1605         col.prop(part, "display_percentage", slider=True, text="Amount")
1606         if part.display_method != 'RENDER' or part.render_type == 'HALO':
1607             col.prop(part, "display_size", text="Size")
1608
1609         if part.display_percentage != 100 and psys is not None:
1610             if part.type == 'HAIR':
1611                 if psys.use_hair_dynamics and psys.point_cache.is_baked is False:
1612                     layout.row().label(text="Display percentage makes dynamics inaccurate without baking")
1613             else:
1614                 phystype = part.physics_type
1615                 if phystype != 'NO' and phystype != 'KEYED' and psys.point_cache.is_baked is False:
1616                     layout.row().label(text="Display percentage makes dynamics inaccurate without baking")
1617         else:
1618             layout.separator()
1619
1620         col = layout.column()
1621         col.prop(part, "show_guide_hairs", text="Guide Hairs")
1622         col.prop(part, "show_size")
1623         col.prop(part, "show_velocity")
1624         col.prop(part, "show_number")
1625         if part.physics_type == 'BOIDS':
1626             col.prop(part, "show_health")
1627
1628         if context.object:
1629             layout.separator()
1630             layout.prop(context.object, "show_instancer_for_viewport", text="Show Emitter")
1631
1632
1633 class PARTICLE_PT_children(ParticleButtonsPanel, Panel):
1634     bl_label = "Children"
1635     bl_options = {'DEFAULT_CLOSED'}
1636     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1637
1638     @classmethod
1639     def poll(cls, context):
1640         return particle_panel_poll(cls, context)
1641
1642     def draw(self, context):
1643         layout = self.layout
1644
1645         psys = context.particle_system
1646         part = particle_get_settings(context)
1647
1648         layout.row().prop(part, "child_type", expand=True)
1649
1650         layout.use_property_split = True
1651
1652         if part.child_type == 'NONE':
1653             return
1654
1655         col = layout.column()
1656
1657         sub = col.column(align=True)
1658         sub.prop(part, "child_nbr", text="Display Amount")
1659         sub.prop(part, "rendered_child_count", text="Render Amount")
1660
1661         col.separator()
1662
1663         col.prop(part, "child_length", slider=True)
1664         col.prop(part, "child_length_threshold", slider=True)
1665         if psys:
1666             col.prop(psys, "child_seed", text="Seed")
1667
1668         col.separator()
1669
1670         if part.child_type == 'INTERPOLATED':
1671             col.prop(part, "virtual_parents", slider=True)
1672             col.prop(part, "create_long_hair_children")
1673         else:
1674             col.separator()
1675             sub = col.column(align=True)
1676             sub.prop(part, "child_size", text="Size")
1677             sub.prop(part, "child_size_random", text="Randomize Size", slider=True)
1678
1679         if part.child_type == 'SIMPLE':
1680             col.separator()
1681             col.prop(part, "child_radius", text="Radius")
1682             col.prop(part, "child_roundness", text="Roundness", slider=True)
1683         elif part.virtual_parents > 0.0:
1684             sub = col.column(align=True)
1685             sub.label(text="Parting not available with virtual parents")
1686
1687
1688 class PARTICLE_PT_children_parting(ParticleButtonsPanel, Panel):
1689     bl_label = "Parting"
1690     bl_parent_id = "PARTICLE_PT_children"
1691     bl_options = {'DEFAULT_CLOSED'}
1692     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1693
1694     @classmethod
1695     def poll(cls, context):
1696         part = particle_get_settings(context)
1697         return part.child_type == 'INTERPOLATED'
1698
1699     def draw(self, context):
1700         layout = self.layout
1701
1702         part = particle_get_settings(context)
1703
1704         layout.use_property_split = True
1705
1706         col = layout.column()
1707         col.prop(part, "child_parting_factor", text="Parting", slider=True)
1708         col.prop(part, "child_parting_min", text="Min")
1709         col.prop(part, "child_parting_max", text="Max")
1710
1711
1712 class PARTICLE_PT_children_clumping(ParticleButtonsPanel, Panel):
1713     bl_label = "Clumping"
1714     bl_parent_id = "PARTICLE_PT_children"
1715     bl_options = {'DEFAULT_CLOSED'}
1716     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1717
1718     @classmethod
1719     def poll(cls, context):
1720         part = particle_get_settings(context)
1721         return part.child_type != 'NONE'
1722
1723     def draw(self, context):
1724         layout = self.layout
1725
1726         part = particle_get_settings(context)
1727
1728         layout.use_property_split = True
1729
1730         col = layout.column()
1731
1732         sub = col.column()
1733
1734         sub.prop(part, "use_clump_curve")
1735         if part.use_clump_curve:
1736             sub.template_curve_mapping(part, "clump_curve")
1737         else:
1738             sub.prop(part, "clump_factor", slider=True)
1739             sub.prop(part, "clump_shape", slider=True)
1740         sub = col.column(align=True)
1741         sub.prop(part, "use_clump_noise")
1742         subsub = sub.column()
1743         subsub.enabled = part.use_clump_noise
1744         subsub.prop(part, "clump_noise_size")
1745
1746         if part.child_type == 'SIMPLE':
1747             sub.prop(part, "twist")
1748             sub.prop(part, "use_twist_curve")
1749             if part.use_twist_curve:
1750                 sub.template_curve_mapping(part, "twist_curve")
1751
1752
1753 class PARTICLE_PT_children_roughness(ParticleButtonsPanel, Panel):
1754     bl_label = "Roughness"
1755     bl_parent_id = "PARTICLE_PT_children"
1756     bl_options = {'DEFAULT_CLOSED'}
1757     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1758
1759     @classmethod
1760     def poll(cls, context):
1761         part = particle_get_settings(context)
1762         return part.child_type != 'NONE'
1763
1764     def draw(self, context):
1765         layout = self.layout
1766
1767         part = particle_get_settings(context)
1768
1769         layout.use_property_split = True
1770
1771         col = layout.column()
1772
1773         col.prop(part, "use_roughness_curve")
1774         if part.use_roughness_curve:
1775             sub = col.column()
1776             sub.template_curve_mapping(part, "roughness_curve")
1777             sub.prop(part, "roughness_1", text="Roughness")
1778             sub.prop(part, "roughness_1_size", text="Size")
1779         else:
1780             sub = col.column(align=True)
1781             sub.prop(part, "roughness_1", text="Uniform")
1782             sub.prop(part, "roughness_1_size", text="Size")
1783
1784             sub = col.column(align=True)
1785             sub.prop(part, "roughness_endpoint", text="Endpoint")
1786             sub.prop(part, "roughness_end_shape")
1787
1788             sub = col.column(align=True)
1789             sub.prop(part, "roughness_2", text="Random")
1790             sub.prop(part, "roughness_2_size", text="Size")
1791             sub.prop(part, "roughness_2_threshold", slider=True)
1792
1793
1794 class PARTICLE_PT_children_kink(ParticleButtonsPanel, Panel):
1795     bl_label = "Kink"
1796     bl_parent_id = "PARTICLE_PT_children"
1797     bl_options = {'DEFAULT_CLOSED'}
1798     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1799
1800     @classmethod
1801     def poll(cls, context):
1802         part = particle_get_settings(context)
1803         return part.child_type != 'NONE'
1804
1805     def draw(self, context):
1806         layout = self.layout
1807
1808         part = particle_get_settings(context)
1809
1810         layout.use_property_split = True
1811
1812         col = layout.column()
1813
1814         col.prop(part, "kink", text="Kink Type")
1815         col = layout.column()
1816         col.active = part.kink != 'NO'
1817
1818         if part.kink == 'SPIRAL':
1819
1820             sub = col.column()
1821             sub.prop(part, "kink_amplitude", text="Amplitude")
1822             sub.prop(part, "kink_amplitude_random", text="Randomize Amplitude", slider=True)
1823
1824             col.separator()
1825
1826             sub = col.column()
1827             sub.prop(part, "kink_axis")
1828             sub.prop(part, "kink_axis_random", text="Randomize Axis", slider=True)
1829
1830             col.separator()
1831
1832             col.prop(part, "kink_frequency", text="Frequency")
1833             col.prop(part, "kink_shape", text="Shape", slider=True)
1834             col.prop(part, "kink_extra_steps", text="Steps")
1835
1836         elif part.kink in {'CURL', 'RADIAL', 'WAVE', 'BRAID', 'WAVE'}:
1837             sub = col.column(align=True)
1838             sub.prop(part, "kink_amplitude")
1839             sub.prop(part, "kink_amplitude_clump", text="Clump", slider=True)
1840             col.prop(part, "kink_flat", slider=True)
1841             col.prop(part, "kink_frequency")
1842             col.prop(part, "kink_shape", slider=True)
1843
1844
1845 class PARTICLE_PT_field_weights(ParticleButtonsPanel, Panel):
1846     bl_label = "Field Weights"
1847     bl_options = {'DEFAULT_CLOSED'}
1848     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1849
1850     @classmethod
1851     def poll(cls, context):
1852         return particle_panel_poll(cls, context)
1853
1854     def draw(self, context):
1855         part = particle_get_settings(context)
1856         effector_weights_ui(self, context, part.effector_weights, 'PSYS')
1857
1858         if part.type == 'HAIR':
1859             row = self.layout.row()
1860             row.prop(part.effector_weights, "apply_to_hair_growing")
1861             row.prop(part, "apply_effector_to_children")
1862             row = self.layout.row()
1863             row.prop(part, "effect_hair", slider=True)
1864
1865
1866 class PARTICLE_PT_force_fields(ParticleButtonsPanel, Panel):
1867     bl_label = "Force Field Settings"
1868     bl_options = {'DEFAULT_CLOSED'}
1869     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1870
1871     def draw(self, context):
1872         layout = self.layout
1873         layout.use_property_split = True
1874
1875         part = particle_get_settings(context)
1876
1877         col = layout.column()
1878         col.prop(part, "use_self_effect")
1879         col.prop(part, "effector_amount", text="Effector Amount")
1880
1881
1882 class PARTICLE_PT_force_fields_type1(ParticleButtonsPanel, Panel):
1883     bl_label = "Type 1"
1884     bl_parent_id = "PARTICLE_PT_force_fields"
1885     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1886
1887     def draw(self, context):
1888         layout = self.layout
1889         layout.use_property_split = True
1890
1891         part = particle_get_settings(context)
1892
1893         col = layout.column()
1894         col.prop(part.force_field_1, "type", text="Type 1")
1895         basic_force_field_settings_ui(self, context, part.force_field_1)
1896
1897
1898 class PARTICLE_PT_force_fields_type2(ParticleButtonsPanel, Panel):
1899     bl_label = "Type 2"
1900     bl_parent_id = "PARTICLE_PT_force_fields"
1901     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1902
1903     def draw(self, context):
1904         layout = self.layout
1905         layout.use_property_split = True
1906
1907         part = particle_get_settings(context)
1908
1909         col = layout.column()
1910         col.prop(part.force_field_2, "type", text="Type 2")
1911         basic_force_field_settings_ui(self, context, part.force_field_2)
1912
1913
1914 class PARTICLE_PT_force_fields_type1_falloff(ParticleButtonsPanel, Panel):
1915     bl_label = "Falloff"
1916     bl_options = {'DEFAULT_CLOSED'}
1917     bl_parent_id = "PARTICLE_PT_force_fields_type1"
1918     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1919
1920     def draw(self, context):
1921         layout = self.layout
1922         layout.use_property_split = True
1923
1924         part = particle_get_settings(context)
1925
1926         basic_force_field_falloff_ui(self, context, part.force_field_1)
1927
1928
1929 class PARTICLE_PT_force_fields_type2_falloff(ParticleButtonsPanel, Panel):
1930     bl_label = "Falloff"
1931     bl_options = {'DEFAULT_CLOSED'}
1932     bl_parent_id = "PARTICLE_PT_force_fields_type2"
1933     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1934
1935     def draw(self, context):
1936         layout = self.layout
1937         layout.use_property_split = True
1938
1939         part = particle_get_settings(context)
1940
1941         basic_force_field_falloff_ui(self, context, part.force_field_2)
1942
1943
1944 class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, Panel):
1945     bl_label = "Vertex Groups"
1946     bl_options = {'DEFAULT_CLOSED'}
1947     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
1948
1949     @classmethod
1950     def poll(cls, context):
1951         if context.particle_system is None:
1952             return False
1953         return particle_panel_poll(cls, context)
1954
1955     def draw(self, context):
1956         layout = self.layout
1957         layout.use_property_split = True
1958
1959         ob = context.object
1960         psys = context.particle_system
1961
1962         col = layout.column()
1963         row = col.row(align=True)
1964         row.prop_search(psys, "vertex_group_density", ob, "vertex_groups", text="Density")
1965         row.prop(psys, "invert_vertex_group_density", text="", toggle=True, icon='ARROW_LEFTRIGHT')
1966
1967         row = col.row(align=True)
1968         row.prop_search(psys, "vertex_group_length", ob, "vertex_groups", text="Length")
1969         row.prop(psys, "invert_vertex_group_length", text="", toggle=True, icon='ARROW_LEFTRIGHT')
1970
1971         row = col.row(align=True)
1972         row.prop_search(psys, "vertex_group_clump", ob, "vertex_groups", text="Clump")
1973         row.prop(psys, "invert_vertex_group_clump", text="", toggle=True, icon='ARROW_LEFTRIGHT')
1974
1975         row = col.row(align=True)
1976         row.prop_search(psys, "vertex_group_kink", ob, "vertex_groups", text="Kink")
1977         row.prop(psys, "invert_vertex_group_kink", text="", toggle=True, icon='ARROW_LEFTRIGHT')
1978
1979         row = col.row(align=True)
1980         row.prop_search(psys, "vertex_group_roughness_1", ob, "vertex_groups", text="Roughness 1")
1981         row.prop(psys, "invert_vertex_group_roughness_1", text="", toggle=True, icon='ARROW_LEFTRIGHT')
1982
1983         row = col.row(align=True)
1984         row.prop_search(psys, "vertex_group_roughness_2", ob, "vertex_groups", text="Roughness 2")
1985         row.prop(psys, "invert_vertex_group_roughness_2", text="", toggle=True, icon='ARROW_LEFTRIGHT')
1986
1987         row = col.row(align=True)
1988         row.prop_search(psys, "vertex_group_roughness_end", ob, "vertex_groups", text="Roughness End")
1989         row.prop(psys, "invert_vertex_group_roughness_end", text="", toggle=True, icon='ARROW_LEFTRIGHT')
1990
1991         row = col.row(align=True)
1992         row.prop_search(psys, "vertex_group_twist", ob, "vertex_groups", text="Twist")
1993         row.prop(psys, "invert_vertex_group_twist", text="", toggle=True, icon='ARROW_LEFTRIGHT')
1994
1995         # Commented out vertex groups don't work and are still waiting for better implementation
1996         # row = layout.row()
1997         # row.prop_search(psys, "vertex_group_velocity", ob, "vertex_groups", text="Velocity")
1998         # row.prop(psys, "invert_vertex_group_velocity", text="")
1999
2000         # row = layout.row()
2001         # row.prop_search(psys, "vertex_group_size", ob, "vertex_groups", text="Size")
2002         # row.prop(psys, "invert_vertex_group_size", text="")
2003
2004         # row = layout.row()
2005         # row.prop_search(psys, "vertex_group_tangent", ob, "vertex_groups", text="Tangent")
2006         # row.prop(psys, "invert_vertex_group_tangent", text="")
2007
2008         # row = layout.row()
2009         # row.prop_search(psys, "vertex_group_rotation", ob, "vertex_groups", text="Rotation")
2010         # row.prop(psys, "invert_vertex_group_rotation", text="")
2011
2012         # row = layout.row()
2013         # row.prop_search(psys, "vertex_group_field", ob, "vertex_groups", text="Field")
2014         # row.prop(psys, "invert_vertex_group_field", text="")
2015
2016
2017 class PARTICLE_PT_textures(ParticleButtonsPanel, Panel):
2018     bl_label = "Textures"
2019     bl_options = {'DEFAULT_CLOSED'}
2020     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
2021
2022     @classmethod
2023     def poll(cls, context):
2024         if context.particle_system is None:
2025             return False
2026         return particle_panel_poll(cls, context)
2027
2028     def draw(self, context):
2029         layout = self.layout
2030
2031         psys = context.particle_system
2032         part = psys.settings
2033
2034         row = layout.row()
2035         row.template_list("TEXTURE_UL_texslots", "", part, "texture_slots", part, "active_texture_index", rows=2)
2036
2037         col = row.column(align=True)
2038         col.operator("texture.slot_move", text="", icon='TRIA_UP').type = 'UP'
2039         col.operator("texture.slot_move", text="", icon='TRIA_DOWN').type = 'DOWN'
2040         col.menu("TEXTURE_MT_specials", icon='DOWNARROW_HLT', text="")
2041
2042         if not part.active_texture:
2043             layout.template_ID(part, "active_texture", new="texture.new")
2044         else:
2045             slot = part.texture_slots[part.active_texture_index]
2046             layout.template_ID(slot, "texture", new="texture.new")
2047
2048
2049 class PARTICLE_PT_hair_shape(ParticleButtonsPanel, Panel):
2050     bl_label = "Hair Shape"
2051     bl_options = {'DEFAULT_CLOSED'}
2052     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
2053
2054     @classmethod
2055     def poll(cls, context):
2056         if context.particle_system is None:
2057             return False
2058         return particle_panel_poll(cls, context)
2059
2060     def draw(self, context):
2061         layout = self.layout
2062         layout.use_property_split = True
2063
2064         psys = context.particle_system
2065         part = psys.settings
2066
2067         layout.prop(part, "shape", text="Strand Shape")
2068
2069         col = layout.column(align=True)
2070         col.prop(part, "root_radius", text="Radius Root")
2071         col.prop(part, "tip_radius", text="Tip")
2072
2073         col = layout.column()
2074         col.prop(part, "radius_scale", text="Radius Scaling")
2075         col.prop(part, "use_close_tip")
2076
2077
2078 class PARTICLE_PT_custom_props(ParticleButtonsPanel, PropertyPanel, Panel):
2079     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
2080     _context_path = "particle_system.settings"
2081     _property_type = bpy.types.ParticleSettings
2082
2083
2084 classes = (
2085     PARTICLE_MT_specials,
2086     PARTICLE_PT_hair_dynamics_presets,
2087     PARTICLE_UL_particle_systems,
2088     PARTICLE_PT_context_particles,
2089     PARTICLE_PT_emission,
2090     PARTICLE_PT_emission_source,
2091     PARTICLE_PT_hair_dynamics,
2092     PARTICLE_PT_hair_dynamics_structure,
2093     PARTICLE_PT_hair_dynamics_volume,
2094     PARTICLE_PT_cache,
2095     PARTICLE_PT_velocity,
2096     PARTICLE_PT_rotation,
2097     PARTICLE_PT_rotation_angular_velocity,
2098     PARTICLE_PT_physics,
2099     PARTICLE_PT_physics_fluid_springs,
2100     PARTICLE_PT_physics_fluid_springs_viscoelastic,
2101     PARTICLE_PT_physics_fluid_springs_advanced,
2102     PARTICLE_PT_physics_fluid_advanced,
2103     PARTICLE_PT_physics_boids_movement,
2104     PARTICLE_PT_physics_boids_battle,
2105     PARTICLE_PT_physics_boids_misc,
2106     PARTICLE_PT_physics_forces,
2107     PARTICLE_PT_physics_deflection,
2108     PARTICLE_PT_physics_integration,
2109     PARTICLE_PT_physics_relations,
2110     PARTICLE_PT_boidbrain,
2111     PARTICLE_PT_render,
2112     PARTICLE_PT_render_line,
2113     PARTICLE_PT_render_path,
2114     PARTICLE_PT_render_path_timing,
2115     PARTICLE_PT_render_object,
2116     PARTICLE_PT_render_collection,
2117     PARTICLE_PT_render_collection_use_count,
2118     PARTICLE_PT_render_billboards_tilt,
2119     PARTICLE_PT_render_billboards_uv,
2120     PARTICLE_PT_render_trails,
2121     PARTICLE_PT_render_extra,
2122     PARTICLE_PT_draw,
2123     PARTICLE_PT_children,
2124     PARTICLE_PT_children_parting,
2125     PARTICLE_PT_children_clumping,
2126     PARTICLE_PT_children_roughness,
2127     PARTICLE_PT_children_kink,
2128     PARTICLE_PT_hair_shape,
2129     PARTICLE_PT_field_weights,
2130     PARTICLE_PT_force_fields,
2131     PARTICLE_PT_force_fields_type1,
2132     PARTICLE_PT_force_fields_type1_falloff,
2133     PARTICLE_PT_force_fields_type2,
2134     PARTICLE_PT_force_fields_type2_falloff,
2135     PARTICLE_PT_vertexgroups,
2136     PARTICLE_PT_textures,
2137     PARTICLE_PT_custom_props,
2138 )
2139
2140 if __name__ == "__main__":  # only for live edit.
2141     from bpy.utils import register_class
2142     for cls in classes:
2143         register_class(cls)