75154550bcba84f5279e39e8cefebf194a3d1a8b
[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
22 from rna_prop_ui import PropertyPanel
23
24 from bl_ui.properties_physics_common import (point_cache_ui,
25                                              effector_weights_ui,
26                                              basic_force_field_settings_ui,
27                                              basic_force_field_falloff_ui,
28                                              )
29
30
31 def particle_panel_enabled(context, psys):
32     if psys is None:
33         return True
34     phystype = psys.settings.physics_type
35     if psys.settings.type in {'EMITTER', 'REACTOR'} and phystype in {'NO', 'KEYED'}:
36         return True
37     else:
38         return (psys.point_cache.is_baked is False) and (not psys.is_edited) and (not context.particle_system_editable)
39
40
41 def particle_panel_poll(cls, context):
42     psys = context.particle_system
43     engine = context.scene.render.engine
44     settings = 0
45
46     if psys:
47         settings = psys.settings
48     elif isinstance(context.space_data.pin_id, bpy.types.ParticleSettings):
49         settings = context.space_data.pin_id
50
51     if not settings:
52         return False
53
54     return settings.is_fluid is False and (engine in cls.COMPAT_ENGINES)
55
56
57 def particle_get_settings(context):
58     if context.particle_system:
59         return context.particle_system.settings
60     elif isinstance(context.space_data.pin_id, bpy.types.ParticleSettings):
61         return context.space_data.pin_id
62     return None
63
64
65 class ParticleButtonsPanel():
66     bl_space_type = 'PROPERTIES'
67     bl_region_type = 'WINDOW'
68     bl_context = "particle"
69
70     @classmethod
71     def poll(cls, context):
72         return particle_panel_poll(cls, context)
73
74
75 class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel):
76     bl_label = ""
77     bl_options = {'HIDE_HEADER'}
78     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
79
80     @classmethod
81     def poll(cls, context):
82         engine = context.scene.render.engine
83         return (context.particle_system or context.object or context.space_data.pin_id) and (engine in cls.COMPAT_ENGINES)
84
85     def draw(self, context):
86         layout = self.layout
87
88         if context.scene.render.engine == 'BLENDER_GAME':
89             layout.label("Not available in the Game Engine")
90             return
91
92         ob = context.object
93         psys = context.particle_system
94         part = 0
95
96         if ob:
97             row = layout.row()
98
99             row.template_list(ob, "particle_systems", ob.particle_systems, "active_index", rows=2)
100
101             col = row.column(align=True)
102             col.operator("object.particle_system_add", icon='ZOOMIN', text="")
103             col.operator("object.particle_system_remove", icon='ZOOMOUT', text="")
104
105         if psys is None:
106             part = particle_get_settings(context)
107
108             if part is None:
109                 return
110
111             layout.template_ID(context.space_data, "pin_id")
112
113             if part.is_fluid:
114                 layout.label(text="Settings used for fluid")
115                 return
116
117             layout.prop(part, "type", text="Type")
118
119         elif not psys.settings:
120             split = layout.split(percentage=0.32)
121
122             col = split.column()
123             col.label(text="Name:")
124             col.label(text="Settings:")
125
126             col = split.column()
127             col.prop(psys, "name", text="")
128             col.template_ID(psys, "settings", new="particle.new")
129         else:
130             part = psys.settings
131
132             split = layout.split(percentage=0.32)
133             col = split.column()
134             col.label(text="Name:")
135             if part.is_fluid is False:
136                 col.label(text="Settings:")
137                 col.label(text="Type:")
138
139             col = split.column()
140             col.prop(psys, "name", text="")
141             if part.is_fluid is False:
142                 row = col.row()
143                 row.enabled = particle_panel_enabled(context, psys)
144                 row.template_ID(psys, "settings", new="particle.new")
145
146             #row = layout.row()
147             #row.label(text="Viewport")
148             #row.label(text="Render")
149
150             if part.is_fluid:
151                 layout.label(text="%d fluid particles for this frame" % part.count)
152                 return
153
154             row = col.row()
155             row.enabled = particle_panel_enabled(context, psys)
156             row.prop(part, "type", text="")
157             row.prop(psys, "seed")
158
159         if part:
160             split = layout.split(percentage=0.65)
161             if part.type == 'HAIR':
162                 if psys is not None and psys.is_edited:
163                     split.operator("particle.edited_clear", text="Free Edit")
164                 else:
165                     row = split.row()
166                     row.enabled = particle_panel_enabled(context, psys)
167                     row.prop(part, "regrow_hair")
168                     row.prop(part, "use_advanced_hair")
169                 row = split.row()
170                 row.enabled = particle_panel_enabled(context, psys)
171                 row.prop(part, "hair_step")
172                 if psys is not None and psys.is_edited:
173                     if psys.is_global_hair:
174                         layout.operator("particle.connect_hair")
175                     else:
176                         layout.operator("particle.disconnect_hair")
177             elif psys is not None and part.type == 'REACTOR':
178                 split.enabled = particle_panel_enabled(context, psys)
179                 split.prop(psys, "reactor_target_object")
180                 split.prop(psys, "reactor_target_particle_system", text="Particle System")
181
182
183 class PARTICLE_PT_emission(ParticleButtonsPanel, Panel):
184     bl_label = "Emission"
185     COMPAT_ENGINES = {'BLENDER_RENDER'}
186
187     @classmethod
188     def poll(cls, context):
189         psys = context.particle_system
190         settings = particle_get_settings(context)
191
192         if settings is None:
193             return False
194         if settings.is_fluid:
195             return False
196         if particle_panel_poll(PARTICLE_PT_emission, context):
197             return psys is None or not context.particle_system.point_cache.use_external
198         return False
199
200     def draw(self, context):
201         layout = self.layout
202
203         psys = context.particle_system
204         part = particle_get_settings(context)
205
206         layout.enabled = particle_panel_enabled(context, psys) and (psys is None or not psys.has_multiple_caches)
207
208         row = layout.row()
209         row.active = part.distribution != 'GRID'
210         row.prop(part, "count")
211
212         if part.type == 'HAIR' and not part.use_advanced_hair:
213             row.prop(part, "hair_length")
214             return
215
216         if part.type != 'HAIR':
217             split = layout.split()
218
219             col = split.column(align=True)
220             col.prop(part, "frame_start")
221             col.prop(part, "frame_end")
222
223             col = split.column(align=True)
224             col.prop(part, "lifetime")
225             col.prop(part, "lifetime_random", slider=True)
226
227         layout.label(text="Emit From:")
228         layout.prop(part, "emit_from", expand=True)
229
230         row = layout.row()
231         if part.emit_from == 'VERT':
232             row.prop(part, "use_emit_random")
233         elif part.distribution == 'GRID':
234             row.prop(part, "invert_grid")
235             row.prop(part, "hexagonal_grid")
236         else:
237             row.prop(part, "use_emit_random")
238             row.prop(part, "use_even_distribution")
239
240         if part.emit_from == 'FACE' or part.emit_from == 'VOLUME':
241             layout.prop(part, "distribution", expand=True)
242
243             row = layout.row()
244             if part.distribution == 'JIT':
245                 row.prop(part, "userjit", text="Particles/Face")
246                 row.prop(part, "jitter_factor", text="Jittering Amount", slider=True)
247             elif part.distribution == 'GRID':
248                 row.prop(part, "grid_resolution")
249                 row.prop(part, "grid_random", text="Random", slider=True)
250
251
252 class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel):
253     bl_label = "Hair dynamics"
254     bl_options = {'DEFAULT_CLOSED'}
255     COMPAT_ENGINES = {'BLENDER_RENDER'}
256
257     @classmethod
258     def poll(cls, context):
259         psys = context.particle_system
260         engine = context.scene.render.engine
261         if psys is None:
262             return False
263         if psys.settings is None:
264             return False
265         return psys.settings.type == 'HAIR' and (engine in cls.COMPAT_ENGINES)
266
267     def draw_header(self, context):
268         psys = context.particle_system
269         self.layout.prop(psys, "use_hair_dynamics", text="")
270
271     def draw(self, context):
272         layout = self.layout
273
274         psys = context.particle_system
275
276         if not psys.cloth:
277             return
278
279         cloth = psys.cloth.settings
280
281         layout.enabled = psys.use_hair_dynamics and psys.point_cache.is_baked is False
282
283         split = layout.split()
284
285         col = split.column()
286         col.label(text="Material:")
287         sub = col.column(align=True)
288         sub.prop(cloth, "pin_stiffness", text="Stiffness")
289         sub.prop(cloth, "mass")
290         sub.prop(cloth, "bending_stiffness", text="Bending")
291         sub.prop(cloth, "internal_friction", slider=True)
292         sub.prop(cloth, "collider_friction", slider=True)
293
294         col = split.column()
295         col.label(text="Damping:")
296         sub = col.column(align=True)
297         sub.prop(cloth, "spring_damping", text="Spring")
298         sub.prop(cloth, "air_damping", text="Air")
299
300         col.label(text="Quality:")
301         col.prop(cloth, "quality", text="Steps", slider=True)
302
303
304 class PARTICLE_PT_cache(ParticleButtonsPanel, Panel):
305     bl_label = "Cache"
306     bl_options = {'DEFAULT_CLOSED'}
307     COMPAT_ENGINES = {'BLENDER_RENDER'}
308
309     @classmethod
310     def poll(cls, context):
311         psys = context.particle_system
312         engine = context.scene.render.engine
313         if psys is None:
314             return False
315         if psys.settings is None:
316             return False
317         if psys.settings.is_fluid:
318             return False
319         phystype = psys.settings.physics_type
320         if phystype == 'NO' or phystype == 'KEYED':
321             return False
322         return (psys.settings.type in {'EMITTER', 'REACTOR'} or (psys.settings.type == 'HAIR' and (psys.use_hair_dynamics or psys.point_cache.is_baked))) and engine in cls.COMPAT_ENGINES
323
324     def draw(self, context):
325         psys = context.particle_system
326
327         point_cache_ui(self, context, psys.point_cache, True, 'HAIR' if (psys.settings.type == 'HAIR') else 'PSYS')
328
329
330 class PARTICLE_PT_velocity(ParticleButtonsPanel, Panel):
331     bl_label = "Velocity"
332     COMPAT_ENGINES = {'BLENDER_RENDER'}
333
334     @classmethod
335     def poll(cls, context):
336         if particle_panel_poll(PARTICLE_PT_velocity, context):
337             psys = context.particle_system
338             settings = particle_get_settings(context)
339
340             if settings.type == 'HAIR' and not settings.use_advanced_hair:
341                 return False
342             return settings.physics_type != 'BOIDS' and (psys is None or not psys.point_cache.use_external)
343         else:
344             return False
345
346     def draw(self, context):
347         layout = self.layout
348
349         psys = context.particle_system
350         part = particle_get_settings(context)
351
352         layout.enabled = particle_panel_enabled(context, psys)
353
354         split = layout.split()
355
356         col = split.column()
357         col.label(text="Emitter Geometry:")
358         col.prop(part, "normal_factor")
359         sub = col.column(align=True)
360         sub.prop(part, "tangent_factor")
361         sub.prop(part, "tangent_phase", slider=True)
362
363         col = split.column()
364         col.label(text="Emitter Object:")
365         col.prop(part, "object_align_factor", text="")
366
367         layout.label(text="Other:")
368         row = layout.row()
369         if part.emit_from == 'PARTICLE':
370             row.prop(part, "particle_factor")
371         else:
372             row.prop(part, "object_factor", slider=True)
373         row.prop(part, "factor_random")
374
375         #if part.type=='REACTOR':
376         #    sub.prop(part, "reactor_factor")
377         #    sub.prop(part, "reaction_shape", slider=True)
378
379
380 class PARTICLE_PT_rotation(ParticleButtonsPanel, Panel):
381     bl_label = "Rotation"
382     bl_options = {'DEFAULT_CLOSED'}
383     COMPAT_ENGINES = {'BLENDER_RENDER'}
384
385     @classmethod
386     def poll(cls, context):
387         if particle_panel_poll(PARTICLE_PT_rotation, context):
388             psys = context.particle_system
389             settings = particle_get_settings(context)
390
391             if settings.type == 'HAIR' and not settings.use_advanced_hair:
392                 return False
393             return settings.physics_type != 'BOIDS' and (psys is None or not psys.point_cache.use_external)
394         else:
395             return False
396
397     def draw_header(self, context):
398         psys = context.particle_system
399         if psys:
400             part = psys.settings
401         else:
402             part = context.space_data.pin_id
403
404         self.layout.prop(part, "use_rotations", text="")
405
406     def draw(self, context):
407         layout = self.layout
408
409         psys = context.particle_system
410         if psys:
411             part = psys.settings
412         else:
413             part = context.space_data.pin_id
414
415         layout.enabled = particle_panel_enabled(context, psys) and part.use_rotations
416
417         layout.label(text="Initial Orientation:")
418
419         split = layout.split()
420
421         col = split.column(align=True)
422         col.prop(part, "rotation_mode", text="")
423         col.prop(part, "rotation_factor_random", slider=True, text="Random")
424
425         col = split.column(align=True)
426         col.prop(part, "phase_factor", slider=True)
427         col.prop(part, "phase_factor_random", text="Random", slider=True)
428
429         if part.type != 'HAIR':
430             layout.label(text="Angular Velocity:")
431
432             split = layout.split()
433             col = split.column(align=True)
434             col.prop(part, "angular_velocity_mode", text="")
435             sub = col.column()
436             sub.active = part.angular_velocity_mode != 'NONE'
437             sub.prop(part, "angular_velocity_factor", text="")
438
439             col = split.column()
440             col.prop(part, "use_dynamic_rotation")
441
442
443 class PARTICLE_PT_physics(ParticleButtonsPanel, Panel):
444     bl_label = "Physics"
445     COMPAT_ENGINES = {'BLENDER_RENDER'}
446
447     @classmethod
448     def poll(cls, context):
449         if particle_panel_poll(PARTICLE_PT_physics, context):
450             psys = context.particle_system
451             settings = particle_get_settings(context)
452
453             if settings.type == 'HAIR' and not settings.use_advanced_hair:
454                 return False
455             return psys is None or not psys.point_cache.use_external
456         else:
457             return False
458
459     def draw(self, context):
460         layout = self.layout
461
462         psys = context.particle_system
463         part = particle_get_settings(context)
464
465         layout.enabled = particle_panel_enabled(context, psys)
466
467         layout.prop(part, "physics_type", expand=True)
468
469         row = layout.row()
470         col = row.column(align=True)
471         col.prop(part, "particle_size")
472         col.prop(part, "size_random", slider=True)
473
474         if part.physics_type != 'NO':
475             col = row.column(align=True)
476             col.prop(part, "mass")
477             col.prop(part, "use_multiply_size_mass", text="Multiply mass with size")
478
479         if part.physics_type in {'NEWTON', 'FLUID'}:
480             split = layout.split()
481
482             col = split.column()
483             col.label(text="Forces:")
484             col.prop(part, "brownian_factor")
485             col.prop(part, "drag_factor", slider=True)
486             col.prop(part, "damping", slider=True)
487
488             col = split.column()
489             col.label(text="Integration:")
490             col.prop(part, "integrator", text="")
491             col.prop(part, "timestep")
492             sub = col.row()
493             sub.prop(part, "subframes")
494             supports_courant = part.physics_type == 'FLUID'
495             subsub = sub.row()
496             subsub.enabled = supports_courant
497             subsub.prop(part, "adaptive_subframes", text="")
498             if supports_courant and part.adaptive_subframes:
499                 col.prop(part, "courant_target", text="Threshold")
500
501             row = layout.row()
502             row.prop(part, "use_size_deflect")
503             row.prop(part, "use_die_on_collision")
504
505             if part.physics_type == 'FLUID':
506                 fluid = part.fluid
507
508                 split = layout.split()
509
510                 col = split.column()
511                 col.label(text="Fluid properties:")
512                 col.prop(fluid, "stiffness", text="Stiffness")
513                 col.prop(fluid, "linear_viscosity", text="Viscosity")
514                 col.prop(fluid, "buoyancy", text="Buoyancy", slider=True)
515
516                 col = split.column()
517                 col.label(text="Advanced:")
518
519                 sub = col.row()
520                 sub.prop(fluid, "repulsion", slider=fluid.factor_repulsion)
521                 sub.prop(fluid, "factor_repulsion", text="")
522
523                 sub = col.row()
524                 sub.prop(fluid, "stiff_viscosity", slider=fluid.factor_stiff_viscosity)
525                 sub.prop(fluid, "factor_stiff_viscosity", text="")
526
527                 sub = col.row()
528                 sub.prop(fluid, "fluid_radius", slider=fluid.factor_radius)
529                 sub.prop(fluid, "factor_radius", text="")
530
531                 sub = col.row()
532                 sub.prop(fluid, "rest_density", slider=fluid.factor_density)
533                 sub.prop(fluid, "factor_density", text="")
534
535                 split = layout.split()
536
537                 col = split.column()
538                 col.label(text="Springs:")
539                 col.prop(fluid, "spring_force", text="Force")
540                 col.prop(fluid, "use_viscoelastic_springs")
541                 sub = col.column(align=True)
542                 sub.active = fluid.use_viscoelastic_springs
543                 sub.prop(fluid, "yield_ratio", slider=True)
544                 sub.prop(fluid, "plasticity", slider=True)
545
546                 col = split.column()
547                 col.label(text="Advanced:")
548                 sub = col.row()
549                 sub.prop(fluid, "rest_length", slider=fluid.factor_rest_length)
550                 sub.prop(fluid, "factor_rest_length", text="")
551                 col.label(text="")
552                 sub = col.column()
553                 sub.active = fluid.use_viscoelastic_springs
554                 sub.prop(fluid, "use_initial_rest_length")
555                 sub.prop(fluid, "spring_frames", text="Frames")
556
557         elif part.physics_type == 'KEYED':
558             split = layout.split()
559             sub = split.column()
560
561             row = layout.row()
562             col = row.column()
563             col.active = not psys.use_keyed_timing
564             col.prop(part, "keyed_loops", text="Loops")
565             if psys:
566                 row.prop(psys, "use_keyed_timing", text="Use Timing")
567
568             layout.label(text="Keys:")
569         elif part.physics_type == 'BOIDS':
570             boids = part.boids
571
572             row = layout.row()
573             row.prop(boids, "use_flight")
574             row.prop(boids, "use_land")
575             row.prop(boids, "use_climb")
576
577             split = layout.split()
578
579             sub = split.column()
580             col = sub.column(align=True)
581             col.active = boids.use_flight
582             col.prop(boids, "air_speed_max")
583             col.prop(boids, "air_speed_min", slider=True)
584             col.prop(boids, "air_acc_max", slider=True)
585             col.prop(boids, "air_ave_max", slider=True)
586             col.prop(boids, "air_personal_space")
587             row = col.row()
588             row.active = (boids.use_land or boids.use_climb) and boids.use_flight
589             row.prop(boids, "land_smooth")
590
591             sub = split.column()
592             col = sub.column(align=True)
593             col.active = boids.use_land or boids.use_climb
594             col.prop(boids, "land_speed_max")
595             col.prop(boids, "land_jump_speed")
596             col.prop(boids, "land_acc_max", slider=True)
597             col.prop(boids, "land_ave_max", slider=True)
598             col.prop(boids, "land_personal_space")
599             col.prop(boids, "land_stick_force")
600
601             row = layout.row()
602
603             col = row.column(align=True)
604             col.label(text="Battle:")
605             col.prop(boids, "health")
606             col.prop(boids, "strength")
607             col.prop(boids, "aggression")
608             col.prop(boids, "accuracy")
609             col.prop(boids, "range")
610
611             col = row.column()
612             col.label(text="Misc:")
613             col.prop(boids, "bank", slider=True)
614             col.prop(boids, "pitch", slider=True)
615             col.prop(boids, "height", slider=True)
616
617         if psys and part.physics_type in {'KEYED', 'BOIDS', 'FLUID'}:
618             if part.physics_type == 'BOIDS':
619                 layout.label(text="Relations:")
620             elif part.physics_type == 'FLUID':
621                 layout.label(text="Fluid interaction:")
622
623             row = layout.row()
624             row.template_list(psys, "targets", psys, "active_particle_target_index")
625
626             col = row.column()
627             sub = col.row()
628             subsub = sub.column(align=True)
629             subsub.operator("particle.new_target", icon='ZOOMIN', text="")
630             subsub.operator("particle.target_remove", icon='ZOOMOUT', text="")
631             sub = col.row()
632             subsub = sub.column(align=True)
633             subsub.operator("particle.target_move_up", icon='MOVE_UP_VEC', text="")
634             subsub.operator("particle.target_move_down", icon='MOVE_DOWN_VEC', text="")
635
636             key = psys.active_particle_target
637             if key:
638                 row = layout.row()
639                 if part.physics_type == 'KEYED':
640                     col = row.column()
641                     #doesn't work yet
642                     #col.alert = key.valid
643                     col.prop(key, "object", text="")
644                     col.prop(key, "system", text="System")
645                     col = row.column()
646                     col.active = psys.use_keyed_timing
647                     col.prop(key, "time")
648                     col.prop(key, "duration")
649                 elif part.physics_type == 'BOIDS':
650                     sub = row.row()
651                     #doesn't work yet
652                     #sub.alert = key.valid
653                     sub.prop(key, "object", text="")
654                     sub.prop(key, "system", text="System")
655
656                     layout.prop(key, "alliance", expand=True)
657                 elif part.physics_type == 'FLUID':
658                     sub = row.row()
659                     #doesn't work yet
660                     #sub.alert = key.valid
661                     sub.prop(key, "object", text="")
662                     sub.prop(key, "system", text="System")
663
664
665 class PARTICLE_PT_boidbrain(ParticleButtonsPanel, Panel):
666     bl_label = "Boid Brain"
667     COMPAT_ENGINES = {'BLENDER_RENDER'}
668
669     @classmethod
670     def poll(cls, context):
671         psys = context.particle_system
672         settings = particle_get_settings(context)
673         engine = context.scene.render.engine
674
675         if settings is None:
676             return False
677         if psys is not None and psys.point_cache.use_external:
678             return False
679         return settings.physics_type == 'BOIDS' and engine in cls.COMPAT_ENGINES
680
681     def draw(self, context):
682         layout = self.layout
683
684         boids = particle_get_settings(context).boids
685
686         layout.enabled = particle_panel_enabled(context, context.particle_system)
687
688         # Currently boids can only use the first state so these are commented out for now.
689         #row = layout.row()
690         #row.template_list(boids, "states", boids, "active_boid_state_index", compact="True")
691         #col = row.row()
692         #sub = col.row(align=True)
693         #sub.operator("boid.state_add", icon='ZOOMIN', text="")
694         #sub.operator("boid.state_del", icon='ZOOMOUT', text="")
695         #sub = row.row(align=True)
696         #sub.operator("boid.state_move_up", icon='MOVE_UP_VEC', text="")
697         #sub.operator("boid.state_move_down", icon='MOVE_DOWN_VEC', text="")
698
699         state = boids.active_boid_state
700
701         #layout.prop(state, "name", text="State name")
702
703         row = layout.row()
704         row.prop(state, "ruleset_type")
705         if state.ruleset_type == 'FUZZY':
706             row.prop(state, "rule_fuzzy", slider=True)
707         else:
708             row.label(text="")
709
710         row = layout.row()
711         row.template_list(state, "rules", state, "active_boid_rule_index")
712
713         col = row.column()
714         sub = col.row()
715         subsub = sub.column(align=True)
716         subsub.operator_menu_enum("boid.rule_add", "type", icon='ZOOMIN', text="")
717         subsub.operator("boid.rule_del", icon='ZOOMOUT', text="")
718         sub = col.row()
719         subsub = sub.column(align=True)
720         subsub.operator("boid.rule_move_up", icon='MOVE_UP_VEC', text="")
721         subsub.operator("boid.rule_move_down", icon='MOVE_DOWN_VEC', text="")
722
723         rule = state.active_boid_rule
724
725         if rule:
726             row = layout.row()
727             row.prop(rule, "name", text="")
728             #somebody make nice icons for boids here please! -jahka
729             row.prop(rule, "use_in_air", icon='MOVE_UP_VEC', text="")
730             row.prop(rule, "use_on_land", icon='MOVE_DOWN_VEC', text="")
731
732             row = layout.row()
733
734             if rule.type == 'GOAL':
735                 row.prop(rule, "object")
736                 row = layout.row()
737                 row.prop(rule, "use_predict")
738             elif rule.type == 'AVOID':
739                 row.prop(rule, "object")
740                 row = layout.row()
741                 row.prop(rule, "use_predict")
742                 row.prop(rule, "fear_factor")
743             elif rule.type == 'FOLLOW_PATH':
744                 row.label(text="Not yet functional")
745             elif rule.type == 'AVOID_COLLISION':
746                 row.prop(rule, "use_avoid")
747                 row.prop(rule, "use_avoid_collision")
748                 row.prop(rule, "look_ahead")
749             elif rule.type == 'FOLLOW_LEADER':
750                 row.prop(rule, "object", text="")
751                 row.prop(rule, "distance")
752                 row = layout.row()
753                 row.prop(rule, "use_line")
754                 sub = row.row()
755                 sub.active = rule.line
756                 sub.prop(rule, "queue_count")
757             elif rule.type == 'AVERAGE_SPEED':
758                 row.prop(rule, "speed", slider=True)
759                 row.prop(rule, "wander", slider=True)
760                 row.prop(rule, "level", slider=True)
761             elif rule.type == 'FIGHT':
762                 row.prop(rule, "distance")
763                 row.prop(rule, "flee_distance")
764
765
766 class PARTICLE_PT_render(ParticleButtonsPanel, Panel):
767     bl_label = "Render"
768     COMPAT_ENGINES = {'BLENDER_RENDER'}
769
770     @classmethod
771     def poll(cls, context):
772         settings = particle_get_settings(context)
773         engine = context.scene.render.engine
774         if settings is None:
775             return False
776
777         return engine in cls.COMPAT_ENGINES
778
779     def draw(self, context):
780         layout = self.layout
781
782         psys = context.particle_system
783         part = particle_get_settings(context)
784
785         row = layout.row()
786         row.prop(part, "material")
787         if psys:
788             row.prop(psys, "parent")
789
790         split = layout.split()
791
792         col = split.column()
793         col.prop(part, "use_render_emitter")
794         col.prop(part, "use_parent_particles")
795
796         col = split.column()
797         col.prop(part, "show_unborn")
798         col.prop(part, "use_dead")
799
800         layout.prop(part, "render_type", expand=True)
801
802         split = layout.split()
803
804         col = split.column()
805
806         if part.render_type == 'LINE':
807             col.prop(part, "line_length_tail")
808             col.prop(part, "line_length_head")
809
810             split.prop(part, "use_velocity_length")
811         elif part.render_type == 'PATH':
812             col.prop(part, "use_strand_primitive")
813             sub = col.column()
814             sub.active = (part.use_strand_primitive is False)
815             sub.prop(part, "use_render_adaptive")
816             sub = col.column()
817             sub.active = part.use_render_adaptive or part.use_strand_primitive is True
818             sub.prop(part, "adaptive_angle")
819             sub = col.column()
820             sub.active = (part.use_render_adaptive is True and part.use_strand_primitive is False)
821             sub.prop(part, "adaptive_pixel")
822             col.prop(part, "use_hair_bspline")
823             col.prop(part, "render_step", text="Steps")
824
825             col = split.column()
826             col.label(text="Timing:")
827             col.prop(part, "use_absolute_path_time")
828             col.prop(part, "path_start", text="Start", slider=not part.use_absolute_path_time)
829             col.prop(part, "path_end", text="End", slider=not part.use_absolute_path_time)
830             col.prop(part, "length_random", text="Random", slider=True)
831
832             row = layout.row()
833             col = row.column()
834
835             if part.type == 'HAIR' and part.use_strand_primitive is True and part.child_type == 'INTERPOLATED':
836                 layout.prop(part, "use_simplify")
837                 if part.use_simplify is True:
838                     row = layout.row()
839                     row.prop(part, "simplify_refsize")
840                     row.prop(part, "simplify_rate")
841                     row.prop(part, "simplify_transition")
842                     row = layout.row()
843                     row.prop(part, "use_simplify_viewport")
844                     sub = row.row()
845                     sub.active = part.use_simplify_viewport is True
846                     sub.prop(part, "simplify_viewport")
847
848         elif part.render_type == 'OBJECT':
849             col.prop(part, "dupli_object")
850             sub = col.row()
851             sub.prop(part, "use_global_dupli")
852             sub.prop(part, "use_rotation_dupli")
853             sub.prop(part, "use_scale_dupli")
854         elif part.render_type == 'GROUP':
855             col.prop(part, "dupli_group")
856             split = layout.split()
857
858             col = split.column()
859             col.prop(part, "use_whole_group")
860             sub = col.column()
861             sub.active = (part.use_whole_group is False)
862             sub.prop(part, "use_group_pick_random")
863             sub.prop(part, "use_group_count")
864
865             col = split.column()
866             sub = col.column()
867             sub.active = (part.use_whole_group is False)
868             sub.prop(part, "use_global_dupli")
869             sub.prop(part, "use_rotation_dupli")
870             sub.prop(part, "use_scale_dupli")
871
872             if part.use_group_count and not part.use_whole_group:
873                 row = layout.row()
874                 row.template_list(part, "dupli_weights", part, "active_dupliweight_index")
875
876                 col = row.column()
877                 sub = col.row()
878                 subsub = sub.column(align=True)
879                 subsub.operator("particle.dupliob_copy", icon='ZOOMIN', text="")
880                 subsub.operator("particle.dupliob_remove", icon='ZOOMOUT', text="")
881                 subsub.operator("particle.dupliob_move_up", icon='MOVE_UP_VEC', text="")
882                 subsub.operator("particle.dupliob_move_down", icon='MOVE_DOWN_VEC', text="")
883
884                 weight = part.active_dupliweight
885                 if weight:
886                     row = layout.row()
887                     row.prop(weight, "count")
888
889         elif part.render_type == 'BILLBOARD':
890             ob = context.object
891
892             col.label(text="Align:")
893
894             row = layout.row()
895             row.prop(part, "billboard_align", expand=True)
896             row.prop(part, "lock_billboard", text="Lock")
897             row = layout.row()
898             row.prop(part, "billboard_object")
899
900             row = layout.row()
901             col = row.column(align=True)
902             col.label(text="Tilt:")
903             col.prop(part, "billboard_tilt", text="Angle", slider=True)
904             col.prop(part, "billboard_tilt_random", text="Random", slider=True)
905             col = row.column()
906             col.prop(part, "billboard_offset")
907
908             row = layout.row()
909             col = row.column()
910             col.prop(part, "billboard_size", text="Scale")
911             if part.billboard_align == 'VEL':
912                 col = row.column(align=True)
913                 col.label("Velocity Scale:")
914                 col.prop(part, "billboard_velocity_head", text="Head")
915                 col.prop(part, "billboard_velocity_tail", text="Tail")
916
917             if psys:
918                 col = layout.column()
919                 col.prop_search(psys, "billboard_normal_uv", ob.data, "uv_textures")
920                 col.prop_search(psys, "billboard_time_index_uv", ob.data, "uv_textures")
921
922             split = layout.split(percentage=0.33)
923             split.label(text="Split UVs:")
924             split.prop(part, "billboard_uv_split", text="Number of splits")
925
926             if psys:
927                 col = layout.column()
928                 col.active = part.billboard_uv_split > 1
929                 col.prop_search(psys, "billboard_split_uv", ob.data, "uv_textures")
930
931             row = col.row()
932             row.label(text="Animate:")
933             row.prop(part, "billboard_animation", text="")
934             row.label(text="Offset:")
935             row.prop(part, "billboard_offset_split", text="")
936
937         if part.render_type == 'HALO' or part.render_type == 'LINE' or part.render_type == 'BILLBOARD':
938             row = layout.row()
939             col = row.column()
940             col.prop(part, "trail_count")
941             if part.trail_count > 1:
942                 col.prop(part, "use_absolute_path_time", text="Length in frames")
943                 col = row.column()
944                 col.prop(part, "path_end", text="Length", slider=not part.use_absolute_path_time)
945                 col.prop(part, "length_random", text="Random", slider=True)
946             else:
947                 col = row.column()
948                 col.label(text="")
949
950         if part.render_type in {'OBJECT', 'GROUP'} and not part.use_advanced_hair:
951             row = layout.row(align=True)
952             row.prop(part, "particle_size")
953             row.prop(part, "size_random", slider=True)
954
955
956 class PARTICLE_PT_draw(ParticleButtonsPanel, Panel):
957     bl_label = "Display"
958     bl_options = {'DEFAULT_CLOSED'}
959     COMPAT_ENGINES = {'BLENDER_RENDER'}
960
961     @classmethod
962     def poll(cls, context):
963         settings = particle_get_settings(context)
964         engine = context.scene.render.engine
965         if settings is None:
966             return False
967         return engine in cls.COMPAT_ENGINES
968
969     def draw(self, context):
970         layout = self.layout
971
972         psys = context.particle_system
973         part = particle_get_settings(context)
974
975         row = layout.row()
976         row.prop(part, "draw_method", expand=True)
977
978         if part.draw_method == 'NONE' or (part.render_type == 'NONE' and part.draw_method == 'RENDER'):
979             return
980
981         path = (part.render_type == 'PATH' and part.draw_method == 'RENDER') or part.draw_method == 'PATH'
982
983         row = layout.row()
984         row.prop(part, "draw_percentage", slider=True)
985         if part.draw_method != 'RENDER' or part.render_type == 'HALO':
986             row.prop(part, "draw_size")
987         else:
988             row.label(text="")
989
990         if part.draw_percentage != 100 and psys is not None:
991             if part.type == 'HAIR':
992                 if psys.use_hair_dynamics and psys.point_cache.is_baked is False:
993                     layout.row().label(text="Display percentage makes dynamics inaccurate without baking!")
994             else:
995                 phystype = part.physics_type
996                 if phystype != 'NO' and phystype != 'KEYED' and psys.point_cache.is_baked is False:
997                     layout.row().label(text="Display percentage makes dynamics inaccurate without baking!")
998
999         row = layout.row()
1000         col = row.column()
1001         col.prop(part, "show_size")
1002         col.prop(part, "show_velocity")
1003         col.prop(part, "show_number")
1004         if part.physics_type == 'BOIDS':
1005             col.prop(part, "show_health")
1006
1007         col = row.column(align=True)
1008         col.label(text="Color:")
1009         col.prop(part, "draw_color", text="")
1010         sub = col.row()
1011         sub.active = (part.draw_color in {'VELOCITY', 'ACCELERATION'})
1012         sub.prop(part, "color_maximum", text="Max")
1013
1014         if path:
1015             col.prop(part, "draw_step")
1016
1017
1018 class PARTICLE_PT_children(ParticleButtonsPanel, Panel):
1019     bl_label = "Children"
1020     bl_options = {'DEFAULT_CLOSED'}
1021     COMPAT_ENGINES = {'BLENDER_RENDER'}
1022
1023     @classmethod
1024     def poll(cls, context):
1025         return particle_panel_poll(cls, context)
1026
1027     def draw(self, context):
1028         layout = self.layout
1029
1030         psys = context.particle_system
1031         part = particle_get_settings(context)
1032
1033         layout.row().prop(part, "child_type", expand=True)
1034
1035         if part.child_type == 'NONE':
1036             return
1037
1038         row = layout.row()
1039
1040         col = row.column(align=True)
1041         col.prop(part, "child_nbr", text="Display")
1042         col.prop(part, "rendered_child_count", text="Render")
1043
1044         if part.child_type == 'INTERPOLATED':
1045             col = row.column()
1046             if psys:
1047                 col.prop(psys, "child_seed", text="Seed")
1048             col.prop(part, "virtual_parents", slider=True)
1049             col.prop(part, "create_long_hair_children")
1050         else:
1051             col = row.column(align=True)
1052             col.prop(part, "child_size", text="Size")
1053             col.prop(part, "child_size_random", text="Random")
1054
1055         split = layout.split()
1056
1057         col = split.column()
1058         col.label(text="Effects:")
1059
1060         sub = col.column(align=True)
1061         sub.prop(part, "clump_factor", slider=True)
1062         sub.prop(part, "clump_shape", slider=True)
1063
1064         sub = col.column(align=True)
1065         sub.prop(part, "child_length", slider=True)
1066         sub.prop(part, "child_length_threshold", slider=True)
1067
1068         if part.child_type == 'SIMPLE':
1069             sub = col.column(align=True)
1070             sub.prop(part, "child_radius", text="Radius")
1071             sub.prop(part, "child_roundness", text="Roundness", slider=True)
1072             if psys:
1073                 sub.prop(psys, "child_seed", text="Seed")
1074         elif part.virtual_parents > 0.0:
1075             sub = col.column(align=True)
1076             sub.label(text="Parting not")
1077             sub.label(text="available with")
1078             sub.label(text="virtual parents")
1079         else:
1080             sub = col.column(align=True)
1081             sub.prop(part, "child_parting_factor", text="Parting", slider=True)
1082             sub.prop(part, "child_parting_min", text="Min")
1083             sub.prop(part, "child_parting_max", text="Max")
1084
1085         col = split.column()
1086         col.label(text="Roughness:")
1087
1088         sub = col.column(align=True)
1089         sub.prop(part, "roughness_1", text="Uniform")
1090         sub.prop(part, "roughness_1_size", text="Size")
1091
1092         sub = col.column(align=True)
1093         sub.prop(part, "roughness_endpoint", "Endpoint")
1094         sub.prop(part, "roughness_end_shape")
1095
1096         sub = col.column(align=True)
1097         sub.prop(part, "roughness_2", text="Random")
1098         sub.prop(part, "roughness_2_size", text="Size")
1099         sub.prop(part, "roughness_2_threshold", slider=True)
1100
1101         layout.row().label(text="Kink:")
1102         layout.row().prop(part, "kink", expand=True)
1103
1104         split = layout.split()
1105         split.active = part.kink != 'NO'
1106
1107         col = split.column()
1108         sub = col.column(align=True)
1109         sub.prop(part, "kink_amplitude")
1110         sub.prop(part, "kink_amplitude_clump", text="Clump", slider=True)
1111         col.prop(part, "kink_flat", slider=True)
1112         col = split.column()
1113         sub = col.column(align=True)
1114         sub.prop(part, "kink_frequency")
1115         sub.prop(part, "kink_shape", slider=True)
1116
1117
1118 class PARTICLE_PT_field_weights(ParticleButtonsPanel, Panel):
1119     bl_label = "Field Weights"
1120     bl_options = {'DEFAULT_CLOSED'}
1121     COMPAT_ENGINES = {'BLENDER_RENDER'}
1122
1123     @classmethod
1124     def poll(cls, context):
1125         return particle_panel_poll(cls, context)
1126
1127     def draw(self, context):
1128         part = particle_get_settings(context)
1129         effector_weights_ui(self, context, part.effector_weights, 'PSYS')
1130
1131         if part.type == 'HAIR':
1132             row = self.layout.row()
1133             row.prop(part.effector_weights, "apply_to_hair_growing")
1134             row.prop(part, "apply_effector_to_children")
1135             row = self.layout.row()
1136             row.prop(part, "effect_hair", slider=True)
1137
1138
1139 class PARTICLE_PT_force_fields(ParticleButtonsPanel, Panel):
1140     bl_label = "Force Field Settings"
1141     bl_options = {'DEFAULT_CLOSED'}
1142     COMPAT_ENGINES = {'BLENDER_RENDER'}
1143
1144     def draw(self, context):
1145         layout = self.layout
1146
1147         part = particle_get_settings(context)
1148
1149         row = layout.row()
1150         row.prop(part, "use_self_effect")
1151         row.prop(part, "effector_amount", text="Amount")
1152
1153         split = layout.split(percentage=0.2)
1154         split.label(text="Type 1:")
1155         split.prop(part.force_field_1, "type", text="")
1156         basic_force_field_settings_ui(self, context, part.force_field_1)
1157         if part.force_field_1.type != 'NONE':
1158             layout.label(text="Falloff:")
1159         basic_force_field_falloff_ui(self, context, part.force_field_1)
1160
1161         if part.force_field_1.type != 'NONE':
1162             layout.label(text="")
1163
1164         split = layout.split(percentage=0.2)
1165         split.label(text="Type 2:")
1166         split.prop(part.force_field_2, "type", text="")
1167         basic_force_field_settings_ui(self, context, part.force_field_2)
1168         if part.force_field_2.type != 'NONE':
1169             layout.label(text="Falloff:")
1170         basic_force_field_falloff_ui(self, context, part.force_field_2)
1171
1172
1173 class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, Panel):
1174     bl_label = "Vertex Groups"
1175     bl_options = {'DEFAULT_CLOSED'}
1176     COMPAT_ENGINES = {'BLENDER_RENDER'}
1177
1178     @classmethod
1179     def poll(cls, context):
1180         if context.particle_system is None:
1181             return False
1182         return particle_panel_poll(cls, context)
1183
1184     def draw(self, context):
1185         layout = self.layout
1186
1187         ob = context.object
1188         psys = context.particle_system
1189
1190         split = layout.split(percentage=0.85)
1191
1192         col = split.column()
1193         col.label(text="Vertex Group:")
1194         col.prop_search(psys, "vertex_group_density", ob, "vertex_groups", text="Density")
1195         col.prop_search(psys, "vertex_group_length", ob, "vertex_groups", text="Length")
1196         col.prop_search(psys, "vertex_group_clump", ob, "vertex_groups", text="Clump")
1197         col.prop_search(psys, "vertex_group_kink", ob, "vertex_groups", text="Kink")
1198         col.prop_search(psys, "vertex_group_roughness_1", ob, "vertex_groups", text="Roughness 1")
1199         col.prop_search(psys, "vertex_group_roughness_2", ob, "vertex_groups", text="Roughness 2")
1200         col.prop_search(psys, "vertex_group_roughness_end", ob, "vertex_groups", text="Roughness End")
1201
1202         col = split.column()
1203         col.label(text="Negate:")
1204         col.alignment = 'RIGHT'
1205         col.prop(psys, "invert_vertex_group_density", text="")
1206         col.prop(psys, "invert_vertex_group_length", text="")
1207         col.prop(psys, "invert_vertex_group_clump", text="")
1208         col.prop(psys, "invert_vertex_group_kink", text="")
1209         col.prop(psys, "invert_vertex_group_roughness_1", text="")
1210         col.prop(psys, "invert_vertex_group_roughness_2", text="")
1211         col.prop(psys, "invert_vertex_group_roughness_end", text="")
1212
1213         # Commented out vertex groups don't work and are still waiting for better implementation
1214         # row = layout.row()
1215         # row.prop_search(psys, "vertex_group_velocity", ob, "vertex_groups", text="Velocity")
1216         # row.prop(psys, "invert_vertex_group_velocity", text="")
1217
1218         # row = layout.row()
1219         # row.prop_search(psys, "vertex_group_size", ob, "vertex_groups", text="Size")
1220         # row.prop(psys, "invert_vertex_group_size", text="")
1221
1222         # row = layout.row()
1223         # row.prop_search(psys, "vertex_group_tangent", ob, "vertex_groups", text="Tangent")
1224         # row.prop(psys, "invert_vertex_group_tangent", text="")
1225
1226         # row = layout.row()
1227         # row.prop_search(psys, "vertex_group_rotation", ob, "vertex_groups", text="Rotation")
1228         # row.prop(psys, "invert_vertex_group_rotation", text="")
1229
1230         # row = layout.row()
1231         # row.prop_search(psys, "vertex_group_field", ob, "vertex_groups", text="Field")
1232         # row.prop(psys, "invert_vertex_group_field", text="")
1233
1234
1235 class PARTICLE_PT_custom_props(ParticleButtonsPanel, PropertyPanel, Panel):
1236     COMPAT_ENGINES = {'BLENDER_RENDER'}
1237     _context_path = "particle_system.settings"
1238     _property_type = bpy.types.ParticleSettings
1239
1240 if __name__ == "__main__":  # only for live edit.
1241     bpy.utils.register_module(__name__)