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