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
24
class FLUID_MT_presets(Menu):
25
bl_label = "Fluid Presets"
26
preset_subdir = "fluid"
27
preset_operator = "script.execute_preset"
28
draw = Menu.draw_preset
31
class PhysicButtonsPanel():
32
bl_space_type = 'PROPERTIES'
33
bl_region_type = 'WINDOW'
34
bl_context = "physics"
37
def poll(cls, context):
39
rd = context.scene.render
40
return (ob and ob.type == 'MESH') and (not rd.use_game_engine) and (context.fluid)
43
class PHYSICS_PT_fluid(PhysicButtonsPanel, Panel):
46
def draw(self, context):
54
col.label("Built without fluids")
57
col.prop(fluid, "type")
58
if fluid.type not in {'NONE', 'DOMAIN', 'PARTICLE', 'FLUID', 'OBSTACLE'}:
59
col.prop(fluid, "use")
61
layout = layout.column()
62
if fluid.type not in {'NONE', 'DOMAIN', 'PARTICLE', 'FLUID', 'OBSTACLE'}:
63
layout.active = fluid.use
65
if fluid.type == 'DOMAIN':
66
# odd formatting here so translation script can extract string
67
layout.operator("fluid.bake", text="Bake (Req. Memory:" + " %s)" % fluid.memory_estimate, icon='MOD_FLUIDSIM')
68
split = layout.split()
71
col.label(text="Resolution:")
72
col.prop(fluid, "resolution", text="Final")
73
col.label(text="Render Display:")
74
col.prop(fluid, "render_display_mode", text="")
78
col.prop(fluid, "preview_resolution", text="Preview")
79
col.label(text="Viewport Display:")
80
col.prop(fluid, "viewport_display_mode", text="")
82
split = layout.split()
85
col.label(text="Time:")
86
sub = col.column(align=True)
87
sub.prop(fluid, "start_time", text="Start")
88
sub.prop(fluid, "end_time", text="End")
89
col.prop(fluid, "simulation_rate", text="Speed")
93
col.prop(fluid, "use_speed_vectors")
94
col.prop(fluid, "use_reverse_frames")
95
col.prop(fluid, "frame_offset", text="Offset")
97
layout.prop(fluid, "filepath", text="")
99
elif fluid.type == 'FLUID':
100
split = layout.split()
103
col.label(text="Volume Initialization:")
104
col.prop(fluid, "volume_initialization", text="")
105
col.prop(fluid, "use_animated_mesh")
108
col.label(text="Initial Velocity:")
109
col.prop(fluid, "initial_velocity", text="")
111
elif fluid.type == 'OBSTACLE':
112
split = layout.split()
115
col.label(text="Volume Initialization:")
116
col.prop(fluid, "volume_initialization", text="")
117
col.prop(fluid, "use_animated_mesh")
120
col.label(text="Slip Type:")
121
col.prop(fluid, "slip_type", text="")
122
if fluid.slip_type == 'PARTIALSLIP':
123
col.prop(fluid, "partial_slip_factor", slider=True, text="Amount")
125
col.label(text="Impact:")
126
col.prop(fluid, "impact_factor", text="Factor")
128
elif fluid.type == 'INFLOW':
129
split = layout.split()
132
col.label(text="Volume Initialization:")
133
col.prop(fluid, "volume_initialization", text="")
134
col.prop(fluid, "use_animated_mesh")
136
row.active = not fluid.use_animated_mesh
137
row.prop(fluid, "use_local_coords")
140
col.label(text="Inflow Velocity:")
141
col.prop(fluid, "inflow_velocity", text="")
143
elif fluid.type == 'OUTFLOW':
144
col = layout.column()
145
col.label(text="Volume Initialization:")
146
col.prop(fluid, "volume_initialization", text="")
147
col.prop(fluid, "use_animated_mesh")
149
elif fluid.type == 'PARTICLE':
150
split = layout.split()
153
col.label(text="Influence:")
154
col.prop(fluid, "particle_influence", text="Size")
155
col.prop(fluid, "alpha_influence", text="Alpha")
158
col.label(text="Type:")
159
col.prop(fluid, "use_drops")
160
col.prop(fluid, "use_floats")
161
col.prop(fluid, "show_tracer")
163
layout.prop(fluid, "filepath", text="")
165
elif fluid.type == 'CONTROL':
166
split = layout.split()
170
col.prop(fluid, "quality", slider=True)
171
col.prop(fluid, "use_reverse_frames")
174
col.label(text="Time:")
175
sub = col.column(align=True)
176
sub.prop(fluid, "start_time", text="Start")
177
sub.prop(fluid, "end_time", text="End")
179
split = layout.split()
182
col.label(text="Attraction Force:")
183
sub = col.column(align=True)
184
sub.prop(fluid, "attraction_strength", text="Strength")
185
sub.prop(fluid, "attraction_radius", text="Radius")
188
col.label(text="Velocity Force:")
189
sub = col.column(align=True)
190
sub.prop(fluid, "velocity_strength", text="Strength")
191
sub.prop(fluid, "velocity_radius", text="Radius")
194
class PHYSICS_PT_domain_gravity(PhysicButtonsPanel, Panel):
195
bl_label = "Domain World"
196
bl_options = {'DEFAULT_CLOSED'}
199
def poll(cls, context):
201
return md and md.settings and (md.settings.type == 'DOMAIN')
203
def draw(self, context):
206
fluid = context.fluid.settings
207
scene = context.scene
209
split = layout.split()
212
if scene.use_gravity:
213
col.label(text="Use Scene Gravity", icon='SCENE_DATA')
216
sub.prop(fluid, "gravity", text="")
218
col.label(text="Gravity:")
219
col.prop(fluid, "gravity", text="")
221
if scene.unit_settings.system != 'NONE':
222
col.label(text="Use Scene Size Units", icon='SCENE_DATA')
225
sub.prop(fluid, "simulation_scale", text="Metres")
227
col.label(text="Real World Size:")
228
col.prop(fluid, "simulation_scale", text="Metres")
231
col.label(text="Viscosity Presets:")
232
sub = col.row(align=True)
233
sub.menu("FLUID_MT_presets", text=bpy.types.FLUID_MT_presets.bl_label)
234
sub.operator("fluid.preset_add", text="", icon='ZOOMIN')
235
sub.operator("fluid.preset_add", text="", icon='ZOOMOUT').remove_active = True
237
subsub = col.column(align=True)
238
subsub.prop(fluid, "viscosity_base", text="Base")
239
subsub.prop(fluid, "viscosity_exponent", text="Exponent", slider=True)
241
col.label(text="Optimization:")
242
col.prop(fluid, "grid_levels", slider=True)
243
col.prop(fluid, "compressibility", slider=True)
246
class PHYSICS_PT_domain_boundary(PhysicButtonsPanel, Panel):
247
bl_label = "Domain Boundary"
248
bl_options = {'DEFAULT_CLOSED'}
251
def poll(cls, context):
253
return md and md.settings and (md.settings.type == 'DOMAIN')
255
def draw(self, context):
258
fluid = context.fluid.settings
260
split = layout.split()
263
col.label(text="Slip Type:")
264
col.prop(fluid, "slip_type", text="")
265
if fluid.slip_type == 'PARTIALSLIP':
266
col.prop(fluid, "partial_slip_factor", slider=True, text="Amount")
267
col.prop(fluid, "surface_noobs")
270
col.label(text="Surface:")
271
col.prop(fluid, "surface_smooth", text="Smoothing")
272
col.prop(fluid, "surface_subdivisions", text="Subdivisions")
275
class PHYSICS_PT_domain_particles(PhysicButtonsPanel, Panel):
276
bl_label = "Domain Particles"
277
bl_options = {'DEFAULT_CLOSED'}
280
def poll(cls, context):
282
return md and md.settings and (md.settings.type == 'DOMAIN')
284
def draw(self, context):
287
fluid = context.fluid.settings
289
col = layout.column(align=True)
290
col.prop(fluid, "tracer_particles")
291
col.prop(fluid, "generate_particles")
293
if __name__ == "__main__": # only for live edit.
294
bpy.utils.register_module(__name__)