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