tabs to spaces, remove trailing white space. (apart of pep8)
[blender-staging.git] / release / scripts / ui / buttons_physics_fluid.py
1
2 import bpy
3
4 class PhysicButtonsPanel(bpy.types.Panel):
5     bl_space_type = 'PROPERTIES'
6     bl_region_type = 'WINDOW'
7     bl_context = "physics"
8
9     def poll(self, context):
10         ob = context.object
11         rd = context.scene.render_data
12         return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
13
14 class PHYSICS_PT_fluid(PhysicButtonsPanel):
15     bl_label = "Fluid"
16
17     def draw(self, context):
18         layout = self.layout
19
20         md = context.fluid
21         ob = context.object
22
23         split = layout.split()
24         split.operator_context = 'EXEC_DEFAULT'
25
26         if md:
27             # remove modifier + settings
28             split.set_context_pointer("modifier", md)
29             split.itemO("object.modifier_remove", text="Remove")
30
31             row = split.row(align=True)
32             row.itemR(md, "render", text="")
33             row.itemR(md, "realtime", text="")
34
35             fluid = md.settings
36
37         else:
38             # add modifier
39             split.item_enumO("object.modifier_add", "type", 'FLUID_SIMULATION', text="Add")
40             split.itemL()
41
42             fluid = None
43
44
45         if fluid:
46             layout.itemR(fluid, "type")
47
48             if fluid.type == 'DOMAIN':
49                 layout.itemO("fluid.bake", text="Bake Fluid Simulation", icon='ICON_MOD_FLUIDSIM')
50                 split = layout.split()
51
52                 col = split.column()
53                 col.itemL(text="Resolution:")
54                 col.itemR(fluid, "resolution", text="Final")
55                 col.itemL(text="Render Display:")
56                 col.itemR(fluid, "render_display_mode", text="")
57                 col.itemL(text="Time:")
58                 sub = col.column(align=True)
59                 sub.itemR(fluid, "start_time", text="Start")
60                 sub.itemR(fluid, "end_time", text="End")
61
62                 col = split.column()
63                 col.itemL(text="Required Memory: " + fluid.memory_estimate)
64                 col.itemR(fluid, "preview_resolution", text="Preview")
65                 col.itemL(text="Viewport Display:")
66                 col.itemR(fluid, "viewport_display_mode", text="")
67                 col.itemL()
68                 col.itemR(fluid, "generate_speed_vectors")
69                 col.itemR(fluid, "reverse_frames")
70
71                 layout.itemR(fluid, "path", text="")
72
73             elif fluid.type == 'FLUID':
74                 split = layout.split()
75
76                 col = split.column()
77                 col.itemL(text="Volume Initialization:")
78                 col.itemR(fluid, "volume_initialization", text="")
79                 col.itemR(fluid, "export_animated_mesh")
80
81                 col = split.column()
82                 col.itemL(text="Initial Velocity:")
83                 col.itemR(fluid, "initial_velocity", text="")
84
85             elif fluid.type == 'OBSTACLE':
86                 split = layout.split()
87
88                 col = split.column()
89                 col.itemL(text="Volume Initialization:")
90                 col.itemR(fluid, "volume_initialization", text="")
91                 col.itemR(fluid, "export_animated_mesh")
92
93                 col = split.column()
94                 col.itemL(text="Slip Type:")
95                 col.itemR(fluid, "slip_type", text="")
96                 if fluid.slip_type == 'PARTIALSLIP':
97                     col.itemR(fluid, "partial_slip_factor", slider=True, text="Amount")
98
99                 col.itemL(text="Impact:")
100                 col.itemR(fluid, "impact_factor", text="Factor")
101
102             elif fluid.type == 'INFLOW':
103                 split = layout.split()
104
105                 col = split.column()
106                 col.itemL(text="Volume Initialization:")
107                 col.itemR(fluid, "volume_initialization", text="")
108                 col.itemR(fluid, "export_animated_mesh")
109                 col.itemR(fluid, "local_coordinates")
110
111                 col = split.column()
112                 col.itemL(text="Inflow Velocity:")
113                 col.itemR(fluid, "inflow_velocity", text="")
114
115             elif fluid.type == 'OUTFLOW':
116                 split = layout.split()
117
118                 col = split.column()
119                 col.itemL(text="Volume Initialization:")
120                 col.itemR(fluid, "volume_initialization", text="")
121                 col.itemR(fluid, "export_animated_mesh")
122
123                 split.column()
124
125             elif fluid.type == 'PARTICLE':
126                 split = layout.split(percentage=0.5)
127
128                 col = split.column()
129                 col.itemL(text="Influence:")
130                 col.itemR(fluid, "particle_influence", text="Size")
131                 col.itemR(fluid, "alpha_influence", text="Alpha")
132
133                 col = split.column()
134                 col.itemL(text="Type:")
135                 col.itemR(fluid, "drops")
136                 col.itemR(fluid, "floats")
137                 col = split.column()
138                 col.itemL()
139                 col.itemR(fluid, "tracer")
140
141                 layout.itemR(fluid, "path", text="")
142
143             elif fluid.type == 'CONTROL':
144                 split = layout.split()
145
146                 col = split.column()
147                 col.itemL(text="")
148                 col.itemR(fluid, "quality", slider=True)
149                 col.itemR(fluid, "reverse_frames")
150
151                 col = split.column()
152                 col.itemL(text="Time:")
153                 sub = col.column(align=True)
154                 sub.itemR(fluid, "start_time", text="Start")
155                 sub.itemR(fluid, "end_time", text="End")
156
157                 split = layout.split()
158
159                 col = split.column()
160                 col.itemL(text="Attraction Force:")
161                 sub = col.column(align=True)
162                 sub.itemR(fluid, "attraction_strength", text="Strength")
163                 sub.itemR(fluid, "attraction_radius", text="Radius")
164
165                 col = split.column()
166                 col.itemL(text="Velocity Force:")
167                 sub = col.column(align=True)
168                 sub.itemR(fluid, "velocity_strength", text="Strength")
169                 sub.itemR(fluid, "velocity_radius", text="Radius")
170
171 class PHYSICS_PT_domain_gravity(PhysicButtonsPanel):
172     bl_label = "Domain World"
173     bl_default_closed = True
174
175     def poll(self, context):
176         md = context.fluid
177         return md and (md.settings.type == 'DOMAIN')
178
179     def draw(self, context):
180         layout = self.layout
181
182         fluid = context.fluid.settings
183
184         split = layout.split()
185
186         col = split.column()
187         col.itemL(text="Gravity:")
188         col.itemR(fluid, "gravity", text="")
189         col.itemL(text="Real World Size:")
190         col.itemR(fluid, "real_world_size", text="Metres")
191
192         col = split.column()
193         col.itemL(text="Viscosity Presets:")
194         sub = col.column(align=True)
195         sub.itemR(fluid, "viscosity_preset", text="")
196
197         if fluid.viscosity_preset == 'MANUAL':
198             sub.itemR(fluid, "viscosity_base", text="Base")
199             sub.itemR(fluid, "viscosity_exponent", text="Exponent", slider=True)
200         else:
201             sub.itemL()
202             sub.itemL()
203
204         col.itemL(text="Optimization:")
205         sub = col.column(align=True)
206         sub.itemR(fluid, "grid_levels", slider=True)
207         sub.itemR(fluid, "compressibility", slider=True)
208
209 class PHYSICS_PT_domain_boundary(PhysicButtonsPanel):
210     bl_label = "Domain Boundary"
211     bl_default_closed = True
212
213     def poll(self, context):
214         md = context.fluid
215         return md and (md.settings.type == 'DOMAIN')
216
217     def draw(self, context):
218         layout = self.layout
219
220         fluid = context.fluid.settings
221
222         split = layout.split()
223
224         col = split.column()
225         col.itemL(text="Slip Type:")
226         sub = col.column(align=True)
227         sub.itemR(fluid, "slip_type", text="")
228         if fluid.slip_type == 'PARTIALSLIP':
229             sub.itemR(fluid, "partial_slip_factor", slider=True, text="Amount")
230
231         col = split.column()
232         col.itemL(text="Surface:")
233         sub = col.column(align=True)
234         sub.itemR(fluid, "surface_smoothing", text="Smoothing")
235         sub.itemR(fluid, "surface_subdivisions", text="Subdivisions")
236
237 class PHYSICS_PT_domain_particles(PhysicButtonsPanel):
238     bl_label = "Domain Particles"
239     bl_default_closed = True
240
241     def poll(self, context):
242         md = context.fluid
243         return md and (md.settings.type == 'DOMAIN')
244
245     def draw(self, context):
246         layout = self.layout
247
248         fluid = context.fluid.settings
249
250         col = layout.column(align=True)
251         col.itemR(fluid, "tracer_particles")
252         col.itemR(fluid, "generate_particles")
253
254 bpy.types.register(PHYSICS_PT_fluid)
255 bpy.types.register(PHYSICS_PT_domain_gravity)
256 bpy.types.register(PHYSICS_PT_domain_boundary)
257 bpy.types.register(PHYSICS_PT_domain_particles)