change python scripts so modules which register with blender have a register() functi...
[blender.git] / release / scripts / 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 rna_prop_ui import PropertyPanel
22
23 from properties_physics_common import point_cache_ui
24 from properties_physics_common import effector_weights_ui
25 from properties_physics_common import basic_force_field_settings_ui
26 from properties_physics_common import basic_force_field_falloff_ui
27
28
29 def particle_panel_enabled(context, psys):
30     return (psys.point_cache.baked is False) and (not psys.edited) and (not context.particle_system_editable)
31
32
33 def particle_panel_poll(context):
34     psys = context.particle_system
35     if psys is None:
36         return False
37     if psys.settings is None:
38         return False
39     return psys.settings.type in ('EMITTER', 'REACTOR', 'HAIR')
40
41
42 class ParticleButtonsPanel(bpy.types.Panel):
43     bl_space_type = 'PROPERTIES'
44     bl_region_type = 'WINDOW'
45     bl_context = "particle"
46
47     def poll(self, context):
48         return particle_panel_poll(context)
49
50
51 class PARTICLE_PT_context_particles(ParticleButtonsPanel):
52     bl_label = ""
53     bl_show_header = False
54
55     def poll(self, context):
56         return (context.particle_system or context.object)
57
58     def draw(self, context):
59         layout = self.layout
60
61         ob = context.object
62         psys = context.particle_system
63
64         if ob:
65             row = layout.row()
66
67             row.template_list(ob, "particle_systems", ob, "active_particle_system_index", rows=2)
68
69             col = row.column(align=True)
70             col.operator("object.particle_system_add", icon='ZOOMIN', text="")
71             col.operator("object.particle_system_remove", icon='ZOOMOUT', text="")
72
73         if psys and not psys.settings:
74             split = layout.split(percentage=0.32)
75
76             col = split.column()
77             col.label(text="Name:")
78             col.label(text="Settings:")
79
80             col = split.column()
81             col.prop(psys, "name", text="")
82             col.template_ID(psys, "settings", new="particle.new")
83         elif psys:
84             part = psys.settings
85
86             split = layout.split(percentage=0.32)
87             col = split.column()
88             col.label(text="Name:")
89             if part.type in ('EMITTER', 'REACTOR', 'HAIR'):
90                 col.label(text="Settings:")
91                 col.label(text="Type:")
92
93             col = split.column()
94             col.prop(psys, "name", text="")
95             if part.type in ('EMITTER', 'REACTOR', 'HAIR'):
96                 col.template_ID(psys, "settings", new="particle.new")
97
98             #row = layout.row()
99             #row.label(text="Viewport")
100             #row.label(text="Render")
101
102             if part:
103                 if part.type not in ('EMITTER', 'REACTOR', 'HAIR'):
104                     layout.label(text="No settings for fluid particles")
105                     return
106
107                 row = col.row()
108                 row.enabled = particle_panel_enabled(context, psys)
109                 row.prop(part, "type", text="")
110                 row.prop(psys, "seed")
111
112                 split = layout.split(percentage=0.65)
113                 if part.type == 'HAIR':
114                     if psys.edited:
115                         split.operator("particle.edited_clear", text="Free Edit")
116                     else:
117                         split.label(text="")
118                     row = split.row()
119                     row.enabled = particle_panel_enabled(context, psys)
120                     row.prop(part, "hair_step")
121                     if psys.edited:
122                         if psys.global_hair:
123                             layout.operator("particle.connect_hair")
124                             layout.label(text="Hair is disconnected.")
125                         else:
126                             layout.operator("particle.disconnect_hair")
127                             layout.label(text="")
128                 elif part.type == 'REACTOR':
129                     split.enabled = particle_panel_enabled(context, psys)
130                     split.prop(psys, "reactor_target_object")
131                     split.prop(psys, "reactor_target_particle_system", text="Particle System")
132
133
134 class PARTICLE_PT_custom_props(ParticleButtonsPanel, PropertyPanel):
135     _context_path = "particle_system.settings"
136
137
138 class PARTICLE_PT_emission(ParticleButtonsPanel):
139     bl_label = "Emission"
140
141     def poll(self, context):
142         if particle_panel_poll(context):
143             return not context.particle_system.point_cache.external
144         else:
145             return False
146
147     def draw(self, context):
148         layout = self.layout
149
150         psys = context.particle_system
151         part = psys.settings
152
153         layout.enabled = particle_panel_enabled(context, psys) and not psys.multiple_caches
154
155         row = layout.row()
156         row.active = part.distribution != 'GRID'
157         row.prop(part, "amount")
158
159         if part.type != 'HAIR':
160             split = layout.split()
161
162             col = split.column(align=True)
163             col.prop(part, "start")
164             col.prop(part, "end")
165
166             col = split.column(align=True)
167             col.prop(part, "lifetime")
168             col.prop(part, "random_lifetime", slider=True)
169
170         layout.row().label(text="Emit From:")
171
172         row = layout.row()
173         row.prop(part, "emit_from", expand=True)
174         row = layout.row()
175         row.prop(part, "trand")
176         if part.distribution != 'GRID':
177             row.prop(part, "even_distribution")
178
179         if part.emit_from == 'FACE' or part.emit_from == 'VOLUME':
180             row = layout.row()
181             row.prop(part, "distribution", expand=True)
182
183             row = layout.row()
184
185             if part.distribution == 'JIT':
186                 row.prop(part, "userjit", text="Particles/Face")
187                 row.prop(part, "jitter_factor", text="Jittering Amount", slider=True)
188             elif part.distribution == 'GRID':
189                 row.prop(part, "grid_resolution")
190
191
192 class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel):
193     bl_label = "Hair dynamics"
194     bl_default_closed = True
195
196     def poll(self, context):
197         psys = context.particle_system
198         if psys is None:
199             return False
200         if psys.settings is None:
201             return False
202         return psys.settings.type == 'HAIR'
203
204     def draw_header(self, context):
205         #cloth = context.cloth.collision_settings
206
207         #self.layout.active = cloth_panel_enabled(context.cloth)
208         #self.layout.prop(cloth, "enable_collision", text="")
209         psys = context.particle_system
210         self.layout.prop(psys, "hair_dynamics", text="")
211
212     def draw(self, context):
213         layout = self.layout
214
215         psys = context.particle_system
216
217         if not psys.cloth:
218             return
219
220         #part = psys.settings
221         cloth = psys.cloth.settings
222
223         layout.enabled = psys.hair_dynamics
224
225         split = layout.split()
226
227         col = split.column()
228         col.label(text="Material:")
229         sub = col.column(align=True)
230         sub.prop(cloth, "pin_stiffness", text="Stiffness")
231         sub.prop(cloth, "mass")
232         sub.prop(cloth, "bending_stiffness", text="Bending")
233         sub.prop(cloth, "internal_friction", slider=True)
234
235         col = split.column()
236
237         col.label(text="Damping:")
238         sub = col.column(align=True)
239         sub.prop(cloth, "spring_damping", text="Spring")
240         sub.prop(cloth, "air_damping", text="Air")
241
242         col.label(text="Quality:")
243         col.prop(cloth, "quality", text="Steps", slider=True)
244
245
246 class PARTICLE_PT_cache(ParticleButtonsPanel):
247     bl_label = "Cache"
248     bl_default_closed = True
249
250     def poll(self, context):
251         psys = context.particle_system
252         if psys is None:
253             return False
254         if psys.settings is None:
255             return False
256         phystype = psys.settings.physics_type
257         if phystype == 'NO' or phystype == 'KEYED':
258             return False
259         return psys.settings.type in ('EMITTER', 'REACTOR') or (psys.settings.type == 'HAIR' and psys.hair_dynamics)
260
261     def draw(self, context):
262
263         psys = context.particle_system
264
265         point_cache_ui(self, context, psys.point_cache, particle_panel_enabled(context, psys), not psys.hair_dynamics, 0)
266
267
268 class PARTICLE_PT_velocity(ParticleButtonsPanel):
269     bl_label = "Velocity"
270
271     def poll(self, context):
272         if particle_panel_poll(context):
273             psys = context.particle_system
274             return psys.settings.physics_type != 'BOIDS' and not psys.point_cache.external
275         else:
276             return False
277
278     def draw(self, context):
279         layout = self.layout
280
281         psys = context.particle_system
282         part = psys.settings
283
284         layout.enabled = particle_panel_enabled(context, psys)
285
286         split = layout.split()
287
288         sub = split.column()
289         sub.label(text="Emitter Geometry:")
290         sub.prop(part, "normal_factor")
291         subsub = sub.column(align=True)
292         subsub.prop(part, "tangent_factor")
293         subsub.prop(part, "tangent_phase", slider=True)
294
295         sub = split.column()
296         sub.label(text="Emitter Object")
297         sub.prop(part, "object_aligned_factor", text="")
298
299         layout.row().label(text="Other:")
300         split = layout.split()
301         sub = split.column()
302         if part.emit_from == 'PARTICLE':
303             sub.prop(part, "particle_factor")
304         else:
305             sub.prop(part, "object_factor", slider=True)
306         sub = split.column()
307         sub.prop(part, "random_factor")
308
309         #if part.type=='REACTOR':
310         #    sub.prop(part, "reactor_factor")
311         #    sub.prop(part, "reaction_shape", slider=True)
312
313
314 class PARTICLE_PT_rotation(ParticleButtonsPanel):
315     bl_label = "Rotation"
316
317     def poll(self, context):
318         if particle_panel_poll(context):
319             psys = context.particle_system
320             return psys.settings.physics_type != 'BOIDS' and not psys.point_cache.external
321         else:
322             return False
323
324     def draw(self, context):
325         layout = self.layout
326
327         psys = context.particle_system
328         part = psys.settings
329
330         layout.enabled = particle_panel_enabled(context, psys)
331
332         split = layout.split()
333         split.label(text="Initial Rotation:")
334         split.prop(part, "rotation_dynamic")
335         split = layout.split()
336
337         sub = split.column(align=True)
338         sub.prop(part, "rotation_mode", text="")
339         sub.prop(part, "random_rotation_factor", slider=True, text="Random")
340
341         sub = split.column(align=True)
342         sub.prop(part, "phase_factor", slider=True)
343         sub.prop(part, "random_phase_factor", text="Random", slider=True)
344
345         layout.row().label(text="Angular Velocity:")
346         layout.row().prop(part, "angular_velocity_mode", expand=True)
347         split = layout.split()
348
349         sub = split.column()
350
351         if part.angular_velocity_mode != 'NONE':
352             sub.prop(part, "angular_velocity_factor", text="")
353
354
355 class PARTICLE_PT_physics(ParticleButtonsPanel):
356     bl_label = "Physics"
357
358     def poll(self, context):
359         if particle_panel_poll(context):
360             return not context.particle_system.point_cache.external
361         else:
362             return False
363
364     def draw(self, context):
365         layout = self.layout
366
367         psys = context.particle_system
368         part = psys.settings
369
370         layout.enabled = particle_panel_enabled(context, psys)
371
372         row = layout.row()
373         row.prop(part, "physics_type", expand=True)
374         if part.physics_type != 'NO':
375             row = layout.row()
376             col = row.column(align=True)
377             col.prop(part, "particle_size")
378             col.prop(part, "random_size", slider=True)
379             col = row.column(align=True)
380             col.prop(part, "mass")
381             col.prop(part, "sizemass", text="Multiply mass with size")
382
383         if part.physics_type == 'NEWTON':
384             split = layout.split()
385             sub = split.column()
386
387             sub.label(text="Forces:")
388             sub.prop(part, "brownian_factor")
389             sub.prop(part, "drag_factor", slider=True)
390             sub.prop(part, "damp_factor", slider=True)
391             sub = split.column()
392             sub.prop(part, "size_deflect")
393             sub.prop(part, "die_on_collision")
394             sub.prop(part, "integrator")
395             sub.prop(part, "time_tweak")
396
397         elif part.physics_type == 'KEYED':
398             split = layout.split()
399             sub = split.column()
400
401             row = layout.row()
402             col = row.column()
403             col.active = not psys.keyed_timing
404             col.prop(part, "keyed_loops", text="Loops")
405             row.prop(psys, "keyed_timing", text="Use Timing")
406
407             layout.label(text="Keys:")
408         elif part.physics_type == 'BOIDS':
409             boids = part.boids
410
411
412             row = layout.row()
413             row.prop(boids, "allow_flight")
414             row.prop(boids, "allow_land")
415             row.prop(boids, "allow_climb")
416
417             split = layout.split()
418
419             sub = split.column()
420             col = sub.column(align=True)
421             col.active = boids.allow_flight
422             col.prop(boids, "air_max_speed")
423             col.prop(boids, "air_min_speed", slider=True)
424             col.prop(boids, "air_max_acc", slider=True)
425             col.prop(boids, "air_max_ave", slider=True)
426             col.prop(boids, "air_personal_space")
427             row = col.row()
428             row.active = (boids.allow_land or boids.allow_climb) and boids.allow_flight
429             row.prop(boids, "landing_smoothness")
430
431             sub = split.column()
432             col = sub.column(align=True)
433             col.active = boids.allow_land or boids.allow_climb
434             col.prop(boids, "land_max_speed")
435             col.prop(boids, "land_jump_speed")
436             col.prop(boids, "land_max_acc", slider=True)
437             col.prop(boids, "land_max_ave", slider=True)
438             col.prop(boids, "land_personal_space")
439             col.prop(boids, "land_stick_force")
440
441             row = layout.row()
442
443             col = row.column(align=True)
444             col.label(text="Battle:")
445             col.prop(boids, "health")
446             col.prop(boids, "strength")
447             col.prop(boids, "aggression")
448             col.prop(boids, "accuracy")
449             col.prop(boids, "range")
450
451             col = row.column()
452             col.label(text="Misc:")
453             col.prop(boids, "banking", slider=True)
454             col.prop(boids, "height", slider=True)
455
456         if part.physics_type == 'KEYED' or part.physics_type == 'BOIDS':
457             if part.physics_type == 'BOIDS':
458                 layout.label(text="Relations:")
459
460             row = layout.row()
461             row.template_list(psys, "targets", psys, "active_particle_target_index")
462
463             col = row.column()
464             sub = col.row()
465             subsub = sub.column(align=True)
466             subsub.operator("particle.new_target", icon='ZOOMIN', text="")
467             subsub.operator("particle.target_remove", icon='ZOOMOUT', text="")
468             sub = col.row()
469             subsub = sub.column(align=True)
470             subsub.operator("particle.target_move_up", icon='MOVE_UP_VEC', text="")
471             subsub.operator("particle.target_move_down", icon='MOVE_DOWN_VEC', text="")
472
473             key = psys.active_particle_target
474             if key:
475                 row = layout.row()
476                 if part.physics_type == 'KEYED':
477                     col = row.column()
478                     #doesn't work yet
479                     #col.red_alert = key.valid
480                     col.prop(key, "object", text="")
481                     col.prop(key, "system", text="System")
482                     col = row.column()
483                     col.active = psys.keyed_timing
484                     col.prop(key, "time")
485                     col.prop(key, "duration")
486                 else:
487                     sub = row.row()
488                     #doesn't work yet
489                     #sub.red_alert = key.valid
490                     sub.prop(key, "object", text="")
491                     sub.prop(key, "system", text="System")
492
493                     layout.prop(key, "mode", expand=True)
494
495
496 class PARTICLE_PT_boidbrain(ParticleButtonsPanel):
497     bl_label = "Boid Brain"
498
499     def poll(self, context):
500         psys = context.particle_system
501         if psys is None:
502             return False
503         if psys.settings is None:
504             return False
505         if psys.point_cache.external:
506             return False
507         return psys.settings.physics_type == 'BOIDS'
508
509     def draw(self, context):
510         layout = self.layout
511
512         boids = context.particle_system.settings.boids
513
514         layout.enabled = particle_panel_enabled(context, context.particle_system)
515
516         # Currently boids can only use the first state so these are commented out for now.
517         #row = layout.row()
518         #row.template_list(boids, "states", boids, "active_boid_state_index", compact="True")
519         #col = row.row()
520         #sub = col.row(align=True)
521         #sub.operator("boid.state_add", icon='ZOOMIN', text="")
522         #sub.operator("boid.state_del", icon='ZOOMOUT', text="")
523         #sub = row.row(align=True)
524         #sub.operator("boid.state_move_up", icon='MOVE_UP_VEC', text="")
525         #sub.operator("boid.state_move_down", icon='MOVE_DOWN_VEC', text="")
526
527         state = boids.active_boid_state
528
529         #layout.prop(state, "name", text="State name")
530
531         row = layout.row()
532         row.prop(state, "ruleset_type")
533         if state.ruleset_type == 'FUZZY':
534             row.prop(state, "rule_fuzziness", slider=True)
535         else:
536             row.label(text="")
537
538         row = layout.row()
539         row.template_list(state, "rules", state, "active_boid_rule_index")
540
541         col = row.column()
542         sub = col.row()
543         subsub = sub.column(align=True)
544         subsub.operator_menu_enum("boid.rule_add", "type", icon='ZOOMIN', text="")
545         subsub.operator("boid.rule_del", icon='ZOOMOUT', text="")
546         sub = col.row()
547         subsub = sub.column(align=True)
548         subsub.operator("boid.rule_move_up", icon='MOVE_UP_VEC', text="")
549         subsub.operator("boid.rule_move_down", icon='MOVE_DOWN_VEC', text="")
550
551         rule = state.active_boid_rule
552
553         if rule:
554             row = layout.row()
555             row.prop(rule, "name", text="")
556             #somebody make nice icons for boids here please! -jahka
557             row.prop(rule, "in_air", icon='MOVE_UP_VEC', text="")
558             row.prop(rule, "on_land", icon='MOVE_DOWN_VEC', text="")
559
560             row = layout.row()
561
562             if rule.type == 'GOAL':
563                 row.prop(rule, "object")
564                 row = layout.row()
565                 row.prop(rule, "predict")
566             elif rule.type == 'AVOID':
567                 row.prop(rule, "object")
568                 row = layout.row()
569                 row.prop(rule, "predict")
570                 row.prop(rule, "fear_factor")
571             elif rule.type == 'FOLLOW_PATH':
572                 row.label(text="Not yet functional.")
573             elif rule.type == 'AVOID_COLLISION':
574                 row.prop(rule, "boids")
575                 row.prop(rule, "deflectors")
576                 row.prop(rule, "look_ahead")
577             elif rule.type == 'FOLLOW_LEADER':
578                 row.prop(rule, "object", text="")
579                 row.prop(rule, "distance")
580                 row = layout.row()
581                 row.prop(rule, "line")
582                 sub = row.row()
583                 sub.active = rule.line
584                 sub.prop(rule, "queue_size")
585             elif rule.type == 'AVERAGE_SPEED':
586                 row.prop(rule, "speed", slider=True)
587                 row.prop(rule, "wander", slider=True)
588                 row.prop(rule, "level", slider=True)
589             elif rule.type == 'FIGHT':
590                 row.prop(rule, "distance")
591                 row.prop(rule, "flee_distance")
592
593
594 class PARTICLE_PT_render(ParticleButtonsPanel):
595     bl_label = "Render"
596
597     def poll(self, context):
598         psys = context.particle_system
599         if psys is None:
600             return False
601         if psys.settings is None:
602             return False
603         return True
604
605     def draw(self, context):
606         layout = self.layout
607
608         psys = context.particle_system
609         part = psys.settings
610
611         row = layout.row()
612         row.prop(part, "material")
613         row.prop(psys, "parent")
614
615         split = layout.split()
616
617         sub = split.column()
618         sub.prop(part, "emitter")
619         sub.prop(part, "parent")
620         sub = split.column()
621         sub.prop(part, "unborn")
622         sub.prop(part, "died")
623
624         row = layout.row()
625         row.prop(part, "ren_as", expand=True)
626
627         split = layout.split()
628
629         sub = split.column()
630
631         if part.ren_as == 'LINE':
632             sub.prop(part, "line_length_tail")
633             sub.prop(part, "line_length_head")
634             sub = split.column()
635             sub.prop(part, "velocity_length")
636         elif part.ren_as == 'PATH':
637
638             if part.type != 'HAIR' and part.physics_type != 'KEYED' and (psys.point_cache.baked is False):
639                 box = layout.box()
640                 box.label(text="Baked or keyed particles needed for correct rendering.")
641                 return
642
643             sub.prop(part, "render_strand")
644             subsub = sub.column()
645             subsub.active = (part.render_strand is False)
646             subsub.prop(part, "render_adaptive")
647             subsub = sub.column()
648             subsub.active = part.render_adaptive or part.render_strand == True
649             subsub.prop(part, "adaptive_angle")
650             subsub = sub.column()
651             subsub.active = (part.render_adaptive is True and part.render_strand is False)
652             subsub.prop(part, "adaptive_pix")
653             sub.prop(part, "hair_bspline")
654             sub.prop(part, "render_step", text="Steps")
655
656             sub = split.column()
657             sub.label(text="Timing:")
658             sub.prop(part, "abs_path_time")
659             sub.prop(part, "path_start", text="Start", slider=not part.abs_path_time)
660             sub.prop(part, "path_end", text="End", slider=not part.abs_path_time)
661             sub.prop(part, "random_length", text="Random", slider=True)
662
663             row = layout.row()
664             col = row.column()
665
666             if part.type == 'HAIR' and part.render_strand == True and part.child_type == 'FACES':
667                 layout.prop(part, "enable_simplify")
668                 if part.enable_simplify == True:
669                     row = layout.row()
670                     row.prop(part, "simplify_refsize")
671                     row.prop(part, "simplify_rate")
672                     row.prop(part, "simplify_transition")
673                     row = layout.row()
674                     row.prop(part, "viewport")
675                     sub = row.row()
676                     sub.active = part.viewport == True
677                     sub.prop(part, "simplify_viewport")
678
679         elif part.ren_as == 'OBJECT':
680             sub.prop(part, "dupli_object")
681             sub.prop(part, "use_global_dupli")
682         elif part.ren_as == 'GROUP':
683             sub.prop(part, "dupli_group")
684             split = layout.split()
685             sub = split.column()
686             sub.prop(part, "whole_group")
687             subsub = sub.column()
688             subsub.active = (part.whole_group is False)
689             subsub.prop(part, "use_group_count")
690
691             sub = split.column()
692             subsub = sub.column()
693             subsub.active = (part.whole_group is False)
694             subsub.prop(part, "use_global_dupli")
695             subsub.prop(part, "rand_group")
696
697             if part.use_group_count and not part.whole_group:
698                 row = layout.row()
699                 row.template_list(part, "dupliweights", part, "active_dupliweight_index")
700
701                 col = row.column()
702                 sub = col.row()
703                 subsub = sub.column(align=True)
704                 subsub.operator("particle.dupliob_copy", icon='ZOOMIN', text="")
705                 subsub.operator("particle.dupliob_remove", icon='ZOOMOUT', text="")
706                 subsub.operator("particle.dupliob_move_up", icon='MOVE_UP_VEC', text="")
707                 subsub.operator("particle.dupliob_move_down", icon='MOVE_DOWN_VEC', text="")
708
709                 weight = part.active_dupliweight
710                 if weight:
711                     row = layout.row()
712                     row.prop(weight, "count")
713
714         elif part.ren_as == 'BILLBOARD':
715             sub.label(text="Align:")
716
717             row = layout.row()
718             row.prop(part, "billboard_align", expand=True)
719             row.prop(part, "billboard_lock", text="Lock")
720             row = layout.row()
721             row.prop(part, "billboard_object")
722
723             row = layout.row()
724             col = row.column(align=True)
725             col.label(text="Tilt:")
726             col.prop(part, "billboard_tilt", text="Angle", slider=True)
727             col.prop(part, "billboard_random_tilt", slider=True)
728             col = row.column()
729             col.prop(part, "billboard_offset")
730
731             row = layout.row()
732             row.prop(psys, "billboard_normal_uv")
733             row = layout.row()
734             row.prop(psys, "billboard_time_index_uv")
735
736             row = layout.row()
737             row.label(text="Split uv's:")
738             row.prop(part, "billboard_uv_split", text="Number of splits")
739             row = layout.row()
740             row.prop(psys, "billboard_split_uv")
741             row = layout.row()
742             row.label(text="Animate:")
743             row.prop(part, "billboard_animation", expand=True)
744             row.label(text="Offset:")
745             row.prop(part, "billboard_split_offset", expand=True)
746
747         if part.ren_as == 'HALO' or part.ren_as == 'LINE' or part.ren_as == 'BILLBOARD':
748             row = layout.row()
749             col = row.column()
750             col.prop(part, "trail_count")
751             if part.trail_count > 1:
752                 col.prop(part, "abs_path_time", text="Length in frames")
753                 col = row.column()
754                 col.prop(part, "path_end", text="Length", slider=not part.abs_path_time)
755                 col.prop(part, "random_length", text="Random", slider=True)
756             else:
757                 col = row.column()
758                 col.label(text="")
759
760
761 class PARTICLE_PT_draw(ParticleButtonsPanel):
762     bl_label = "Display"
763     bl_default_closed = True
764
765     def poll(self, context):
766         psys = context.particle_system
767         if psys is None:
768             return False
769         if psys.settings is None:
770             return False
771         return True
772
773     def draw(self, context):
774         layout = self.layout
775
776         psys = context.particle_system
777         part = psys.settings
778
779         row = layout.row()
780         row.prop(part, "draw_as", expand=True)
781
782         if part.draw_as == 'NONE' or (part.ren_as == 'NONE' and part.draw_as == 'RENDER'):
783             return
784
785         path = (part.ren_as == 'PATH' and part.draw_as == 'RENDER') or part.draw_as == 'PATH'
786
787         if path and part.type != 'HAIR' and part.physics_type != 'KEYED' and psys.point_cache.baked is False:
788             box = layout.box()
789             box.label(text="Baked or keyed particles needed for correct drawing.")
790             return
791
792         row = layout.row()
793         row.prop(part, "display", slider=True)
794         if part.draw_as != 'RENDER' or part.ren_as == 'HALO':
795             row.prop(part, "draw_size")
796         else:
797             row.label(text="")
798
799         row = layout.row()
800         col = row.column()
801         col.prop(part, "show_size")
802         col.prop(part, "velocity")
803         col.prop(part, "num")
804         if part.physics_type == 'BOIDS':
805             col.prop(part, "draw_health")
806
807         col = row.column()
808         col.prop(part, "material_color", text="Use material color")
809
810         if (path):
811             col.prop(part, "draw_step")
812         else:
813             sub = col.column()
814             sub.active = (part.material_color is False)
815             #sub.label(text="color")
816             #sub.label(text="Override material color")
817
818
819 class PARTICLE_PT_children(ParticleButtonsPanel):
820     bl_label = "Children"
821     bl_default_closed = True
822
823     def draw(self, context):
824         layout = self.layout
825
826         psys = context.particle_system
827         part = psys.settings
828
829         layout.row().prop(part, "child_type", expand=True)
830
831         if part.child_type == 'NONE':
832             return
833
834         row = layout.row()
835
836         col = row.column(align=True)
837         col.prop(part, "child_nbr", text="Display")
838         col.prop(part, "rendered_child_nbr", text="Render")
839
840         col = row.column(align=True)
841
842         if part.child_type == 'FACES':
843             col.prop(part, "virtual_parents", slider=True)
844         else:
845             col.prop(part, "child_radius", text="Radius")
846             col.prop(part, "child_roundness", text="Roundness", slider=True)
847
848             col = row.column(align=True)
849             col.prop(part, "child_size", text="Size")
850             col.prop(part, "child_random_size", text="Random")
851
852         layout.row().label(text="Effects:")
853
854         row = layout.row()
855
856         col = row.column(align=True)
857         col.prop(part, "clump_factor", slider=True)
858         col.prop(part, "clumppow", slider=True)
859
860         col = row.column(align=True)
861         col.prop(part, "rough_endpoint")
862         col.prop(part, "rough_end_shape")
863
864         row = layout.row()
865
866         col = row.column(align=True)
867         col.prop(part, "rough1")
868         col.prop(part, "rough1_size")
869
870         col = row.column(align=True)
871         col.prop(part, "rough2")
872         col.prop(part, "rough2_size")
873         col.prop(part, "rough2_thres", slider=True)
874
875         row = layout.row()
876         col = row.column(align=True)
877         col.prop(part, "child_length", slider=True)
878         col.prop(part, "child_length_thres", slider=True)
879
880         col = row.column(align=True)
881         col.label(text="Space reserved for")
882         col.label(text="hair parting controls")
883
884         layout.row().label(text="Kink:")
885         layout.row().prop(part, "kink", expand=True)
886
887         split = layout.split()
888
889         col = split.column()
890         col.prop(part, "kink_amplitude")
891         col.prop(part, "kink_frequency")
892         col = split.column()
893         col.prop(part, "kink_shape", slider=True)
894
895
896 class PARTICLE_PT_field_weights(ParticleButtonsPanel):
897     bl_label = "Field Weights"
898     bl_default_closed = True
899
900     def draw(self, context):
901         part = context.particle_system.settings
902         effector_weights_ui(self, context, part.effector_weights)
903
904         if part.type == 'HAIR':
905             self.layout.prop(part.effector_weights, "do_growing_hair")
906
907
908 class PARTICLE_PT_force_fields(ParticleButtonsPanel):
909     bl_label = "Force Field Settings"
910     bl_default_closed = True
911
912     def draw(self, context):
913         layout = self.layout
914
915         part = context.particle_system.settings
916
917         layout.prop(part, "self_effect")
918
919         split = layout.split(percentage=0.2)
920         split.label(text="Type 1:")
921         split.prop(part.force_field_1, "type", text="")
922         basic_force_field_settings_ui(self, context, part.force_field_1)
923         basic_force_field_falloff_ui(self, context, part.force_field_1)
924
925         if part.force_field_1.type != 'NONE':
926             layout.label(text="")
927
928         split = layout.split(percentage=0.2)
929         split.label(text="Type 2:")
930         split.prop(part.force_field_2, "type", text="")
931         basic_force_field_settings_ui(self, context, part.force_field_2)
932         basic_force_field_falloff_ui(self, context, part.force_field_2)
933
934
935 class PARTICLE_PT_vertexgroups(ParticleButtonsPanel):
936     bl_label = "Vertexgroups"
937     bl_default_closed = True
938
939     def draw(self, context):
940         layout = self.layout
941
942         ob = context.object
943         psys = context.particle_system
944         # part = psys.settings
945
946         # layout.label(text="Nothing here yet.")
947
948         row = layout.row()
949         row.label(text="Vertex Group")
950         row.label(text="Negate")
951
952
953         row = layout.row()
954         row.prop_object(psys, "vertex_group_density", ob, "vertex_groups", text="Density")
955         row.prop(psys, "vertex_group_density_negate", text="")
956
957         row = layout.row()
958         row.prop_object(psys, "vertex_group_velocity", ob, "vertex_groups", text="Velocity")
959         row.prop(psys, "vertex_group_velocity_negate", text="")
960
961         row = layout.row()
962         row.prop_object(psys, "vertex_group_length", ob, "vertex_groups", text="Length")
963         row.prop(psys, "vertex_group_length_negate", text="")
964
965         row = layout.row()
966         row.prop_object(psys, "vertex_group_clump", ob, "vertex_groups", text="Clump")
967         row.prop(psys, "vertex_group_clump_negate", text="")
968
969         row = layout.row()
970         row.prop_object(psys, "vertex_group_kink", ob, "vertex_groups", text="Kink")
971         row.prop(psys, "vertex_group_kink_negate", text="")
972
973         row = layout.row()
974         row.prop_object(psys, "vertex_group_roughness1", ob, "vertex_groups", text="Roughness 1")
975         row.prop(psys, "vertex_group_roughness1_negate", text="")
976
977         row = layout.row()
978         row.prop_object(psys, "vertex_group_roughness2", ob, "vertex_groups", text="Roughness 2")
979         row.prop(psys, "vertex_group_roughness2_negate", text="")
980
981         row = layout.row()
982         row.prop_object(psys, "vertex_group_roughness_end", ob, "vertex_groups", text="Roughness End")
983         row.prop(psys, "vertex_group_roughness_end_negate", text="")
984
985         row = layout.row()
986         row.prop_object(psys, "vertex_group_size", ob, "vertex_groups", text="Size")
987         row.prop(psys, "vertex_group_size_negate", text="")
988
989         row = layout.row()
990         row.prop_object(psys, "vertex_group_tangent", ob, "vertex_groups", text="Tangent")
991         row.prop(psys, "vertex_group_tangent_negate", text="")
992
993         row = layout.row()
994         row.prop_object(psys, "vertex_group_rotation", ob, "vertex_groups", text="Rotation")
995         row.prop(psys, "vertex_group_rotation_negate", text="")
996
997         row = layout.row()
998         row.prop_object(psys, "vertex_group_field", ob, "vertex_groups", text="Field")
999         row.prop(psys, "vertex_group_field_negate", text="")
1000
1001
1002 classes = [
1003     PARTICLE_PT_context_particles,
1004     PARTICLE_PT_hair_dynamics,
1005     PARTICLE_PT_cache,
1006     PARTICLE_PT_emission,
1007     PARTICLE_PT_velocity,
1008     PARTICLE_PT_rotation,
1009     PARTICLE_PT_physics,
1010     PARTICLE_PT_boidbrain,
1011     PARTICLE_PT_render,
1012     PARTICLE_PT_draw,
1013     PARTICLE_PT_children,
1014     PARTICLE_PT_field_weights,
1015     PARTICLE_PT_force_fields,
1016     PARTICLE_PT_vertexgroups,
1017
1018     PARTICLE_PT_custom_props]
1019
1020
1021 def register():
1022     register = bpy.types.register
1023     for cls in classes:
1024         register(cls)
1025
1026 def unregister():
1027     unregister = bpy.types.unregister
1028     for cls in classes:
1029         unregister(cls)