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