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