use set as a suffix (matches operators)
[blender.git] / release / scripts / ui / properties_physics_fluid.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
22
23 class PhysicButtonsPanel():
24     bl_space_type = 'PROPERTIES'
25     bl_region_type = 'WINDOW'
26     bl_context = "physics"
27
28     @classmethod
29     def poll(cls, context):
30         ob = context.object
31         rd = context.scene.render
32         return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
33
34
35 class PHYSICS_PT_fluid(PhysicButtonsPanel, bpy.types.Panel):
36     bl_label = "Fluid"
37
38     def draw(self, context):
39         layout = self.layout
40
41         md = context.fluid
42
43         split = layout.split()
44
45         if md:
46             # remove modifier + settings
47             split.context_pointer_set("modifier", md)
48             split.operator("object.modifier_remove", text="Remove")
49
50             row = split.row(align=True)
51             row.prop(md, "show_render", text="")
52             row.prop(md, "show_viewport", text="")
53
54             fluid = md.settings
55
56         else:
57             # add modifier
58             split.operator("object.modifier_add", text="Add").type = 'FLUID_SIMULATION'
59             split.label()
60
61
62         if md:
63             row = layout.row()
64             row.prop(fluid, "type")
65             if fluid.type not in ('NONE', 'DOMAIN', 'PARTICLE'):
66                 row.prop(fluid, "use", text="")
67
68             layout = layout.column()
69             if fluid.type not in ('NONE', 'DOMAIN', 'PARTICLE'):
70                 layout.active = fluid.use
71
72             if fluid.type == 'DOMAIN':
73                 layout.operator("fluid.bake", text="Bake (Req. Memory: %s)" % fluid.memory_estimate, icon='MOD_FLUIDSIM')
74                 split = layout.split()
75
76                 col = split.column()
77                 col.label(text="Resolution:")
78                 col.prop(fluid, "resolution", text="Final")
79                 col.label(text="Render Display:")
80                 col.prop(fluid, "render_display_mode", text="")
81
82                 col = split.column()
83                 col.label()
84                 col.prop(fluid, "preview_resolution", text="Preview")
85                 col.label(text="Viewport Display:")
86                 col.prop(fluid, "viewport_display_mode", text="")
87
88                 split = layout.split()
89
90                 col = split.column()
91                 col.label(text="Time:")
92                 sub = col.column(align=True)
93                 sub.prop(fluid, "start_time", text="Start")
94                 sub.prop(fluid, "end_time", text="End")
95
96                 col = split.column()
97                 col.label()
98                 col.prop(fluid, "use_speed_vectors")
99                 col.prop(fluid, "use_reverse_frames")
100
101                 layout.prop(fluid, "filepath", text="")
102
103             elif fluid.type == 'FLUID':
104                 split = layout.split()
105
106                 col = split.column()
107                 col.label(text="Volume Initialization:")
108                 col.prop(fluid, "volume_initialization", text="")
109                 col.prop(fluid, "use_animated_mesh")
110
111                 col = split.column()
112                 col.label(text="Initial Velocity:")
113                 col.prop(fluid, "initial_velocity", text="")
114
115             elif fluid.type == 'OBSTACLE':
116                 split = layout.split()
117
118                 col = split.column()
119                 col.label(text="Volume Initialization:")
120                 col.prop(fluid, "volume_initialization", text="")
121                 col.prop(fluid, "use_animated_mesh")
122
123                 col = split.column()
124                 col.label(text="Slip Type:")
125                 col.prop(fluid, "slip_type", text="")
126                 if fluid.slip_type == 'PARTIALSLIP':
127                     col.prop(fluid, "partial_slip_factor", slider=True, text="Amount")
128
129                 col.label(text="Impact:")
130                 col.prop(fluid, "impact_factor", text="Factor")
131
132             elif fluid.type == 'INFLOW':
133                 split = layout.split()
134
135                 col = split.column()
136                 col.label(text="Volume Initialization:")
137                 col.prop(fluid, "volume_initialization", text="")
138                 col.prop(fluid, "use_animated_mesh")
139                 col.prop(fluid, "use_local_coords")
140
141                 col = split.column()
142                 col.label(text="Inflow Velocity:")
143                 col.prop(fluid, "inflow_velocity", text="")
144
145             elif fluid.type == 'OUTFLOW':
146                 split = layout.split()
147
148                 col = split.column()
149                 col.label(text="Volume Initialization:")
150                 col.prop(fluid, "volume_initialization", text="")
151                 col.prop(fluid, "use_animated_mesh")
152
153                 split.column()
154
155             elif fluid.type == 'PARTICLE':
156                 split = layout.split()
157
158                 col = split.column()
159                 col.label(text="Influence:")
160                 col.prop(fluid, "particle_influence", text="Size")
161                 col.prop(fluid, "alpha_influence", text="Alpha")
162
163                 col = split.column()
164                 col.label(text="Type:")
165                 col.prop(fluid, "use_drops")
166                 col.prop(fluid, "use_floats")
167                 col.prop(fluid, "show_tracer")
168
169                 layout.prop(fluid, "filepath", text="")
170
171             elif fluid.type == 'CONTROL':
172                 split = layout.split()
173
174                 col = split.column()
175                 col.label(text="")
176                 col.prop(fluid, "quality", slider=True)
177                 col.prop(fluid, "use_reverse_frames")
178
179                 col = split.column()
180                 col.label(text="Time:")
181                 sub = col.column(align=True)
182                 sub.prop(fluid, "start_time", text="Start")
183                 sub.prop(fluid, "end_time", text="End")
184
185                 split = layout.split()
186
187                 col = split.column()
188                 col.label(text="Attraction Force:")
189                 sub = col.column(align=True)
190                 sub.prop(fluid, "attraction_strength", text="Strength")
191                 sub.prop(fluid, "attraction_radius", text="Radius")
192
193                 col = split.column()
194                 col.label(text="Velocity Force:")
195                 sub = col.column(align=True)
196                 sub.prop(fluid, "velocity_strength", text="Strength")
197                 sub.prop(fluid, "velocity_radius", text="Radius")
198
199
200 class PHYSICS_PT_domain_gravity(PhysicButtonsPanel, bpy.types.Panel):
201     bl_label = "Domain World"
202     bl_options = {'DEFAULT_CLOSED'}
203
204     @classmethod
205     def poll(cls, context):
206         md = context.fluid
207         return md and md.settings and (md.settings.type == 'DOMAIN')
208
209     def draw(self, context):
210         layout = self.layout
211
212         fluid = context.fluid.settings
213         scene = context.scene
214
215         split = layout.split()
216
217         col = split.column()
218         if scene.use_gravity:
219             col.label(text="Using Scene Gravity", icon="SCENE_DATA")
220             sub = col.column()
221             sub.enabled = False
222             sub.prop(fluid, "gravity", text="")
223         else:
224             col.label(text="Gravity:")
225             col.prop(fluid, "gravity", text="")
226
227         if scene.unit_settings.system != 'NONE':
228             col.label(text="Using Scene Size Units", icon="SCENE_DATA")
229             sub = col.column()
230             sub.enabled = False
231             sub.prop(fluid, "simulation_scale", text="Metres")
232         else:
233             col.label(text="Real World Size:")
234             col.prop(fluid, "simulation_scale", text="Metres")
235
236         col = split.column()
237         col.label(text="Viscosity Presets:")
238         sub = col.column(align=True)
239         sub.prop(fluid, "viscosity_preset", text="")
240
241         if fluid.viscosity_preset == 'MANUAL':
242             sub.prop(fluid, "viscosity_base", text="Base")
243             sub.prop(fluid, "viscosity_exponent", text="Exponent", slider=True)
244
245         col.label(text="Optimization:")
246         col.prop(fluid, "grid_levels", slider=True)
247         col.prop(fluid, "compressibility", slider=True)
248
249
250 class PHYSICS_PT_domain_boundary(PhysicButtonsPanel, bpy.types.Panel):
251     bl_label = "Domain Boundary"
252     bl_options = {'DEFAULT_CLOSED'}
253
254     @classmethod
255     def poll(cls, context):
256         md = context.fluid
257         return md and md.settings and (md.settings.type == 'DOMAIN')
258
259     def draw(self, context):
260         layout = self.layout
261
262         fluid = context.fluid.settings
263
264         split = layout.split()
265
266         col = split.column()
267         col.label(text="Slip Type:")
268         col.prop(fluid, "slip_type", text="")
269         if fluid.slip_type == 'PARTIALSLIP':
270             col.prop(fluid, "partial_slip_factor", slider=True, text="Amount")
271
272         col = split.column()
273         col.label(text="Surface:")
274         col.prop(fluid, "surface_smooth", text="Smoothing")
275         col.prop(fluid, "surface_subdivisions", text="Subdivisions")
276
277
278 class PHYSICS_PT_domain_particles(PhysicButtonsPanel, bpy.types.Panel):
279     bl_label = "Domain Particles"
280     bl_options = {'DEFAULT_CLOSED'}
281
282     @classmethod
283     def poll(cls, context):
284         md = context.fluid
285         return md and md.settings and (md.settings.type == 'DOMAIN')
286
287     def draw(self, context):
288         layout = self.layout
289
290         fluid = context.fluid.settings
291
292         col = layout.column(align=True)
293         col.prop(fluid, "tracer_particles")
294         col.prop(fluid, "generate_particles")
295
296
297 def register():
298     pass
299
300
301 def unregister():
302     pass
303
304 if __name__ == "__main__":
305     register()