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