1 # ##### BEGIN GPL LICENSE BLOCK #####
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.
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.
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.
17 # ##### END GPL LICENSE BLOCK #####
21 from bpy.types import Panel, Menu
22 from rna_prop_ui import PropertyPanel
23 from bpy.app.translations import pgettext_iface as iface_
25 from .properties_physics_common import (
28 basic_force_field_settings_ui,
29 basic_force_field_falloff_ui,
33 def particle_panel_enabled(context, psys):
36 phystype = psys.settings.physics_type
37 if psys.settings.type in {'EMITTER', 'REACTOR'} and phystype in {'NO', 'KEYED'}:
40 return (psys.point_cache.is_baked is False) and (not psys.is_edited) and (not context.particle_system_editable)
43 def particle_panel_poll(cls, context):
44 psys = context.particle_system
45 engine = context.scene.render.engine
49 settings = psys.settings
50 elif isinstance(context.space_data.pin_id, bpy.types.ParticleSettings):
51 settings = context.space_data.pin_id
56 return settings.is_fluid is False and (engine in cls.COMPAT_ENGINES)
59 def particle_get_settings(context):
60 if context.particle_system:
61 return context.particle_system.settings
62 elif isinstance(context.space_data.pin_id, bpy.types.ParticleSettings):
63 return context.space_data.pin_id
67 class PARTICLE_MT_specials(Menu):
68 bl_label = "Particle Specials"
69 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
71 def draw(self, context):
74 props = layout.operator("particle.copy_particle_systems", text="Copy Active to Selected Objects")
75 props.use_active = True
76 props.remove_target_particles = False
78 props = layout.operator("particle.copy_particle_systems", text="Copy All to Selected Objects")
79 props.use_active = False
80 props.remove_target_particles = True
82 layout.operator("particle.duplicate_particle_system")
85 class PARTICLE_MT_hair_dynamics_presets(Menu):
86 bl_label = "Hair Dynamics Presets"
87 preset_subdir = "hair_dynamics"
88 preset_operator = "script.execute_preset"
89 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
90 draw = Menu.draw_preset
93 class ParticleButtonsPanel:
94 bl_space_type = 'PROPERTIES'
95 bl_region_type = 'WINDOW'
96 bl_context = "particle"
99 def poll(cls, context):
100 return particle_panel_poll(cls, context)
103 def find_modifier(ob, psys):
104 for md in ob.modifiers:
105 if md.type == 'PARTICLE_SYSTEM':
106 if md.particle_system == psys:
110 class PARTICLE_UL_particle_systems(bpy.types.UIList):
112 def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index, flt_flag):
116 if self.layout_type in {'DEFAULT', 'COMPACT'}:
117 md = find_modifier(ob, psys)
119 layout.prop(psys, "name", text="", emboss=False, icon_value=icon)
121 layout.prop(md, "show_render", emboss=False, icon_only=True,
122 icon='RESTRICT_RENDER_OFF' if md.show_render else 'RESTRICT_RENDER_ON')
123 layout.prop(md, "show_viewport", emboss=False, icon_only=True,
124 icon='RESTRICT_VIEW_OFF' if md.show_viewport else 'RESTRICT_VIEW_ON')
126 elif self.layout_type == 'GRID':
127 layout.alignment = 'CENTER'
128 layout.label(text="", icon_value=icon)
131 class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel):
133 bl_options = {'HIDE_HEADER'}
134 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
137 def poll(cls, context):
138 engine = context.scene.render.engine
139 return (context.particle_system or context.object or context.space_data.pin_id) and (engine in cls.COMPAT_ENGINES)
141 def draw(self, context):
144 if context.scene.render.engine == 'BLENDER_GAME':
145 layout.label("Not available in the Game Engine")
149 psys = context.particle_system
155 row.template_list("PARTICLE_UL_particle_systems", "particle_systems", ob, "particle_systems",
156 ob.particle_systems, "active_index", rows=1)
158 col = row.column(align=True)
159 col.operator("object.particle_system_add", icon='ZOOMIN', text="")
160 col.operator("object.particle_system_remove", icon='ZOOMOUT', text="")
161 col.menu("PARTICLE_MT_specials", icon='DOWNARROW_HLT', text="")
164 part = particle_get_settings(context)
166 layout.operator("object.particle_system_add", icon='ZOOMIN', text="New")
171 layout.template_ID(context.space_data, "pin_id")
174 layout.label(text="Settings used for fluid")
177 layout.prop(part, "type", text="Type")
179 elif not psys.settings:
180 split = layout.split(percentage=0.32)
183 col.label(text="Settings:")
186 col.template_ID(psys, "settings", new="particle.new")
190 split = layout.split(percentage=0.32)
192 if part.is_fluid is False:
193 col.label(text="Settings:")
194 col.label(text="Type:")
197 if part.is_fluid is False:
199 row.enabled = particle_panel_enabled(context, psys)
200 row.template_ID(psys, "settings", new="particle.new")
203 layout.label(text=iface_("%d fluid particles for this frame") % part.count, translate=False)
207 row.enabled = particle_panel_enabled(context, psys)
208 row.prop(part, "type", text="")
209 row.prop(psys, "seed")
212 split = layout.split(percentage=0.65)
213 if part.type == 'HAIR':
214 if psys is not None and psys.is_edited:
215 split.operator("particle.edited_clear", text="Free Edit")
218 row.enabled = particle_panel_enabled(context, psys)
219 row.prop(part, "regrow_hair")
220 row.prop(part, "use_advanced_hair")
222 row.enabled = particle_panel_enabled(context, psys)
223 row.prop(part, "hair_step")
224 if psys is not None and psys.is_edited:
225 if psys.is_global_hair:
226 row = layout.row(align=True)
227 row.operator("particle.connect_hair").all = False
228 row.operator("particle.connect_hair", text="Connect All").all = True
230 row = layout.row(align=True)
231 row.operator("particle.disconnect_hair").all = False
232 row.operator("particle.disconnect_hair", text="Disconnect All").all = True
233 elif psys is not None and part.type == 'REACTOR':
234 split.enabled = particle_panel_enabled(context, psys)
235 split.prop(psys, "reactor_target_object")
236 split.prop(psys, "reactor_target_particle_system", text="Particle System")
239 class PARTICLE_PT_emission(ParticleButtonsPanel, Panel):
240 bl_label = "Emission"
241 COMPAT_ENGINES = {'BLENDER_RENDER'}
244 def poll(cls, context):
245 psys = context.particle_system
246 settings = particle_get_settings(context)
250 if settings.is_fluid:
252 if particle_panel_poll(PARTICLE_PT_emission, context):
253 return psys is None or not context.particle_system.point_cache.use_external
256 def draw(self, context):
259 psys = context.particle_system
260 part = particle_get_settings(context)
262 layout.enabled = particle_panel_enabled(context, psys) and (psys is None or not psys.has_multiple_caches)
265 row.active = part.emit_from == 'VERT' or part.distribution != 'GRID'
266 row.prop(part, "count")
268 if part.type == 'HAIR':
269 row.prop(part, "hair_length")
270 if not part.use_advanced_hair:
272 row.prop(part, "use_modifier_stack")
275 if part.type != 'HAIR':
276 split = layout.split()
278 col = split.column(align=True)
279 col.prop(part, "frame_start")
280 col.prop(part, "frame_end")
282 col = split.column(align=True)
283 col.prop(part, "lifetime")
284 col.prop(part, "lifetime_random", slider=True)
286 layout.label(text="Emit From:")
287 layout.row().prop(part, "emit_from", expand=True)
290 if part.emit_from == 'VERT':
291 row.prop(part, "use_emit_random")
292 elif part.distribution == 'GRID':
293 row.prop(part, "invert_grid")
294 row.prop(part, "hexagonal_grid")
296 row.prop(part, "use_emit_random")
297 row.prop(part, "use_even_distribution")
299 if part.emit_from == 'FACE' or part.emit_from == 'VOLUME':
300 layout.row().prop(part, "distribution", expand=True)
303 if part.distribution == 'JIT':
304 row.prop(part, "userjit", text="Particles/Face")
305 row.prop(part, "jitter_factor", text="Jittering Amount", slider=True)
306 elif part.distribution == 'GRID':
307 row.prop(part, "grid_resolution")
308 row.prop(part, "grid_random", text="Random", slider=True)
311 row.prop(part, "use_modifier_stack")
314 class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel):
315 bl_label = "Hair Dynamics"
316 bl_options = {'DEFAULT_CLOSED'}
317 COMPAT_ENGINES = {'BLENDER_RENDER'}
320 def poll(cls, context):
321 psys = context.particle_system
322 engine = context.scene.render.engine
325 if psys.settings is None:
327 return psys.settings.type == 'HAIR' and (engine in cls.COMPAT_ENGINES)
329 def draw_header(self, context):
330 psys = context.particle_system
331 self.layout.prop(psys, "use_hair_dynamics", text="")
333 def draw(self, context):
336 psys = context.particle_system
341 cloth_md = psys.cloth
342 cloth = cloth_md.settings
343 result = cloth_md.solver_result
345 layout.enabled = psys.use_hair_dynamics and psys.point_cache.is_baked is False
347 row = layout.row(align=True)
348 row.menu("PARTICLE_MT_hair_dynamics_presets", text=bpy.types.PARTICLE_MT_hair_dynamics_presets.bl_label)
349 row.operator("particle.hair_dynamics_preset_add", text="", icon='ZOOMIN')
350 row.operator("particle.hair_dynamics_preset_add", text="", icon='ZOOMOUT').remove_active = True
352 split = layout.column()
355 col.label(text="Structure")
356 col.prop(cloth, "mass")
357 sub = col.column(align=True)
358 subsub = sub.row(align=True)
359 subsub.prop(cloth, "bending_stiffness", text="Stiffness")
360 subsub.prop(psys.settings, "bending_random", text="Random")
361 sub.prop(cloth, "bending_damping", text="Damping")
362 # XXX has no noticeable effect with stiff hair structure springs
363 #col.prop(cloth, "spring_damping", text="Damping")
368 col.label(text="Volume")
369 col.prop(cloth, "air_damping", text="Air Drag")
370 col.prop(cloth, "internal_friction", slider=True)
371 sub = col.column(align=True)
372 sub.prop(cloth, "density_target", text="Density Target")
373 sub.prop(cloth, "density_strength", slider=True, text="Strength")
374 col.prop(cloth, "voxel_cell_size")
379 col.label(text="Pinning")
380 col.prop(cloth, "pin_stiffness", text="Goal Strength")
385 col.label(text="Quality:")
386 col.prop(cloth, "quality", text="Steps", slider=True)
389 row.prop(psys.settings, "show_hair_grid", text="HairGrid")
394 if not result.status:
397 elif result.status == {'SUCCESS'}:
400 elif result.status - {'SUCCESS'} == {'NO_CONVERGENCE'}:
401 label = "No Convergence"
406 box.label(label, icon=icon)
407 box.label("Iterations: %d .. %d (avg. %d)" %
408 (result.min_iterations, result.max_iterations, result.avg_iterations))
409 box.label("Error: %.5f .. %.5f (avg. %.5f)" % (result.min_error, result.max_error, result.avg_error))
412 class PARTICLE_PT_cache(ParticleButtonsPanel, Panel):
414 bl_options = {'DEFAULT_CLOSED'}
415 COMPAT_ENGINES = {'BLENDER_RENDER'}
418 def poll(cls, context):
419 psys = context.particle_system
420 engine = context.scene.render.engine
423 if psys.settings is None:
425 if psys.settings.is_fluid:
427 phystype = psys.settings.physics_type
428 if phystype == 'NO' or phystype == 'KEYED':
431 (psys.settings.type in {'EMITTER', 'REACTOR'} or
432 (psys.settings.type == 'HAIR' and
433 (psys.use_hair_dynamics or psys.point_cache.is_baked))) and
434 engine in cls.COMPAT_ENGINES
437 def draw(self, context):
438 psys = context.particle_system
440 point_cache_ui(self, context, psys.point_cache, True, 'HAIR' if (psys.settings.type == 'HAIR') else 'PSYS')
443 class PARTICLE_PT_velocity(ParticleButtonsPanel, Panel):
444 bl_label = "Velocity"
445 COMPAT_ENGINES = {'BLENDER_RENDER'}
448 def poll(cls, context):
449 if particle_panel_poll(PARTICLE_PT_velocity, context):
450 psys = context.particle_system
451 settings = particle_get_settings(context)
453 if settings.type == 'HAIR' and not settings.use_advanced_hair:
455 return settings.physics_type != 'BOIDS' and (psys is None or not psys.point_cache.use_external)
459 def draw(self, context):
462 psys = context.particle_system
463 part = particle_get_settings(context)
465 layout.enabled = particle_panel_enabled(context, psys)
467 split = layout.split()
470 col.label(text="Emitter Geometry:")
471 col.prop(part, "normal_factor")
472 sub = col.column(align=True)
473 sub.prop(part, "tangent_factor")
474 sub.prop(part, "tangent_phase", slider=True)
477 col.label(text="Emitter Object:")
478 col.prop(part, "object_align_factor", text="")
480 layout.label(text="Other:")
482 if part.emit_from == 'PARTICLE':
483 row.prop(part, "particle_factor")
485 row.prop(part, "object_factor", slider=True)
486 row.prop(part, "factor_random")
488 #if part.type=='REACTOR':
489 # sub.prop(part, "reactor_factor")
490 # sub.prop(part, "reaction_shape", slider=True)
493 class PARTICLE_PT_rotation(ParticleButtonsPanel, Panel):
494 bl_label = "Rotation"
495 bl_options = {'DEFAULT_CLOSED'}
496 COMPAT_ENGINES = {'BLENDER_RENDER'}
499 def poll(cls, context):
500 if particle_panel_poll(PARTICLE_PT_rotation, context):
501 psys = context.particle_system
502 settings = particle_get_settings(context)
504 if settings.type == 'HAIR' and not settings.use_advanced_hair:
506 return settings.physics_type != 'BOIDS' and (psys is None or not psys.point_cache.use_external)
510 def draw_header(self, context):
511 psys = context.particle_system
515 part = context.space_data.pin_id
517 self.layout.prop(part, "use_rotations", text="")
519 def draw(self, context):
522 psys = context.particle_system
526 part = context.space_data.pin_id
528 layout.enabled = particle_panel_enabled(context, psys) and part.use_rotations
530 layout.label(text="Initial Orientation:")
532 split = layout.split()
534 col = split.column(align=True)
535 col.prop(part, "rotation_mode", text="")
536 col.prop(part, "rotation_factor_random", slider=True, text="Random")
538 col = split.column(align=True)
539 col.prop(part, "phase_factor", slider=True)
540 col.prop(part, "phase_factor_random", text="Random", slider=True)
542 if part.type != 'HAIR':
543 layout.label(text="Angular Velocity:")
545 split = layout.split()
547 col = split.column(align=True)
548 col.prop(part, "angular_velocity_mode", text="")
549 sub = col.column(align=True)
550 sub.active = part.angular_velocity_mode != 'NONE'
551 sub.prop(part, "angular_velocity_factor", text="")
554 col.prop(part, "use_dynamic_rotation")
557 class PARTICLE_PT_physics(ParticleButtonsPanel, Panel):
559 COMPAT_ENGINES = {'BLENDER_RENDER'}
562 def poll(cls, context):
563 if particle_panel_poll(PARTICLE_PT_physics, context):
564 psys = context.particle_system
565 settings = particle_get_settings(context)
567 if settings.type == 'HAIR' and not settings.use_advanced_hair:
569 return psys is None or not psys.point_cache.use_external
573 def draw(self, context):
576 psys = context.particle_system
577 part = particle_get_settings(context)
579 layout.enabled = particle_panel_enabled(context, psys)
581 layout.row().prop(part, "physics_type", expand=True)
584 if part.physics_type != 'NO':
585 col = row.column(align=True)
586 col.prop(part, "mass")
587 col.prop(part, "use_multiply_size_mass", text="Multiply mass with size")
589 if part.physics_type in {'NEWTON', 'FLUID'}:
590 split = layout.split()
593 col.label(text="Forces:")
594 col.prop(part, "brownian_factor")
595 col.prop(part, "drag_factor", slider=True)
596 col.prop(part, "damping", slider=True)
599 col.label(text="Integration:")
600 col.prop(part, "integrator", text="")
601 col.prop(part, "timestep")
603 sub.prop(part, "subframes")
604 supports_courant = part.physics_type == 'FLUID'
606 subsub.enabled = supports_courant
607 subsub.prop(part, "use_adaptive_subframes", text="")
608 if supports_courant and part.use_adaptive_subframes:
609 col.prop(part, "courant_target", text="Threshold")
612 row.prop(part, "use_size_deflect")
613 row.prop(part, "use_die_on_collision")
615 layout.prop(part, "collision_group")
617 if part.physics_type == 'FLUID':
620 split = layout.split()
622 sub.prop(fluid, "solver", expand=True)
624 split = layout.split()
627 col.label(text="Fluid Properties:")
628 col.prop(fluid, "stiffness", text="Stiffness")
629 col.prop(fluid, "linear_viscosity", text="Viscosity")
630 col.prop(fluid, "buoyancy", text="Buoyancy", slider=True)
633 col.label(text="Advanced:")
635 if fluid.solver == 'DDR':
637 sub.prop(fluid, "repulsion", slider=fluid.factor_repulsion)
638 sub.prop(fluid, "factor_repulsion", text="")
641 sub.prop(fluid, "stiff_viscosity", slider=fluid.factor_stiff_viscosity)
642 sub.prop(fluid, "factor_stiff_viscosity", text="")
645 sub.prop(fluid, "fluid_radius", slider=fluid.factor_radius)
646 sub.prop(fluid, "factor_radius", text="")
649 sub.prop(fluid, "rest_density", slider=fluid.use_factor_density)
650 sub.prop(fluid, "use_factor_density", text="")
652 if fluid.solver == 'CLASSICAL':
653 # With the classical solver, it is possible to calculate the
654 # spacing between particles when the fluid is at rest. This
655 # makes it easier to set stable initial conditions.
656 particle_volume = part.mass / fluid.rest_density
657 spacing = pow(particle_volume, 1.0 / 3.0)
659 sub.label(text="Spacing: %g" % spacing)
661 elif fluid.solver == 'DDR':
662 split = layout.split()
665 col.label(text="Springs:")
666 col.prop(fluid, "spring_force", text="Force")
667 col.prop(fluid, "use_viscoelastic_springs")
668 sub = col.column(align=True)
669 sub.active = fluid.use_viscoelastic_springs
670 sub.prop(fluid, "yield_ratio", slider=True)
671 sub.prop(fluid, "plasticity", slider=True)
674 col.label(text="Advanced:")
676 sub.prop(fluid, "rest_length", slider=fluid.factor_rest_length)
677 sub.prop(fluid, "factor_rest_length", text="")
680 sub.active = fluid.use_viscoelastic_springs
681 sub.prop(fluid, "use_initial_rest_length")
682 sub.prop(fluid, "spring_frames", text="Frames")
684 elif part.physics_type == 'KEYED':
685 split = layout.split()
690 col.active = not psys.use_keyed_timing
691 col.prop(part, "keyed_loops", text="Loops")
693 row.prop(psys, "use_keyed_timing", text="Use Timing")
695 layout.label(text="Keys:")
696 elif part.physics_type == 'BOIDS':
700 row.prop(boids, "use_flight")
701 row.prop(boids, "use_land")
702 row.prop(boids, "use_climb")
704 split = layout.split()
706 col = split.column(align=True)
707 col.active = boids.use_flight
708 col.prop(boids, "air_speed_max")
709 col.prop(boids, "air_speed_min", slider=True)
710 col.prop(boids, "air_acc_max", slider=True)
711 col.prop(boids, "air_ave_max", slider=True)
712 col.prop(boids, "air_personal_space")
713 row = col.row(align=True)
714 row.active = (boids.use_land or boids.use_climb) and boids.use_flight
715 row.prop(boids, "land_smooth")
717 col = split.column(align=True)
718 col.active = boids.use_land or boids.use_climb
719 col.prop(boids, "land_speed_max")
720 col.prop(boids, "land_jump_speed")
721 col.prop(boids, "land_acc_max", slider=True)
722 col.prop(boids, "land_ave_max", slider=True)
723 col.prop(boids, "land_personal_space")
724 col.prop(boids, "land_stick_force")
726 layout.prop(part, "collision_group")
728 split = layout.split()
730 col = split.column(align=True)
731 col.label(text="Battle:")
732 col.prop(boids, "health")
733 col.prop(boids, "strength")
734 col.prop(boids, "aggression")
735 col.prop(boids, "accuracy")
736 col.prop(boids, "range")
739 col.label(text="Misc:")
740 col.prop(boids, "bank", slider=True)
741 col.prop(boids, "pitch", slider=True)
742 col.prop(boids, "height", slider=True)
744 if psys and part.physics_type in {'KEYED', 'BOIDS', 'FLUID'}:
745 if part.physics_type == 'BOIDS':
746 layout.label(text="Relations:")
747 elif part.physics_type == 'FLUID':
748 layout.label(text="Fluid Interaction:")
751 row.template_list("UI_UL_list", "particle_targets", psys, "targets",
752 psys, "active_particle_target_index", rows=4)
756 subsub = sub.column(align=True)
757 subsub.operator("particle.new_target", icon='ZOOMIN', text="")
758 subsub.operator("particle.target_remove", icon='ZOOMOUT', text="")
760 subsub = sub.column(align=True)
761 subsub.operator("particle.target_move_up", icon='TRIA_UP', text="")
762 subsub.operator("particle.target_move_down", icon='TRIA_DOWN', text="")
764 key = psys.active_particle_target
767 if part.physics_type == 'KEYED':
770 #col.alert = key.valid
771 col.prop(key, "object", text="")
772 col.prop(key, "system", text="System")
774 col.active = psys.use_keyed_timing
775 col.prop(key, "time")
776 col.prop(key, "duration")
777 elif part.physics_type == 'BOIDS':
780 #sub.alert = key.valid
781 sub.prop(key, "object", text="")
782 sub.prop(key, "system", text="System")
784 layout.row().prop(key, "alliance", expand=True)
785 elif part.physics_type == 'FLUID':
788 #sub.alert = key.valid
789 sub.prop(key, "object", text="")
790 sub.prop(key, "system", text="System")
793 class PARTICLE_PT_boidbrain(ParticleButtonsPanel, Panel):
794 bl_label = "Boid Brain"
795 COMPAT_ENGINES = {'BLENDER_RENDER'}
798 def poll(cls, context):
799 psys = context.particle_system
800 settings = particle_get_settings(context)
801 engine = context.scene.render.engine
805 if psys is not None and psys.point_cache.use_external:
807 return settings.physics_type == 'BOIDS' and engine in cls.COMPAT_ENGINES
809 def draw(self, context):
812 boids = particle_get_settings(context).boids
814 layout.enabled = particle_panel_enabled(context, context.particle_system)
816 # Currently boids can only use the first state so these are commented out for now.
818 #row.template_list("UI_UL_list", "particle_boids", boids, "states",
819 # boids, "active_boid_state_index", compact="True")
821 #sub = col.row(align=True)
822 #sub.operator("boid.state_add", icon='ZOOMIN', text="")
823 #sub.operator("boid.state_del", icon='ZOOMOUT', text="")
824 #sub = row.row(align=True)
825 #sub.operator("boid.state_move_up", icon='TRIA_UP', text="")
826 #sub.operator("boid.state_move_down", icon='TRIA_DOWN', text="")
828 state = boids.active_boid_state
830 #layout.prop(state, "name", text="State name")
833 row.prop(state, "ruleset_type")
834 if state.ruleset_type == 'FUZZY':
835 row.prop(state, "rule_fuzzy", slider=True)
840 row.template_list("UI_UL_list", "particle_boids_rules", state,
841 "rules", state, "active_boid_rule_index", rows=4)
845 subsub = sub.column(align=True)
846 subsub.operator_menu_enum("boid.rule_add", "type", icon='ZOOMIN', text="")
847 subsub.operator("boid.rule_del", icon='ZOOMOUT', text="")
849 subsub = sub.column(align=True)
850 subsub.operator("boid.rule_move_up", icon='TRIA_UP', text="")
851 subsub.operator("boid.rule_move_down", icon='TRIA_DOWN', text="")
853 rule = state.active_boid_rule
857 row.prop(rule, "name", text="")
858 # somebody make nice icons for boids here please! -jahka
859 row.prop(rule, "use_in_air", icon='TRIA_UP', text="")
860 row.prop(rule, "use_on_land", icon='TRIA_DOWN', text="")
864 if rule.type == 'GOAL':
865 row.prop(rule, "object")
867 row.prop(rule, "use_predict")
868 elif rule.type == 'AVOID':
869 row.prop(rule, "object")
871 row.prop(rule, "use_predict")
872 row.prop(rule, "fear_factor")
873 elif rule.type == 'FOLLOW_PATH':
874 row.label(text="Not yet functional")
875 elif rule.type == 'AVOID_COLLISION':
876 row.prop(rule, "use_avoid")
877 row.prop(rule, "use_avoid_collision")
878 row.prop(rule, "look_ahead")
879 elif rule.type == 'FOLLOW_LEADER':
880 row.prop(rule, "object", text="")
881 row.prop(rule, "distance")
883 row.prop(rule, "use_line")
885 sub.active = rule.line
886 sub.prop(rule, "queue_count")
887 elif rule.type == 'AVERAGE_SPEED':
888 row.prop(rule, "speed", slider=True)
889 row.prop(rule, "wander", slider=True)
890 row.prop(rule, "level", slider=True)
891 elif rule.type == 'FIGHT':
892 row.prop(rule, "distance")
893 row.prop(rule, "flee_distance")
896 class PARTICLE_PT_render(ParticleButtonsPanel, Panel):
898 COMPAT_ENGINES = {'BLENDER_RENDER'}
901 def poll(cls, context):
902 settings = particle_get_settings(context)
903 engine = context.scene.render.engine
907 return engine in cls.COMPAT_ENGINES
909 def draw(self, context):
912 psys = context.particle_system
913 part = particle_get_settings(context)
917 if part.render_type in {'OBJECT', 'GROUP'}:
919 row.prop(part, "material_slot", text="")
920 row.prop(psys, "parent")
922 split = layout.split()
925 col.prop(part, "use_render_emitter")
926 col.prop(part, "use_parent_particles")
929 col.prop(part, "show_unborn")
930 col.prop(part, "use_dead")
932 layout.row().prop(part, "render_type", expand=True)
934 split = layout.split()
938 if part.render_type == 'LINE':
939 col.prop(part, "line_length_tail")
940 col.prop(part, "line_length_head")
942 split.prop(part, "use_velocity_length")
943 elif part.render_type == 'PATH':
944 col.prop(part, "use_strand_primitive")
946 sub.active = (part.use_strand_primitive is False)
947 sub.prop(part, "use_render_adaptive")
949 sub.active = part.use_render_adaptive or part.use_strand_primitive is True
950 sub.prop(part, "adaptive_angle")
952 sub.active = (part.use_render_adaptive is True and part.use_strand_primitive is False)
953 sub.prop(part, "adaptive_pixel")
954 col.prop(part, "use_hair_bspline")
955 col.prop(part, "render_step", text="Steps")
958 col.label(text="Timing:")
959 col.prop(part, "use_absolute_path_time")
961 if part.type == 'HAIR' or psys.point_cache.is_baked:
962 col.prop(part, "path_start", text="Start", slider=not part.use_absolute_path_time)
964 col.prop(part, "trail_count")
966 col.prop(part, "path_end", text="End", slider=not part.use_absolute_path_time)
967 col.prop(part, "length_random", text="Random", slider=True)
972 if part.type == 'HAIR' and part.use_strand_primitive is True and part.child_type == 'INTERPOLATED':
973 layout.prop(part, "use_simplify")
974 if part.use_simplify is True:
976 row.prop(part, "simplify_refsize")
977 row.prop(part, "simplify_rate")
978 row.prop(part, "simplify_transition")
980 row.prop(part, "use_simplify_viewport")
982 sub.active = part.use_simplify_viewport is True
983 sub.prop(part, "simplify_viewport")
985 elif part.render_type == 'OBJECT':
986 col.prop(part, "dupli_object")
988 sub.prop(part, "use_global_dupli")
989 sub.prop(part, "use_rotation_dupli")
990 sub.prop(part, "use_scale_dupli")
991 elif part.render_type == 'GROUP':
992 col.prop(part, "dupli_group")
993 split = layout.split()
996 col.prop(part, "use_whole_group")
998 sub.active = (part.use_whole_group is False)
999 sub.prop(part, "use_group_pick_random")
1000 sub.prop(part, "use_group_count")
1002 col = split.column()
1004 sub.active = (part.use_whole_group is False)
1005 sub.prop(part, "use_global_dupli")
1006 sub.prop(part, "use_rotation_dupli")
1007 sub.prop(part, "use_scale_dupli")
1009 if part.use_group_count and not part.use_whole_group:
1011 row.template_list("UI_UL_list", "particle_dupli_weights", part, "dupli_weights",
1012 part, "active_dupliweight_index")
1016 subsub = sub.column(align=True)
1017 subsub.operator("particle.dupliob_copy", icon='ZOOMIN', text="")
1018 subsub.operator("particle.dupliob_remove", icon='ZOOMOUT', text="")
1019 subsub.operator("particle.dupliob_move_up", icon='TRIA_UP', text="")
1020 subsub.operator("particle.dupliob_move_down", icon='TRIA_DOWN', text="")
1022 weight = part.active_dupliweight
1025 row.prop(weight, "count")
1027 elif part.render_type == 'BILLBOARD':
1030 col.label(text="Align:")
1033 row.prop(part, "billboard_align", expand=True)
1034 row.prop(part, "lock_billboard", text="Lock")
1036 row.prop(part, "billboard_object")
1039 col = row.column(align=True)
1040 col.label(text="Tilt:")
1041 col.prop(part, "billboard_tilt", text="Angle", slider=True)
1042 col.prop(part, "billboard_tilt_random", text="Random", slider=True)
1044 col.prop(part, "billboard_offset")
1048 col.prop(part, "billboard_size", text="Scale")
1049 if part.billboard_align == 'VEL':
1050 col = row.column(align=True)
1051 col.label("Velocity Scale:")
1052 col.prop(part, "billboard_velocity_head", text="Head")
1053 col.prop(part, "billboard_velocity_tail", text="Tail")
1056 col = layout.column()
1057 col.prop_search(psys, "billboard_normal_uv", ob.data, "uv_textures")
1058 col.prop_search(psys, "billboard_time_index_uv", ob.data, "uv_textures")
1060 split = layout.split(percentage=0.33)
1061 split.label(text="Split UVs:")
1062 split.prop(part, "billboard_uv_split", text="Number of splits")
1065 col = layout.column()
1066 col.active = part.billboard_uv_split > 1
1067 col.prop_search(psys, "billboard_split_uv", ob.data, "uv_textures")
1070 row.label(text="Animate:")
1071 row.prop(part, "billboard_animation", text="")
1072 row.label(text="Offset:")
1073 row.prop(part, "billboard_offset_split", text="")
1075 if part.render_type == 'HALO' or part.render_type == 'LINE' or part.render_type == 'BILLBOARD':
1078 col.prop(part, "trail_count")
1079 if part.trail_count > 1:
1080 col.prop(part, "use_absolute_path_time", text="Length in Frames")
1082 col.prop(part, "path_end", text="Length", slider=not part.use_absolute_path_time)
1083 col.prop(part, "length_random", text="Random", slider=True)
1088 if part.type == 'EMITTER' or \
1089 (part.render_type in {'OBJECT', 'GROUP'} and part.type == 'HAIR' and not part.use_advanced_hair):
1090 row = layout.row(align=True)
1091 row.prop(part, "particle_size")
1092 row.prop(part, "size_random", slider=True)
1095 class PARTICLE_PT_draw(ParticleButtonsPanel, Panel):
1096 bl_label = "Display"
1097 bl_options = {'DEFAULT_CLOSED'}
1098 COMPAT_ENGINES = {'BLENDER_RENDER'}
1101 def poll(cls, context):
1102 settings = particle_get_settings(context)
1103 engine = context.scene.render.engine
1104 if settings is None:
1106 return engine in cls.COMPAT_ENGINES
1108 def draw(self, context):
1109 layout = self.layout
1111 psys = context.particle_system
1112 part = particle_get_settings(context)
1115 row.prop(part, "draw_method", expand=True)
1116 row.prop(part, "show_guide_hairs")
1118 if part.draw_method == 'NONE' or (part.render_type == 'NONE' and part.draw_method == 'RENDER'):
1121 path = (part.render_type == 'PATH' and part.draw_method == 'RENDER') or part.draw_method == 'PATH'
1124 row.prop(part, "draw_percentage", slider=True)
1125 if part.draw_method != 'RENDER' or part.render_type == 'HALO':
1126 row.prop(part, "draw_size")
1130 if part.draw_percentage != 100 and psys is not None:
1131 if part.type == 'HAIR':
1132 if psys.use_hair_dynamics and psys.point_cache.is_baked is False:
1133 layout.row().label(text="Display percentage makes dynamics inaccurate without baking!")
1135 phystype = part.physics_type
1136 if phystype != 'NO' and phystype != 'KEYED' and psys.point_cache.is_baked is False:
1137 layout.row().label(text="Display percentage makes dynamics inaccurate without baking!")
1141 col.prop(part, "show_size")
1142 col.prop(part, "show_velocity")
1143 col.prop(part, "show_number")
1144 if part.physics_type == 'BOIDS':
1145 col.prop(part, "show_health")
1147 col = row.column(align=True)
1148 col.label(text="Color:")
1149 col.prop(part, "draw_color", text="")
1150 sub = col.row(align=True)
1151 sub.active = (part.draw_color in {'VELOCITY', 'ACCELERATION'})
1152 sub.prop(part, "color_maximum", text="Max")
1155 col.prop(part, "draw_step")
1158 class PARTICLE_PT_children(ParticleButtonsPanel, Panel):
1159 bl_label = "Children"
1160 bl_options = {'DEFAULT_CLOSED'}
1161 COMPAT_ENGINES = {'BLENDER_RENDER'}
1164 def poll(cls, context):
1165 return particle_panel_poll(cls, context)
1167 def draw(self, context):
1168 layout = self.layout
1170 psys = context.particle_system
1171 part = particle_get_settings(context)
1173 layout.row().prop(part, "child_type", expand=True)
1175 if part.child_type == 'NONE':
1180 col = row.column(align=True)
1181 col.prop(part, "child_nbr", text="Display")
1182 col.prop(part, "rendered_child_count", text="Render")
1184 if part.child_type == 'INTERPOLATED':
1187 col.prop(psys, "child_seed", text="Seed")
1188 col.prop(part, "virtual_parents", slider=True)
1189 col.prop(part, "create_long_hair_children")
1191 col = row.column(align=True)
1192 col.prop(part, "child_size", text="Size")
1193 col.prop(part, "child_size_random", text="Random")
1195 split = layout.split()
1197 col = split.column()
1198 col.label(text="Effects:")
1200 sub = col.column(align=True)
1201 sub.prop(part, "use_clump_curve")
1202 if part.use_clump_curve:
1203 sub.template_curve_mapping(part, "clump_curve")
1205 sub.prop(part, "clump_factor", slider=True)
1206 sub.prop(part, "clump_shape", slider=True)
1207 sub = col.column(align=True)
1208 sub.prop(part, "use_clump_noise")
1209 subsub = sub.column()
1210 subsub.enabled = part.use_clump_noise
1211 subsub.prop(part, "clump_noise_size")
1213 sub = col.column(align=True)
1214 sub.prop(part, "child_length", slider=True)
1215 sub.prop(part, "child_length_threshold", slider=True)
1217 if part.child_type == 'SIMPLE':
1218 sub = col.column(align=True)
1219 sub.prop(part, "child_radius", text="Radius")
1220 sub.prop(part, "child_roundness", text="Roundness", slider=True)
1222 sub.prop(psys, "child_seed", text="Seed")
1223 elif part.virtual_parents > 0.0:
1224 sub = col.column(align=True)
1225 sub.label(text="Parting not")
1226 sub.label(text="available with")
1227 sub.label(text="virtual parents")
1229 sub = col.column(align=True)
1230 sub.prop(part, "child_parting_factor", text="Parting", slider=True)
1231 sub.prop(part, "child_parting_min", text="Min")
1232 sub.prop(part, "child_parting_max", text="Max")
1234 col = split.column()
1236 col.prop(part, "use_roughness_curve")
1237 if part.use_roughness_curve:
1239 sub.template_curve_mapping(part, "roughness_curve")
1240 sub.prop(part, "roughness_1", text="Roughness")
1241 sub.prop(part, "roughness_1_size", text="Size")
1243 col.label(text="Roughness:")
1245 sub = col.column(align=True)
1246 sub.prop(part, "roughness_1", text="Uniform")
1247 sub.prop(part, "roughness_1_size", text="Size")
1249 sub = col.column(align=True)
1250 sub.prop(part, "roughness_endpoint", "Endpoint")
1251 sub.prop(part, "roughness_end_shape")
1253 sub = col.column(align=True)
1254 sub.prop(part, "roughness_2", text="Random")
1255 sub.prop(part, "roughness_2_size", text="Size")
1256 sub.prop(part, "roughness_2_threshold", slider=True)
1258 layout.row().label(text="Kink:")
1259 layout.row().prop(part, "kink", expand=True)
1261 split = layout.split()
1262 split.active = part.kink != 'NO'
1264 if part.kink == 'SPIRAL':
1265 col = split.column()
1266 sub = col.column(align=True)
1267 sub.prop(part, "kink_amplitude", text="Radius")
1268 sub.prop(part, "kink_amplitude_random", text="Random", slider=True)
1269 sub = col.column(align=True)
1270 sub.prop(part, "kink_axis")
1271 sub.prop(part, "kink_axis_random", text="Random", slider=True)
1272 col = split.column(align=True)
1273 col.prop(part, "kink_frequency", text="Frequency")
1274 col.prop(part, "kink_shape", text="Shape", slider=True)
1275 col.prop(part, "kink_extra_steps", text="Steps")
1277 col = split.column()
1278 sub = col.column(align=True)
1279 sub.prop(part, "kink_amplitude")
1280 sub.prop(part, "kink_amplitude_clump", text="Clump", slider=True)
1281 col.prop(part, "kink_flat", slider=True)
1282 col = split.column(align=True)
1283 col.prop(part, "kink_frequency")
1284 col.prop(part, "kink_shape", slider=True)
1287 class PARTICLE_PT_field_weights(ParticleButtonsPanel, Panel):
1288 bl_label = "Field Weights"
1289 bl_options = {'DEFAULT_CLOSED'}
1290 COMPAT_ENGINES = {'BLENDER_RENDER'}
1293 def poll(cls, context):
1294 return particle_panel_poll(cls, context)
1296 def draw(self, context):
1297 part = particle_get_settings(context)
1298 effector_weights_ui(self, context, part.effector_weights, 'PSYS')
1300 if part.type == 'HAIR':
1301 row = self.layout.row()
1302 row.prop(part.effector_weights, "apply_to_hair_growing")
1303 row.prop(part, "apply_effector_to_children")
1304 row = self.layout.row()
1305 row.prop(part, "effect_hair", slider=True)
1308 class PARTICLE_PT_force_fields(ParticleButtonsPanel, Panel):
1309 bl_label = "Force Field Settings"
1310 bl_options = {'DEFAULT_CLOSED'}
1311 COMPAT_ENGINES = {'BLENDER_RENDER'}
1313 def draw(self, context):
1314 layout = self.layout
1316 part = particle_get_settings(context)
1319 row.prop(part, "use_self_effect")
1320 row.prop(part, "effector_amount", text="Amount")
1322 split = layout.split(percentage=0.2)
1323 split.label(text="Type 1:")
1324 split.prop(part.force_field_1, "type", text="")
1325 basic_force_field_settings_ui(self, context, part.force_field_1)
1326 if part.force_field_1.type != 'NONE':
1327 layout.label(text="Falloff:")
1328 basic_force_field_falloff_ui(self, context, part.force_field_1)
1330 if part.force_field_1.type != 'NONE':
1331 layout.label(text="")
1333 split = layout.split(percentage=0.2)
1334 split.label(text="Type 2:")
1335 split.prop(part.force_field_2, "type", text="")
1336 basic_force_field_settings_ui(self, context, part.force_field_2)
1337 if part.force_field_2.type != 'NONE':
1338 layout.label(text="Falloff:")
1339 basic_force_field_falloff_ui(self, context, part.force_field_2)
1342 class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, Panel):
1343 bl_label = "Vertex Groups"
1344 bl_options = {'DEFAULT_CLOSED'}
1345 COMPAT_ENGINES = {'BLENDER_RENDER'}
1348 def poll(cls, context):
1349 if context.particle_system is None:
1351 return particle_panel_poll(cls, context)
1353 def draw(self, context):
1354 layout = self.layout
1357 psys = context.particle_system
1359 col = layout.column()
1360 row = col.row(align=True)
1361 row.prop_search(psys, "vertex_group_density", ob, "vertex_groups", text="Density")
1362 row.prop(psys, "invert_vertex_group_density", text="", toggle=True, icon='ARROW_LEFTRIGHT')
1364 row = col.row(align=True)
1365 row.prop_search(psys, "vertex_group_length", ob, "vertex_groups", text="Length")
1366 row.prop(psys, "invert_vertex_group_length", text="", toggle=True, icon='ARROW_LEFTRIGHT')
1368 row = col.row(align=True)
1369 row.prop_search(psys, "vertex_group_clump", ob, "vertex_groups", text="Clump")
1370 row.prop(psys, "invert_vertex_group_clump", text="", toggle=True, icon='ARROW_LEFTRIGHT')
1372 row = col.row(align=True)
1373 row.prop_search(psys, "vertex_group_kink", ob, "vertex_groups", text="Kink")
1374 row.prop(psys, "invert_vertex_group_kink", text="", toggle=True, icon='ARROW_LEFTRIGHT')
1376 row = col.row(align=True)
1377 row.prop_search(psys, "vertex_group_roughness_1", ob, "vertex_groups", text="Roughness 1")
1378 row.prop(psys, "invert_vertex_group_roughness_1", text="", toggle=True, icon='ARROW_LEFTRIGHT')
1380 row = col.row(align=True)
1381 row.prop_search(psys, "vertex_group_roughness_2", ob, "vertex_groups", text="Roughness 2")
1382 row.prop(psys, "invert_vertex_group_roughness_2", text="", toggle=True, icon='ARROW_LEFTRIGHT')
1384 row = col.row(align=True)
1385 row.prop_search(psys, "vertex_group_roughness_end", ob, "vertex_groups", text="Roughness End")
1386 row.prop(psys, "invert_vertex_group_roughness_end", text="", toggle=True, icon='ARROW_LEFTRIGHT')
1388 # Commented out vertex groups don't work and are still waiting for better implementation
1389 # row = layout.row()
1390 # row.prop_search(psys, "vertex_group_velocity", ob, "vertex_groups", text="Velocity")
1391 # row.prop(psys, "invert_vertex_group_velocity", text="")
1393 # row = layout.row()
1394 # row.prop_search(psys, "vertex_group_size", ob, "vertex_groups", text="Size")
1395 # row.prop(psys, "invert_vertex_group_size", text="")
1397 # row = layout.row()
1398 # row.prop_search(psys, "vertex_group_tangent", ob, "vertex_groups", text="Tangent")
1399 # row.prop(psys, "invert_vertex_group_tangent", text="")
1401 # row = layout.row()
1402 # row.prop_search(psys, "vertex_group_rotation", ob, "vertex_groups", text="Rotation")
1403 # row.prop(psys, "invert_vertex_group_rotation", text="")
1405 # row = layout.row()
1406 # row.prop_search(psys, "vertex_group_field", ob, "vertex_groups", text="Field")
1407 # row.prop(psys, "invert_vertex_group_field", text="")
1410 class PARTICLE_PT_custom_props(ParticleButtonsPanel, PropertyPanel, Panel):
1411 COMPAT_ENGINES = {'BLENDER_RENDER'}
1412 _context_path = "particle_system.settings"
1413 _property_type = bpy.types.ParticleSettings
1417 PARTICLE_MT_specials,
1418 PARTICLE_MT_hair_dynamics_presets,
1419 PARTICLE_UL_particle_systems,
1420 PARTICLE_PT_context_particles,
1421 PARTICLE_PT_emission,
1422 PARTICLE_PT_hair_dynamics,
1424 PARTICLE_PT_velocity,
1425 PARTICLE_PT_rotation,
1426 PARTICLE_PT_physics,
1427 PARTICLE_PT_boidbrain,
1430 PARTICLE_PT_children,
1431 PARTICLE_PT_field_weights,
1432 PARTICLE_PT_force_fields,
1433 PARTICLE_PT_vertexgroups,
1434 PARTICLE_PT_custom_props,
1437 if __name__ == "__main__": # only for live edit.
1438 from bpy.utils import register_class