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