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